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

Commit caf9ac3b authored by Riddle Hsu's avatar Riddle Hsu Committed by Android (Google) Code Review
Browse files

Merge "Report launch finish for drawn without transition"

parents bb0b74d3 ff7b16ee
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -741,7 +741,8 @@ class ActivityMetricsLogger {
        info.mWindowsDrawnDelayMs = info.calculateDelay(timestampNs);
        info.mIsDrawn = true;
        final TransitionInfoSnapshot infoSnapshot = new TransitionInfoSnapshot(info);
        if (info.mLoggedTransitionStarting) {
        if (info.mLoggedTransitionStarting || (!r.mDisplayContent.mOpeningApps.contains(r)
                && !r.mTransitionController.isCollecting(r))) {
            done(false /* abort */, info, "notifyWindowsDrawn", timestampNs);
        }
        return infoSnapshot;
+22 −1
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.server.wm;
import static android.app.ActivityManager.START_SUCCESS;
import static android.app.ActivityManager.START_TASK_TO_FRONT;
import static android.content.ComponentName.createRelative;
import static android.view.WindowManager.TRANSIT_OPEN;

import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.mock;
@@ -75,6 +76,7 @@ public class ActivityMetricsLaunchObserverTests extends WindowTestsBase {
    private ActivityRecord mTrampolineActivity;
    private ActivityRecord mTopActivity;
    private ActivityOptions mActivityOptions;
    private Transition mTransition;
    private boolean mLaunchTopByTrampoline;
    private boolean mNewActivityCreated = true;
    private long mExpectedStartedId;
@@ -98,6 +100,11 @@ public class ActivityMetricsLaunchObserverTests extends WindowTestsBase {
                .setTask(mTrampolineActivity.getTask())
                .setComponent(createRelative(DEFAULT_COMPONENT_PACKAGE_NAME, "TopActivity"))
                .build();
        mTopActivity.mDisplayContent.mOpeningApps.add(mTopActivity);
        mTransition = new Transition(TRANSIT_OPEN, 0 /* flags */,
                mTopActivity.mTransitionController, createTestBLASTSyncEngine());
        mTransition.mParticipants.add(mTopActivity);
        mTopActivity.mTransitionController.moveToCollecting(mTransition);
        // becomes invisible when covered by mTopActivity
        mTrampolineActivity.mVisibleRequested = false;
    }
@@ -437,11 +444,13 @@ public class ActivityMetricsLaunchObserverTests extends WindowTestsBase {
    @Test
    public void testActivityDrawnBeforeTransition() {
        mTopActivity.setVisible(false);
        notifyActivityLaunching(mTopActivity.intent);
        onIntentStarted(mTopActivity.intent);
        // Assume the activity is launched the second time consecutively. The drawn event is from
        // the first time (omitted in test) launch that is earlier than transition.
        doReturn(true).when(mTopActivity).isReportedDrawn();
        notifyWindowsDrawn(mTopActivity);
        verifyNoMoreInteractions(mLaunchObserver);

        notifyActivityLaunched(START_SUCCESS, mTopActivity);
        // If the launching activity was drawn when starting transition, the launch event should
        // be reported successfully.
@@ -451,6 +460,18 @@ public class ActivityMetricsLaunchObserverTests extends WindowTestsBase {
        verifyOnActivityLaunchFinished(mTopActivity);
    }

    @Test
    public void testActivityDrawnWithoutTransition() {
        mTopActivity.mDisplayContent.mOpeningApps.remove(mTopActivity);
        mTransition.mParticipants.remove(mTopActivity);
        onIntentStarted(mTopActivity.intent);
        notifyAndVerifyActivityLaunched(mTopActivity);
        notifyWindowsDrawn(mTopActivity);
        // Even if there is no notifyTransitionStarting, the launch event can still be reported
        // because the drawn activity is not involved in transition.
        verifyOnActivityLaunchFinished(mTopActivity);
    }

    @Test
    public void testConcurrentLaunches() {
        onActivityLaunched(mTopActivity);