Fix ClassCastException in QuickstepModelDelegate

- Added a casting check as an immediate fix to b/173838775
- Added logging to help debug the corrupt state where an item of type other than FolderInfo is used as an other item's container.
- Added LoaderMemoryLogger for adding large logs that are only conditionally printed.

Bug: 173838775
Test: manually checked logs
Change-Id: I9491cb421b9fb807d5fb110b04ad069481de768f
This commit is contained in:
Schneider Victor-tulias
2021-11-19 13:47:29 -08:00
parent 1c4871298e
commit 380f8fd890
5 changed files with 153 additions and 13 deletions

View File

@@ -31,6 +31,8 @@ import android.text.TextUtils;
import android.util.ArraySet;
import android.util.Log;
import androidx.annotation.Nullable;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.Workspace;
@@ -215,6 +217,19 @@ public class BgDataModel {
}
public synchronized void addItem(Context context, ItemInfo item, boolean newItem) {
addItem(context, item, newItem, null);
}
public synchronized void addItem(
Context context, ItemInfo item, boolean newItem, @Nullable LoaderMemoryLogger logger) {
if (logger != null) {
logger.addLog(
Log.DEBUG,
TAG,
String.format("Adding item to ID map: %s", item.toString()),
/* stackTrace= */ null);
}
itemsIdMap.put(item.id, item);
switch (item.itemType) {
case LauncherSettings.Favorites.ITEM_TYPE_FOLDER: