Merge "Fix race condition when setting boot color sysproprs." into sc-qpr1-dev am: 5541e5a2fa
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15680184 Change-Id: I98372bba5ae2cf3eed8f68c628597fdac0544714
This commit is contained in:
@@ -198,9 +198,11 @@ public class DependencyProvider {
|
|||||||
@SysUISingleton
|
@SysUISingleton
|
||||||
@Provides
|
@Provides
|
||||||
static ThemeOverlayApplier provideThemeOverlayManager(Context context,
|
static ThemeOverlayApplier provideThemeOverlayManager(Context context,
|
||||||
@Background Executor bgExecutor, OverlayManager overlayManager,
|
@Background Executor bgExecutor,
|
||||||
|
@Main Executor mainExecutor,
|
||||||
|
OverlayManager overlayManager,
|
||||||
DumpManager dumpManager) {
|
DumpManager dumpManager) {
|
||||||
return new ThemeOverlayApplier(overlayManager, bgExecutor,
|
return new ThemeOverlayApplier(overlayManager, bgExecutor, mainExecutor,
|
||||||
context.getString(R.string.launcher_overlayable_package),
|
context.getString(R.string.launcher_overlayable_package),
|
||||||
context.getString(R.string.themepicker_overlayable_package), dumpManager);
|
context.getString(R.string.themepicker_overlayable_package), dumpManager);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,14 +132,18 @@ public class ThemeOverlayApplier implements Dumpable {
|
|||||||
/* Target package for each overlay category. */
|
/* Target package for each overlay category. */
|
||||||
private final Map<String, String> mCategoryToTargetPackage = new ArrayMap<>();
|
private final Map<String, String> mCategoryToTargetPackage = new ArrayMap<>();
|
||||||
private final OverlayManager mOverlayManager;
|
private final OverlayManager mOverlayManager;
|
||||||
private final Executor mExecutor;
|
private final Executor mBgExecutor;
|
||||||
|
private final Executor mMainExecutor;
|
||||||
private final String mLauncherPackage;
|
private final String mLauncherPackage;
|
||||||
private final String mThemePickerPackage;
|
private final String mThemePickerPackage;
|
||||||
|
|
||||||
public ThemeOverlayApplier(OverlayManager overlayManager, Executor executor,
|
public ThemeOverlayApplier(OverlayManager overlayManager,
|
||||||
|
Executor bgExecutor,
|
||||||
|
Executor mainExecutor,
|
||||||
String launcherPackage, String themePickerPackage, DumpManager dumpManager) {
|
String launcherPackage, String themePickerPackage, DumpManager dumpManager) {
|
||||||
mOverlayManager = overlayManager;
|
mOverlayManager = overlayManager;
|
||||||
mExecutor = executor;
|
mBgExecutor = bgExecutor;
|
||||||
|
mMainExecutor = mainExecutor;
|
||||||
mLauncherPackage = launcherPackage;
|
mLauncherPackage = launcherPackage;
|
||||||
mThemePickerPackage = themePickerPackage;
|
mThemePickerPackage = themePickerPackage;
|
||||||
mTargetPackageToCategories.put(ANDROID_PACKAGE, Sets.newHashSet(
|
mTargetPackageToCategories.put(ANDROID_PACKAGE, Sets.newHashSet(
|
||||||
@@ -170,12 +174,13 @@ public class ThemeOverlayApplier implements Dumpable {
|
|||||||
* Apply the set of overlay packages to the set of {@code UserHandle}s provided. Overlays that
|
* Apply the set of overlay packages to the set of {@code UserHandle}s provided. Overlays that
|
||||||
* affect sysui will also be applied to the system user.
|
* affect sysui will also be applied to the system user.
|
||||||
*/
|
*/
|
||||||
void applyCurrentUserOverlays(
|
public void applyCurrentUserOverlays(
|
||||||
Map<String, OverlayIdentifier> categoryToPackage,
|
Map<String, OverlayIdentifier> categoryToPackage,
|
||||||
FabricatedOverlay[] pendingCreation,
|
FabricatedOverlay[] pendingCreation,
|
||||||
int currentUser,
|
int currentUser,
|
||||||
Set<UserHandle> managedProfiles) {
|
Set<UserHandle> managedProfiles,
|
||||||
mExecutor.execute(() -> {
|
Runnable onOverlaysApplied) {
|
||||||
|
mBgExecutor.execute(() -> {
|
||||||
|
|
||||||
// Disable all overlays that have not been specified in the user setting.
|
// Disable all overlays that have not been specified in the user setting.
|
||||||
final Set<String> overlayCategoriesToDisable = new HashSet<>(THEME_CATEGORIES);
|
final Set<String> overlayCategoriesToDisable = new HashSet<>(THEME_CATEGORIES);
|
||||||
@@ -221,6 +226,7 @@ public class ThemeOverlayApplier implements Dumpable {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
mOverlayManager.commit(transaction.build());
|
mOverlayManager.commit(transaction.build());
|
||||||
|
mMainExecutor.execute(onOverlaysApplied);
|
||||||
} catch (SecurityException | IllegalStateException e) {
|
} catch (SecurityException | IllegalStateException e) {
|
||||||
Log.e(TAG, "setEnabled failed", e);
|
Log.e(TAG, "setEnabled failed", e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -521,16 +521,16 @@ public class ThemeOverlayController extends SystemUI implements Dumpable {
|
|||||||
.map(key -> key + " -> " + categoryToPackage.get(key)).collect(
|
.map(key -> key + " -> " + categoryToPackage.get(key)).collect(
|
||||||
Collectors.joining(", ")));
|
Collectors.joining(", ")));
|
||||||
}
|
}
|
||||||
|
Runnable overlaysAppliedRunnable = () -> onOverlaysApplied();
|
||||||
if (mNeedsOverlayCreation) {
|
if (mNeedsOverlayCreation) {
|
||||||
mNeedsOverlayCreation = false;
|
mNeedsOverlayCreation = false;
|
||||||
mThemeManager.applyCurrentUserOverlays(categoryToPackage, new FabricatedOverlay[] {
|
mThemeManager.applyCurrentUserOverlays(categoryToPackage, new FabricatedOverlay[] {
|
||||||
mSecondaryOverlay, mNeutralOverlay
|
mSecondaryOverlay, mNeutralOverlay
|
||||||
}, currentUser, managedProfiles);
|
}, currentUser, managedProfiles, overlaysAppliedRunnable);
|
||||||
} else {
|
} else {
|
||||||
mThemeManager.applyCurrentUserOverlays(categoryToPackage, null, currentUser,
|
mThemeManager.applyCurrentUserOverlays(categoryToPackage, null, currentUser,
|
||||||
managedProfiles);
|
managedProfiles, overlaysAppliedRunnable);
|
||||||
}
|
}
|
||||||
onOverlaysApplied();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onOverlaysApplied() {
|
protected void onOverlaysApplied() {
|
||||||
|
|||||||
@@ -96,6 +96,8 @@ public class ThemeOverlayApplierTest extends SysuiTestCase {
|
|||||||
DumpManager mDumpManager;
|
DumpManager mDumpManager;
|
||||||
@Mock
|
@Mock
|
||||||
OverlayManagerTransaction.Builder mTransactionBuilder;
|
OverlayManagerTransaction.Builder mTransactionBuilder;
|
||||||
|
@Mock
|
||||||
|
Runnable mOnOverlaysApplied;
|
||||||
|
|
||||||
private ThemeOverlayApplier mManager;
|
private ThemeOverlayApplier mManager;
|
||||||
private boolean mGetOverlayInfoEnabled = true;
|
private boolean mGetOverlayInfoEnabled = true;
|
||||||
@@ -103,7 +105,8 @@ public class ThemeOverlayApplierTest extends SysuiTestCase {
|
|||||||
@Before
|
@Before
|
||||||
public void setup() throws Exception {
|
public void setup() throws Exception {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mManager = new ThemeOverlayApplier(mOverlayManager, MoreExecutors.directExecutor(),
|
mManager = new ThemeOverlayApplier(mOverlayManager,
|
||||||
|
MoreExecutors.directExecutor(), MoreExecutors.directExecutor(),
|
||||||
LAUNCHER_PACKAGE, THEMEPICKER_PACKAGE, mDumpManager) {
|
LAUNCHER_PACKAGE, THEMEPICKER_PACKAGE, mDumpManager) {
|
||||||
@Override
|
@Override
|
||||||
protected OverlayManagerTransaction.Builder getTransactionBuilder() {
|
protected OverlayManagerTransaction.Builder getTransactionBuilder() {
|
||||||
@@ -173,7 +176,7 @@ public class ThemeOverlayApplierTest extends SysuiTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void allCategoriesSpecified_allEnabledExclusively() {
|
public void allCategoriesSpecified_allEnabledExclusively() {
|
||||||
mManager.applyCurrentUserOverlays(ALL_CATEGORIES_MAP, null, TEST_USER.getIdentifier(),
|
mManager.applyCurrentUserOverlays(ALL_CATEGORIES_MAP, null, TEST_USER.getIdentifier(),
|
||||||
TEST_USER_HANDLES);
|
TEST_USER_HANDLES, mOnOverlaysApplied);
|
||||||
verify(mOverlayManager).commit(any());
|
verify(mOverlayManager).commit(any());
|
||||||
|
|
||||||
for (OverlayIdentifier overlayPackage : ALL_CATEGORIES_MAP.values()) {
|
for (OverlayIdentifier overlayPackage : ALL_CATEGORIES_MAP.values()) {
|
||||||
@@ -185,7 +188,7 @@ public class ThemeOverlayApplierTest extends SysuiTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void allCategoriesSpecified_sysuiCategoriesAlsoAppliedToSysuiUser() {
|
public void allCategoriesSpecified_sysuiCategoriesAlsoAppliedToSysuiUser() {
|
||||||
mManager.applyCurrentUserOverlays(ALL_CATEGORIES_MAP, null, TEST_USER.getIdentifier(),
|
mManager.applyCurrentUserOverlays(ALL_CATEGORIES_MAP, null, TEST_USER.getIdentifier(),
|
||||||
TEST_USER_HANDLES);
|
TEST_USER_HANDLES, mOnOverlaysApplied);
|
||||||
|
|
||||||
for (Map.Entry<String, OverlayIdentifier> entry : ALL_CATEGORIES_MAP.entrySet()) {
|
for (Map.Entry<String, OverlayIdentifier> entry : ALL_CATEGORIES_MAP.entrySet()) {
|
||||||
if (SYSTEM_USER_CATEGORIES.contains(entry.getKey())) {
|
if (SYSTEM_USER_CATEGORIES.contains(entry.getKey())) {
|
||||||
@@ -202,8 +205,9 @@ public class ThemeOverlayApplierTest extends SysuiTestCase {
|
|||||||
public void allCategoriesSpecified_enabledForAllUserHandles() {
|
public void allCategoriesSpecified_enabledForAllUserHandles() {
|
||||||
Set<UserHandle> userHandles = Sets.newHashSet(TEST_USER_HANDLES);
|
Set<UserHandle> userHandles = Sets.newHashSet(TEST_USER_HANDLES);
|
||||||
mManager.applyCurrentUserOverlays(ALL_CATEGORIES_MAP, null, TEST_USER.getIdentifier(),
|
mManager.applyCurrentUserOverlays(ALL_CATEGORIES_MAP, null, TEST_USER.getIdentifier(),
|
||||||
userHandles);
|
userHandles, mOnOverlaysApplied);
|
||||||
|
|
||||||
|
verify(mOnOverlaysApplied).run();
|
||||||
for (OverlayIdentifier overlayPackage : ALL_CATEGORIES_MAP.values()) {
|
for (OverlayIdentifier overlayPackage : ALL_CATEGORIES_MAP.values()) {
|
||||||
verify(mTransactionBuilder).setEnabled(eq(overlayPackage), eq(true),
|
verify(mTransactionBuilder).setEnabled(eq(overlayPackage), eq(true),
|
||||||
eq(TEST_USER.getIdentifier()));
|
eq(TEST_USER.getIdentifier()));
|
||||||
@@ -219,7 +223,7 @@ public class ThemeOverlayApplierTest extends SysuiTestCase {
|
|||||||
|
|
||||||
Set<UserHandle> userHandles = Sets.newHashSet(TEST_USER_HANDLES);
|
Set<UserHandle> userHandles = Sets.newHashSet(TEST_USER_HANDLES);
|
||||||
mManager.applyCurrentUserOverlays(ALL_CATEGORIES_MAP, null, TEST_USER.getIdentifier(),
|
mManager.applyCurrentUserOverlays(ALL_CATEGORIES_MAP, null, TEST_USER.getIdentifier(),
|
||||||
userHandles);
|
userHandles, mOnOverlaysApplied);
|
||||||
|
|
||||||
for (OverlayIdentifier overlayPackage : ALL_CATEGORIES_MAP.values()) {
|
for (OverlayIdentifier overlayPackage : ALL_CATEGORIES_MAP.values()) {
|
||||||
verify(mTransactionBuilder, never()).setEnabled(eq(overlayPackage), eq(true),
|
verify(mTransactionBuilder, never()).setEnabled(eq(overlayPackage), eq(true),
|
||||||
@@ -233,7 +237,7 @@ public class ThemeOverlayApplierTest extends SysuiTestCase {
|
|||||||
mock(FabricatedOverlay.class)
|
mock(FabricatedOverlay.class)
|
||||||
};
|
};
|
||||||
mManager.applyCurrentUserOverlays(ALL_CATEGORIES_MAP, pendingCreation,
|
mManager.applyCurrentUserOverlays(ALL_CATEGORIES_MAP, pendingCreation,
|
||||||
TEST_USER.getIdentifier(), TEST_USER_HANDLES);
|
TEST_USER.getIdentifier(), TEST_USER_HANDLES, mOnOverlaysApplied);
|
||||||
|
|
||||||
for (FabricatedOverlay overlay : pendingCreation) {
|
for (FabricatedOverlay overlay : pendingCreation) {
|
||||||
verify(mTransactionBuilder).registerFabricatedOverlay(eq(overlay));
|
verify(mTransactionBuilder).registerFabricatedOverlay(eq(overlay));
|
||||||
@@ -247,7 +251,7 @@ public class ThemeOverlayApplierTest extends SysuiTestCase {
|
|||||||
categoryToPackage.remove(OVERLAY_CATEGORY_ICON_ANDROID);
|
categoryToPackage.remove(OVERLAY_CATEGORY_ICON_ANDROID);
|
||||||
|
|
||||||
mManager.applyCurrentUserOverlays(categoryToPackage, null, TEST_USER.getIdentifier(),
|
mManager.applyCurrentUserOverlays(categoryToPackage, null, TEST_USER.getIdentifier(),
|
||||||
TEST_USER_HANDLES);
|
TEST_USER_HANDLES, mOnOverlaysApplied);
|
||||||
|
|
||||||
for (OverlayIdentifier overlayPackage : categoryToPackage.values()) {
|
for (OverlayIdentifier overlayPackage : categoryToPackage.values()) {
|
||||||
verify(mTransactionBuilder).setEnabled(eq(overlayPackage), eq(true),
|
verify(mTransactionBuilder).setEnabled(eq(overlayPackage), eq(true),
|
||||||
@@ -264,7 +268,7 @@ public class ThemeOverlayApplierTest extends SysuiTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void zeroCategoriesSpecified_allDisabled() {
|
public void zeroCategoriesSpecified_allDisabled() {
|
||||||
mManager.applyCurrentUserOverlays(Maps.newArrayMap(), null, TEST_USER.getIdentifier(),
|
mManager.applyCurrentUserOverlays(Maps.newArrayMap(), null, TEST_USER.getIdentifier(),
|
||||||
TEST_USER_HANDLES);
|
TEST_USER_HANDLES, mOnOverlaysApplied);
|
||||||
|
|
||||||
for (String category : THEME_CATEGORIES) {
|
for (String category : THEME_CATEGORIES) {
|
||||||
verify(mTransactionBuilder).setEnabled(
|
verify(mTransactionBuilder).setEnabled(
|
||||||
@@ -279,7 +283,7 @@ public class ThemeOverlayApplierTest extends SysuiTestCase {
|
|||||||
categoryToPackage.put("blah.category", new OverlayIdentifier("com.example.blah.category"));
|
categoryToPackage.put("blah.category", new OverlayIdentifier("com.example.blah.category"));
|
||||||
|
|
||||||
mManager.applyCurrentUserOverlays(categoryToPackage, null, TEST_USER.getIdentifier(),
|
mManager.applyCurrentUserOverlays(categoryToPackage, null, TEST_USER.getIdentifier(),
|
||||||
TEST_USER_HANDLES);
|
TEST_USER_HANDLES, mOnOverlaysApplied);
|
||||||
|
|
||||||
verify(mTransactionBuilder, never()).setEnabled(
|
verify(mTransactionBuilder, never()).setEnabled(
|
||||||
eq(new OverlayIdentifier("com.example.blah.category")), eq(false),
|
eq(new OverlayIdentifier("com.example.blah.category")), eq(false),
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ public class ThemeOverlayControllerTest extends SysuiTestCase {
|
|||||||
ArgumentCaptor.forClass(Map.class);
|
ArgumentCaptor.forClass(Map.class);
|
||||||
|
|
||||||
verify(mThemeOverlayApplier)
|
verify(mThemeOverlayApplier)
|
||||||
.applyCurrentUserOverlays(themeOverlays.capture(), any(), anyInt(), any());
|
.applyCurrentUserOverlays(themeOverlays.capture(), any(), anyInt(), any(), any());
|
||||||
|
|
||||||
// Assert that we received the colors that we were expecting
|
// Assert that we received the colors that we were expecting
|
||||||
assertThat(themeOverlays.getValue().get(OVERLAY_CATEGORY_SYSTEM_PALETTE))
|
assertThat(themeOverlays.getValue().get(OVERLAY_CATEGORY_SYSTEM_PALETTE))
|
||||||
@@ -183,7 +183,7 @@ public class ThemeOverlayControllerTest extends SysuiTestCase {
|
|||||||
mBroadcastReceiver.getValue().onReceive(null, new Intent(Intent.ACTION_WALLPAPER_CHANGED));
|
mBroadcastReceiver.getValue().onReceive(null, new Intent(Intent.ACTION_WALLPAPER_CHANGED));
|
||||||
mColorsListener.getValue().onColorsChanged(new WallpaperColors(Color.valueOf(Color.BLACK),
|
mColorsListener.getValue().onColorsChanged(new WallpaperColors(Color.valueOf(Color.BLACK),
|
||||||
null, null), WallpaperManager.FLAG_SYSTEM);
|
null, null), WallpaperManager.FLAG_SYSTEM);
|
||||||
verify(mThemeOverlayApplier).applyCurrentUserOverlays(any(), any(), anyInt(), any());
|
verify(mThemeOverlayApplier).applyCurrentUserOverlays(any(), any(), anyInt(), any(), any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -204,7 +204,7 @@ public class ThemeOverlayControllerTest extends SysuiTestCase {
|
|||||||
ArgumentCaptor.forClass(Map.class);
|
ArgumentCaptor.forClass(Map.class);
|
||||||
|
|
||||||
verify(mThemeOverlayApplier)
|
verify(mThemeOverlayApplier)
|
||||||
.applyCurrentUserOverlays(themeOverlays.capture(), any(), anyInt(), any());
|
.applyCurrentUserOverlays(themeOverlays.capture(), any(), anyInt(), any(), any());
|
||||||
|
|
||||||
// Assert that we received the colors that we were expecting
|
// Assert that we received the colors that we were expecting
|
||||||
assertThat(themeOverlays.getValue().get(OVERLAY_CATEGORY_SYSTEM_PALETTE))
|
assertThat(themeOverlays.getValue().get(OVERLAY_CATEGORY_SYSTEM_PALETTE))
|
||||||
@@ -240,7 +240,7 @@ public class ThemeOverlayControllerTest extends SysuiTestCase {
|
|||||||
.isFalse();
|
.isFalse();
|
||||||
|
|
||||||
verify(mThemeOverlayApplier)
|
verify(mThemeOverlayApplier)
|
||||||
.applyCurrentUserOverlays(any(), any(), anyInt(), any());
|
.applyCurrentUserOverlays(any(), any(), anyInt(), any(), any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -270,7 +270,7 @@ public class ThemeOverlayControllerTest extends SysuiTestCase {
|
|||||||
"android.theme.customization.color_both\":\"0")).isTrue();
|
"android.theme.customization.color_both\":\"0")).isTrue();
|
||||||
|
|
||||||
verify(mThemeOverlayApplier)
|
verify(mThemeOverlayApplier)
|
||||||
.applyCurrentUserOverlays(any(), any(), anyInt(), any());
|
.applyCurrentUserOverlays(any(), any(), anyInt(), any(), any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -300,7 +300,7 @@ public class ThemeOverlayControllerTest extends SysuiTestCase {
|
|||||||
"android.theme.customization.color_both\":\"1")).isTrue();
|
"android.theme.customization.color_both\":\"1")).isTrue();
|
||||||
|
|
||||||
verify(mThemeOverlayApplier)
|
verify(mThemeOverlayApplier)
|
||||||
.applyCurrentUserOverlays(any(), any(), anyInt(), any());
|
.applyCurrentUserOverlays(any(), any(), anyInt(), any(), any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -327,7 +327,7 @@ public class ThemeOverlayControllerTest extends SysuiTestCase {
|
|||||||
assertThat(updatedSetting.getValue().contains("android.theme.customization.color_index"))
|
assertThat(updatedSetting.getValue().contains("android.theme.customization.color_index"))
|
||||||
.isFalse();
|
.isFalse();
|
||||||
verify(mThemeOverlayApplier)
|
verify(mThemeOverlayApplier)
|
||||||
.applyCurrentUserOverlays(any(), any(), anyInt(), any());
|
.applyCurrentUserOverlays(any(), any(), anyInt(), any(), any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -354,7 +354,7 @@ public class ThemeOverlayControllerTest extends SysuiTestCase {
|
|||||||
assertThat(updatedSetting.getValue().contains("android.theme.customization.color_index"))
|
assertThat(updatedSetting.getValue().contains("android.theme.customization.color_index"))
|
||||||
.isFalse();
|
.isFalse();
|
||||||
verify(mThemeOverlayApplier)
|
verify(mThemeOverlayApplier)
|
||||||
.applyCurrentUserOverlays(any(), any(), anyInt(), any());
|
.applyCurrentUserOverlays(any(), any(), anyInt(), any(), any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -382,7 +382,7 @@ public class ThemeOverlayControllerTest extends SysuiTestCase {
|
|||||||
eq(Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES), updatedSetting.capture());
|
eq(Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES), updatedSetting.capture());
|
||||||
|
|
||||||
verify(mThemeOverlayApplier)
|
verify(mThemeOverlayApplier)
|
||||||
.applyCurrentUserOverlays(any(), any(), anyInt(), any());
|
.applyCurrentUserOverlays(any(), any(), anyInt(), any(), any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -411,14 +411,14 @@ public class ThemeOverlayControllerTest extends SysuiTestCase {
|
|||||||
|
|
||||||
|
|
||||||
verify(mThemeOverlayApplier, never())
|
verify(mThemeOverlayApplier, never())
|
||||||
.applyCurrentUserOverlays(any(), any(), anyInt(), any());
|
.applyCurrentUserOverlays(any(), any(), anyInt(), any(), any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onProfileAdded_setsTheme() {
|
public void onProfileAdded_setsTheme() {
|
||||||
mBroadcastReceiver.getValue().onReceive(null,
|
mBroadcastReceiver.getValue().onReceive(null,
|
||||||
new Intent(Intent.ACTION_MANAGED_PROFILE_ADDED));
|
new Intent(Intent.ACTION_MANAGED_PROFILE_ADDED));
|
||||||
verify(mThemeOverlayApplier).applyCurrentUserOverlays(any(), any(), anyInt(), any());
|
verify(mThemeOverlayApplier).applyCurrentUserOverlays(any(), any(), anyInt(), any(), any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -428,7 +428,7 @@ public class ThemeOverlayControllerTest extends SysuiTestCase {
|
|||||||
mBroadcastReceiver.getValue().onReceive(null,
|
mBroadcastReceiver.getValue().onReceive(null,
|
||||||
new Intent(Intent.ACTION_MANAGED_PROFILE_ADDED));
|
new Intent(Intent.ACTION_MANAGED_PROFILE_ADDED));
|
||||||
verify(mThemeOverlayApplier)
|
verify(mThemeOverlayApplier)
|
||||||
.applyCurrentUserOverlays(any(), any(), anyInt(), any());
|
.applyCurrentUserOverlays(any(), any(), anyInt(), any(), any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -438,7 +438,7 @@ public class ThemeOverlayControllerTest extends SysuiTestCase {
|
|||||||
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())
|
||||||
.applyCurrentUserOverlays(any(), any(), anyInt(), any());
|
.applyCurrentUserOverlays(any(), any(), anyInt(), any(), any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -450,7 +450,7 @@ public class ThemeOverlayControllerTest extends SysuiTestCase {
|
|||||||
Color.valueOf(Color.BLUE), null);
|
Color.valueOf(Color.BLUE), null);
|
||||||
mColorsListener.getValue().onColorsChanged(mainColors, WallpaperManager.FLAG_SYSTEM);
|
mColorsListener.getValue().onColorsChanged(mainColors, WallpaperManager.FLAG_SYSTEM);
|
||||||
|
|
||||||
verify(mThemeOverlayApplier).applyCurrentUserOverlays(any(), any(), anyInt(), any());
|
verify(mThemeOverlayApplier).applyCurrentUserOverlays(any(), any(), anyInt(), any(), any());
|
||||||
|
|
||||||
// Regression test: null events should not reset the internal state and allow colors to be
|
// Regression test: null events should not reset the internal state and allow colors to be
|
||||||
// applied again.
|
// applied again.
|
||||||
@@ -458,11 +458,11 @@ public class ThemeOverlayControllerTest extends SysuiTestCase {
|
|||||||
mBroadcastReceiver.getValue().onReceive(null, new Intent(Intent.ACTION_WALLPAPER_CHANGED));
|
mBroadcastReceiver.getValue().onReceive(null, new Intent(Intent.ACTION_WALLPAPER_CHANGED));
|
||||||
mColorsListener.getValue().onColorsChanged(null, WallpaperManager.FLAG_SYSTEM);
|
mColorsListener.getValue().onColorsChanged(null, WallpaperManager.FLAG_SYSTEM);
|
||||||
verify(mThemeOverlayApplier, never()).applyCurrentUserOverlays(any(), any(), anyInt(),
|
verify(mThemeOverlayApplier, never()).applyCurrentUserOverlays(any(), any(), anyInt(),
|
||||||
any());
|
any(), any());
|
||||||
mColorsListener.getValue().onColorsChanged(new WallpaperColors(Color.valueOf(Color.GREEN),
|
mColorsListener.getValue().onColorsChanged(new WallpaperColors(Color.valueOf(Color.GREEN),
|
||||||
null, null), WallpaperManager.FLAG_SYSTEM);
|
null, null), WallpaperManager.FLAG_SYSTEM);
|
||||||
verify(mThemeOverlayApplier, never()).applyCurrentUserOverlays(any(), any(), anyInt(),
|
verify(mThemeOverlayApplier, never()).applyCurrentUserOverlays(any(), any(), anyInt(),
|
||||||
any());
|
any(), any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -499,7 +499,7 @@ public class ThemeOverlayControllerTest extends SysuiTestCase {
|
|||||||
verify(mDeviceProvisionedController).addCallback(mDeviceProvisionedListener.capture());
|
verify(mDeviceProvisionedController).addCallback(mDeviceProvisionedListener.capture());
|
||||||
|
|
||||||
// Colors were applied during controller initialization.
|
// Colors were applied during controller initialization.
|
||||||
verify(mThemeOverlayApplier).applyCurrentUserOverlays(any(), any(), anyInt(), any());
|
verify(mThemeOverlayApplier).applyCurrentUserOverlays(any(), any(), anyInt(), any(), any());
|
||||||
clearInvocations(mThemeOverlayApplier);
|
clearInvocations(mThemeOverlayApplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -533,7 +533,7 @@ public class ThemeOverlayControllerTest extends SysuiTestCase {
|
|||||||
verify(mDeviceProvisionedController).addCallback(mDeviceProvisionedListener.capture());
|
verify(mDeviceProvisionedController).addCallback(mDeviceProvisionedListener.capture());
|
||||||
|
|
||||||
// Colors were applied during controller initialization.
|
// Colors were applied during controller initialization.
|
||||||
verify(mThemeOverlayApplier).applyCurrentUserOverlays(any(), any(), anyInt(), any());
|
verify(mThemeOverlayApplier).applyCurrentUserOverlays(any(), any(), anyInt(), any(), any());
|
||||||
clearInvocations(mThemeOverlayApplier);
|
clearInvocations(mThemeOverlayApplier);
|
||||||
|
|
||||||
WallpaperColors mainColors = new WallpaperColors(Color.valueOf(Color.RED),
|
WallpaperColors mainColors = new WallpaperColors(Color.valueOf(Color.RED),
|
||||||
@@ -542,12 +542,12 @@ public class ThemeOverlayControllerTest extends SysuiTestCase {
|
|||||||
|
|
||||||
// Defers event because we already have initial colors.
|
// Defers event because we already have initial colors.
|
||||||
verify(mThemeOverlayApplier, never())
|
verify(mThemeOverlayApplier, never())
|
||||||
.applyCurrentUserOverlays(any(), any(), anyInt(), any());
|
.applyCurrentUserOverlays(any(), any(), anyInt(), any(), any());
|
||||||
|
|
||||||
// Then event happens after setup phase is over.
|
// Then event happens after setup phase is over.
|
||||||
when(mDeviceProvisionedController.isCurrentUserSetup()).thenReturn(true);
|
when(mDeviceProvisionedController.isCurrentUserSetup()).thenReturn(true);
|
||||||
mDeviceProvisionedListener.getValue().onUserSetupChanged();
|
mDeviceProvisionedListener.getValue().onUserSetupChanged();
|
||||||
verify(mThemeOverlayApplier).applyCurrentUserOverlays(any(), any(), anyInt(), any());
|
verify(mThemeOverlayApplier).applyCurrentUserOverlays(any(), any(), anyInt(), any(), any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -568,11 +568,11 @@ public class ThemeOverlayControllerTest extends SysuiTestCase {
|
|||||||
Color.valueOf(Color.RED), null);
|
Color.valueOf(Color.RED), null);
|
||||||
mColorsListener.getValue().onColorsChanged(mainColors, WallpaperManager.FLAG_SYSTEM);
|
mColorsListener.getValue().onColorsChanged(mainColors, WallpaperManager.FLAG_SYSTEM);
|
||||||
verify(mThemeOverlayApplier, never())
|
verify(mThemeOverlayApplier, never())
|
||||||
.applyCurrentUserOverlays(any(), any(), anyInt(), any());
|
.applyCurrentUserOverlays(any(), any(), anyInt(), any(), any());
|
||||||
|
|
||||||
mWakefulnessLifecycle.dispatchFinishedGoingToSleep();
|
mWakefulnessLifecycle.dispatchFinishedGoingToSleep();
|
||||||
verify(mThemeOverlayApplier, never())
|
verify(mThemeOverlayApplier, never())
|
||||||
.applyCurrentUserOverlays(any(), any(), anyInt(), any());
|
.applyCurrentUserOverlays(any(), any(), anyInt(), any(), any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -592,10 +592,10 @@ public class ThemeOverlayControllerTest extends SysuiTestCase {
|
|||||||
Color.valueOf(Color.RED), null);
|
Color.valueOf(Color.RED), null);
|
||||||
mColorsListener.getValue().onColorsChanged(mainColors, WallpaperManager.FLAG_SYSTEM);
|
mColorsListener.getValue().onColorsChanged(mainColors, WallpaperManager.FLAG_SYSTEM);
|
||||||
verify(mThemeOverlayApplier, never())
|
verify(mThemeOverlayApplier, never())
|
||||||
.applyCurrentUserOverlays(any(), any(), anyInt(), any());
|
.applyCurrentUserOverlays(any(), any(), anyInt(), any(), any());
|
||||||
|
|
||||||
mWakefulnessLifecycleObserver.getValue().onFinishedGoingToSleep();
|
mWakefulnessLifecycleObserver.getValue().onFinishedGoingToSleep();
|
||||||
verify(mThemeOverlayApplier).applyCurrentUserOverlays(any(), any(), anyInt(), any());
|
verify(mThemeOverlayApplier).applyCurrentUserOverlays(any(), any(), anyInt(), any(), any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -614,7 +614,7 @@ public class ThemeOverlayControllerTest extends SysuiTestCase {
|
|||||||
ArgumentCaptor.forClass(Map.class);
|
ArgumentCaptor.forClass(Map.class);
|
||||||
|
|
||||||
verify(mThemeOverlayApplier)
|
verify(mThemeOverlayApplier)
|
||||||
.applyCurrentUserOverlays(themeOverlays.capture(), any(), anyInt(), any());
|
.applyCurrentUserOverlays(themeOverlays.capture(), any(), anyInt(), any(), any());
|
||||||
|
|
||||||
// Assert that we received the colors that we were expecting
|
// Assert that we received the colors that we were expecting
|
||||||
assertThat(themeOverlays.getValue().get(OVERLAY_CATEGORY_SYSTEM_PALETTE))
|
assertThat(themeOverlays.getValue().get(OVERLAY_CATEGORY_SYSTEM_PALETTE))
|
||||||
|
|||||||
Reference in New Issue
Block a user