Loading services/core/java/com/android/server/rollback/Rollback.java +4 −3 Original line number Diff line number Diff line Loading @@ -59,6 +59,7 @@ import java.text.ParseException; import java.time.Instant; import java.util.ArrayList; import java.util.List; import java.util.Objects; /** Loading Loading @@ -182,7 +183,7 @@ class Rollback { /** * The extension versions supported at the time of rollback creation. */ private final SparseIntArray mExtensionVersions; @NonNull private final SparseIntArray mExtensionVersions; /** * Constructs a new, empty Rollback instance. Loading Loading @@ -210,7 +211,7 @@ class Rollback { mState = ROLLBACK_STATE_ENABLING; mTimestamp = Instant.now(); mPackageSessionIds = packageSessionIds != null ? packageSessionIds : new int[0]; mExtensionVersions = extensionVersions; mExtensionVersions = Objects.requireNonNull(extensionVersions); } Rollback(int rollbackId, File backupDir, int stagedSessionId, int userId, Loading @@ -234,7 +235,7 @@ class Rollback { mState = state; mApkSessionId = apkSessionId; mRestoreUserDataInProgress = restoreUserDataInProgress; mExtensionVersions = extensionVersions; mExtensionVersions = Objects.requireNonNull(extensionVersions); // TODO(b/120200473): Include this field during persistence. This field will be used to // decide which rollback to expire when ACTION_PACKAGE_REPLACED is received. Note persisting // this field is not backward compatible. We won't fix b/120200473 until S to minimize the Loading services/core/java/com/android/server/rollback/RollbackStore.java +2 −3 Original line number Diff line number Diff line Loading @@ -21,7 +21,6 @@ import static android.os.UserHandle.USER_SYSTEM; import static com.android.server.rollback.Rollback.rollbackStateFromString; import android.annotation.NonNull; import android.annotation.Nullable; import android.content.pm.PackageManager; import android.content.pm.VersionedPackage; import android.content.rollback.PackageRollbackInfo; Loading Loading @@ -178,7 +177,7 @@ class RollbackStore { return ceSnapshotInodes; } private static @Nullable JSONArray extensionVersionsToJson( private static @NonNull JSONArray extensionVersionsToJson( SparseIntArray extensionVersions) throws JSONException { JSONArray array = new JSONArray(); for (int i = 0; i < extensionVersions.size(); i++) { Loading @@ -190,7 +189,7 @@ class RollbackStore { return array; } private static @Nullable SparseIntArray extensionVersionsFromJson(JSONArray json) private static @NonNull SparseIntArray extensionVersionsFromJson(JSONArray json) throws JSONException { if (json == null) { return new SparseIntArray(0); Loading services/tests/servicestests/src/com/android/server/rollback/RollbackUnitTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -331,7 +331,7 @@ public class RollbackUnitTest { public void notifySessionWithSuccess() { int[] sessionIds = new int[]{ 7777, 8888 }; Rollback rollback = new Rollback(123, new File("/test/testing"), -1, USER, INSTALLER, sessionIds, null); sessionIds, new SparseIntArray(0)); // The 1st invocation returns false because not all child sessions are notified. assertThat(rollback.notifySessionWithSuccess()).isFalse(); // The 2nd invocation returns true because now all child sessions are notified. Loading @@ -342,7 +342,7 @@ public class RollbackUnitTest { public void allPackagesEnabled() { int[] sessionIds = new int[]{ 7777, 8888 }; Rollback rollback = new Rollback(123, new File("/test/testing"), -1, USER, INSTALLER, sessionIds, null); sessionIds, new SparseIntArray(0)); // #allPackagesEnabled returns false when 1 out of 2 packages is enabled. rollback.info.getPackages().add(newPkgInfoFor(PKG_1, 12, 10, false)); assertThat(rollback.allPackagesEnabled()).isFalse(); Loading Loading
services/core/java/com/android/server/rollback/Rollback.java +4 −3 Original line number Diff line number Diff line Loading @@ -59,6 +59,7 @@ import java.text.ParseException; import java.time.Instant; import java.util.ArrayList; import java.util.List; import java.util.Objects; /** Loading Loading @@ -182,7 +183,7 @@ class Rollback { /** * The extension versions supported at the time of rollback creation. */ private final SparseIntArray mExtensionVersions; @NonNull private final SparseIntArray mExtensionVersions; /** * Constructs a new, empty Rollback instance. Loading Loading @@ -210,7 +211,7 @@ class Rollback { mState = ROLLBACK_STATE_ENABLING; mTimestamp = Instant.now(); mPackageSessionIds = packageSessionIds != null ? packageSessionIds : new int[0]; mExtensionVersions = extensionVersions; mExtensionVersions = Objects.requireNonNull(extensionVersions); } Rollback(int rollbackId, File backupDir, int stagedSessionId, int userId, Loading @@ -234,7 +235,7 @@ class Rollback { mState = state; mApkSessionId = apkSessionId; mRestoreUserDataInProgress = restoreUserDataInProgress; mExtensionVersions = extensionVersions; mExtensionVersions = Objects.requireNonNull(extensionVersions); // TODO(b/120200473): Include this field during persistence. This field will be used to // decide which rollback to expire when ACTION_PACKAGE_REPLACED is received. Note persisting // this field is not backward compatible. We won't fix b/120200473 until S to minimize the Loading
services/core/java/com/android/server/rollback/RollbackStore.java +2 −3 Original line number Diff line number Diff line Loading @@ -21,7 +21,6 @@ import static android.os.UserHandle.USER_SYSTEM; import static com.android.server.rollback.Rollback.rollbackStateFromString; import android.annotation.NonNull; import android.annotation.Nullable; import android.content.pm.PackageManager; import android.content.pm.VersionedPackage; import android.content.rollback.PackageRollbackInfo; Loading Loading @@ -178,7 +177,7 @@ class RollbackStore { return ceSnapshotInodes; } private static @Nullable JSONArray extensionVersionsToJson( private static @NonNull JSONArray extensionVersionsToJson( SparseIntArray extensionVersions) throws JSONException { JSONArray array = new JSONArray(); for (int i = 0; i < extensionVersions.size(); i++) { Loading @@ -190,7 +189,7 @@ class RollbackStore { return array; } private static @Nullable SparseIntArray extensionVersionsFromJson(JSONArray json) private static @NonNull SparseIntArray extensionVersionsFromJson(JSONArray json) throws JSONException { if (json == null) { return new SparseIntArray(0); Loading
services/tests/servicestests/src/com/android/server/rollback/RollbackUnitTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -331,7 +331,7 @@ public class RollbackUnitTest { public void notifySessionWithSuccess() { int[] sessionIds = new int[]{ 7777, 8888 }; Rollback rollback = new Rollback(123, new File("/test/testing"), -1, USER, INSTALLER, sessionIds, null); sessionIds, new SparseIntArray(0)); // The 1st invocation returns false because not all child sessions are notified. assertThat(rollback.notifySessionWithSuccess()).isFalse(); // The 2nd invocation returns true because now all child sessions are notified. Loading @@ -342,7 +342,7 @@ public class RollbackUnitTest { public void allPackagesEnabled() { int[] sessionIds = new int[]{ 7777, 8888 }; Rollback rollback = new Rollback(123, new File("/test/testing"), -1, USER, INSTALLER, sessionIds, null); sessionIds, new SparseIntArray(0)); // #allPackagesEnabled returns false when 1 out of 2 packages is enabled. rollback.info.getPackages().add(newPkgInfoFor(PKG_1, 12, 10, false)); assertThat(rollback.allPackagesEnabled()).isFalse(); Loading