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

Commit 1c92e890 authored by Mohammad Islam's avatar Mohammad Islam Committed by Automerger Merge Worker
Browse files

Merge "Propagate classpath info for staged apex to PackageManager" am:...

Merge "Propagate classpath info for staged apex to PackageManager" am: e583e6d6 am: d17d71ef am: c15d4bbf am: 939d307e

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1849818

Change-Id: I18ae9e025d39b439859ceb64d499bb4cbeed81d9
parents b1cde220 939d307e
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -1255,6 +1255,9 @@ public class StagingManager {
                    info.diskImagePath = ai.modulePath;
                    info.diskImagePath = ai.modulePath;
                    info.versionCode = ai.versionCode;
                    info.versionCode = ai.versionCode;
                    info.versionName = ai.versionName;
                    info.versionName = ai.versionName;
                    info.hasBootClassPathJars = ai.hasBootClassPathJars;
                    info.hasDex2OatBootClassPathJars = ai.hasDex2OatBootClassPathJars;
                    info.hasSystemServerClassPathJars = ai.hasSystemServerClassPathJars;
                    return info;
                    return info;
                }
                }
            }
            }
+2 −0
Original line number Original line Diff line number Diff line
@@ -31,6 +31,7 @@ android_test_helper_app {
    ],
    ],
    test_suites: ["general-tests"],
    test_suites: ["general-tests"],
    java_resources: [
    java_resources: [
        ":apex.apexd_test_classpath",
        ":com.android.apex.apkrollback.test_v2",
        ":com.android.apex.apkrollback.test_v2",
        ":StagedInstallTestApexV2",
        ":StagedInstallTestApexV2",
        ":StagedInstallTestApexV2_WrongSha",
        ":StagedInstallTestApexV2_WrongSha",
@@ -54,6 +55,7 @@ java_test_host {
        "cts-install-lib-host",
        "cts-install-lib-host",
    ],
    ],
    data: [
    data: [
        ":apex.apexd_test",
        ":com.android.apex.apkrollback.test_v1",
        ":com.android.apex.apkrollback.test_v1",
        ":StagedInstallTestApexV2",
        ":StagedInstallTestApexV2",
        ":StagedInstallTestApexV2_WrongSha",
        ":StagedInstallTestApexV2_WrongSha",
+10 −3
Original line number Original line Diff line number Diff line
@@ -74,6 +74,11 @@ public class StagedInstallInternalTest {
            "ApexV2", SHIM_APEX_PACKAGE_NAME, 2, /* isApex= */ true,
            "ApexV2", SHIM_APEX_PACKAGE_NAME, 2, /* isApex= */ true,
            "com.android.apex.cts.shim.v2.apex");
            "com.android.apex.cts.shim.v2.apex");


    private static final String TEST_APEX_PACKAGE_NAME = "com.android.apex.test_package";
    private static final TestApp TEST_APEX_CLASSPATH = new TestApp("TestApex",
            TEST_APEX_PACKAGE_NAME, 1, /*isApex=*/true,
            "apex.apexd_test_classpath.apex");

    private File mTestStateFile = new File(
    private File mTestStateFile = new File(
            InstrumentationRegistry.getInstrumentation().getContext().getFilesDir(),
            InstrumentationRegistry.getInstrumentation().getContext().getFilesDir(),
            "stagedinstall_state");
            "stagedinstall_state");
@@ -439,11 +444,13 @@ public class StagedInstallInternalTest {
        StagedApexInfo result = getPackageManagerNative().getStagedApexInfo("not found");
        StagedApexInfo result = getPackageManagerNative().getStagedApexInfo("not found");
        assertThat(result).isNull();
        assertThat(result).isNull();
        // Stage an apex
        // Stage an apex
        int sessionId = Install.single(APEX_V2).setStaged().commit();
        int sessionId = Install.single(TEST_APEX_CLASSPATH).setStaged().commit();
        waitForSessionReady(sessionId);
        waitForSessionReady(sessionId);
        // Query proper module name
        // Query proper module name
        result = getPackageManagerNative().getStagedApexInfo(SHIM_APEX_PACKAGE_NAME);
        result = getPackageManagerNative().getStagedApexInfo(TEST_APEX_PACKAGE_NAME);
        assertThat(result.moduleName).isEqualTo(SHIM_APEX_PACKAGE_NAME);
        assertThat(result.moduleName).isEqualTo(TEST_APEX_PACKAGE_NAME);
        assertThat(result.hasBootClassPathJars).isTrue();
        assertThat(result.hasSystemServerClassPathJars).isTrue();
        InstallUtils.openPackageInstallerSession(sessionId).abandon();
        InstallUtils.openPackageInstallerSession(sessionId).abandon();
    }
    }


+14 −0
Original line number Original line Diff line number Diff line
@@ -61,6 +61,7 @@ public class StagedInstallInternalTest extends BaseHostJUnit4Test {
    private static final String APEX_WRONG_SHA = "com.android.apex.cts.shim.v2_wrong_sha.apex";
    private static final String APEX_WRONG_SHA = "com.android.apex.cts.shim.v2_wrong_sha.apex";
    private static final String APK_A = "TestAppAv1.apk";
    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 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 TEST_VENDOR_APEX_ALLOW_LIST =
    private static final String TEST_VENDOR_APEX_ALLOW_LIST =
            "/vendor/etc/sysconfig/test-vendor-apex-allow-list.xml";
            "/vendor/etc/sysconfig/test-vendor-apex-allow-list.xml";
@@ -480,16 +481,29 @@ public class StagedInstallInternalTest extends BaseHostJUnit4Test {


    @Test
    @Test
    public void testGetStagedModuleNames() throws Exception {
    public void testGetStagedModuleNames() throws Exception {
        assumeTrue("Device does not support updating APEX",
                mHostUtils.isApexUpdateSupported());

        runPhase("testGetStagedModuleNames");
        runPhase("testGetStagedModuleNames");
    }
    }


    @Test
    @Test
    @LargeTest
    public void testGetStagedApexInfo() throws Exception {
    public void testGetStagedApexInfo() throws Exception {
        assumeTrue("Device does not support updating APEX",
                mHostUtils.isApexUpdateSupported());

        pushTestApex(APEXD_TEST_APEX);
        getDevice().reboot();

        runPhase("testGetStagedApexInfo");
        runPhase("testGetStagedApexInfo");
    }
    }


    @Test
    @Test
    public void testStagedApexObserver() throws Exception {
    public void testStagedApexObserver() throws Exception {
        assumeTrue("Device does not support updating APEX",
                mHostUtils.isApexUpdateSupported());

        runPhase("testStagedApexObserver");
        runPhase("testStagedApexObserver");
    }
    }