Merge "Apply colors when a non managed user is added" into sc-dev
This commit is contained in:
@@ -240,11 +240,14 @@ public class ThemeOverlayController extends SystemUI implements Dumpable {
|
|||||||
private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
|
private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
if (Intent.ACTION_USER_STARTED.equals(intent.getAction())
|
boolean newWorkProfile = Intent.ACTION_MANAGED_PROFILE_ADDED.equals(intent.getAction());
|
||||||
|| Intent.ACTION_MANAGED_PROFILE_ADDED.equals(intent.getAction())) {
|
boolean userStarted = Intent.ACTION_USER_STARTED.equals(intent.getAction());
|
||||||
if (!mDeviceProvisionedController.isCurrentUserSetup()) {
|
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()
|
Log.i(TAG, "User setup not finished when " + intent.getAction()
|
||||||
+ " was received. Deferring...");
|
+ " was received. Deferring... Managed profile? " + isManagedProfile);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (DEBUG) Log.d(TAG, "Updating overlays for user switch / profile added.");
|
if (DEBUG) Log.d(TAG, "Updating overlays for user switch / profile added.");
|
||||||
|
|||||||
@@ -428,9 +428,20 @@ public class ThemeOverlayControllerTest extends SysuiTestCase {
|
|||||||
verify(mThemeOverlayApplier).applyCurrentUserOverlays(any(), any(), anyInt(), any());
|
verify(mThemeOverlayApplier).applyCurrentUserOverlays(any(), any(), anyInt(), any());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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
|
@Test
|
||||||
public void onProfileAdded_ignoresUntilSetupComplete() {
|
public void onProfileAdded_ignoresUntilSetupComplete() {
|
||||||
reset(mDeviceProvisionedController);
|
reset(mDeviceProvisionedController);
|
||||||
|
when(mUserManager.isManagedProfile(anyInt())).thenReturn(true);
|
||||||
mBroadcastReceiver.getValue().onReceive(null,
|
mBroadcastReceiver.getValue().onReceive(null,
|
||||||
new Intent(Intent.ACTION_MANAGED_PROFILE_ADDED));
|
new Intent(Intent.ACTION_MANAGED_PROFILE_ADDED));
|
||||||
verify(mThemeOverlayApplier, never())
|
verify(mThemeOverlayApplier, never())
|
||||||
|
|||||||
Reference in New Issue
Block a user