Fix shortcut componentname in workspace layout logging

Bug: 146172747
Test: $ adb shell dumpsys activity provider com.google.android.apps.nexuslauncher/com.android.launcher3.LauncherProvider --proto --debug
SHORTCUT, package=com.android.vending, component=VIEW_MY_DOWNLOADS, grid(3,4), span(1,1), pageIdx=0 user=0


Change-Id: Ic8537d499d66675fbe190f137b50fb693d6c21d5
This commit is contained in:
Hyunyoung Song 2019-12-16 09:43:13 -08:00
parent 9c592e210e
commit b9ba427576
1 changed files with 25 additions and 7 deletions

View File

@ -15,17 +15,22 @@
*/
package com.android.launcher3.logging;
import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT;
import android.content.ComponentName;
import android.os.Process;
import android.text.TextUtils;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.LauncherAppWidgetInfo;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.model.nano.LauncherDumpProto;
import com.android.launcher3.model.nano.LauncherDumpProto.ContainerType;
import com.android.launcher3.model.nano.LauncherDumpProto.DumpTarget;
import com.android.launcher3.model.nano.LauncherDumpProto.ItemType;
import com.android.launcher3.model.nano.LauncherDumpProto.UserType;
import com.android.launcher3.util.ShortcutUtil;
import java.util.ArrayList;
import java.util.List;
@ -73,20 +78,23 @@ public class DumpTargetWrapper {
public DumpTarget newItemTarget(ItemInfo info) {
DumpTarget dt = new DumpTarget();
dt.type = DumpTarget.Type.ITEM;
if (info == null) {
return dt;
}
switch (info.itemType) {
case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION:
dt.itemType = ItemType.APP_ICON;
break;
case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT:
dt.itemType = ItemType.UNKNOWN_ITEMTYPE;
break;
case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET:
dt.itemType = ItemType.WIDGET;
break;
case LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT:
case ITEM_TYPE_DEEP_SHORTCUT:
case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT:
dt.itemType = ItemType.SHORTCUT;
break;
default:
dt.itemType = ItemType.UNKNOWN_ITEMTYPE;
break;
}
return dt;
}
@ -120,6 +128,9 @@ public class DumpTargetWrapper {
}
private static String getItemStr(DumpTarget t) {
if (t == null) {
return "";
}
String typeStr = LoggerUtils.getFieldName(t.itemType, ItemType.class);
if (!TextUtils.isEmpty(t.packageName)) {
typeStr += ", package=" + t.packageName;
@ -132,8 +143,15 @@ public class DumpTargetWrapper {
}
public DumpTarget writeToDumpTarget(ItemInfo info) {
node.component = info.getTargetComponent() == null? "":
info.getTargetComponent().flattenToString();
if (info == null) {
return node;
}
if (ShortcutUtil.isDeepShortcut(info)) {
node.component = ((WorkspaceItemInfo) info).getDeepShortcutId();
} else {
ComponentName cmp = info.getTargetComponent();
node.component = cmp == null ? "" : cmp.flattenToString();
}
node.packageName = info.getTargetComponent() == null? "":
info.getTargetComponent().getPackageName();
if (info instanceof LauncherAppWidgetInfo) {