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

Commit d46e4287 authored by Vadim Tryshev's avatar Vadim Tryshev
Browse files

Generating fake “to Recents” events for overview NOT from task

These records are required by “Transition Delay - Hot Launch From
Recents” test. It doesn’t look at transition times for this event. They
are just a part of its expected sequence of events.

I generate transition delay times as zeroes because no one is looking at
them.

Bug: 72967764
Test: atest google/perf/app-transition/app-transition-from-recents-trace
Change-Id: I4a5b76b95c6c4b54e7fb620951342a3ed8564aed
parent 51fc778e
Loading
Loading
Loading
Loading
+48 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import static com.android.launcher3.touch.SwipeDetector.VERTICAL;
import static com.android.quickstep.TouchInteractionService.EDGE_NAV_BAR;

import android.graphics.Rect;
import android.metrics.LogMaker;
import android.view.MotionEvent;

import com.android.launcher3.DeviceProfile;
@@ -34,6 +35,40 @@ import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.util.VerticalSwipeController;
import com.android.quickstep.RecentsView;

class EventLogTags {
    private EventLogTags() {
    }  // don't instantiate

    /** 524292 sysui_multi_action (content|4) */
    public static final int SYSUI_MULTI_ACTION = 524292;

    public static void writeSysuiMultiAction(Object[] content) {
        android.util.EventLog.writeEvent(SYSUI_MULTI_ACTION, content);
    }
}

class MetricsLogger {
    private static MetricsLogger sMetricsLogger;

    private static MetricsLogger getLogger() {
        if (sMetricsLogger == null) {
            sMetricsLogger = new MetricsLogger();
        }
        return sMetricsLogger;
    }

    protected void saveLog(Object[] rep) {
        EventLogTags.writeSysuiMultiAction(rep);
    }

    public void write(LogMaker content) {
        if (content.getType() == 0/*MetricsEvent.TYPE_UNKNOWN*/) {
            content.setType(4/*MetricsEvent.TYPE_ACTION*/);
        }
        saveLog(content.serialize());
    }
}

/**
 * Extension of {@link VerticalSwipeController} to go from NORMAL to OVERVIEW.
 */
@@ -42,6 +77,8 @@ public class EdgeSwipeController extends VerticalSwipeController implements

    private static final Rect sTempRect = new Rect();

    private final MetricsLogger mMetricsLogger = new MetricsLogger();

    public EdgeSwipeController(Launcher l) {
        super(l, NORMAL, OVERVIEW, l.getDeviceProfile().isVerticalBarLayout()
                ? HORIZONTAL : VERTICAL);
@@ -70,6 +107,17 @@ public class EdgeSwipeController extends VerticalSwipeController implements

    @Override
    protected void onTransitionComplete(boolean wasFling, boolean stateChanged) {
        if (stateChanged && mToState instanceof OverviewState) {
            // Mimic ActivityMetricsLogger.logAppTransitionMultiEvents() logging for
            // "Recents" activity for app transition tests.
            final LogMaker builder = new LogMaker(761/*APP_TRANSITION*/);
            builder.setPackageName("com.android.systemui");
            builder.addTaggedData(871/*FIELD_CLASS_NAME*/,
                    "com.android.systemui.recents.RecentsActivity");
            builder.addTaggedData(319/*APP_TRANSITION_DELAY_MS*/,
                    0/* zero time */);
            mMetricsLogger.write(builder);
        }
        // TODO: Log something
    }

+1 −1
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ public abstract class VerticalSwipeController extends AnimatorListenerAdapter
    private boolean mNoIntercept;

    private AnimatorPlaybackController mCurrentAnimation;
    private LauncherState mToState;
    protected LauncherState mToState;

    private float mStartProgress;
    // Ratio of transition process [0, 1] to drag displacement (px)