Log the reason why a WorkspaceItemInfo was removed

In the past we've seen a WorkspaceItem disappeared from the workspace
but wasn't able to determine why it was removed. This CL includes the
reason why it was removed in the error log, which hopefully would help
us debugging similar issues in the future.

Bug: 231239260
Test: make
Change-Id: Iba3d57568c9b3e011a6b65b26f0d4170d42fe1a5
This commit is contained in:
Pinyao Ting
2022-05-10 23:47:36 +00:00
parent 9c7551a9c9
commit 6a41d56b50
12 changed files with 67 additions and 31 deletions

View File

@@ -3068,7 +3068,8 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
if (info instanceof LauncherAppWidgetInfo) {
LauncherAppWidgetInfo appWidgetInfo = (LauncherAppWidgetInfo) info;
if (appWidgetInfo.appWidgetId == appWidgetId) {
mLauncher.removeItem(view, appWidgetInfo, true);
mLauncher.removeItem(view, appWidgetInfo, true,
"widget is removed in response to widget remove broadcast");
return true;
}
}
@@ -3318,8 +3319,9 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
*
* @param matcher the matcher generated by the caller.
*/
public void persistRemoveItemsByMatcher(Predicate<ItemInfo> matcher) {
mLauncher.getModelWriter().deleteItemsFromDatabase(matcher);
public void persistRemoveItemsByMatcher(Predicate<ItemInfo> matcher,
@Nullable final String reason) {
mLauncher.getModelWriter().deleteItemsFromDatabase(matcher, reason);
removeItemsByMatcher(matcher);
}