Loading services/core/java/com/android/server/pm/Settings.java +1 −1 Original line number Diff line number Diff line Loading @@ -799,7 +799,6 @@ public final class Settings implements Watchable, Snappable { // always make sure the system package code and resource paths dont change if (dp == null && p.getPkg() != null && p.getPkg().isSystem() && !p.getPkgState().isUpdatedSystemApp()) { p.getPkgState().setUpdatedSystemApp(true); final PackageSetting disabled; if (replaced) { // a little trick... when we install the new package, we don't Loading @@ -810,6 +809,7 @@ public final class Settings implements Watchable, Snappable { } else { disabled = p; } p.getPkgState().setUpdatedSystemApp(true); mDisabledSysPackages.put(name, disabled); SharedUserSetting sharedUserSetting = getSharedUserSettingLPr(disabled); if (sharedUserSetting != null) { Loading tests/StagedInstallTest/app/src/com/android/tests/stagedinstallinternal/StagedInstallInternalTest.java +57 −0 Original line number Diff line number Diff line Loading @@ -114,6 +114,63 @@ public class StagedInstallInternalTest { Uninstall.packages(TestApp.A, TestApp.B); } private boolean isSystem(PackageInfo info) { return (info.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0; } private boolean isUpdatedSystem(PackageInfo info) { return (info.applicationInfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0; } @Test public void testUpdateSystemApp_InstallV2() throws Exception { assertThat(InstallUtils.getInstalledVersion(TestApp.A)).isEqualTo(1); PackageManager pm = InstrumentationRegistry.getInstrumentation().getContext().getPackageManager(); PackageInfo info; // Check factory version info = pm.getPackageInfo(TestApp.A, PackageManager.PackageInfoFlags.of(PackageManager.MATCH_FACTORY_ONLY)); assertThat(isSystem(info)).isTrue(); assertThat(isUpdatedSystem(info)).isFalse(); // Check active version info = pm.getPackageInfo(TestApp.A, PackageManager.PackageInfoFlags.of(0)); assertThat(isSystem(info)).isTrue(); assertThat(isUpdatedSystem(info)).isFalse(); Install.single(TestApp.A2).commit(); assertThat(InstallUtils.getInstalledVersion(TestApp.A)).isEqualTo(2); // Check factory version info = pm.getPackageInfo(TestApp.A, PackageManager.PackageInfoFlags.of(PackageManager.MATCH_FACTORY_ONLY)); assertThat(isSystem(info)).isTrue(); assertThat(isUpdatedSystem(info)).isFalse(); // Check active version info = pm.getPackageInfo(TestApp.A, PackageManager.PackageInfoFlags.of(0)); assertThat(isSystem(info)).isTrue(); assertThat(isUpdatedSystem(info)).isTrue(); } @Test public void testUpdateSystemApp_PostInstallV2() throws Exception { assertThat(InstallUtils.getInstalledVersion(TestApp.A)).isEqualTo(2); PackageManager pm = InstrumentationRegistry.getInstrumentation().getContext().getPackageManager(); PackageInfo info; // Check factory version info = pm.getPackageInfo(TestApp.A, PackageManager.PackageInfoFlags.of(PackageManager.MATCH_FACTORY_ONLY)); assertThat(isSystem(info)).isTrue(); assertThat(isUpdatedSystem(info)).isFalse(); // Check active version info = pm.getPackageInfo(TestApp.A, PackageManager.PackageInfoFlags.of(0)); assertThat(isSystem(info)).isTrue(); assertThat(isUpdatedSystem(info)).isTrue(); } @Test public void testDuplicateApkInApexShouldFail_Commit() throws Exception { assertThat(InstallUtils.getInstalledVersion(TestApp.A)).isEqualTo(1); Loading tests/StagedInstallTest/src/com/android/tests/stagedinstallinternal/host/StagedInstallInternalTest.java +20 −0 Original line number Diff line number Diff line Loading @@ -95,6 +95,7 @@ public class StagedInstallInternalTest extends BaseHostJUnit4Test { "/data/apex/active/" + SHIM_APEX_PACKAGE_NAME + "*.apex", "/system/apex/test.rebootless_apex_v*.apex", "/data/apex/active/test.apex.rebootless*.apex", "/system/app/TestApp/TestAppAv1.apk", TEST_VENDOR_APEX_ALLOW_LIST); } Loading Loading @@ -162,6 +163,25 @@ public class StagedInstallInternalTest extends BaseHostJUnit4Test { getDevice().pushFile(file, TEST_VENDOR_APEX_ALLOW_LIST); } /** * Tests app info flags are set correctly when updating a system app. */ @Test public void testUpdateSystemApp() throws Exception { // Push TestAppAv1.apk to /system final File apkFile = mHostUtils.getTestFile(APK_A); if (!getDevice().isAdbRoot()) { getDevice().enableAdbRoot(); } getDevice().remountSystemWritable(); assertTrue(getDevice().pushFile(apkFile, "/system/app/TestApp/" + apkFile.getName())); getDevice().reboot(); runPhase("testUpdateSystemApp_InstallV2"); getDevice().reboot(); runPhase("testUpdateSystemApp_PostInstallV2"); } /** * Tests that duplicate packages in apk-in-apex and apk should fail to install. */ Loading Loading
services/core/java/com/android/server/pm/Settings.java +1 −1 Original line number Diff line number Diff line Loading @@ -799,7 +799,6 @@ public final class Settings implements Watchable, Snappable { // always make sure the system package code and resource paths dont change if (dp == null && p.getPkg() != null && p.getPkg().isSystem() && !p.getPkgState().isUpdatedSystemApp()) { p.getPkgState().setUpdatedSystemApp(true); final PackageSetting disabled; if (replaced) { // a little trick... when we install the new package, we don't Loading @@ -810,6 +809,7 @@ public final class Settings implements Watchable, Snappable { } else { disabled = p; } p.getPkgState().setUpdatedSystemApp(true); mDisabledSysPackages.put(name, disabled); SharedUserSetting sharedUserSetting = getSharedUserSettingLPr(disabled); if (sharedUserSetting != null) { Loading
tests/StagedInstallTest/app/src/com/android/tests/stagedinstallinternal/StagedInstallInternalTest.java +57 −0 Original line number Diff line number Diff line Loading @@ -114,6 +114,63 @@ public class StagedInstallInternalTest { Uninstall.packages(TestApp.A, TestApp.B); } private boolean isSystem(PackageInfo info) { return (info.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0; } private boolean isUpdatedSystem(PackageInfo info) { return (info.applicationInfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0; } @Test public void testUpdateSystemApp_InstallV2() throws Exception { assertThat(InstallUtils.getInstalledVersion(TestApp.A)).isEqualTo(1); PackageManager pm = InstrumentationRegistry.getInstrumentation().getContext().getPackageManager(); PackageInfo info; // Check factory version info = pm.getPackageInfo(TestApp.A, PackageManager.PackageInfoFlags.of(PackageManager.MATCH_FACTORY_ONLY)); assertThat(isSystem(info)).isTrue(); assertThat(isUpdatedSystem(info)).isFalse(); // Check active version info = pm.getPackageInfo(TestApp.A, PackageManager.PackageInfoFlags.of(0)); assertThat(isSystem(info)).isTrue(); assertThat(isUpdatedSystem(info)).isFalse(); Install.single(TestApp.A2).commit(); assertThat(InstallUtils.getInstalledVersion(TestApp.A)).isEqualTo(2); // Check factory version info = pm.getPackageInfo(TestApp.A, PackageManager.PackageInfoFlags.of(PackageManager.MATCH_FACTORY_ONLY)); assertThat(isSystem(info)).isTrue(); assertThat(isUpdatedSystem(info)).isFalse(); // Check active version info = pm.getPackageInfo(TestApp.A, PackageManager.PackageInfoFlags.of(0)); assertThat(isSystem(info)).isTrue(); assertThat(isUpdatedSystem(info)).isTrue(); } @Test public void testUpdateSystemApp_PostInstallV2() throws Exception { assertThat(InstallUtils.getInstalledVersion(TestApp.A)).isEqualTo(2); PackageManager pm = InstrumentationRegistry.getInstrumentation().getContext().getPackageManager(); PackageInfo info; // Check factory version info = pm.getPackageInfo(TestApp.A, PackageManager.PackageInfoFlags.of(PackageManager.MATCH_FACTORY_ONLY)); assertThat(isSystem(info)).isTrue(); assertThat(isUpdatedSystem(info)).isFalse(); // Check active version info = pm.getPackageInfo(TestApp.A, PackageManager.PackageInfoFlags.of(0)); assertThat(isSystem(info)).isTrue(); assertThat(isUpdatedSystem(info)).isTrue(); } @Test public void testDuplicateApkInApexShouldFail_Commit() throws Exception { assertThat(InstallUtils.getInstalledVersion(TestApp.A)).isEqualTo(1); Loading
tests/StagedInstallTest/src/com/android/tests/stagedinstallinternal/host/StagedInstallInternalTest.java +20 −0 Original line number Diff line number Diff line Loading @@ -95,6 +95,7 @@ public class StagedInstallInternalTest extends BaseHostJUnit4Test { "/data/apex/active/" + SHIM_APEX_PACKAGE_NAME + "*.apex", "/system/apex/test.rebootless_apex_v*.apex", "/data/apex/active/test.apex.rebootless*.apex", "/system/app/TestApp/TestAppAv1.apk", TEST_VENDOR_APEX_ALLOW_LIST); } Loading Loading @@ -162,6 +163,25 @@ public class StagedInstallInternalTest extends BaseHostJUnit4Test { getDevice().pushFile(file, TEST_VENDOR_APEX_ALLOW_LIST); } /** * Tests app info flags are set correctly when updating a system app. */ @Test public void testUpdateSystemApp() throws Exception { // Push TestAppAv1.apk to /system final File apkFile = mHostUtils.getTestFile(APK_A); if (!getDevice().isAdbRoot()) { getDevice().enableAdbRoot(); } getDevice().remountSystemWritable(); assertTrue(getDevice().pushFile(apkFile, "/system/app/TestApp/" + apkFile.getName())); getDevice().reboot(); runPhase("testUpdateSystemApp_InstallV2"); getDevice().reboot(); runPhase("testUpdateSystemApp_PostInstallV2"); } /** * Tests that duplicate packages in apk-in-apex and apk should fail to install. */ Loading