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

Commit 54cff64e authored by Jorim Jaggi's avatar Jorim Jaggi Committed by Bryce Lee
Browse files

Insert correct app transition events for recents anim

The transition delay will be the latency until all the leashes
were created etc. Thus, the actual latency is going to be in
WINDOWS_DRAWN_DELAY.

Also fix an issue where we inadvertently started a transition,
and then the transition logger was hanging.

Bug: 72967764
Test: Swipe up from home button, observe eventlog
Change-Id: I2b1fb7d9d694a629a33653c1fa3d5ed47f53de6b
parent 5a8deab6
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -68,6 +68,13 @@ public abstract class ActivityManagerInternal {
    public static final int APP_TRANSITION_SNAPSHOT =
              AppProtoEnums.APP_TRANSITION_SNAPSHOT; // 4

    /**
     * Type for {@link #notifyAppTransitionStarting}: The transition was started because it was a
     * recents animation and we only needed to wait on the wallpaper.
     */
    public static final int APP_TRANSITION_RECENTS_ANIM =
            AppProtoEnums.APP_TRANSITION_RECENTS_ANIM; // 5

    /**
     * The bundle key to extract the assist data.
     */
+3 −0
Original line number Diff line number Diff line
@@ -32,6 +32,9 @@ enum AppTransitionReasonEnum {
    APP_TRANSITION_TIMEOUT = 3;
    // The transition was started because of a we drew a task snapshot.
    APP_TRANSITION_SNAPSHOT = 4;
    // The transition was started because it was a recents animation and we only needed to wait on
    // the wallpaper.
    APP_TRANSITION_RECENTS_ANIM = 5;
}

// ActivityManager.java PROCESS_STATEs
+9 −1
Original line number Diff line number Diff line
@@ -299,7 +299,7 @@ class ActivityMetricsLogger {

        final boolean otherWindowModesLaunching =
                mWindowingModeTransitionInfo.size() > 0 && info == null;
        if ((resultCode < 0 || launchedActivity == null || !processSwitch
        if ((!isLoggableResultCode(resultCode) || launchedActivity == null || !processSwitch
                || windowingMode == WINDOWING_MODE_UNDEFINED) && !otherWindowModesLaunching) {

            // Failed to launch or it was not a process switch, so we don't care about the timing.
@@ -321,6 +321,14 @@ class ActivityMetricsLogger {
        mCurrentTransitionDeviceUptime = (int) (SystemClock.uptimeMillis() / 1000);
    }

    /**
     * @return True if we should start logging an event for an activity start that returned
     *         {@code resultCode} and that we'll indeed get a windows drawn event.
     */
    private boolean isLoggableResultCode(int resultCode) {
        return resultCode == START_SUCCESS || resultCode == START_TASK_TO_FRONT;
    }

    /**
     * Notifies the tracker that all windows of the app have been drawn.
     */
+6 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.server.am;

import static android.app.ActivityManager.START_TASK_TO_FRONT;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
import static android.content.Intent.FLAG_ACTIVITY_NO_ANIMATION;
@@ -95,6 +96,8 @@ class RecentsAnimation implements RecentsAnimationCallbacks {
            }
        }

        mStackSupervisor.getActivityMetricsLogger().notifyActivityLaunching();

        mService.setRunningRemoteAnimation(mCallingPid, true);

        mWindowManager.deferSurfaceLayout();
@@ -143,6 +146,9 @@ class RecentsAnimation implements RecentsAnimationCallbacks {
            // If we updated the launch-behind state, update the visibility of the activities after
            // we fetch the visible tasks to be controlled by the animation
            mStackSupervisor.ensureActivitiesVisibleLocked(null, 0, PRESERVE_WINDOWS);

            mStackSupervisor.getActivityMetricsLogger().notifyActivityLaunched(START_TASK_TO_FRONT,
                    homeActivity);
        } finally {
            mWindowManager.continueSurfaceLayout();
            Trace.traceEnd(TRACE_TAG_ACTIVITY_MANAGER);
+8 −0
Original line number Diff line number Diff line
@@ -16,13 +16,16 @@

package com.android.server.wm;

import static android.app.ActivityManagerInternal.APP_TRANSITION_RECENTS_ANIM;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;
import static android.view.RemoteAnimationTarget.MODE_CLOSING;
import static android.view.WindowManager.INPUT_CONSUMER_RECENTS_ANIMATION;
import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
import static com.android.server.wm.WindowManagerService.H.NOTIFY_APP_TRANSITION_STARTING;
import static com.android.server.wm.proto.RemoteAnimationAdapterWrapperProto.TARGET;
import static com.android.server.wm.proto.AnimationAdapterProto.REMOTE;

@@ -37,6 +40,7 @@ import android.util.ArraySet;
import android.util.Log;
import android.util.Slog;import android.util.proto.ProtoOutputStream;
import android.util.SparseBooleanArray;
import android.util.SparseIntArray;
import android.util.proto.ProtoOutputStream;
import android.view.IRecentsAnimationController;
import android.view.IRecentsAnimationRunner;
@@ -279,6 +283,10 @@ public class RecentsAnimationController {
        } catch (RemoteException e) {
            Slog.e(TAG, "Failed to start recents animation", e);
        }
        final SparseIntArray reasons = new SparseIntArray();
        reasons.put(WINDOWING_MODE_FULLSCREEN, APP_TRANSITION_RECENTS_ANIM);
        mService.mH.obtainMessage(NOTIFY_APP_TRANSITION_STARTING,
                reasons).sendToTarget();
    }

    void cancelAnimation() {