Report launch finish for drawn without transition
An activity can be launched and drawn without transition, e.g.
quick open camera from lockscreen, so the launch metrics can
be reported directly when it is drawn. Otherwise there may be
unexpected long trace and metric if the activity launches
another activity with transition after a while.
Bug: 204488635
Test: atest ActivityMetricsLaunchObserverTests# \
testActivityDrawnWithoutTransition
Test: Enabled secured lock. Enter lock screen. Double press
power key to launch camera. Wait 5s, click photo and
unlock. The 5s should not count to photo (event log
wm_activity_launch_time).
Change-Id: Ib47784bf5a83d6bec2271f85ed165f31784ce937
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user