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

Commit 51fc778e authored by Vadim Tryshev's avatar Vadim Tryshev
Browse files

Fixing “Transition Delay - App to Recents” test: the Launcher part

The fix is quite hacky and should be re-done soon. I’m not leaving TODOs
in the code, but I’m tracking the cleanup elsewhere.

We also need a fix in the server to make the test work, but that will be
another CL.

Bug: 72967764
Test: atest google/perf/app-transition/app-transition-to-recents
Change-Id: Ia21c308caa81bd5502f4a4587ae445928f6eca17
parent 704e6986
Loading
Loading
Loading
Loading
+50 −2
Original line number Diff line number Diff line
@@ -38,8 +38,10 @@ import android.graphics.Color;
import android.graphics.Point;
import android.graphics.PointF;
import android.graphics.Rect;
import android.metrics.LogMaker;
import android.os.Bundle;
import android.os.Looper;
import android.os.SystemClock;
import android.util.Log;
import android.view.Display;
import android.view.MotionEvent;
@@ -64,6 +66,40 @@ import com.android.systemui.shared.system.WindowManagerWrapper;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

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());
    }
}

/**
 * Touch consumer for handling events originating from an activity other than Launcher
 */
@@ -91,6 +127,8 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC

    private VelocityTracker mVelocityTracker;

    private final MetricsLogger mMetricsLogger = new MetricsLogger();

    public OtherActivityTouchConsumer(Context base, RunningTaskInfo runningTaskInfo,
            RecentsModel recentsModel, Intent homeIntent, ISystemUiProxy systemUiProxy,
            MainThreadExecutor mainThreadExecutor) {
@@ -125,7 +163,7 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC
                // Start the window animation on down to give more time for launcher to draw if the
                // user didn't start the gesture over the back button
                if (!isUsingScreenShot()) {
                    startTouchTrackingForWindowAnimation();
                    startTouchTrackingForWindowAnimation(ev.getEventTime());
                }

                Display display = getSystemService(WindowManager.class).getDefaultDisplay();
@@ -264,7 +302,7 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC
        }
    }

    private void startTouchTrackingForWindowAnimation() {
    private void startTouchTrackingForWindowAnimation(long touchTimeMs) {
        // Create the shared handler
        final WindowTransformSwipeHandler handler =
                new WindowTransformSwipeHandler(mRunningTask, this);
@@ -302,6 +340,16 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC
                        } else {
                            controller.finish(false /* toHome */);
                        }

                        // 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*/,
                                SystemClock.uptimeMillis() - touchTimeMs);
                        mMetricsLogger.write(builder);
                    }

                    public void onAnimationCanceled() {