Fix restore not migrating to new grid
- In reinitializeAfterRestore, use db path instead of grid name to check if migration is necessary, so migration will still happen if grid names are renamed. Also, only remove the target db path instead of all non source db paths, which are not necessary to be removed.
- In LauncherBackupAgent, remove old files before restoring to avoid old files from overriding restored files e.g. grid name in shared preferences
- Make sure InvariantDeviceProfile is intialize before we set pending to false, so unsupported grids can still be initialized and then be migratead
- Renamed 6x5 grid so it no longer collides with 4x4
Fix: 218500583
Test: Restore backup from supported and unsupported grids
Change-Id: Ic78e0bc7dc44ad86bd217c736b88708ad488ac0b
diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java
index a381787..dfe4bb0 100644
--- a/src/com/android/launcher3/InvariantDeviceProfile.java
+++ b/src/com/android/launcher3/InvariantDeviceProfile.java
@@ -250,11 +250,12 @@
* Reinitialize the current grid after a restore, where some grids might now be disabled.
*/
public void reinitializeAfterRestore(Context context) {
+ String currentGridName = getCurrentGridName(context);
String currentDbFile = dbFile;
- String gridName = getCurrentGridName(context);
- String newGridName = initGrid(context, gridName);
- if (!newGridName.equals(gridName)) {
- Log.d(TAG, "Restored grid is disabled : " + gridName
+ String newGridName = initGrid(context, currentGridName);
+ String newDbFile = dbFile;
+ if (!newDbFile.equals(currentDbFile)) {
+ Log.d(TAG, "Restored grid is disabled : " + currentGridName
+ ", migrating to: " + newGridName
+ ", removing all other grid db files");
for (String gridDbFile : LauncherFiles.GRID_DB_FILES) {
@@ -265,7 +266,7 @@
Log.d(TAG, "Removed old grid db file: " + gridDbFile);
}
}
- setCurrentGrid(context, gridName);
+ setCurrentGrid(context, newGridName);
}
}