From e35ef91c3e17cd386492aecfe9b591645ede2437 Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Mon, 20 Sep 2021 12:11:12 +0100 Subject: [PATCH] Workaround: don't migrate grid when hotseat size or device type changes in multi display Bug: 198965093 Test: manual Change-Id: I804ec854b98d27717c32723028f892ca2556d327 --- src/com/android/launcher3/model/DeviceGridState.java | 12 +++++++++++- .../launcher3/model/GridSizeMigrationTaskV2.java | 8 +++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/com/android/launcher3/model/DeviceGridState.java b/src/com/android/launcher3/model/DeviceGridState.java index 0fc4c2d716..992a3f231e 100644 --- a/src/com/android/launcher3/model/DeviceGridState.java +++ b/src/com/android/launcher3/model/DeviceGridState.java @@ -24,6 +24,7 @@ import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCH import android.content.Context; import android.content.SharedPreferences; import android.text.TextUtils; +import android.util.Log; import androidx.annotation.IntDef; @@ -134,8 +135,17 @@ public class DeviceGridState { public boolean isCompatible(DeviceGridState other) { if (this == other) return true; if (other == null) return false; - return mNumHotseat == other.mNumHotseat + boolean isCompatible = mNumHotseat == other.mNumHotseat && deviceTypeCompatible(mDeviceType, other.mDeviceType) && Objects.equals(mGridSizeString, other.mGridSizeString); + // TODO(b/198965093): Temporary fix for multi-display devices, ignore hotseat size changes + // and type compatibility. + if ((mDeviceType == TYPE_MULTI_DISPLAY || other.mDeviceType == TYPE_MULTI_DISPLAY) + && !isCompatible && Objects.equals(mGridSizeString, other.mGridSizeString)) { + Log.d("b/198965093", "Hotseat and deice type compatibility ignored: " + this + + ", other: " + other); + isCompatible = true; + } + return isCompatible; } } diff --git a/src/com/android/launcher3/model/GridSizeMigrationTaskV2.java b/src/com/android/launcher3/model/GridSizeMigrationTaskV2.java index fc86cf83f6..ca680b72c6 100644 --- a/src/com/android/launcher3/model/GridSizeMigrationTaskV2.java +++ b/src/com/android/launcher3/model/GridSizeMigrationTaskV2.java @@ -106,9 +106,11 @@ public class GridSizeMigrationTaskV2 { 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); + // TODO(b/198965093): Revert this change after bug is fixed + if (needsToMigrate) { + Log.d("b/198965093", "Migration is needed. idpGridState: " + idpGridState + + ", contextGridState: " + contextGridState); + } return needsToMigrate; }