Pass in dbFile from idpGridState for grid migration
- IDP can get re-initializeed during grid migration task, causing src/dest dbFile to be the same when prepareForMigration, which fails the migration and causes a wipe
- The fix is to cache IDP state as DeviceGridState, and use DeviceGridState to determine migration, trigger migration and save configuration after migration
- This should avoid migration failure in b/198965093 that causes homescreen wipe. Homescreen icon may still be messed up by the migration, but won't completely disappear
Bug: 198965093
Fix: 223579388
Test: manually trigger grid migration
Change-Id: I9890a6d5d530ff87aed8f601ec7d35a672b7cd46
diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java
index e004a4b..9891a60 100644
--- a/src/com/android/launcher3/LauncherProvider.java
+++ b/src/com/android/launcher3/LauncherProvider.java
@@ -158,6 +158,7 @@
private synchronized boolean prepForMigration(String dbFile, String targetTableName,
Supplier<DatabaseHelper> src, Supplier<DatabaseHelper> dst) {
if (TextUtils.equals(dbFile, mOpenHelper.getDatabaseName())) {
+ Log.e("b/198965093", "prepForMigration - target db is same as current: " + dbFile);
return false;
}
@@ -427,7 +428,7 @@
Bundle result = new Bundle();
result.putBoolean(LauncherSettings.Settings.EXTRA_VALUE,
prepForMigration(
- InvariantDeviceProfile.INSTANCE.get(getContext()).dbFile,
+ arg /* dbFile */,
Favorites.TMP_TABLE,
() -> mOpenHelper,
() -> DatabaseHelper.createDatabaseHelper(