Loading services/core/java/com/android/server/wm/ActivityMetricsLogger.java +2 −1 Original line number Diff line number Diff line Loading @@ -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; Loading services/tests/wmtests/src/com/android/server/wm/ActivityMetricsLaunchObserverTests.java +22 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading @@ -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; } Loading Loading @@ -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. Loading @@ -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); Loading Loading
services/core/java/com/android/server/wm/ActivityMetricsLogger.java +2 −1 Original line number Diff line number Diff line Loading @@ -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; Loading
services/tests/wmtests/src/com/android/server/wm/ActivityMetricsLaunchObserverTests.java +22 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading @@ -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; } Loading Loading @@ -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. Loading @@ -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); Loading