From 020ff8a390052455757c71134d2584881232adae Mon Sep 17 00:00:00 2001 From: Christopher Tate Date: Tue, 17 Oct 2017 14:39:24 -0700 Subject: [PATCH] Use correct flags on ACTION_TIME_CHANGED broadcast When Settings changes the display format for 12/24 hour time, it fakes an ACTION_TIME_CHANGED broadcast to provoke apps to update their display. It needs to use the right flags on that broadcast to match the way the OS sends it when the time actually changes. Bug: 67881917 Test: calendar widget, Deskclock, QCT timeservice Change-Id: I46ce261c36d9c7180f6b8eae806ef9fbf271fa53 --- .../settings/datetime/TimeFormatPreferenceController.java | 1 + .../settings/datetime/TimeChangeListenerMixinTest.java | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/com/android/settings/datetime/TimeFormatPreferenceController.java b/src/com/android/settings/datetime/TimeFormatPreferenceController.java index c594b264ac8..302c624c757 100644 --- a/src/com/android/settings/datetime/TimeFormatPreferenceController.java +++ b/src/com/android/settings/datetime/TimeFormatPreferenceController.java @@ -103,6 +103,7 @@ public class TimeFormatPreferenceController extends AbstractPreferenceController static void timeUpdated(Context context, Boolean is24Hour) { Intent timeChanged = new Intent(Intent.ACTION_TIME_CHANGED); + timeChanged.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND); int timeFormatPreference; if (is24Hour == null) { timeFormatPreference = Intent.EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT; diff --git a/tests/robotests/src/com/android/settings/datetime/TimeChangeListenerMixinTest.java b/tests/robotests/src/com/android/settings/datetime/TimeChangeListenerMixinTest.java index 843c753d9a6..ada59f4513c 100644 --- a/tests/robotests/src/com/android/settings/datetime/TimeChangeListenerMixinTest.java +++ b/tests/robotests/src/com/android/settings/datetime/TimeChangeListenerMixinTest.java @@ -66,7 +66,8 @@ public class TimeChangeListenerMixinTest { public void onResume_shouldRegisterIntentFilter() { mMixin.onResume(); mContext.sendBroadcast(new Intent(Intent.ACTION_TIME_TICK)); - mContext.sendBroadcast(new Intent(Intent.ACTION_TIME_CHANGED)); + mContext.sendBroadcast(new Intent(Intent.ACTION_TIME_CHANGED) + .addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND)); mContext.sendBroadcast(new Intent(Intent.ACTION_TIMEZONE_CHANGED)); verify(mCallback, times(3)).updateTimeAndDateDisplay(mContext); @@ -77,7 +78,8 @@ public class TimeChangeListenerMixinTest { mMixin.onResume(); mMixin.onPause(); mContext.sendBroadcast(new Intent(Intent.ACTION_TIME_TICK)); - mContext.sendBroadcast(new Intent(Intent.ACTION_TIME_CHANGED)); + mContext.sendBroadcast(new Intent(Intent.ACTION_TIME_CHANGED) + .addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND)); mContext.sendBroadcast(new Intent(Intent.ACTION_TIMEZONE_CHANGED)); verify(mCallback, never()).updateTimeAndDateDisplay(mContext);