Loading services/core/java/com/android/server/pm/ApexManager.java +2 −0 Original line number Diff line number Diff line Loading @@ -582,6 +582,8 @@ public abstract class ApexManager { ApexInfo ai = parsingApexInfo.get(parseResult.scanFile); if (throwable == null) { // Calling hideAsFinal to assign derived fields for the app info flags. parseResult.parsedPackage.hideAsFinal(); final PackageInfo packageInfo = PackageInfoWithoutStateUtils.generate( parseResult.parsedPackage, ai, flags); if (packageInfo == null) { Loading tests/StagedInstallTest/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -62,6 +62,7 @@ java_test_host { ":TestAppAv1", ":test.rebootless_apex_v1", ":test.rebootless_apex_v2", ":test_com.android.server", ], test_suites: ["general-tests"], test_config: "StagedInstallInternalTest.xml", Loading tests/StagedInstallTest/app/src/com/android/tests/stagedinstallinternal/StagedInstallInternalTest.java +13 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import android.content.pm.IStagedApexObserver; import android.content.pm.PackageInfo; import android.content.pm.PackageInstaller; import android.content.pm.PackageManager; import android.content.pm.PackageManager.ApplicationInfoFlags; import android.content.pm.StagedApexInfo; import android.os.IBinder; import android.os.ServiceManager; Loading Loading @@ -79,6 +80,8 @@ public class StagedInstallInternalTest { TEST_APEX_PACKAGE_NAME, 1, /*isApex=*/true, "apex.apexd_test_classpath.apex"); private static final String TEST_APEX_SYSTEM_SERVER_PACKAGE_NAME = "test_com.android.server"; private File mTestStateFile = new File( InstrumentationRegistry.getInstrumentation().getContext().getFilesDir(), "stagedinstall_state"); Loading Loading @@ -480,6 +483,16 @@ public class StagedInstallInternalTest { InstallUtils.openPackageInstallerSession(sessionId).abandon(); } @Test public void testGetAppInfo_flagTestOnlyIsSet() throws Exception { final PackageManager pm = InstrumentationRegistry.getInstrumentation().getContext().getPackageManager(); final ApplicationInfo info = pm.getApplicationInfo(TEST_APEX_SYSTEM_SERVER_PACKAGE_NAME, ApplicationInfoFlags.of(PackageManager.MATCH_APEX)); assertThat(info).isNotNull(); assertThat((info.flags & ApplicationInfo.FLAG_TEST_ONLY) != 0).isTrue(); } public static class MockStagedApexObserver extends IStagedApexObserver.Stub { @Override public void onApexStaged(ApexStagedEvent event) { Loading tests/StagedInstallTest/src/com/android/tests/stagedinstallinternal/host/StagedInstallInternalTest.java +13 −0 Original line number Diff line number Diff line Loading @@ -62,6 +62,7 @@ public class StagedInstallInternalTest extends BaseHostJUnit4Test { private static final String APK_A = "TestAppAv1.apk"; private static final String APK_IN_APEX_TESTAPEX_NAME = "com.android.apex.apkrollback.test"; private static final String APEXD_TEST_APEX = "apex.apexd_test.apex"; private static final String FAKE_APEX_SYSTEM_SERVER_APEX = "test_com.android.server.apex"; private static final String TEST_VENDOR_APEX_ALLOW_LIST = "/vendor/etc/sysconfig/test-vendor-apex-allow-list.xml"; Loading Loading @@ -512,6 +513,18 @@ public class StagedInstallInternalTest extends BaseHostJUnit4Test { runPhase("testGetStagedApexInfo"); } @Test @LargeTest public void testGetAppInfo_flagTestOnlyIsSet() throws Exception { assumeTrue("Device does not support updating APEX", mHostUtils.isApexUpdateSupported()); pushTestApex(FAKE_APEX_SYSTEM_SERVER_APEX); getDevice().reboot(); runPhase("testGetAppInfo_flagTestOnlyIsSet"); } @Test public void testStagedApexObserver() throws Exception { assumeTrue("Device does not support updating APEX", Loading Loading
services/core/java/com/android/server/pm/ApexManager.java +2 −0 Original line number Diff line number Diff line Loading @@ -582,6 +582,8 @@ public abstract class ApexManager { ApexInfo ai = parsingApexInfo.get(parseResult.scanFile); if (throwable == null) { // Calling hideAsFinal to assign derived fields for the app info flags. parseResult.parsedPackage.hideAsFinal(); final PackageInfo packageInfo = PackageInfoWithoutStateUtils.generate( parseResult.parsedPackage, ai, flags); if (packageInfo == null) { Loading
tests/StagedInstallTest/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -62,6 +62,7 @@ java_test_host { ":TestAppAv1", ":test.rebootless_apex_v1", ":test.rebootless_apex_v2", ":test_com.android.server", ], test_suites: ["general-tests"], test_config: "StagedInstallInternalTest.xml", Loading
tests/StagedInstallTest/app/src/com/android/tests/stagedinstallinternal/StagedInstallInternalTest.java +13 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import android.content.pm.IStagedApexObserver; import android.content.pm.PackageInfo; import android.content.pm.PackageInstaller; import android.content.pm.PackageManager; import android.content.pm.PackageManager.ApplicationInfoFlags; import android.content.pm.StagedApexInfo; import android.os.IBinder; import android.os.ServiceManager; Loading Loading @@ -79,6 +80,8 @@ public class StagedInstallInternalTest { TEST_APEX_PACKAGE_NAME, 1, /*isApex=*/true, "apex.apexd_test_classpath.apex"); private static final String TEST_APEX_SYSTEM_SERVER_PACKAGE_NAME = "test_com.android.server"; private File mTestStateFile = new File( InstrumentationRegistry.getInstrumentation().getContext().getFilesDir(), "stagedinstall_state"); Loading Loading @@ -480,6 +483,16 @@ public class StagedInstallInternalTest { InstallUtils.openPackageInstallerSession(sessionId).abandon(); } @Test public void testGetAppInfo_flagTestOnlyIsSet() throws Exception { final PackageManager pm = InstrumentationRegistry.getInstrumentation().getContext().getPackageManager(); final ApplicationInfo info = pm.getApplicationInfo(TEST_APEX_SYSTEM_SERVER_PACKAGE_NAME, ApplicationInfoFlags.of(PackageManager.MATCH_APEX)); assertThat(info).isNotNull(); assertThat((info.flags & ApplicationInfo.FLAG_TEST_ONLY) != 0).isTrue(); } public static class MockStagedApexObserver extends IStagedApexObserver.Stub { @Override public void onApexStaged(ApexStagedEvent event) { Loading
tests/StagedInstallTest/src/com/android/tests/stagedinstallinternal/host/StagedInstallInternalTest.java +13 −0 Original line number Diff line number Diff line Loading @@ -62,6 +62,7 @@ public class StagedInstallInternalTest extends BaseHostJUnit4Test { private static final String APK_A = "TestAppAv1.apk"; private static final String APK_IN_APEX_TESTAPEX_NAME = "com.android.apex.apkrollback.test"; private static final String APEXD_TEST_APEX = "apex.apexd_test.apex"; private static final String FAKE_APEX_SYSTEM_SERVER_APEX = "test_com.android.server.apex"; private static final String TEST_VENDOR_APEX_ALLOW_LIST = "/vendor/etc/sysconfig/test-vendor-apex-allow-list.xml"; Loading Loading @@ -512,6 +513,18 @@ public class StagedInstallInternalTest extends BaseHostJUnit4Test { runPhase("testGetStagedApexInfo"); } @Test @LargeTest public void testGetAppInfo_flagTestOnlyIsSet() throws Exception { assumeTrue("Device does not support updating APEX", mHostUtils.isApexUpdateSupported()); pushTestApex(FAKE_APEX_SYSTEM_SERVER_APEX); getDevice().reboot(); runPhase("testGetAppInfo_flagTestOnlyIsSet"); } @Test public void testStagedApexObserver() throws Exception { assumeTrue("Device does not support updating APEX", Loading