summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Lucas Dupin <dupin@google.com> 2021-06-09 21:16:47 -0700
committer Lucas Dupin <dupin@google.com> 2021-06-09 21:16:47 -0700
commite750ddd8fbfd8ab577162316946f28f5e15bf5a2 (patch)
treed74dce8bad82459e0fac69f9b4d6574c4ce63a26
parent789fe3896866748744855e4eaf7f633fefdebcf2 (diff)
Apply colors when a non managed user is added
This way we'll be able to have colors on SetupWizard when added a secondary user. Test: manual Test: atest ThemeOverlayControllerTest Fixes: 189168701 Change-Id: I8c7e5cc3a4804c34ad4ace0ba473a373b939cb83
-rw-r--r--packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java11
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/theme/ThemeOverlayControllerTest.java11
2 files changed, 18 insertions, 4 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java b/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java
index 428921ee34ec..1ce2dacf7751 100644
--- a/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java
+++ b/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java
@@ -240,11 +240,14 @@ 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_STARTED.equals(intent.getAction())
- || Intent.ACTION_MANAGED_PROFILE_ADDED.equals(intent.getAction())) {
- if (!mDeviceProvisionedController.isCurrentUserSetup()) {
+ boolean newWorkProfile = Intent.ACTION_MANAGED_PROFILE_ADDED.equals(intent.getAction());
+ boolean userStarted = Intent.ACTION_USER_STARTED.equals(intent.getAction());
+ boolean isManagedProfile = mUserManager.isManagedProfile(
+ intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0));
+ if (userStarted || newWorkProfile) {
+ if (!mDeviceProvisionedController.isCurrentUserSetup() && isManagedProfile) {
Log.i(TAG, "User setup not finished when " + intent.getAction()
- + " was received. Deferring...");
+ + " was received. Deferring... Managed profile? " + isManagedProfile);
return;
}
if (DEBUG) Log.d(TAG, "Updating overlays for user switch / profile added.");
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 3cf92126c5c6..208790b24d8a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/theme/ThemeOverlayControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/theme/ThemeOverlayControllerTest.java
@@ -429,8 +429,19 @@ public class ThemeOverlayControllerTest extends SysuiTestCase {
}
@Test
+ public void onUserAdded_appliesTheme_ifNotManagedProfile() {
+ reset(mDeviceProvisionedController);
+ when(mUserManager.isManagedProfile(anyInt())).thenReturn(false);
+ mBroadcastReceiver.getValue().onReceive(null,
+ new Intent(Intent.ACTION_MANAGED_PROFILE_ADDED));
+ verify(mThemeOverlayApplier)
+ .applyCurrentUserOverlays(any(), any(), anyInt(), any());
+ }
+
+ @Test
public void onProfileAdded_ignoresUntilSetupComplete() {
reset(mDeviceProvisionedController);
+ when(mUserManager.isManagedProfile(anyInt())).thenReturn(true);
mBroadcastReceiver.getValue().onReceive(null,
new Intent(Intent.ACTION_MANAGED_PROFILE_ADDED));
verify(mThemeOverlayApplier, never())