From 94fecb94e9f869d620b79792a849d91238de9449 Mon Sep 17 00:00:00 2001 From: Todd Kennedy Date: Thu, 10 May 2018 10:26:07 -0700 Subject: [PATCH] OMS: rebase settings when overlays update When an overlay package has been upgraded, OMS needs to reconcile any previous settings about the overlay with the new state of affairs. Sometimes it is possible to rebase the OMS settings on the new information [e.g. the overlay has changed categories]; sometimes the OMS settings have to be scrapped [e.g. the overlay has changed target package]. Update OMS to do The Right Thing. Bug: 78809704 Test: manual (adb shell stop, adb push specially prepared overlays, adb shell start, adb exec-out cmd overlay dump) Test: ran unit tests Test: adb install out/target/product/walleye/data/app/SettingsUnitTests/SettingsUnitTests.apk Test: adb shell am instrument -w -e class com.android.settings.display.ThemePreferenceControllerTest com.android.settings.tests.unit/android.support.test.runner.AndroidJUnitRunner Test: NOTE: 3 of 4 failures both pre and post change; looks like there are issue with the unit tests themselves Change-Id: Icd1ae633dbee5b5ca957fa6b652af6209b4b1260 --- .../display/ThemePreferenceControllerTest.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/unit/src/com/android/settings/display/ThemePreferenceControllerTest.java b/tests/unit/src/com/android/settings/display/ThemePreferenceControllerTest.java index e618343d8de..586c4486846 100644 --- a/tests/unit/src/com/android/settings/display/ThemePreferenceControllerTest.java +++ b/tests/unit/src/com/android/settings/display/ThemePreferenceControllerTest.java @@ -69,9 +69,9 @@ public class ThemePreferenceControllerTest { @Test public void testUpdateState() throws Exception { OverlayInfo info1 = new OverlayInfo("com.android.Theme1", "android", - "", "", OverlayInfo.STATE_ENABLED, 0); + "", "", OverlayInfo.STATE_ENABLED, 0, 0, true); OverlayInfo info2 = new OverlayInfo("com.android.Theme2", "android", - "", "", 0, 0); + "", "", 0, 0, 0, true); when(mMockPackageManager.getApplicationInfo(any(), anyInt())).thenAnswer(inv -> { ApplicationInfo info = mock(ApplicationInfo.class); if ("com.android.Theme1".equals(inv.getArguments()[0])) { @@ -105,9 +105,9 @@ public class ThemePreferenceControllerTest { @Test public void testUpdateState_withStaticOverlay() throws Exception { OverlayInfo info1 = new OverlayInfo("com.android.Theme1", "android", - "", "", OverlayInfo.STATE_ENABLED, 0); + "", "", OverlayInfo.STATE_ENABLED, 0, 0, true); OverlayInfo info2 = new OverlayInfo("com.android.Theme2", "android", - "", "", OverlayInfo.STATE_ENABLED, 0); + "", "", OverlayInfo.STATE_ENABLED, 0, 0, true); when(mMockPackageManager.getApplicationInfo(any(), anyInt())).thenAnswer(inv -> { ApplicationInfo info = mock(ApplicationInfo.class); if ("com.android.Theme1".equals(inv.getArguments()[0])) { @@ -145,7 +145,7 @@ public class ThemePreferenceControllerTest { when(mMockPackageManager.getPackageInfo(anyString(), anyInt())).thenReturn( new PackageInfo()); when(mMockOverlayManager.getOverlayInfosForTarget(any(), anyInt())) - .thenReturn(list(new OverlayInfo("", "", "", "", 0, 0))); + .thenReturn(list(new OverlayInfo("", "", "", "", 0, 0, 0, false))); assertThat(mPreferenceController.isAvailable()).isFalse(); } @@ -154,8 +154,8 @@ public class ThemePreferenceControllerTest { when(mMockPackageManager.getPackageInfo(anyString(), anyInt())).thenReturn( new PackageInfo()); when(mMockOverlayManager.getOverlayInfosForTarget(any(), anyInt())) - .thenReturn(list(new OverlayInfo("", "", "", "", 0, 0), - new OverlayInfo("", "", "", "", 0, 0))); + .thenReturn(list(new OverlayInfo("", "", "", "", 0, 0, 0, true), + new OverlayInfo("", "", "", "", 0, 0, 0, true))); assertThat(mPreferenceController.isAvailable()).isTrue(); }