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

Commit b3fbc0ba authored by Hyunyoung Song's avatar Hyunyoung Song
Browse files

Quick step/scrub/switch logging

- state transition happening due to Home and back is handled by
  specifying src target as 'from' container and dst target as the 'to'
  container
- Source and Destination container shows FROM and TO state for SWIPE/FLING
- event.isStateChange = true indicates that an action resulted in
  state transition
- Elapsed container millis is the screen time on the source container

Bug: 70181187

- logcat printout with setprop log.tag.UserEvent VERBOSE
1) State: WORKSPACE -> ALLAPPS
  action:FLING direction=UP
  Source child:HOTSEAT id=0	parent:WORKSPACE id=0
  Destination child:ALLAPPS
  Elapsed container 1225 ms, session 1225 ms, action 0 ms

2) ALLAPPS -> HOMESCREEN
  action:FLING direction=DOWN
  Source child:ALLAPPS	parent:ALLAPPS
  Destination child:WORKSPACE id=0
  Elapsed container 971 ms, session 2197 ms, action 0 ms

3) HOMESCREEN -> OVERVIEW
  action:FLING direction=UP
  Source child:NAVBAR	parent:WORKSPACE id=0
  Destination child:TASKSWITCHER
  Elapsed container 4834 ms, session 4834 ms, action 0 ms

4) OVERVIEW-> ALLAPPS
  action:FLING direction=UP
  Source child:TASK	parent:TASKSWITCHER
  Destination child:ALLAPPS
  Elapsed container 2176 ms, session 7010 ms, action 0 ms

5) ALLAPPS->OVERVIEW
  action:FLING direction=DOWN
  Source child:ALLAPPS	parent:ALLAPPS
  Destination child:TASKSWITCHER
  Elapsed container 3683 ms, session 10693 ms, action 0 ms

6) OVERVIEW-> HOMESCREEN
  action:FLING direction=DOWN
  Source child:TASK	parent:TASKSWITCHER
  Destination child:WORKSPACE id=0
  Elapsed container 2108 ms, session 12801 ms, action 0 ms

7) APPS-> OVERVIEW
  action:FLING direction=UP
  Source child:NAVBAR	parent:APP
  Destination child:TASKSWITCHER
  Elapsed container 104 ms, session 104 ms, action 0 ms

8) Quickscrub: action:DRAGANDDROP Source child: QUICK

9) Quickswitch: action:FLING Source child: QUICK

Change-Id: I5898230859ff600f48a2a873a40b670fe4d39a0d
parent 224f58c4
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ enum ItemType {
  SEARCHBOX = 6;
  EDITTEXT = 7;
  NOTIFICATION = 8;
  TASK = 9;         // Each page of Recents UI (QuickStep)
}

// Used to define what type of container a Target would represent.
@@ -78,11 +79,14 @@ enum ContainerType {
  FOLDER = 3;
  ALLAPPS = 4;
  WIDGETS = 5;
  OVERVIEW = 6;
  OVERVIEW = 6;   // Zoomed out workspace (without QuickStep)
  PREDICTION = 7;
  SEARCHRESULT = 8;
  DEEPSHORTCUTS = 9;
  PINITEM = 10;    // confirmation screen
  NAVBAR = 11;
  TASKSWITCHER = 12; // Recents UI Container (QuickStep)
  APP = 13; // Foreground activity is another app (QuickStep)
}

// Used to define what type of control a Target would represent.
@@ -100,6 +104,7 @@ enum ControlType {
  HOME_INTENT = 10; // Deprecated, use enum Command instead
  BACK_BUTTON = 11; // Deprecated, use enum Command instead
  // GO_TO_PLAYSTORE
  QUICK_SCRUB_BUTTON = 12;
}

// Used to define the action component of the LauncherEvent.
@@ -141,6 +146,7 @@ message Action {
  optional Command command = 4;
  // Log if the action was performed on outside of the container
  optional bool is_outside = 5;
  optional bool is_state_change = 6;
}

