Merge "Clear invisible transition info" into sc-dev

This commit is contained in:
Riddle Hsu
2021-06-28 05:02:43 +00:00
committed by Android (Google) Code Review
2 changed files with 27 additions and 2 deletions

View File

@@ -638,12 +638,24 @@ class ActivityMetricsLogger {
launchObserverNotifyIntentFailed();
}
if (launchedActivity.mDisplayContent.isSleeping()) {
// It is unknown whether the activity can be drawn or not, e.g. ut depends on the
// It is unknown whether the activity can be drawn or not, e.g. it depends on the
// keyguard states and the attributes or flags set by the activity. If the activity
// keeps invisible in the grace period, the tracker will be cancelled so it won't get
// a very long launch time that takes unlocking as the end of launch.
scheduleCheckActivityToBeDrawn(launchedActivity, UNKNOWN_VISIBILITY_CHECK_DELAY_MS);
}
// If the previous transitions are no longer visible, abort them to avoid counting the
// launch time when resuming from back stack. E.g. launch 2 independent tasks in a short
// time, the transition info of the first task should not keep active until it becomes
// visible such as after the top task is finished.
for (int i = mTransitionInfoList.size() - 2; i >= 0; i--) {
final TransitionInfo prevInfo = mTransitionInfoList.get(i);
prevInfo.updatePendingDraw();
if (prevInfo.allDrawn()) {
abort(prevInfo, "nothing will be drawn");
}
}
}
/**
@@ -864,6 +876,7 @@ class ActivityMetricsLogger {
final Boolean isHibernating =
mLastHibernationStates.remove(info.mLastLaunchedActivity.packageName);
if (abort) {
mLastTransitionInfo.remove(info.mLastLaunchedActivity);
mSupervisor.stopWaitingForActivityVisible(info.mLastLaunchedActivity);
launchObserverNotifyActivityLaunchCancelled(info);
} else {

View File

@@ -270,9 +270,16 @@ public class ActivityMetricsLaunchObserverTests extends WindowTestsBase {
@Test
public void testOnReportFullyDrawn() {
// Create an invisible event that should be cancelled after the next event starts.
onActivityLaunched(mTrampolineActivity);
mTrampolineActivity.mVisibleRequested = false;
mActivityOptions = ActivityOptions.makeBasic();
mActivityOptions.setSourceInfo(SourceInfo.TYPE_LAUNCHER, SystemClock.uptimeMillis() - 10);
onActivityLaunched(mTopActivity);
onIntentStarted(mTopActivity.intent);
notifyActivityLaunched(START_SUCCESS, mTopActivity);
verifyAsync(mLaunchObserver).onActivityLaunched(eqProto(mTopActivity), anyInt());
verifyAsync(mLaunchObserver).onActivityLaunchCancelled(eqProto(mTrampolineActivity));
// The activity reports fully drawn before windows drawn, then the fully drawn event will
// be pending (see {@link WindowingModeTransitionInfo#pendingFullyDrawn}).
@@ -287,6 +294,10 @@ public class ActivityMetricsLaunchObserverTests extends WindowTestsBase {
verifyAsync(mLaunchObserver).onReportFullyDrawn(eqProto(mTopActivity), anyLong());
verifyOnActivityLaunchFinished(mTopActivity);
verifyNoMoreInteractions(mLaunchObserver);
final ActivityMetricsLogger.TransitionInfoSnapshot fullyDrawnInfo = mActivityMetricsLogger
.logAppTransitionReportedDrawn(mTopActivity, false /* restoredFromBundle */);
assertWithMessage("Invisible event must be dropped").that(fullyDrawnInfo).isNull();
}
private void onActivityLaunchedTrampoline() {
@@ -480,6 +491,7 @@ public class ActivityMetricsLaunchObserverTests extends WindowTestsBase {
@Test
public void testConsecutiveLaunchWithDifferentWindowingMode() {
mTopActivity.setWindowingMode(WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW);
mTrampolineActivity.mVisibleRequested = true;
onActivityLaunched(mTrampolineActivity);
mActivityMetricsLogger.notifyActivityLaunching(mTopActivity.intent,
mTrampolineActivity /* caller */, mTrampolineActivity.getUid());