Moving data sanitization before bind
Data sanitization changes the launcher model data, which makes it
out of sync with what Launcher is displaying.
This would lead to widgetsIds getting deleted when they are created
by Launcher on UI thread, but have not yet been updated in the model
Also clearing all ghost widgets on every load. This would remove
the flaky behavior where widget update depends on folder and
other icons getting removed
Test: Presubmit
Bug: 181680555
Change-Id: I3cce69383d9d92a283c5197c3f99fbb539d93dbb
diff --git a/src/com/android/launcher3/model/LoaderTask.java b/src/com/android/launcher3/model/LoaderTask.java
index 209c5be..f6c7c06 100644
--- a/src/com/android/launcher3/model/LoaderTask.java
+++ b/src/com/android/launcher3/model/LoaderTask.java
@@ -192,6 +192,16 @@
loadWorkspace(allShortcuts);
logger.addSplit("loadWorkspace");
+ // Sanitize data re-syncs widgets/shortcuts based on the workspace loaded from db.
+ // sanitizeData should not be invoked if the workspace is loaded from a db different
+ // from the main db as defined in the invariant device profile.
+ // (e.g. both grid preview and minimal device mode uses a different db)
+ if (mApp.getInvariantDeviceProfile().dbFile.equals(mDbName)) {
+ verifyNotStopped();
+ sanitizeData();
+ logger.addSplit("sanitizeData");
+ }
+
verifyNotStopped();
mResults.bindWorkspace();
logger.addSplit("bindWorkspace");
@@ -274,14 +284,6 @@
loadFolderNames();
}
- // Sanitize data re-syncs widgets/shortcuts based on the workspace loaded from db.
- // sanitizeData should not be invoked if the workspace is loaded from a db different
- // from the main db as defined in the invariant device profile.
- // (e.g. both grid preview and minimal device mode uses a different db)
- if (mApp.getInvariantDeviceProfile().dbFile.equals(mDbName)) {
- sanitizeData();
- }
-
verifyNotStopped();
updateHandler.finish();
logger.addSplit("finish icon update");
@@ -875,10 +877,11 @@
mBgDataModel.itemsIdMap.remove(folderId);
}
}
- // Remove any ghost widgets
- LauncherSettings.Settings.call(contentResolver,
- LauncherSettings.Settings.METHOD_REMOVE_GHOST_WIDGETS);
+
}
+ // Remove any ghost widgets
+ LauncherSettings.Settings.call(contentResolver,
+ LauncherSettings.Settings.METHOD_REMOVE_GHOST_WIDGETS);
// Update pinned state of model shortcuts
mBgDataModel.updateShortcutPinnedState(context);