summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Neil Fuller <nfuller@google.com> 2016-11-14 16:06:42 +0000
committer Neil Fuller <nfuller@google.com> 2016-11-14 16:06:42 +0000
commitc66ec40d38e8d51a7351d37e9c08260aae0737a7 (patch)
tree53b3bfae1df46fb25b4a4e0b28aa10a65c5ba138
parent0bebfe76fc216ce2b1b7405eec93c9fe21f5a059 (diff)
Correctly handle when the user has no explicit time_12_24 setting
The code would previously interpret "null" (meaning the user hasn't touched the setting in the Settings app) as meaning "use 12 hour format". The actual meaning of "null" is generally accepted in the platform as "use the locale default". For example, the Settings app does this, as does the code in libcore.icu.LocaleData. For locales where the default is "use 12 hour format" anyway this wasn't obvious. However, locales like Germany should default to 24 hour, and then the setting is displayed incorrectly in the Settings app. Also, German devices boot for the first time with 12 hour SHORT and MEDIUM time formats too. After the user had explicitly set the format the setting would be correct. There appear to be no tests for this behavior, presumably because of the difficulty in forcing the setting to "unset" which would have to have to happen before the app was launched, and the fact that CTS tests run in the US locale. Bug: 32868036 Test: Manual testing with a device set to German Change-Id: Ifd2e8d345f6afee467d7525d6793fc8fda37c900
-rw-r--r--core/java/android/app/ActivityThread.java9
1 files changed, 8 insertions, 1 deletions
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index c1b37e6d2623..d242ba194c6a 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -5149,7 +5149,14 @@ public final class ActivityThread {
}
updateDefaultDensity();
- final boolean is24Hr = "24".equals(mCoreSettings.getString(Settings.System.TIME_12_24));
+ final String use24HourSetting = mCoreSettings.getString(Settings.System.TIME_12_24);
+ Boolean is24Hr = null;
+ if (use24HourSetting != null) {
+ is24Hr = "24".equals(use24HourSetting) ? Boolean.TRUE : Boolean.FALSE;
+ }
+ // null : use locale default for 12/24 hour formatting,
+ // false : use 12 hour format,
+ // true : use 24 hour format.
DateFormat.set24HourTimePref(is24Hr);
View.mDebugViewAttributes =