summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Lucas Dupin <dupin@google.com> 2021-04-21 23:54:01 -0700
committer Lucas Dupin <dupin@google.com> 2021-04-22 22:35:56 +0000
commit9c07bde8738672abbf7687128fed26d32cfb6fd7 (patch)
treeaaaa80de1299a760031e86efc077f57e389ac4f4
parent469e1b49423f14359278c123333e1f2aaad901eb (diff)
Fix issue where theme would be accepted in SUW
An event passing null would cause the internal state of ThemeOverlayController to be reset, accepting future theming events. Test: atest ThemeOverlayControllerTest Bug: 182560740 Change-Id: Ie619ff5ae73b97e6a26cc90227bcad1c6277b30b
-rw-r--r--packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java4
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/theme/ThemeOverlayControllerTest.java12
2 files changed, 16 insertions, 0 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java b/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java
index fdd929cae17d..5c5052d4d0d7 100644
--- a/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java
+++ b/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java
@@ -151,6 +151,10 @@ public class ThemeOverlayController extends SystemUI implements Dumpable {
+ wallpaperColors);
mDeferredThemeEvaluation = true;
return;
+ } else if (mDeferredThemeEvaluation) {
+ Log.i(TAG, "Wallpaper color event received, but we already were deferring eval: "
+ + wallpaperColors);
+ return;
} else {
if (DEBUG) {
Log.i(TAG, "During user setup, but allowing first color event: had? "
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 ddf39d1e7c6e..1d1411ad2ec1 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/theme/ThemeOverlayControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/theme/ThemeOverlayControllerTest.java
@@ -212,6 +212,18 @@ public class ThemeOverlayControllerTest extends SysuiTestCase {
mColorsListener.getValue().onColorsChanged(mainColors, WallpaperManager.FLAG_SYSTEM);
verify(mThemeOverlayApplier).applyCurrentUserOverlays(any(), any(), anyInt(), any());
+
+ // Regression test: null events should not reset the internal state and allow colors to be
+ // applied again.
+ clearInvocations(mThemeOverlayApplier);
+ mBroadcastReceiver.getValue().onReceive(null, new Intent(Intent.ACTION_WALLPAPER_CHANGED));
+ mColorsListener.getValue().onColorsChanged(null, WallpaperManager.FLAG_SYSTEM);
+ verify(mThemeOverlayApplier, never()).applyCurrentUserOverlays(any(), any(), anyInt(),
+ any());
+ mColorsListener.getValue().onColorsChanged(new WallpaperColors(Color.valueOf(Color.GREEN),
+ null, null), WallpaperManager.FLAG_SYSTEM);
+ verify(mThemeOverlayApplier, never()).applyCurrentUserOverlays(any(), any(), anyInt(),
+ any());
}
@Test