Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4ff5ee3a authored by Yogisha Dixit's avatar Yogisha Dixit
Browse files

Add new log events for widgets.

Design doc: go/widgets-logging

Bug: 185778648
Test: manual
Change-Id: Ia3c6edb87766a33e77865e9461e7101a1df864c1
parent b1e51e2a
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -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;
+30 −2
Original line number Diff line number Diff line
@@ -5,6 +5,8 @@ import static android.appwidget.AppWidgetHostView.getDefaultPaddingForWidget;
import static com.android.launcher3.LauncherAnimUtils.LAYOUT_HEIGHT;
import static com.android.launcher3.LauncherAnimUtils.LAYOUT_WIDTH;
import static com.android.launcher3.Utilities.ATLEAST_S;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_WIDGET_RESIZE_COMPLETED;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_WIDGET_RESIZE_STARTED;
import static com.android.launcher3.views.BaseDragLayer.LAYOUT_X;
import static com.android.launcher3.views.BaseDragLayer.LAYOUT_Y;

@@ -31,6 +33,10 @@ import android.widget.ImageView;

import com.android.launcher3.accessibility.DragViewStateAnnouncer;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.logging.InstanceId;
import com.android.launcher3.logging.InstanceIdSequence;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.util.PendingRequestArgs;
import com.android.launcher3.widget.LauncherAppWidgetHostView;
import com.android.launcher3.widget.LauncherAppWidgetProviderInfo;

@@ -96,6 +102,8 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O
    private final IntRange mDeltaYRange = new IntRange();
    private final IntRange mBaselineY = new IntRange();

    private final InstanceId logInstanceId = new InstanceIdSequence().newInstanceId();

    private boolean mLeftBorderActive;
    private boolean mRightBorderActive;
    private boolean mTopBorderActive;
@@ -222,12 +230,21 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O
        mReconfigureButton = (ImageButton) findViewById(R.id.widget_reconfigure_button);
        if (info.isReconfigurable()) {
            mReconfigureButton.setVisibility(VISIBLE);
            mReconfigureButton.setOnClickListener(view -> mLauncher
            mReconfigureButton.setOnClickListener(view -> {
                mLauncher.setWaitingForResult(
                        PendingRequestArgs.forWidgetInfo(
                                mWidgetView.getAppWidgetId(),
                                // Widget add handler is null since we're reconfiguring an existing
                                // widget.
                                /* widgetHandler= */ null,
                                (ItemInfo) mWidgetView.getTag()));
                mLauncher
                    .getAppWidgetHost()
                    .startConfigActivity(
                            mLauncher,
                            mWidgetView.getAppWidgetId(),
                            Launcher.REQUEST_RECONFIGURE_APPWIDGET));
                            Launcher.REQUEST_RECONFIGURE_APPWIDGET);
            });
        }

        // When we create the resize frame, we first mark all cells as unoccupied. The appropriate
@@ -235,6 +252,12 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O
        // frame is dismissed.
        mCellLayout.markCellsAsUnoccupiedForView(mWidgetView);

        mLauncher.getStatsLogManager()
                .logger()
                .withInstanceId(logInstanceId)
                .withItemInfo((ItemInfo) mWidgetView.getTag())
                .log(LAUNCHER_WIDGET_RESIZE_STARTED);

        setOnKeyListener(this);
    }

@@ -482,6 +505,11 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O

        // We are done with resizing the widget. Save the widget size & position to LauncherModel
        resizeWidgetIfNeeded(true);
        mLauncher.getStatsLogManager()
                .logger()
                .withInstanceId(logInstanceId)
                .withItemInfo((ItemInfo) mWidgetView.getTag())
                .log(LAUNCHER_WIDGET_RESIZE_COMPLETED);
    }

    private void onTouchUp() {
+2 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCH
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_EXIT;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ONRESUME;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ONSTOP;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_WIDGET_RECONFIGURED;
import static com.android.launcher3.model.ItemInstallQueue.FLAG_ACTIVITY_PAUSED;
import static com.android.launcher3.model.ItemInstallQueue.FLAG_DRAG_AND_DROP;
import static com.android.launcher3.model.ItemInstallQueue.FLAG_LOADER_RUNNING;
@@ -683,6 +684,7 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche
                completeAddAppWidget(appWidgetId, info, null, null);
                break;
            case REQUEST_RECONFIGURE_APPWIDGET:
                mStatsLogManager.logger().withItemInfo(info).log(LAUNCHER_WIDGET_RECONFIGURED);
                completeRestoreAppWidget(appWidgetId, LauncherAppWidgetInfo.RESTORE_COMPLETED);
                break;
            case REQUEST_BIND_PENDING_APPWIDGET: {
+3 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.ItemInfoWithIcon;
import com.android.launcher3.model.data.LauncherAppWidgetInfo;
import com.android.launcher3.util.PackageManagerHelper;
import com.android.launcher3.util.PendingRequestArgs;
import com.android.launcher3.widget.LauncherAppWidgetProviderInfo;

import java.net.URISyntaxException;
@@ -267,6 +268,8 @@ public class SecondaryDropTarget extends ButtonDropTarget implements OnAlarmList
        if (mCurrentAccessibilityAction == RECONFIGURE) {
            int widgetId = getReconfigurableWidgetId(view);
            if (widgetId != INVALID_APPWIDGET_ID) {
                mLauncher.setWaitingForResult(
                        PendingRequestArgs.forWidgetInfo(widgetId, null, info));
                mLauncher.getAppWidgetHost().startConfigActivity(mLauncher, widgetId,
                        REQUEST_RECONFIGURE_APPWIDGET);
            }
+16 −1
Original line number Diff line number Diff line
@@ -135,6 +135,12 @@ public class StatsLogManager implements ResourceBasedOverride {
        @UiEvent(doc = "User tapped or long pressed on widget tray icon inside launcher settings.")
        LAUNCHER_WIDGETSTRAY_BUTTON_TAP_OR_LONGPRESS(464),

        @UiEvent(doc = "User expanded the list of widgets for a single app in the widget picker.")
        LAUNCHER_WIDGETSTRAY_APP_EXPANDED(818),

        @UiEvent(doc = "User searched for a widget in the widget picker.")
        LAUNCHER_WIDGETSTRAY_SEARCHED(819),

        @UiEvent(doc = "A dragged item is dropped on 'Remove' button in the target bar")
        LAUNCHER_ITEM_DROPPED_ON_REMOVE(465),

@@ -458,7 +464,16 @@ public class StatsLogManager implements ResourceBasedOverride {
        LAUNCHER_OVERVIEW_SHARING_TAP_MORE_TO_SHARE_URL(777),

        @UiEvent(doc = "User taps the More button to share an image")
        LAUNCHER_OVERVIEW_SHARING_TAP_MORE_TO_SHARE_IMAGE(778)
        LAUNCHER_OVERVIEW_SHARING_TAP_MORE_TO_SHARE_IMAGE(778),

        @UiEvent(doc = "User started resizing a widget on their home screen.")
        LAUNCHER_WIDGET_RESIZE_STARTED(820),

        @UiEvent(doc = "User finished resizing a widget on their home screen.")
        LAUNCHER_WIDGET_RESIZE_COMPLETED(824),

        @UiEvent(doc = "User reconfigured a widget on their home screen.")
        LAUNCHER_WIDGET_RECONFIGURED(821)
        ;

        // ADD MORE
Loading