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

Commit c8ddbaab authored by Mohammad Samiul Islam's avatar Mohammad Samiul Islam Committed by Android (Google) Code Review
Browse files

Merge "Ensure system behaves properly when app-staging dir is deleted"

parents 9713e3e4 37c56220
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -140,6 +140,21 @@ public class StagedInstallInternalTest {
                Install.multi(TestApp.AIncompleteSplit, TestApp.B1, TestApp.Apex1).setStaged());
    }

    @Test
    public void testFailStagedSessionIfStagingDirectoryDeleted_Commit() throws Exception {
        int sessionId = Install.multi(TestApp.A1, TestApp.Apex1).setStaged().commit();
        assertSessionReady(sessionId);
        storeSessionId(sessionId);
    }

    @Test
    public void testFailStagedSessionIfStagingDirectoryDeleted_Verify() throws Exception {
        int sessionId = retrieveLastSessionId();
        PackageInstaller.SessionInfo info =
                InstallUtils.getPackageInstaller().getSessionInfo(sessionId);
        assertThat(info.isStagedSessionFailed()).isTrue();
    }

    private static void assertSessionReady(int sessionId) {
        assertSessionState(sessionId,
                (session) -> assertThat(session.isStagedSessionReady()).isTrue());
+15 −0
Original line number Diff line number Diff line
@@ -279,6 +279,21 @@ public class StagedInstallInternalTest extends BaseHostJUnit4Test {
        assertThat(getStagingDirectories()).isEmpty();
    }

    @Test
    public void testFailStagedSessionIfStagingDirectoryDeleted() throws Exception {
        // Create a staged session
        runPhase("testFailStagedSessionIfStagingDirectoryDeleted_Commit");

        // Delete the staging directory
        getDevice().enableAdbRoot();
        getDevice().executeShellCommand("rm -r /data/app-staging");
        getDevice().disableAdbRoot();

        getDevice().reboot();

        runPhase("testFailStagedSessionIfStagingDirectoryDeleted_Verify");
    }

    private List<String> getStagingDirectories() throws DeviceNotAvailableException {
        String baseDir = "/data/app-staging";
        try {