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
This commit is contained in:
Todd Kennedy
2018-05-10 10:26:07 -07:00
parent e30007dcc0
commit 94fecb94e9

View File

@@ -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();
}