OMS: ensure framework overlays affect newly installed apps
Make sure to tell the package manager about an application's overlay paths if there is at least one enabled overlay affecting the application. This includes looking at framework overlays (which affect all applications). Also, add a test to verify the following flow: - Enable an overlay targeting "android" - Install an app - Launch the newly installed app - Assert that the newly installed app uses the framework overlay Also, update InstallOverlayTests#installPlatformSignedFrameworkOverlay\ AndUpdate to assert the correct resource (framework instead of app resource). Bug: 78808367 Test: atest 'OverlayHostTests:InstallOverlayTests#enabledFrameworkOverlayMustAffectNewlyInstalledPackage' Change-Id: Ic3450af6c2e827efce056874606caf1d853359eb
This commit is contained in:
committed by
Todd Kennedy
parent
497945cfa1
commit
a3bd3491cc
@@ -118,7 +118,7 @@ public class InstallOverlayTests extends BaseHostJUnit4Test {
|
||||
|
||||
@Test
|
||||
public void installPlatformSignedFrameworkOverlayAndUpdate() throws Exception {
|
||||
assertTrue(runDeviceTests(DEVICE_TEST_PKG, DEVICE_TEST_CLS, "expectAppResource"));
|
||||
assertTrue(runDeviceTests(DEVICE_TEST_PKG, DEVICE_TEST_CLS, "expectFrameworkResource"));
|
||||
|
||||
installPackage("OverlayHostTests_FrameworkOverlayV1.apk");
|
||||
setOverlayEnabled(FRAMEWORK_OVERLAY_PACKAGE_NAME, true);
|
||||
@@ -138,6 +138,27 @@ public class InstallOverlayTests extends BaseHostJUnit4Test {
|
||||
"expectFrameworkOverlayV2Resource"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void enabledFrameworkOverlayMustAffectNewlyInstalledPackage() throws Exception {
|
||||
try {
|
||||
setPackageEnabled(DEVICE_TEST_PKG, false);
|
||||
|
||||
installPackage("OverlayHostTests_FrameworkOverlayV1.apk");
|
||||
setOverlayEnabled(FRAMEWORK_OVERLAY_PACKAGE_NAME, true);
|
||||
assertTrue(overlayManagerContainsPackage(FRAMEWORK_OVERLAY_PACKAGE_NAME));
|
||||
|
||||
setPackageEnabled(DEVICE_TEST_PKG, true);
|
||||
assertTrue(runDeviceTests(DEVICE_TEST_PKG, DEVICE_TEST_CLS,
|
||||
"expectFrameworkOverlayV1Resource"));
|
||||
} finally {
|
||||
setPackageEnabled(DEVICE_TEST_PKG, true);
|
||||
}
|
||||
}
|
||||
|
||||
private void setPackageEnabled(String pkg, boolean enabled) throws Exception {
|
||||
getDevice().executeShellCommand("cmd package " + (enabled ? "enable " : "disable ") + pkg);
|
||||
}
|
||||
|
||||
private void setOverlayEnabled(String pkg, boolean enabled) throws Exception {
|
||||
getDevice().executeShellCommand("cmd overlay " + (enabled ? "enable " : "disable ") + pkg);
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public class UpdateOverlayTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void expectFrameworkOverlayResource() throws Exception {
|
||||
public void expectFrameworkResource() throws Exception {
|
||||
assertEquals("OK", mResources.getString(android.R.string.ok));
|
||||
}
|
||||
|
||||
|
||||
@@ -254,7 +254,11 @@ final class OverlayManagerServiceImpl {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the settings were modified for this target.
|
||||
* Update the state of any overlays for this target.
|
||||
*
|
||||
* Returns true if the system should refresh the app's overlay paths (i.e.
|
||||
* if the settings were modified for this target, or there is at least one
|
||||
* enabled framework overlay).
|
||||
*/
|
||||
private boolean updateAllOverlaysForTarget(@NonNull final String targetPackageName,
|
||||
final int userId, final int flags) {
|
||||
@@ -277,6 +281,10 @@ final class OverlayManagerServiceImpl {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check for enabled framework overlays
|
||||
modified = modified || !getEnabledOverlayPackageNames("android", userId).isEmpty();
|
||||
|
||||
return modified;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user