summaryrefslogtreecommitdiff
path: root/cmds/bootanimation/BootAnimation.cpp
diff options
context:
space:
mode:
authorBaligh Uddin <baligh@google.com>2016-11-22 17:19:45 -0800
committerBaligh Uddin <baligh@google.com>2016-11-22 17:19:45 -0800
commitb1df48d32632d0ba5a2389fb9fad2943dcb55562 (patch)
tree7a1135a5911de2bbaa7bb6a4954fbcca71b71632 /cmds/bootanimation/BootAnimation.cpp
parent201cf4fb27a42237cc70fba44f05195e6a38e4cb (diff)
parent466bb400bbc7a249f6598d8dc24ac685a43df74d (diff)
Merge remote-tracking branch 'goog/cw-f-dev' into fix_merger
Bug: 32849428 * goog/cw-f-dev: (98 commits) Revert "Catch KeyStoreException for setting profile lock" Fix createConfirmDeviceCredentialIntent for wear for CTS. Fix default dialog background colour for watch devices. Catch KeyStoreException for setting profile lock Add cross-links between FINE and COARSE location permissions. bug: 25371600 Fixed a bug with the emergency affordance in multi user Zygote: Additional whitelists for runtime overlay / other static resources. Import translations. DO NOT MERGE Import translations. DO NOT MERGE Import translations. DO NOT MERGE Import translations. DO NOT MERGE Import translations. DO NOT MERGE Import translations. DO NOT MERGE Import translations. DO NOT MERGE Zygote : Block SIGCHLD during fork. colors: add missing accent_material_{700,50} resources. Import translations. DO NOT MERGE Import translations. DO NOT MERGE Zygote : Block SIGCHLD during fork. DO NOT MERGE ANYWHERE Revert "DO NOT MERGE ANYWHERE libhwui: make setSurface asynchronous" ... Change-Id: I63468da5bfa21ed9ac5985bbdbf3a61d4c389aa0
Diffstat (limited to 'cmds/bootanimation/BootAnimation.cpp')
-rw-r--r--cmds/bootanimation/BootAnimation.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/cmds/bootanimation/BootAnimation.cpp b/cmds/bootanimation/BootAnimation.cpp
index c9211939ec6c..5fe8ba06f536 100644
--- a/cmds/bootanimation/BootAnimation.cpp
+++ b/cmds/bootanimation/BootAnimation.cpp
@@ -74,6 +74,7 @@ static const char LAST_TIME_CHANGED_FILE_NAME[] = "last_time_change";
static const char LAST_TIME_CHANGED_FILE_PATH[] = "/data/system/time/last_time_change";
static const char ACCURATE_TIME_FLAG_FILE_NAME[] = "time_is_accurate";
static const char ACCURATE_TIME_FLAG_FILE_PATH[] = "/data/system/time/time_is_accurate";
+static const char TIME_FORMAT_12_HOUR_FLAG_FILE_PATH[] = "/data/system/time/time_format_12_hour";
// Java timestamp format. Don't show the clock if the date is before 2000-01-01 00:00:00.
static const long long ACCURATE_TIME_EPOCH = 946684800000;
static constexpr char FONT_BEGIN_CHAR = ' ';
@@ -99,7 +100,7 @@ static const std::vector<std::string> PLAY_SOUND_BOOTREASON_BLACKLIST {
// ---------------------------------------------------------------------------
BootAnimation::BootAnimation() : Thread(false), mClockEnabled(true), mTimeIsAccurate(false),
- mTimeCheckThread(NULL) {
+ mTimeFormat12Hour(false), mTimeCheckThread(NULL) {
mSession = new SurfaceComposerClient();
// If the system has already booted, the animation is not being used for a boot.
@@ -590,9 +591,10 @@ void BootAnimation::drawText(const char* str, const Font& font, bool bold, int*
glBindTexture(GL_TEXTURE_2D, 0);
}
-// We render 24 hour time.
+// We render 12 or 24 hour time.
void BootAnimation::drawClock(const Font& font, const int xPos, const int yPos) {
- static constexpr char TIME_FORMAT[] = "%H:%M";
+ static constexpr char TIME_FORMAT_12[] = "%l:%M";
+ static constexpr char TIME_FORMAT_24[] = "%H:%M";
static constexpr int TIME_LENGTH = 6;
time_t rawtime;
@@ -600,7 +602,8 @@ void BootAnimation::drawClock(const Font& font, const int xPos, const int yPos)
struct tm* timeInfo = localtime(&rawtime);
char timeBuff[TIME_LENGTH];
- size_t length = strftime(timeBuff, TIME_LENGTH, TIME_FORMAT, timeInfo);
+ const char* timeFormat = mTimeFormat12Hour ? TIME_FORMAT_12 : TIME_FORMAT_24;
+ size_t length = strftime(timeBuff, TIME_LENGTH, timeFormat, timeInfo);
if (length != TIME_LENGTH - 1) {
ALOGE("Couldn't format time; abandoning boot animation clock");
@@ -1062,6 +1065,11 @@ bool BootAnimation::updateIsTimeAccurate() {
}
struct stat statResult;
+
+ if(stat(TIME_FORMAT_12_HOUR_FLAG_FILE_PATH, &statResult) == 0) {
+ mTimeFormat12Hour = true;
+ }
+
if(stat(ACCURATE_TIME_FLAG_FILE_PATH, &statResult) == 0) {
mTimeIsAccurate = true;
return true;