From e02895a32fce38713acf0160b9d0f6a1604cb26c Mon Sep 17 00:00:00 2001 From: Lucas Dupin Date: Wed, 2 Jun 2021 17:29:42 -0700 Subject: [PATCH] Apply colors a bit earlier when switching users ACTION_USER_STARTED is dispatched a bit earlier than ACTION_USER_SWITCHED. Test: atest ThemeOverlayControllerTest Bug: 189075412 Change-Id: Iabd6e3bffede4caa53c6bcc61fbf17a2b8de9c55 --- .../com/android/systemui/theme/ThemeOverlayController.java | 4 ++-- .../android/systemui/theme/ThemeOverlayControllerTest.java | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java b/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java index 4be4b11f3d373..c23e0b479c227 100644 --- a/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java +++ b/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java @@ -237,7 +237,7 @@ public class ThemeOverlayController extends SystemUI implements Dumpable { private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { - if (Intent.ACTION_USER_SWITCHED.equals(intent.getAction()) + if (Intent.ACTION_USER_STARTED.equals(intent.getAction()) || Intent.ACTION_MANAGED_PROFILE_ADDED.equals(intent.getAction())) { if (!mDeviceProvisionedController.isCurrentUserSetup()) { Log.i(TAG, "User setup not finished when " + intent.getAction() @@ -282,7 +282,7 @@ public class ThemeOverlayController extends SystemUI implements Dumpable { public void start() { if (DEBUG) Log.d(TAG, "Start"); final IntentFilter filter = new IntentFilter(); - filter.addAction(Intent.ACTION_USER_SWITCHED); + filter.addAction(Intent.ACTION_USER_STARTED); filter.addAction(Intent.ACTION_MANAGED_PROFILE_ADDED); filter.addAction(Intent.ACTION_WALLPAPER_CHANGED); mBroadcastDispatcher.registerReceiver(mBroadcastReceiver, filter, mMainExecutor, diff --git a/packages/SystemUI/tests/src/com/android/systemui/theme/ThemeOverlayControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/theme/ThemeOverlayControllerTest.java index cfaffd08a1a70..3d2a0f1720750 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/theme/ThemeOverlayControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/theme/ThemeOverlayControllerTest.java @@ -359,6 +359,13 @@ public class ThemeOverlayControllerTest extends SysuiTestCase { .applyCurrentUserOverlays(any(), any(), anyInt(), any()); } + @Test + public void onUserSwitch_setsTheme() { + mBroadcastReceiver.getValue().onReceive(null, + new Intent(Intent.ACTION_USER_STARTED)); + verify(mThemeOverlayApplier).applyCurrentUserOverlays(any(), any(), anyInt(), any()); + } + @Test public void onProfileAdded_setsTheme() { mBroadcastReceiver.getValue().onReceive(null,