Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 23e14a4a authored by Jackal Guo's avatar Jackal Guo Committed by Android (Google) Code Review
Browse files

Merge "Fix the dervied fileds in ApplicationInfo are missing for APEXes"

parents 416f76d9 f012f582
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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) {
+1 −0
Original line number Diff line number Diff line
@@ -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",
+13 −0
Original line number Diff line number Diff line
@@ -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;
@@ -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");
@@ -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) {
+13 −0
Original line number Diff line number Diff line
@@ -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";
@@ -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",