//
@@ -150,7 +156,6 @@ message Action {
//
message LauncherEvent {
  required Action action = 1;

  // List of targets that touch actions can be operated on.
  repeated Target src_target = 2;
  repeated Target dest_target = 3;
+22 −1
Original line number Diff line number Diff line
@@ -30,8 +30,12 @@ import android.view.MotionEvent;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.anim.SpringAnimationHandler;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction;
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
import com.android.launcher3.util.VerticalSwipeController;
import com.android.quickstep.RecentsView;

@@ -100,6 +104,10 @@ public class EdgeSwipeController extends VerticalSwipeController implements
        return isTransitionFlipped() ? DIRECTION_NEGATIVE : DIRECTION_POSITIVE;
    }

    public EdgeSwipeController(Launcher l, LauncherState baseState) {
        super(l, baseState);
    }

    @Override
    protected boolean isTransitionFlipped() {
        return mLauncher.getDeviceProfile().isSeascape();
@@ -117,8 +125,21 @@ public class EdgeSwipeController extends VerticalSwipeController implements
            builder.addTaggedData(319/*APP_TRANSITION_DELAY_MS*/,
                    0/* zero time */);
            mMetricsLogger.write(builder);

            // Add user event logging for launcher pipeline
            int direction = Direction.UP;
            if (mLauncher.getDeviceProfile().isLandscape) {
                direction = Direction.LEFT;
                if (mLauncher.getDeviceProfile().isSeascape()) {
                    direction = Direction.RIGHT;
                }
            }
            mLauncher.getUserEventDispatcher().logStateChangeAction(
                    wasFling ? Touch.FLING : Touch.SWIPE, direction,
                    ContainerType.NAVBAR, ContainerType.WORKSPACE, // src target
                    ContainerType.TASKSWITCHER,                    // dst target
                    mLauncher.getWorkspace().getCurrentPage());
        }
        // TODO: Log something
    }

    @Override
+1 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ public class OverviewState extends LauncherState {
            | FLAG_DISABLE_RESTORE;

    public OverviewState(int id) {
        super(id, ContainerType.WORKSPACE, OVERVIEW_TRANSITION_MS, STATE_FLAGS);
        super(id, ContainerType.TASKSWITCHER, OVERVIEW_TRANSITION_MS, STATE_FLAGS);
    }

    @Override
+23 −5
Original line number Diff line number Diff line
@@ -31,6 +31,10 @@ import com.android.launcher3.Utilities;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.touch.SwipeDetector;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch;
import com.android.launcher3.util.TouchController;
import com.android.quickstep.RecentsView;
import com.android.quickstep.TaskView;
@@ -70,6 +74,7 @@ public class OverviewSwipeController extends AnimatorListenerAdapter
    private float mDisplacementShift;
    private float mProgressMultiplier;
    private float mEndDisplacement;
    private int mStartingTarget;

    private TaskView mTaskBeingDragged;

@@ -120,7 +125,6 @@ public class OverviewSwipeController extends AnimatorListenerAdapter
            // calling the callbacks.
            final int directionsToDetectScroll;
            boolean ignoreSlopWhenSettling = false;

            if (mCurrentAnimation != null) {
                directionsToDetectScroll = SwipeDetector.DIRECTION_BOTH;
                ignoreSlopWhenSettling = true;
@@ -139,12 +143,15 @@ public class OverviewSwipeController extends AnimatorListenerAdapter
                        // The tile can be dragged down to open the task.
                        mTaskBeingDragged = (TaskView) view;
                        directionsToDetectScroll = SwipeDetector.DIRECTION_BOTH;
                        mStartingTarget = LauncherLogProto.ItemType.TASK;
                    } else if (isEventOverHotseat(ev)) {
                        // The hotseat is being dragged
                        directionsToDetectScroll = SwipeDetector.DIRECTION_POSITIVE;
                        mSwipeDownEnabled = false;
                        mStartingTarget = ContainerType.HOTSEAT;
                    } else {
                        mNoIntercept = true;
                        mStartingTarget = ContainerType.WORKSPACE;
                        return false;
                    }
                }
