Adding WEB_APP item type for logging.

Set in LoggerUtils.newItemTarget if instant app

Bug:67049361
Change-Id: I8e99e5c60bf1a2083f898e8978d403138f803276
This commit is contained in:
Mario Bertschler 2018-03-29 21:12:12 +02:00
parent 86d7b2d81d
commit d2e3c5de56
4 changed files with 26 additions and 11 deletions

View File

@ -69,6 +69,7 @@ enum ItemType {
EDITTEXT = 7; EDITTEXT = 7;
NOTIFICATION = 8; NOTIFICATION = 8;
TASK = 9; // Each page of Recents UI (QuickStep) TASK = 9; // Each page of Recents UI (QuickStep)
WEB_APP = 10;
} }
// Used to define what type of container a Target would represent. // Used to define what type of container a Target would represent.

View File

@ -53,6 +53,7 @@ import com.android.launcher3.model.WidgetItem;
import com.android.launcher3.shortcuts.ShortcutInfoCompat; import com.android.launcher3.shortcuts.ShortcutInfoCompat;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action; import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
import com.android.launcher3.util.InstantAppResolver;
import com.android.launcher3.widget.PendingAddShortcutInfo; import com.android.launcher3.widget.PendingAddShortcutInfo;
import com.android.launcher3.widget.PendingAddWidgetInfo; import com.android.launcher3.widget.PendingAddWidgetInfo;
import com.android.launcher3.widget.WidgetHostViewLoader; import com.android.launcher3.widget.WidgetHostViewLoader;
@ -82,6 +83,7 @@ public class AddItemActivity extends BaseActivity implements OnLongClickListener
private Bundle mWidgetOptions; private Bundle mWidgetOptions;
private boolean mFinishOnPause = false; private boolean mFinishOnPause = false;
private InstantAppResolver mInstantAppResolver;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -95,6 +97,7 @@ public class AddItemActivity extends BaseActivity implements OnLongClickListener
mApp = LauncherAppState.getInstance(this); mApp = LauncherAppState.getInstance(this);
mIdp = mApp.getInvariantDeviceProfile(); mIdp = mApp.getInvariantDeviceProfile();
mInstantAppResolver = InstantAppResolver.newInstance(this);
// Use the application context to get the device profile, as in multiwindow-mode, the // Use the application context to get the device profile, as in multiwindow-mode, the
// confirmation activity might be rotated. // confirmation activity might be rotated.
@ -298,7 +301,7 @@ public class AddItemActivity extends BaseActivity implements OnLongClickListener
private void logCommand(int command) { private void logCommand(int command) {
getUserEventDispatcher().dispatchUserEvent(newLauncherEvent( getUserEventDispatcher().dispatchUserEvent(newLauncherEvent(
newCommandAction(command), newCommandAction(command),
newItemTarget(mWidgetCell.getWidgetView()), newItemTarget(mWidgetCell.getWidgetView(), mInstantAppResolver),
newContainerTarget(ContainerType.PINITEM)), null); newContainerTarget(ContainerType.PINITEM)), null);
} }
} }

View File

