Loading services/core/java/com/android/server/pm/Installer.java +9 −10 Original line number Diff line number Diff line Loading @@ -680,17 +680,18 @@ public class Installer extends SystemService { * @param snapshotId id of this snapshot. * @param storageFlags flags controlling which data (CE or DE) to snapshot. * * @return inode of the snapshot of users CE package data, or {@code 0} if a remote calls * shouldn't be continued. See {@link #checkBeforeRemote}. * @return {@code true} if the snapshot was taken successfully, or {@code false} if a remote * call shouldn't be continued. See {@link #checkBeforeRemote}. * * @throws InstallerException if failed to snapshot user data. */ public long snapshotAppData(String pkg, @UserIdInt int userId, int snapshotId, int storageFlags) throws InstallerException { if (!checkBeforeRemote()) return 0; public boolean snapshotAppData(String pkg, @UserIdInt int userId, int snapshotId, int storageFlags) throws InstallerException { if (!checkBeforeRemote()) return false; try { return mInstalld.snapshotAppData(null, pkg, userId, snapshotId, storageFlags); mInstalld.snapshotAppData(null, pkg, userId, snapshotId, storageFlags); return true; } catch (Exception e) { throw InstallerException.from(e); } Loading Loading @@ -728,7 +729,6 @@ public class Installer extends SystemService { * * @param pkg name of the package to delete user data snapshot for. * @param userId id of the user whose user data snapshot to delete. * @param ceSnapshotInode inode of CE user data snapshot. * @param snapshotId id of the snapshot to delete. * @param storageFlags flags controlling which user data snapshot (CE or DE) to delete. * Loading @@ -737,13 +737,12 @@ public class Installer extends SystemService { * * @throws InstallerException if failed to delete user data snapshot. */ public boolean destroyAppDataSnapshot(String pkg, @UserIdInt int userId, long ceSnapshotInode, public boolean destroyAppDataSnapshot(String pkg, @UserIdInt int userId, int snapshotId, int storageFlags) throws InstallerException { if (!checkBeforeRemote()) return false; try { mInstalld.destroyAppDataSnapshot(null, pkg, userId, ceSnapshotInode, snapshotId, storageFlags); mInstalld.destroyAppDataSnapshot(null, pkg, userId, 0, snapshotId, storageFlags); return true; } catch (Exception e) { throw InstallerException.from(e); Loading services/core/java/com/android/server/rollback/AppDataRollbackHelper.java +2 −2 Original line number Diff line number Diff line Loading @@ -133,7 +133,7 @@ public class AppDataRollbackHelper { } else { // APK try { mInstaller.snapshotAppData( return mInstaller.snapshotAppData( packageRollbackInfo.getPackageName(), userId, rollbackId, flags); } catch (InstallerException ie) { Slog.e(TAG, "Unable to create app data snapshot for: " Loading Loading @@ -198,7 +198,7 @@ public class AppDataRollbackHelper { try { // Delete both DE and CE snapshots if any mInstaller.destroyAppDataSnapshot(packageRollbackInfo.getPackageName(), user, 0, rollbackId, Installer.FLAG_STORAGE_DE | Installer.FLAG_STORAGE_CE); rollbackId, Installer.FLAG_STORAGE_DE | Installer.FLAG_STORAGE_CE); } catch (InstallerException ie) { Slog.e(TAG, "Unable to delete app data snapshot for " + packageRollbackInfo.getPackageName(), ie); Loading services/tests/servicestests/src/com/android/server/rollback/AppDataRollbackHelperTest.java +4 −4 Original line number Diff line number Diff line Loading @@ -83,7 +83,7 @@ public class AppDataRollbackHelperTest { // One of the users is unlocked but the other isn't doReturn(false).when(helper).isUserCredentialLocked(eq(10)); doReturn(true).when(helper).isUserCredentialLocked(eq(11)); when(installer.snapshotAppData(anyString(), anyInt(), anyInt(), anyInt())).thenReturn(239L); when(installer.snapshotAppData(anyString(), anyInt(), anyInt(), anyInt())).thenReturn(true); PackageRollbackInfo info2 = createPackageRollbackInfo("com.foo.bar"); helper.snapshotAppData(7, info2, new int[]{10, 11}); Loading Loading @@ -204,10 +204,10 @@ public class AppDataRollbackHelperTest { InOrder inOrder = Mockito.inOrder(installer); inOrder.verify(installer).destroyAppDataSnapshot( eq("com.foo.bar"), eq(10) /* userId */, eq(0L) /* ceSnapshotInode */, eq("com.foo.bar"), eq(10) /* userId */, eq(5) /* rollbackId */, eq(Installer.FLAG_STORAGE_DE | Installer.FLAG_STORAGE_CE)); inOrder.verify(installer).destroyAppDataSnapshot( eq("com.foo.bar"), eq(11) /* userId */, eq(0L) /* ceSnapshotInode */, eq("com.foo.bar"), eq(11) /* userId */, eq(5) /* rollbackId */, eq(Installer.FLAG_STORAGE_DE | Installer.FLAG_STORAGE_CE)); inOrder.verifyNoMoreInteractions(); } Loading @@ -217,7 +217,7 @@ public class AppDataRollbackHelperTest { Installer installer = mock(Installer.class); AppDataRollbackHelper helper = new AppDataRollbackHelper(installer, mApexManager); when(installer.snapshotAppData(anyString(), anyInt(), anyInt(), anyInt())).thenReturn(53L); when(installer.snapshotAppData(anyString(), anyInt(), anyInt(), anyInt())).thenReturn(true); // This one should be backed up. PackageRollbackInfo pendingBackup = createPackageRollbackInfo("com.foo", new int[]{37, 73}); Loading Loading
services/core/java/com/android/server/pm/Installer.java +9 −10 Original line number Diff line number Diff line Loading @@ -680,17 +680,18 @@ public class Installer extends SystemService { * @param snapshotId id of this snapshot. * @param storageFlags flags controlling which data (CE or DE) to snapshot. * * @return inode of the snapshot of users CE package data, or {@code 0} if a remote calls * shouldn't be continued. See {@link #checkBeforeRemote}. * @return {@code true} if the snapshot was taken successfully, or {@code false} if a remote * call shouldn't be continued. See {@link #checkBeforeRemote}. * * @throws InstallerException if failed to snapshot user data. */ public long snapshotAppData(String pkg, @UserIdInt int userId, int snapshotId, int storageFlags) throws InstallerException { if (!checkBeforeRemote()) return 0; public boolean snapshotAppData(String pkg, @UserIdInt int userId, int snapshotId, int storageFlags) throws InstallerException { if (!checkBeforeRemote()) return false; try { return mInstalld.snapshotAppData(null, pkg, userId, snapshotId, storageFlags); mInstalld.snapshotAppData(null, pkg, userId, snapshotId, storageFlags); return true; } catch (Exception e) { throw InstallerException.from(e); } Loading Loading @@ -728,7 +729,6 @@ public class Installer extends SystemService { * * @param pkg name of the package to delete user data snapshot for. * @param userId id of the user whose user data snapshot to delete. * @param ceSnapshotInode inode of CE user data snapshot. * @param snapshotId id of the snapshot to delete. * @param storageFlags flags controlling which user data snapshot (CE or DE) to delete. * Loading @@ -737,13 +737,12 @@ public class Installer extends SystemService { * * @throws InstallerException if failed to delete user data snapshot. */ public boolean destroyAppDataSnapshot(String pkg, @UserIdInt int userId, long ceSnapshotInode, public boolean destroyAppDataSnapshot(String pkg, @UserIdInt int userId, int snapshotId, int storageFlags) throws InstallerException { if (!checkBeforeRemote()) return false; try { mInstalld.destroyAppDataSnapshot(null, pkg, userId, ceSnapshotInode, snapshotId, storageFlags); mInstalld.destroyAppDataSnapshot(null, pkg, userId, 0, snapshotId, storageFlags); return true; } catch (Exception e) { throw InstallerException.from(e); Loading
services/core/java/com/android/server/rollback/AppDataRollbackHelper.java +2 −2 Original line number Diff line number Diff line Loading @@ -133,7 +133,7 @@ public class AppDataRollbackHelper { } else { // APK try { mInstaller.snapshotAppData( return mInstaller.snapshotAppData( packageRollbackInfo.getPackageName(), userId, rollbackId, flags); } catch (InstallerException ie) { Slog.e(TAG, "Unable to create app data snapshot for: " Loading Loading @@ -198,7 +198,7 @@ public class AppDataRollbackHelper { try { // Delete both DE and CE snapshots if any mInstaller.destroyAppDataSnapshot(packageRollbackInfo.getPackageName(), user, 0, rollbackId, Installer.FLAG_STORAGE_DE | Installer.FLAG_STORAGE_CE); rollbackId, Installer.FLAG_STORAGE_DE | Installer.FLAG_STORAGE_CE); } catch (InstallerException ie) { Slog.e(TAG, "Unable to delete app data snapshot for " + packageRollbackInfo.getPackageName(), ie); Loading
services/tests/servicestests/src/com/android/server/rollback/AppDataRollbackHelperTest.java +4 −4 Original line number Diff line number Diff line Loading @@ -83,7 +83,7 @@ public class AppDataRollbackHelperTest { // One of the users is unlocked but the other isn't doReturn(false).when(helper).isUserCredentialLocked(eq(10)); doReturn(true).when(helper).isUserCredentialLocked(eq(11)); when(installer.snapshotAppData(anyString(), anyInt(), anyInt(), anyInt())).thenReturn(239L); when(installer.snapshotAppData(anyString(), anyInt(), anyInt(), anyInt())).thenReturn(true); PackageRollbackInfo info2 = createPackageRollbackInfo("com.foo.bar"); helper.snapshotAppData(7, info2, new int[]{10, 11}); Loading Loading @@ -204,10 +204,10 @@ public class AppDataRollbackHelperTest { InOrder inOrder = Mockito.inOrder(installer); inOrder.verify(installer).destroyAppDataSnapshot( eq("com.foo.bar"), eq(10) /* userId */, eq(0L) /* ceSnapshotInode */, eq("com.foo.bar"), eq(10) /* userId */, eq(5) /* rollbackId */, eq(Installer.FLAG_STORAGE_DE | Installer.FLAG_STORAGE_CE)); inOrder.verify(installer).destroyAppDataSnapshot( eq("com.foo.bar"), eq(11) /* userId */, eq(0L) /* ceSnapshotInode */, eq("com.foo.bar"), eq(11) /* userId */, eq(5) /* rollbackId */, eq(Installer.FLAG_STORAGE_DE | Installer.FLAG_STORAGE_CE)); inOrder.verifyNoMoreInteractions(); } Loading @@ -217,7 +217,7 @@ public class AppDataRollbackHelperTest { Installer installer = mock(Installer.class); AppDataRollbackHelper helper = new AppDataRollbackHelper(installer, mApexManager); when(installer.snapshotAppData(anyString(), anyInt(), anyInt(), anyInt())).thenReturn(53L); when(installer.snapshotAppData(anyString(), anyInt(), anyInt(), anyInt())).thenReturn(true); // This one should be backed up. PackageRollbackInfo pendingBackup = createPackageRollbackInfo("com.foo", new int[]{37, 73}); Loading