Loading services/core/java/com/android/server/wm/ActivityMetricsLogger.java +5 −1 Original line number Diff line number Diff line Loading @@ -657,7 +657,7 @@ class ActivityMetricsLogger { for (int i = mTransitionInfoList.size() - 2; i >= 0; i--) { final TransitionInfo prevInfo = mTransitionInfoList.get(i); if (prevInfo.mIsDrawn || !prevInfo.mLastLaunchedActivity.mVisibleRequested) { abort(prevInfo, "nothing will be drawn"); scheduleCheckActivityToBeDrawn(prevInfo.mLastLaunchedActivity, 0 /* delay */); } } } Loading Loading @@ -757,6 +757,10 @@ class ActivityMetricsLogger { /** Makes sure that the reference to the removed activity is cleared. */ void notifyActivityRemoved(@NonNull ActivityRecord r) { mLastTransitionInfo.remove(r); final TransitionInfo info = getActiveTransitionInfo(r); if (info != null) { abort(info, "removed"); } final int packageUid = r.info.applicationInfo.uid; final PackageCompatStateInfo compatStateInfo = mPackageUidToCompatStateInfo.get(packageUid); Loading services/tests/wmtests/src/com/android/server/wm/ActivityMetricsLaunchObserverTests.java +12 −3 Original line number Diff line number Diff line Loading @@ -256,6 +256,14 @@ public class ActivityMetricsLaunchObserverTests extends WindowTestsBase { mActivityMetricsLogger.notifyVisibilityChanged(noDrawnActivity); verifyAsync(mLaunchObserver).onActivityLaunchCancelled(eqProto(noDrawnActivity)); // If an activity is removed immediately before visibility update, it should cancel too. final ActivityRecord removedImm = new ActivityBuilder(mAtm).setCreateTask(true).build(); clearInvocations(mLaunchObserver); onActivityLaunched(removedImm); removedImm.removeImmediately(); // Verify any() instead of proto because the field of record may be changed. verifyAsync(mLaunchObserver).onActivityLaunchCancelled(any()); } @Test Loading Loading @@ -299,15 +307,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; final ActivityRecord prev = new ActivityBuilder(mAtm).setCreateTask(true).build(); onActivityLaunched(prev); prev.mVisibleRequested = false; mActivityOptions = ActivityOptions.makeBasic(); mActivityOptions.setSourceInfo(SourceInfo.TYPE_LAUNCHER, SystemClock.uptimeMillis() - 10); onIntentStarted(mTopActivity.intent); notifyActivityLaunched(START_SUCCESS, mTopActivity); verifyAsync(mLaunchObserver).onActivityLaunched(eqProto(mTopActivity), anyInt()); verifyAsync(mLaunchObserver).onActivityLaunchCancelled(eqProto(mTrampolineActivity)); verifyAsync(mLaunchObserver).onActivityLaunchCancelled(eqProto(prev)); // The activity reports fully drawn before windows drawn, then the fully drawn event will // be pending (see {@link WindowingModeTransitionInfo#pendingFullyDrawn}). Loading Loading
services/core/java/com/android/server/wm/ActivityMetricsLogger.java +5 −1 Original line number Diff line number Diff line Loading @@ -657,7 +657,7 @@ class ActivityMetricsLogger { for (int i = mTransitionInfoList.size() - 2; i >= 0; i--) { final TransitionInfo prevInfo = mTransitionInfoList.get(i); if (prevInfo.mIsDrawn || !prevInfo.mLastLaunchedActivity.mVisibleRequested) { abort(prevInfo, "nothing will be drawn"); scheduleCheckActivityToBeDrawn(prevInfo.mLastLaunchedActivity, 0 /* delay */); } } } Loading Loading @@ -757,6 +757,10 @@ class ActivityMetricsLogger { /** Makes sure that the reference to the removed activity is cleared. */ void notifyActivityRemoved(@NonNull ActivityRecord r) { mLastTransitionInfo.remove(r); final TransitionInfo info = getActiveTransitionInfo(r); if (info != null) { abort(info, "removed"); } final int packageUid = r.info.applicationInfo.uid; final PackageCompatStateInfo compatStateInfo = mPackageUidToCompatStateInfo.get(packageUid); Loading
services/tests/wmtests/src/com/android/server/wm/ActivityMetricsLaunchObserverTests.java +12 −3 Original line number Diff line number Diff line Loading @@ -256,6 +256,14 @@ public class ActivityMetricsLaunchObserverTests extends WindowTestsBase { mActivityMetricsLogger.notifyVisibilityChanged(noDrawnActivity); verifyAsync(mLaunchObserver).onActivityLaunchCancelled(eqProto(noDrawnActivity)); // If an activity is removed immediately before visibility update, it should cancel too. final ActivityRecord removedImm = new ActivityBuilder(mAtm).setCreateTask(true).build(); clearInvocations(mLaunchObserver); onActivityLaunched(removedImm); removedImm.removeImmediately(); // Verify any() instead of proto because the field of record may be changed. verifyAsync(mLaunchObserver).onActivityLaunchCancelled(any()); } @Test Loading Loading @@ -299,15 +307,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; final ActivityRecord prev = new ActivityBuilder(mAtm).setCreateTask(true).build(); onActivityLaunched(prev); prev.mVisibleRequested = false; mActivityOptions = ActivityOptions.makeBasic(); mActivityOptions.setSourceInfo(SourceInfo.TYPE_LAUNCHER, SystemClock.uptimeMillis() - 10); onIntentStarted(mTopActivity.intent); notifyActivityLaunched(START_SUCCESS, mTopActivity); verifyAsync(mLaunchObserver).onActivityLaunched(eqProto(mTopActivity), anyInt()); verifyAsync(mLaunchObserver).onActivityLaunchCancelled(eqProto(mTrampolineActivity)); verifyAsync(mLaunchObserver).onActivityLaunchCancelled(eqProto(prev)); // The activity reports fully drawn before windows drawn, then the fully drawn event will // be pending (see {@link WindowingModeTransitionInfo#pendingFullyDrawn}). Loading