Allow restore across form factors
- Removed deviceTypeCompatible check and allow restore across for mfactors
- In AOSP default device_profile, mark 3x3, 4x4, and 5x5 as phone only. On tablets they'll reflow to 6x5.
Bug: 198575341
Bug: 210129187
Test: Only 3x3, 4x4 and 5x5 are enabled on phone
Test: Only 6x5 is enabled on tablet
Test: Phone backup of 4x4 get restored and reflow to 6x5 on tablet
Change-Id: I36a641d47fcee86ace0fea3d9194d61d12517f13
diff --git a/res/xml/device_profiles.xml b/res/xml/device_profiles.xml
index b4bb43e..08698e7 100644
--- a/res/xml/device_profiles.xml
+++ b/res/xml/device_profiles.xml
@@ -25,7 +25,8 @@
launcher:numFolderColumns="3"
launcher:numHotseatIcons="3"
launcher:dbFile="launcher_3_by_3.db"
- launcher:defaultLayoutId="@xml/default_workspace_3x3" >
+ launcher:defaultLayoutId="@xml/default_workspace_3x3"
+ launcher:deviceCategory="phone|multi_display" >
<display-option
launcher:name="Super Short Stubby"
@@ -53,7 +54,8 @@
launcher:numFolderColumns="4"
launcher:numHotseatIcons="4"
launcher:dbFile="launcher_4_by_4.db"
- launcher:defaultLayoutId="@xml/default_workspace_4x4" >
+ launcher:defaultLayoutId="@xml/default_workspace_4x4"
+ launcher:deviceCategory="phone|multi_display" >
<display-option
launcher:name="Short Stubby"
@@ -105,7 +107,8 @@
launcher:numFolderColumns="4"
launcher:numHotseatIcons="5"
launcher:dbFile="launcher.db"
- launcher:defaultLayoutId="@xml/default_workspace_5x5" >
+ launcher:defaultLayoutId="@xml/default_workspace_5x5"
+ launcher:deviceCategory="phone|multi_display" >
<display-option
launcher:name="Large Phone"
@@ -143,7 +146,7 @@
launcher:numAllAppsColumns="6"
launcher:dbFile="launcher_6_by_5.db"
launcher:defaultLayoutId="@xml/default_workspace_6x5"
- launcher:deviceCategory="tablet">
+ launcher:deviceCategory="tablet" >
<display-option
launcher:name="Tablet"
diff --git a/src/com/android/launcher3/LauncherFiles.java b/src/com/android/launcher3/LauncherFiles.java
index 64f1d95..e59eac8 100644
--- a/src/com/android/launcher3/LauncherFiles.java
+++ b/src/com/android/launcher3/LauncherFiles.java
@@ -16,6 +16,7 @@
private static final String XML = ".xml";
public static final String LAUNCHER_DB = "launcher.db";
+ public static final String LAUNCHER_6_BY_5_DB = "launcher_6_by_5.db";
public static final String LAUNCHER_4_BY_5_DB = "launcher_4_by_5.db";
public static final String LAUNCHER_4_BY_4_DB = "launcher_4_by_4.db";
public static final String LAUNCHER_3_BY_3_DB = "launcher_3_by_3.db";
@@ -32,6 +33,7 @@
public static final List<String> GRID_DB_FILES = Collections.unmodifiableList(Arrays.asList(
LAUNCHER_DB,
+ LAUNCHER_6_BY_5_DB,
LAUNCHER_4_BY_5_DB,
LAUNCHER_4_BY_4_DB,
LAUNCHER_3_BY_3_DB,
diff --git a/src/com/android/launcher3/model/DeviceGridState.java b/src/com/android/launcher3/model/DeviceGridState.java
index 01ebc53..fa11d4e 100644
--- a/src/com/android/launcher3/model/DeviceGridState.java
+++ b/src/com/android/launcher3/model/DeviceGridState.java
@@ -17,7 +17,6 @@
package com.android.launcher3.model;
import static com.android.launcher3.InvariantDeviceProfile.DeviceType;
-import static com.android.launcher3.InvariantDeviceProfile.TYPE_MULTI_DISPLAY;
import static com.android.launcher3.InvariantDeviceProfile.TYPE_PHONE;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_GRID_SIZE_2;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_GRID_SIZE_3;
@@ -31,7 +30,6 @@
import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.Utilities;
import com.android.launcher3.logging.StatsLogManager.LauncherEvent;
-import com.android.launcher3.util.IntSet;
import java.util.Locale;
import java.util.Objects;
@@ -45,13 +43,6 @@
public static final String KEY_HOTSEAT_COUNT = "migration_src_hotseat_count";
public static final String KEY_DEVICE_TYPE = "migration_src_device_type";
- private static final IntSet COMPATIBLE_TYPES = IntSet.wrap(TYPE_PHONE, TYPE_MULTI_DISPLAY);
-
- public static boolean deviceTypeCompatible(@DeviceType int typeA, @DeviceType int typeB) {
- return typeA == typeB
- || (COMPATIBLE_TYPES.contains(typeA) && COMPATIBLE_TYPES.contains(typeB));
- }
-
private final String mGridSizeString;
private final int mNumHotseat;
private final @DeviceType int mDeviceType;
@@ -123,7 +114,6 @@
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/provider/RestoreDbTask.java b/src/com/android/launcher3/provider/RestoreDbTask.java
index 4c0930b..d994dbe 100644
--- a/src/com/android/launcher3/provider/RestoreDbTask.java
+++ b/src/com/android/launcher3/provider/RestoreDbTask.java
@@ -87,12 +87,6 @@
}
private static boolean performRestore(Context context, DatabaseHelper helper) {
- if (!DeviceGridState.deviceTypeCompatible(
- new DeviceGridState(LauncherAppState.getIDP(context)).getDeviceType(),
- Utilities.getPrefs(context).getInt(RESTORED_DEVICE_TYPE, TYPE_PHONE))) {
- // DO NOT restore if the device types are incompatible.
- return false;
- }
SQLiteDatabase db = helper.getWritableDatabase();
try (SQLiteTransaction t = new SQLiteTransaction(db)) {
RestoreDbTask task = new RestoreDbTask();