@ -15,10 +15,12 @@
*/ */
package com.android.launcher3.logging; package com.android.launcher3.logging;
import android.content.Context;
import android.util.ArrayMap; import android.util.ArrayMap;
import android.util.SparseArray; import android.util.SparseArray;
import android.view.View; import android.view.View;
import com.android.launcher3.AppInfo;
import com.android.launcher3.ButtonDropTarget; import com.android.launcher3.ButtonDropTarget;
import com.android.launcher3.ItemInfo; import com.android.launcher3.ItemInfo;
import com.android.launcher3.LauncherSettings; import com.android.launcher3.LauncherSettings;
@ -29,6 +31,7 @@ import com.android.launcher3.userevent.nano.LauncherLogProto.ControlType;
import com.android.launcher3.userevent.nano.LauncherLogProto.ItemType; import com.android.launcher3.userevent.nano.LauncherLogProto.ItemType;
import com.android.launcher3.userevent.nano.LauncherLogProto.LauncherEvent; import com.android.launcher3.userevent.nano.LauncherLogProto.LauncherEvent;
import com.android.launcher3.userevent.nano.LauncherLogProto.Target; import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
import com.android.launcher3.util.InstantAppResolver;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
@ -127,18 +130,21 @@ public class LoggerUtils {
return t; return t;
} }
public static Target newItemTarget(View v) { public static Target newItemTarget(View v, InstantAppResolver instantAppResolver) {
return (v.getTag() instanceof ItemInfo) return (v.getTag() instanceof ItemInfo)
? newItemTarget((ItemInfo) v.getTag()) ? newItemTarget((ItemInfo) v.getTag(), instantAppResolver)
: newTarget(Target.Type.ITEM); : newTarget(Target.Type.ITEM);
} }
public static Target newItemTarget(ItemInfo info) { public static Target newItemTarget(ItemInfo info, InstantAppResolver instantAppResolver) {
Target t = newTarget(Target.Type.ITEM); Target t = newTarget(Target.Type.ITEM);
switch (info.itemType) { switch (info.itemType) {
case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION: case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION:
t.itemType = ItemType.APP_ICON; t.itemType = (instantAppResolver != null && info instanceof AppInfo
&& instantAppResolver.isInstantApp(((AppInfo) info)) )
? ItemType.WEB_APP
: ItemType.APP_ICON;
t.predictedRank = -100; // Never assigned t.predictedRank = -100; // Never assigned
break; break;
case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT: case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT:

View File

@ -38,6 +38,7 @@ import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
import com.android.launcher3.userevent.nano.LauncherLogProto.LauncherEvent; import com.android.launcher3.userevent.nano.LauncherLogProto.LauncherEvent;
import com.android.launcher3.userevent.nano.LauncherLogProto.Target; import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
import com.android.launcher3.util.InstantAppResolver;
import com.android.launcher3.util.LogConfig; import com.android.launcher3.util.LogConfig;
import java.util.Locale; import java.util.Locale;
@ -78,6 +79,7 @@ public class UserEventDispatcher {
ued.mIsInLandscapeMode = dp.isVerticalBarLayout(); ued.mIsInLandscapeMode = dp.isVerticalBarLayout();
ued.mIsInMultiWindowMode = dp.isMultiWindowMode; ued.mIsInMultiWindowMode = dp.isMultiWindowMode;
ued.mUuidStr = uuidStr; ued.mUuidStr = uuidStr;
ued.mInstantAppResolver = InstantAppResolver.newInstance(context);
return ued; return ued;
} }
@ -126,6 +128,7 @@ public class UserEventDispatcher {
private boolean mIsInMultiWindowMode; private boolean mIsInMultiWindowMode;
private boolean mIsInLandscapeMode; private boolean mIsInLandscapeMode;
private String mUuidStr; private String mUuidStr;
protected InstantAppResolver mInstantAppResolver;
// APP_ICON SHORTCUT WIDGET // APP_ICON SHORTCUT WIDGET
// -------------------------------------------------------------- // --------------------------------------------------------------
@ -151,7 +154,7 @@ public class UserEventDispatcher {
public void logAppLaunch(View v, Intent intent) { public void logAppLaunch(View v, Intent intent) {
LauncherEvent event = newLauncherEvent(newTouchAction(Action.Touch.TAP), LauncherEvent event = newLauncherEvent(newTouchAction(Action.Touch.TAP),
newItemTarget(v), newTarget(Target.Type.CONTAINER)); newItemTarget(v, mInstantAppResolver), newTarget(Target.Type.CONTAINER));
if (fillInLogContainerData(event, v)) { if (fillInLogContainerData(event, v)) {
fillIntentInfo(event.srcTarget[0], intent); fillIntentInfo(event.srcTarget[0], intent);
@ -184,7 +187,7 @@ public class UserEventDispatcher {
public void logNotificationLaunch(View v, PendingIntent intent) { public void logNotificationLaunch(View v, PendingIntent intent) {
LauncherEvent event = newLauncherEvent(newTouchAction(Action.Touch.TAP), LauncherEvent event = newLauncherEvent(newTouchAction(Action.Touch.TAP),
newItemTarget(v), newTarget(Target.Type.CONTAINER)); newItemTarget(v, mInstantAppResolver), newTarget(Target.Type.CONTAINER));
if (fillInLogContainerData(event, v)) { if (fillInLogContainerData(event, v)) {
event.srcTarget[0].packageNameHash = (mUuidStr + intent.getCreatorPackage()).hashCode(); event.srcTarget[0].packageNameHash = (mUuidStr + intent.getCreatorPackage()).hashCode();
} }
@ -215,7 +218,7 @@ public class UserEventDispatcher {
*/ */
public void logActionCommand(int command, View itemView, int srcContainerType) { public void logActionCommand(int command, View itemView, int srcContainerType) {
LauncherEvent event = newLauncherEvent(newCommandAction(command), LauncherEvent event = newLauncherEvent(newCommandAction(command),
newItemTarget(itemView), newTarget(Target.Type.CONTAINER)); newItemTarget(itemView, mInstantAppResolver), newTarget(Target.Type.CONTAINER));
if (fillInLogContainerData(event, itemView)) { if (fillInLogContainerData(event, itemView)) {
// TODO: Remove the following two lines once fillInLogContainerData can take in a // TODO: Remove the following two lines once fillInLogContainerData can take in a
@ -320,7 +323,7 @@ public class UserEventDispatcher {
} }
ItemInfo info = (ItemInfo) icon.getTag(); ItemInfo info = (ItemInfo) icon.getTag();
LauncherEvent event = newLauncherEvent(newTouchAction(Action.Touch.LONGPRESS), LauncherEvent event = newLauncherEvent(newTouchAction(Action.Touch.LONGPRESS),
newItemTarget(info), newTarget(Target.Type.CONTAINER)); newItemTarget(info, mInstantAppResolver), newTarget(Target.Type.CONTAINER));
provider.fillInLogContainerData(icon, info, event.srcTarget[0], event.srcTarget[1]); provider.fillInLogContainerData(icon, info, event.srcTarget[0], event.srcTarget[1]);
dispatchUserEvent(event, null); dispatchUserEvent(event, null);
@ -338,9 +341,11 @@ public class UserEventDispatcher {
public void logDragNDrop(DropTarget.DragObject dragObj, View dropTargetAsView) { public void logDragNDrop(DropTarget.DragObject dragObj, View dropTargetAsView) {
LauncherEvent event = newLauncherEvent(newTouchAction(Action.Touch.DRAGDROP), LauncherEvent event = newLauncherEvent(newTouchAction(Action.Touch.DRAGDROP),
newItemTarget(dragObj.originalDragInfo), newTarget(Target.Type.CONTAINER)); newItemTarget(dragObj.originalDragInfo, mInstantAppResolver),
newTarget(Target.Type.CONTAINER));
event.destTarget = new Target[] { event.destTarget = new Target[] {
newItemTarget(dragObj.originalDragInfo), newDropTarget(dropTargetAsView) newItemTarget(dragObj.originalDragInfo, mInstantAppResolver),
newDropTarget(dropTargetAsView)
}; };
dragObj.dragSource.fillInLogContainerData(null, dragObj.originalDragInfo, dragObj.dragSource.fillInLogContainerData(null, dragObj.originalDragInfo,