diff --git a/src/com/android/launcher3/model/DeviceGridState.java b/src/com/android/launcher3/model/DeviceGridState.java index e2df16d45a..0fc4c2d716 100644 --- a/src/com/android/launcher3/model/DeviceGridState.java +++ b/src/com/android/launcher3/model/DeviceGridState.java @@ -119,12 +119,23 @@ public class DeviceGridState { } @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - DeviceGridState that = (DeviceGridState) o; - return mNumHotseat == that.mNumHotseat - && deviceTypeCompatible(mDeviceType, that.mDeviceType) - && Objects.equals(mGridSizeString, that.mGridSizeString); + public String toString() { + return "DeviceGridState{" + + "mGridSizeString='" + mGridSizeString + '\'' + + ", mNumHotseat=" + mNumHotseat + + ", mDeviceType=" + mDeviceType + + '}'; + } + + /** + * Returns true if the database from another DeviceGridState can be loaded into the current + * DeviceGridState without migration, or false otherwise. + */ + public boolean isCompatible(DeviceGridState other) { + if (this == other) return true; + if (other == null) return false; + return mNumHotseat == other.mNumHotseat + && deviceTypeCompatible(mDeviceType, other.mDeviceType) + && Objects.equals(mGridSizeString, other.mGridSizeString); } } diff --git a/src/com/android/launcher3/model/GridSizeMigrationTaskV2.java b/src/com/android/launcher3/model/GridSizeMigrationTaskV2.java index e7d0749e9e..fc86cf83f6 100644 --- a/src/com/android/launcher3/model/GridSizeMigrationTaskV2.java +++ b/src/com/android/launcher3/model/GridSizeMigrationTaskV2.java @@ -103,7 +103,13 @@ public class GridSizeMigrationTaskV2 { * Check given a new IDP, if migration is necessary. */ public static boolean needsToMigrate(Context context, InvariantDeviceProfile idp) { - return !new DeviceGridState(idp).equals(new DeviceGridState(context)); + DeviceGridState idpGridState = new DeviceGridState(idp); + DeviceGridState contextGridState = new DeviceGridState(context); + boolean needsToMigrate = !idpGridState.isCompatible(contextGridState); + // TODO: Revert this change after b/200010396 is fixed + Log.d(TAG, "Migration is needed. idpGridState: " + idpGridState + + ", contextGridState: " + contextGridState); + return needsToMigrate; } /** See {@link #migrateGridIfNeeded(Context, InvariantDeviceProfile)} */