summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/java/android/app/ActivityThread.java3
-rwxr-xr-xcore/java/android/text/format/DateFormat.java29
2 files changed, 22 insertions, 10 deletions
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index c302647..1f374e8 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -4555,7 +4555,8 @@ public final class ActivityThread {
}
- final boolean is24Hr = android.text.format.DateFormat.is24HourFormat(appContext);
+ final boolean is24Hr = android.text.format.DateFormat.is24HourFormat(
+ mCoreSettings.getString(Settings.System.TIME_12_24), data.config.locale);
DateFormat.set24HourTimePref(is24Hr);
View.mDebugViewAttributes =
diff --git a/core/java/android/text/format/DateFormat.java b/core/java/android/text/format/DateFormat.java
index 3ed37b3..998fa9d 100755
--- a/core/java/android/text/format/DateFormat.java
+++ b/core/java/android/text/format/DateFormat.java
@@ -177,12 +177,23 @@ public class DateFormat {
* @hide
*/
public static boolean is24HourFormat(Context context, int userHandle) {
- String value = Settings.System.getStringForUser(context.getContentResolver(),
+ String setting = Settings.System.getStringForUser(context.getContentResolver(),
Settings.System.TIME_12_24, userHandle);
+ Locale locale = context.getResources().getConfiguration().locale;
+ return is24HourFormat(setting, locale);
+ }
- if (value == null) {
- Locale locale = context.getResources().getConfiguration().locale;
-
+ /**
+ * Returns true if user preference with the given user handle is set to 24-hour format.
+ * @param setting value of the TIME_12_24 system setting, which may be null
+ * @param locale current default locale for this device
+ * @param userHandle the user handle of the user to query.
+ * @return true if 24 hour time format is selected, false otherwise.
+ *
+ * @hide
+ */
+ public static boolean is24HourFormat(String setting, Locale locale) {
+ if (setting == null) {
synchronized (sLocaleLock) {
if (sIs24HourLocale != null && sIs24HourLocale.equals(locale)) {
return sIs24Hour;
@@ -197,23 +208,23 @@ public class DateFormat {
String pattern = sdf.toPattern();
if (pattern.indexOf('H') >= 0) {
- value = "24";
+ setting = "24";
} else {
- value = "12";
+ setting = "12";
}
} else {
- value = "12";
+ setting = "12";
}
synchronized (sLocaleLock) {
sIs24HourLocale = locale;
- sIs24Hour = value.equals("24");
+ sIs24Hour = setting.equals("24");
}
return sIs24Hour;
}
- return value.equals("24");
+ return setting.equals("24");
}
/**