Loading services/core/java/com/android/server/rollback/RollbackManagerServiceImpl.java +2 −4 Original line number Diff line number Diff line Loading @@ -554,10 +554,8 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub { PackageInstaller.SessionInfo session = mContext.getPackageManager() .getPackageInstaller().getSessionInfo(rollback.getStagedSessionId()); if (session == null || session.isStagedSessionFailed()) { if (rollback.isEnabling()) { iter.remove(); rollback.delete(mAppDataRollbackHelper); } continue; } Loading tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/StagedRollbackTest.java +0 −27 Original line number Diff line number Diff line Loading @@ -481,33 +481,6 @@ public class StagedRollbackTest { assertThat(sm.isCheckpointSupported()).isTrue(); } @Test public void testExpireSession_Phase1_Install() throws Exception { assertThat(InstallUtils.getInstalledVersion(TestApp.A)).isEqualTo(-1); Install.single(TestApp.A1).commit(); assertThat(InstallUtils.getInstalledVersion(TestApp.A)).isEqualTo(1); Install.single(TestApp.A2).setEnableRollback().setStaged().commit(); } @Test public void testExpireSession_Phase2_VerifyInstall() throws Exception { assertThat(InstallUtils.getInstalledVersion(TestApp.A)).isEqualTo(2); RollbackManager rm = RollbackUtils.getRollbackManager(); RollbackInfo rollback = getUniqueRollbackInfoForPackage( rm.getAvailableRollbacks(), TestApp.A); assertThat(rollback).isNotNull(); assertThat(rollback).packagesContainsExactly(Rollback.from(TestApp.A2).to(TestApp.A1)); assertThat(rollback.isStaged()).isTrue(); } @Test public void testExpireSession_Phase3_VerifyRollback() throws Exception { RollbackManager rm = RollbackUtils.getRollbackManager(); RollbackInfo rollback = getUniqueRollbackInfoForPackage( rm.getAvailableRollbacks(), TestApp.A); assertThat(rollback).isNotNull(); } @Test public void hasMainlineModule() throws Exception { String pkgName = getModuleMetadataPackageName(); Loading tests/RollbackTest/StagedRollbackTest/src/com/android/tests/rollback/host/StagedRollbackTest.java +0 −37 Original line number Diff line number Diff line Loading @@ -38,9 +38,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import java.io.File; import java.time.Instant; import java.util.Collections; import java.util.Date; import java.util.List; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; Loading Loading @@ -443,27 +441,6 @@ public class StagedRollbackTest extends BaseHostJUnit4Test { after.forEach(dir -> assertDirectoryIsEmpty(dir)); } /** * Tests an available rollback shouldn't be deleted when its session expires. */ @Test public void testExpireSession() throws Exception { runPhase("testExpireSession_Phase1_Install"); getDevice().reboot(); runPhase("testExpireSession_Phase2_VerifyInstall"); // Advance system clock by 7 days to expire the staged session Instant t1 = Instant.ofEpochMilli(getDevice().getDeviceDate()); Instant t2 = t1.plusMillis(TimeUnit.DAYS.toMillis(7)); runAsRoot(() -> getDevice().setDate(Date.from(t2))); // Somehow we need to wait for a while before reboot. Otherwise the change to the // system clock will be reset after reboot. Thread.sleep(3000); getDevice().reboot(); runPhase("testExpireSession_Phase3_VerifyRollback"); } private void pushTestApex() throws Exception { CompatibilityBuildHelper buildHelper = new CompatibilityBuildHelper(getBuild()); final String fileName = APK_IN_APEX_TESTAPEX_NAME + "_v1.apex"; Loading Loading @@ -544,18 +521,4 @@ public class StagedRollbackTest extends BaseHostJUnit4Test { return false; } } @FunctionalInterface private interface ExceptionalRunnable { void run() throws Exception; } private void runAsRoot(ExceptionalRunnable runnable) throws Exception { try { getDevice().enableAdbRoot(); runnable.run(); } finally { getDevice().disableAdbRoot(); } } } Loading
services/core/java/com/android/server/rollback/RollbackManagerServiceImpl.java +2 −4 Original line number Diff line number Diff line Loading @@ -554,10 +554,8 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub { PackageInstaller.SessionInfo session = mContext.getPackageManager() .getPackageInstaller().getSessionInfo(rollback.getStagedSessionId()); if (session == null || session.isStagedSessionFailed()) { if (rollback.isEnabling()) { iter.remove(); rollback.delete(mAppDataRollbackHelper); } continue; } Loading
tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/StagedRollbackTest.java +0 −27 Original line number Diff line number Diff line Loading @@ -481,33 +481,6 @@ public class StagedRollbackTest { assertThat(sm.isCheckpointSupported()).isTrue(); } @Test public void testExpireSession_Phase1_Install() throws Exception { assertThat(InstallUtils.getInstalledVersion(TestApp.A)).isEqualTo(-1); Install.single(TestApp.A1).commit(); assertThat(InstallUtils.getInstalledVersion(TestApp.A)).isEqualTo(1); Install.single(TestApp.A2).setEnableRollback().setStaged().commit(); } @Test public void testExpireSession_Phase2_VerifyInstall() throws Exception { assertThat(InstallUtils.getInstalledVersion(TestApp.A)).isEqualTo(2); RollbackManager rm = RollbackUtils.getRollbackManager(); RollbackInfo rollback = getUniqueRollbackInfoForPackage( rm.getAvailableRollbacks(), TestApp.A); assertThat(rollback).isNotNull(); assertThat(rollback).packagesContainsExactly(Rollback.from(TestApp.A2).to(TestApp.A1)); assertThat(rollback.isStaged()).isTrue(); } @Test public void testExpireSession_Phase3_VerifyRollback() throws Exception { RollbackManager rm = RollbackUtils.getRollbackManager(); RollbackInfo rollback = getUniqueRollbackInfoForPackage( rm.getAvailableRollbacks(), TestApp.A); assertThat(rollback).isNotNull(); } @Test public void hasMainlineModule() throws Exception { String pkgName = getModuleMetadataPackageName(); Loading
tests/RollbackTest/StagedRollbackTest/src/com/android/tests/rollback/host/StagedRollbackTest.java +0 −37 Original line number Diff line number Diff line Loading @@ -38,9 +38,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import java.io.File; import java.time.Instant; import java.util.Collections; import java.util.Date; import java.util.List; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; Loading Loading @@ -443,27 +441,6 @@ public class StagedRollbackTest extends BaseHostJUnit4Test { after.forEach(dir -> assertDirectoryIsEmpty(dir)); } /** * Tests an available rollback shouldn't be deleted when its session expires. */ @Test public void testExpireSession() throws Exception { runPhase("testExpireSession_Phase1_Install"); getDevice().reboot(); runPhase("testExpireSession_Phase2_VerifyInstall"); // Advance system clock by 7 days to expire the staged session Instant t1 = Instant.ofEpochMilli(getDevice().getDeviceDate()); Instant t2 = t1.plusMillis(TimeUnit.DAYS.toMillis(7)); runAsRoot(() -> getDevice().setDate(Date.from(t2))); // Somehow we need to wait for a while before reboot. Otherwise the change to the // system clock will be reset after reboot. Thread.sleep(3000); getDevice().reboot(); runPhase("testExpireSession_Phase3_VerifyRollback"); } private void pushTestApex() throws Exception { CompatibilityBuildHelper buildHelper = new CompatibilityBuildHelper(getBuild()); final String fileName = APK_IN_APEX_TESTAPEX_NAME + "_v1.apex"; Loading Loading @@ -544,18 +521,4 @@ public class StagedRollbackTest extends BaseHostJUnit4Test { return false; } } @FunctionalInterface private interface ExceptionalRunnable { void run() throws Exception; } private void runAsRoot(ExceptionalRunnable runnable) throws Exception { try { getDevice().enableAdbRoot(); runnable.run(); } finally { getDevice().disableAdbRoot(); } } }