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

Commit 41d58f71 authored by Winson Chung's avatar Winson Chung
Browse files

Add launcher logging of back button

Bug: 127848641
Test: adb shell setprop log.tag.UserEvent VERBOSE, then hit back
Change-Id: I020738280d2e51a8a192e577baf48c0b092f22f6
(cherry picked from commit df7d0032)
parent 131e0b1d
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -85,6 +85,10 @@ public class TouchInteractionService extends Service {
            // TODO handle assistant
        }

        public void onBackAction(boolean completed, int downX, int downY, boolean isButton,
                boolean gestureSwipeLeft) {
        }

        /** Deprecated methods **/
        public void onQuickStep(MotionEvent motionEvent) { }

+2 −1
Original line number Diff line number Diff line
@@ -106,7 +106,7 @@ enum ControlType {
  RESIZE_HANDLE = 8;
  VERTICAL_SCROLL = 9;
  HOME_INTENT = 10; // Deprecated, use enum Command instead
  BACK_BUTTON = 11; // Deprecated, use enum Command instead
  BACK_BUTTON = 11;
  QUICK_SCRUB_BUTTON = 12;
  CLEAR_ALL_BUTTON = 13;
  CANCEL_TARGET = 14;
@@ -114,6 +114,7 @@ enum ControlType {
  SPLIT_SCREEN_TARGET = 16;
  REMOTE_ACTION_SHORTCUT = 17;
  APP_USAGE_SETTINGS = 18;
  BACK_GESTURE = 19;
}

enum TipType {
+5 −1
Original line number Diff line number Diff line
@@ -192,7 +192,11 @@ public final class FallbackActivityControllerHelper implements

    @Override
    public int getContainerType() {
        return LauncherLogProto.ContainerType.SIDELOADED_LAUNCHER;
        RecentsActivity activity = getCreatedActivity();
        boolean visible = activity != null && activity.isStarted() && activity.hasWindowFocus();
        return visible
                ? LauncherLogProto.ContainerType.SIDELOADED_LAUNCHER
                : LauncherLogProto.ContainerType.APP;
    }

    @Override
+9 −0
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ import com.android.launcher3.MainThreadExecutor;
import com.android.launcher3.Utilities;
import com.android.launcher3.compat.UserManagerCompat;
import com.android.launcher3.logging.EventLogArray;
import com.android.launcher3.logging.UserEventDispatcher;
import com.android.launcher3.util.LooperExecutor;
import com.android.launcher3.util.UiThreadHelper;
import com.android.quickstep.SysUINavigationMode.Mode;
@@ -141,6 +142,14 @@ public class TouchInteractionService extends Service implements
            });
        }

        public void onBackAction(boolean completed, int downX, int downY, boolean isButton,
                boolean gestureSwipeLeft) {
            final ActivityControlHelper activityControl =
                    mOverviewComponentObserver.getActivityControlHelper();
            UserEventDispatcher.newInstance(getBaseContext()).logActionBack(completed, downX, downY,
                    isButton, gestureSwipeLeft, activityControl.getContainerType());
        }

        /** Deprecated methods **/
        public void onQuickStep(MotionEvent motionEvent) { }

+23 −3
Original line number Diff line number Diff line
@@ -34,7 +34,8 @@ import android.content.SharedPreferences;
import android.os.SystemClock;
import android.util.Log;
import android.view.View;
import android.view.ViewParent;

import androidx.annotation.Nullable;

import com.android.launcher3.DropTarget;
import com.android.launcher3.ItemInfo;
@@ -54,8 +55,6 @@ import com.android.launcher3.util.ResourceBasedOverride;
import java.util.Locale;
import java.util.UUID;

import androidx.annotation.Nullable;

/**
 * Manages the creation of {@link LauncherEvent}.
 * To debug this class, execute following command before side loading a new apk.
@@ -359,6 +358,27 @@ public class UserEventDispatcher implements ResourceBasedOverride {
        dispatchUserEvent(event, null);
    }

    public void logActionBack(boolean completed, int downX, int downY, boolean isButton,
            boolean gestureSwipeLeft, int containerType) {
        int actionTouch = isButton ? Action.Touch.TAP : Action.Touch.SWIPE;
        Action action = newCommandAction(actionTouch);
        action.command = Action.Command.BACK;
        action.dir = isButton
                ? Action.Direction.NONE
                : gestureSwipeLeft
                        ? Action.Direction.LEFT
                        : Action.Direction.RIGHT;
        Target target = newControlTarget(isButton
                ? LauncherLogProto.ControlType.BACK_BUTTON
                : LauncherLogProto.ControlType.BACK_GESTURE);
        target.spanX = downX;
        target.spanY = downY;
        target.cardinality = completed ? 1 : 0;
        LauncherEvent event = newLauncherEvent(action, target, newContainerTarget(containerType));

        dispatchUserEvent(event, null);
    }

    /**
     * Currently logs following containers: workspace, allapps, widget tray.
     * @param reason