Add new log events for widgets.

Design doc: go/widgets-logging

Bug: 185778648
Test: manual
Change-Id: Ia3c6edb87766a33e77865e9461e7101a1df864c1
This commit is contained in:
Yogisha Dixit
2021-05-04 14:58:34 +01:00
parent b1e51e2a3f
commit 4ff5ee3a8f
7 changed files with 77 additions and 3 deletions

View File

@@ -15,6 +15,8 @@
*/
package com.android.launcher3.uioverrides;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_APP_LAUNCH_TAP;
import android.app.ActivityOptions;
import android.app.ActivityTaskManager;
import android.app.PendingIntent;
@@ -26,6 +28,7 @@ import android.view.View;
import android.widget.RemoteViews;
import com.android.launcher3.Utilities;
import com.android.launcher3.logging.StatsLogManager;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.util.ActivityOptionsWrapper;
import com.android.launcher3.widget.LauncherAppWidgetHostView;
@@ -72,9 +75,24 @@ class QuickstepInteractionHandler implements RemoteViews.InteractionHandler {
mLauncher.addLaunchCookie((ItemInfo) itemInfo, activityOptions.options);
}
options = Pair.create(options.first, activityOptions.options);
if (pendingIntent.isActivity()) {
logAppLaunch(itemInfo);
}
return RemoteViews.startPendingIntent(hostView, pendingIntent, options);
}
/**
* Logs that the app was launched from the widget.
* @param itemInfo the widget info.
*/
private void logAppLaunch(Object itemInfo) {
StatsLogManager.StatsLogger logger = mLauncher.getStatsLogManager().logger();
if (itemInfo instanceof ItemInfo) {
logger.withItemInfo((ItemInfo) itemInfo);
}
logger.log(LAUNCHER_APP_LAUNCH_TAP);
}
private LauncherAppWidgetHostView findHostViewAncestor(View v) {
while (v != null) {
if (v instanceof LauncherAppWidgetHostView) return (LauncherAppWidgetHostView) v;