diff options
| author | Wilhelm Fitzpatrick <rafial@cyngn.com> | 2015-08-26 10:39:29 -0700 |
|---|---|---|
| committer | Steve Kondik <steve@cyngn.com> | 2015-10-28 13:30:29 -0700 |
| commit | 2f5d120114235e3209dff99106fbb5fdf70f5a9d (patch) | |
| tree | 7e014c281b5efb8ee7977b607da9c04c62545383 | |
| parent | a4e229c7c09f39ee54df4a150826cab9e435f890 (diff) | |
| download | frameworks_base-2f5d120114235e3209dff99106fbb5fdf70f5a9d.zip frameworks_base-2f5d120114235e3209dff99106fbb5fdf70f5a9d.tar.gz frameworks_base-2f5d120114235e3209dff99106fbb5fdf70f5a9d.tar.bz2 | |
Fix "Select correct 12 or 24 time format" breaking Chrome
Due to Chrome's process isolation, using a ContentResolver is
forbidden. However ActivityThread already has direct access to
settings and locale, so modify DateFormat's utility method to
allow those values to be passed directly.
CYNGNOS-495
Change-Id: I5284b94459ac03214f1712c8a1fddcbefeae3783
| -rw-r--r-- | core/java/android/app/ActivityThread.java | 3 | ||||
| -rwxr-xr-x | core/java/android/text/format/DateFormat.java | 29 |
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"); } /** |