@@ -249,8 +256,9 @@ public class OverviewSwipeController extends AnimatorListenerAdapter
    @Override
    public void onDragEnd(float velocity, boolean fling) {
        final boolean goingToEnd;

        final int logAction;
        if (fling) {
            logAction = Touch.FLING;
            boolean goingUp = velocity < 0;
            if (!goingUp && !mSwipeDownEnabled) {
                goingToEnd = false;
@@ -269,6 +277,7 @@ public class OverviewSwipeController extends AnimatorListenerAdapter
                goingToEnd = true;
            }
        } else {
            logAction = Touch.SWIPE;
            goingToEnd = mCurrentAnimation.getProgressFraction() > SUCCESS_TRANSITION_PROGRESS;
        }

@@ -280,7 +289,7 @@ public class OverviewSwipeController extends AnimatorListenerAdapter
                progress + velocity * SINGLE_FRAME_MS / Math.abs(mEndDisplacement), 0f, 1f);


        mCurrentAnimation.setEndAction(() -> onCurrentAnimationEnd(goingToEnd));
        mCurrentAnimation.setEndAction(() -> onCurrentAnimationEnd(goingToEnd, logAction));

        ValueAnimator anim = mCurrentAnimation.getAnimationPlayer();
        anim.setFloatValues(nextFrameProgress, goingToEnd ? 1f : 0f);
@@ -289,18 +298,27 @@ public class OverviewSwipeController extends AnimatorListenerAdapter
        anim.start();
    }

    private void onCurrentAnimationEnd(boolean wasSuccess) {
        // TODO: Might be a good time to log something.
    private void onCurrentAnimationEnd(boolean wasSuccess, int logAction) {
        if (mTaskBeingDragged == null) {
            LauncherState state = wasSuccess ?
                    (mCurrentAnimationIsGoingUp ? ALL_APPS : NORMAL) : OVERVIEW;
            mLauncher.getStateManager().goToState(state, false);

        } else if (wasSuccess) {
            if (mCurrentAnimationIsGoingUp) {
                mRecentsView.onTaskDismissed(mTaskBeingDragged);
            } else {
                mTaskBeingDragged.launchTask(false);
                mLauncher.getUserEventDispatcher().logTaskLaunch(logAction,
                        Direction.DOWN, mTaskBeingDragged.getTask().getTopComponent());
            }
        }
        if (mTaskBeingDragged == null || (wasSuccess && mCurrentAnimationIsGoingUp)) {
            mLauncher.getUserEventDispatcher().logStateChangeAction(logAction,
                    mCurrentAnimationIsGoingUp ? Direction.UP : Direction.DOWN,
                    mStartingTarget, ContainerType.TASKSWITCHER,
                    mLauncher.getStateManager().getState().containerType,
                    mRecentsView.getCurrentPage());
        }
        mDetector.finishedScrolling();
        mTaskBeingDragged = null;
+4 −2
Original line number Diff line number Diff line
@@ -58,10 +58,12 @@ public class OverviewSwipeUpController extends VerticalSwipeController {
    protected void onTransitionComplete(boolean wasFling, boolean stateChanged) {
        if (stateChanged) {
            // Transition complete. log the action
            mLauncher.getUserEventDispatcher().logActionOnContainer(
            mLauncher.getUserEventDispatcher().logStateChangeAction(
                    wasFling ? Touch.FLING : Touch.SWIPE,
                    Direction.UP,
                    ContainerType.OVERVIEW,
                    ContainerType.HOTSEAT,
                    ContainerType.TASKSWITCHER,
                    ContainerType.ALLAPPS,
                    mLauncher.getWorkspace().getCurrentPage());
        }

Loading