Merge "Ensure system behaves properly when app-staging dir is deleted"
This commit is contained in:
committed by
Android (Google) Code Review
commit
c8ddbaabeb
@@ -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());
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user