From 67094bfdfbe4cc5dcc9a8b44dfff89681e8ffa9b Mon Sep 17 00:00:00 2001 From: Pat Manning Date: Wed, 26 May 2021 12:38:13 +0000 Subject: [PATCH] Prevent clearing home between display size changes. Split display support was previously based on the sizes of supported device profiles. If a device supporting split display increased display size too much, it could trigger a grid migration (due to number of hotseat icons displayed vs in the DB changing as it was no longer seen as split display). The migration would not run however, as the grid had not actually changed, but would still have cleard the DB in preparation of the migration. By counting the number of supported profiles instead, we can estimate the number of screens invariant of display size changes and avoid undesired grid migrations. Test: manual Fix: 187689871 Bug: 187689871 Change-Id: If740c501cab0e80ef6144356ec5618ee30134ed7 --- .../launcher3/InvariantDeviceProfile.java | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java index 318dde1ecc..115d3aeebb 100644 --- a/src/com/android/launcher3/InvariantDeviceProfile.java +++ b/src/com/android/launcher3/InvariantDeviceProfile.java @@ -36,7 +36,6 @@ import android.graphics.Rect; import android.text.TextUtils; import android.util.AttributeSet; import android.util.DisplayMetrics; -import android.util.Log; import android.util.SparseArray; import android.util.TypedValue; import android.util.Xml; @@ -45,7 +44,6 @@ import android.view.Display; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; -import com.android.launcher3.testing.TestProtocol; import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.DisplayController.Info; import com.android.launcher3.util.IntArray; @@ -250,17 +248,10 @@ public class InvariantDeviceProfile { private String initGrid(Context context, String gridName) { Info displayInfo = DisplayController.INSTANCE.get(context).getInfo(); - // Determine if we have split display - - boolean isTablet = false, isPhone = false; - for (WindowBounds bounds : displayInfo.supportedBounds) { - if (displayInfo.isTablet(bounds)) { - isTablet = true; - } else { - isPhone = true; - } - } - boolean isSplitDisplay = isPhone && isTablet && ENABLE_TWO_PANEL_HOME.get(); + // Each screen has two profiles (portrait/landscape), so devices with four or more + // supported profiles implies two or more internal displays. + boolean isSplitDisplay = + displayInfo.supportedBounds.size() >= 4 && ENABLE_TWO_PANEL_HOME.get(); ArrayList allOptions = getPredefinedDeviceProfiles(context, gridName, isSplitDisplay);