Do not ignore forceReload requests

A recent optimization was causing reevaluateSystemTheme to be skipped
for secondary/managed profiles.
This change makes sure that forceReload requests will be honored.

Test: atest ThemeOverlayControllerTest
Fixes: 229837333
Change-Id: Id868000da327b49264e4ff62aa006b40a87228a3
This commit is contained in:
Lucas Dupin
2022-04-27 14:51:45 -07:00
parent e5f9c3da5c
commit 376e805767
2 changed files with 13 additions and 1 deletions

View File

@@ -474,7 +474,7 @@ public class ThemeOverlayController extends CoreStartable implements Dumpable {
mThemeStyle = fetchThemeStyleFromSetting();
mSecondaryOverlay = getOverlay(mMainWallpaperColor, ACCENT, mThemeStyle);
mNeutralOverlay = getOverlay(mMainWallpaperColor, NEUTRAL, mThemeStyle);
if (colorSchemeIsApplied()) {
if (colorSchemeIsApplied() && !forceReload) {
Log.d(TAG, "Skipping overlay creation. Theme was already: " + mColorScheme);
return;
}

View File

@@ -729,6 +729,18 @@ public class ThemeOverlayControllerTest extends SysuiTestCase {
mColorsListener.getValue().onColorsChanged(mainColors, WallpaperManager.FLAG_SYSTEM,
USER_SYSTEM);
reset(mResources);
when(mResources.getColor(eq(android.R.color.system_accent1_500), any()))
.thenReturn(mThemeOverlayController.mColorScheme.getAccent1().get(6));
when(mResources.getColor(eq(android.R.color.system_accent2_500), any()))
.thenReturn(mThemeOverlayController.mColorScheme.getAccent2().get(6));
when(mResources.getColor(eq(android.R.color.system_accent3_500), any()))
.thenReturn(mThemeOverlayController.mColorScheme.getAccent3().get(6));
when(mResources.getColor(eq(android.R.color.system_neutral1_500), any()))
.thenReturn(mThemeOverlayController.mColorScheme.getNeutral1().get(6));
when(mResources.getColor(eq(android.R.color.system_neutral2_500), any()))
.thenReturn(mThemeOverlayController.mColorScheme.getNeutral2().get(6));
// Defers event because we already have initial colors.
verify(mThemeOverlayApplier, never())
.applyCurrentUserOverlays(any(), any(), anyInt(), any());