Loading services/core/java/com/android/server/wm/ActivityRecord.java +5 −1 Original line number Diff line number Diff line Loading @@ -2592,7 +2592,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A // When finishing the activity preemptively take the snapshot before the app window // is marked as hidden and any configuration changes take place if (mAtmService.mWindowManager.mTaskSnapshotController != null) { // Note that RecentsAnimation will handle task snapshot while switching apps with // the best capture timing (e.g. IME window capture), // No need additional task capture while task is controlled by RecentsAnimation. if (mAtmService.mWindowManager.mTaskSnapshotController != null && !task.isAnimatingByRecents()) { final ArraySet<Task> tasks = Sets.newArraySet(task); mAtmService.mWindowManager.mTaskSnapshotController.snapshotTasks(tasks); mAtmService.mWindowManager.mTaskSnapshotController Loading services/core/java/com/android/server/wm/Task.java +4 −8 Original line number Diff line number Diff line Loading @@ -113,6 +113,7 @@ import static com.android.server.wm.ActivityTaskManagerService.H.FIRST_ACTIVITY_ import static com.android.server.wm.IdentifierProto.HASH_CODE; import static com.android.server.wm.IdentifierProto.TITLE; import static com.android.server.wm.IdentifierProto.USER_ID; import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_RECENTS; import static com.android.server.wm.Task.ActivityState.PAUSED; import static com.android.server.wm.Task.ActivityState.PAUSING; import static com.android.server.wm.Task.ActivityState.RESUMED; Loading Loading @@ -3661,14 +3662,9 @@ class Task extends WindowContainer<WindowContainer> { super.setInitialSurfaceControlProperties(b); } boolean isTaskAnimating() { final RecentsAnimationController recentsAnim = mWmService.getRecentsAnimationController(); if (recentsAnim != null) { if (recentsAnim.isAnimatingTask(this)) { return true; } } return forAllTasks((t) -> { return t != this && t.isTaskAnimating(); }); /** Checking if self or its child tasks are animated by recents animation. */ boolean isAnimatingByRecents() { return isAnimating(CHILDREN, ANIMATION_TYPE_RECENTS); } @Override Loading services/core/java/com/android/server/wm/TaskDisplayArea.java +1 −1 Original line number Diff line number Diff line Loading @@ -751,7 +751,7 @@ final class TaskDisplayArea extends DisplayArea<Task> { // The split screen divider anchor is located above the split screen window. mTmpLayerForSplitScreenDividerAnchor = layer++; } if (s.isTaskAnimating() || s.isAppTransitioning()) { if (s.isAnimatingByRecents() || s.isAppTransitioning()) { // The animation layer is located above the highest animating stack and no // higher. mTmpLayerForAnimationLayer = layer++; Loading services/core/java/com/android/server/wm/TaskSnapshotController.java +12 −3 Original line number Diff line number Diff line Loading @@ -157,7 +157,6 @@ class TaskSnapshotController { if (shouldDisableSnapshots()) { return; } // We need to take a snapshot of the task if and only if all activities of the task are // either closing or hidden. getClosingTasks(closingApps, mTmpTasks); Loading Loading @@ -445,10 +444,17 @@ class TaskSnapshotController { for (int i = closingApps.size() - 1; i >= 0; i--) { final ActivityRecord activity = closingApps.valueAt(i); final Task task = activity.getTask(); if (task == null) continue; // Since RecentsAnimation will handle task snapshot while switching apps with the // best capture timing (e.g. IME window capture), // No need additional task capture while task is controlled by RecentsAnimation. if (task.isAnimatingByRecents()) { mSkipClosingAppSnapshotTasks.add(task); } // If the task of the app is not visible anymore, it means no other app in that task // is opening. Thus, the task is closing. if (task != null && !task.isVisible() && !mSkipClosingAppSnapshotTasks.contains(task)) { if (!task.isVisible() && !mSkipClosingAppSnapshotTasks.contains(task)) { outClosingTasks.add(task); } } Loading Loading @@ -571,7 +577,10 @@ class TaskSnapshotController { synchronized (mService.mGlobalLock) { mTmpTasks.clear(); mService.mRoot.forAllTasks(task -> { if (task.isVisible()) { // Since RecentsAnimation will handle task snapshot while switching apps // with the best capture timing (e.g. IME window capture), No need // additional task capture while task is controlled by RecentsAnimation. if (task.isVisible() && !task.isAnimatingByRecents()) { mTmpTasks.add(task); } }); Loading services/tests/wmtests/src/com/android/server/wm/RecentsAnimationControllerTest.java +20 −0 Original line number Diff line number Diff line Loading @@ -476,6 +476,26 @@ public class RecentsAnimationControllerTest extends WindowTestsBase { assertFalse(wallpaperWindowToken.hasFixedRotationTransform()); } @Test public void testIsAnimatingByRecents() { final ActivityRecord homeActivity = createHomeActivity(); final Task rootTask = createTaskStackOnDisplay(mDefaultDisplay); final Task childTask = createTaskInStack(rootTask, 0 /* userId */); final Task leafTask = createTaskInStack(childTask, 0 /* userId */); spyOn(leafTask); doReturn(true).when(leafTask).isVisible(); initializeRecentsAnimationController(mController, homeActivity); // Verify RecentsAnimationController will animate visible leaf task by default. verify(mController).addAnimation(eq(leafTask), anyBoolean(), anyBoolean(), eq(null)); assertTrue(leafTask.isAnimatingByRecents()); // Make sure isAnimatingByRecents will also return true when it called by the parent task. assertTrue(rootTask.isAnimatingByRecents()); assertTrue(childTask.isAnimatingByRecents()); } private ActivityRecord createHomeActivity() { final ActivityRecord homeActivity = new ActivityBuilder(mWm.mAtmService) .setStack(mRootHomeTask) Loading Loading
services/core/java/com/android/server/wm/ActivityRecord.java +5 −1 Original line number Diff line number Diff line Loading @@ -2592,7 +2592,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A // When finishing the activity preemptively take the snapshot before the app window // is marked as hidden and any configuration changes take place if (mAtmService.mWindowManager.mTaskSnapshotController != null) { // Note that RecentsAnimation will handle task snapshot while switching apps with // the best capture timing (e.g. IME window capture), // No need additional task capture while task is controlled by RecentsAnimation. if (mAtmService.mWindowManager.mTaskSnapshotController != null && !task.isAnimatingByRecents()) { final ArraySet<Task> tasks = Sets.newArraySet(task); mAtmService.mWindowManager.mTaskSnapshotController.snapshotTasks(tasks); mAtmService.mWindowManager.mTaskSnapshotController Loading
services/core/java/com/android/server/wm/Task.java +4 −8 Original line number Diff line number Diff line Loading @@ -113,6 +113,7 @@ import static com.android.server.wm.ActivityTaskManagerService.H.FIRST_ACTIVITY_ import static com.android.server.wm.IdentifierProto.HASH_CODE; import static com.android.server.wm.IdentifierProto.TITLE; import static com.android.server.wm.IdentifierProto.USER_ID; import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_RECENTS; import static com.android.server.wm.Task.ActivityState.PAUSED; import static com.android.server.wm.Task.ActivityState.PAUSING; import static com.android.server.wm.Task.ActivityState.RESUMED; Loading Loading @@ -3661,14 +3662,9 @@ class Task extends WindowContainer<WindowContainer> { super.setInitialSurfaceControlProperties(b); } boolean isTaskAnimating() { final RecentsAnimationController recentsAnim = mWmService.getRecentsAnimationController(); if (recentsAnim != null) { if (recentsAnim.isAnimatingTask(this)) { return true; } } return forAllTasks((t) -> { return t != this && t.isTaskAnimating(); }); /** Checking if self or its child tasks are animated by recents animation. */ boolean isAnimatingByRecents() { return isAnimating(CHILDREN, ANIMATION_TYPE_RECENTS); } @Override Loading
services/core/java/com/android/server/wm/TaskDisplayArea.java +1 −1 Original line number Diff line number Diff line Loading @@ -751,7 +751,7 @@ final class TaskDisplayArea extends DisplayArea<Task> { // The split screen divider anchor is located above the split screen window. mTmpLayerForSplitScreenDividerAnchor = layer++; } if (s.isTaskAnimating() || s.isAppTransitioning()) { if (s.isAnimatingByRecents() || s.isAppTransitioning()) { // The animation layer is located above the highest animating stack and no // higher. mTmpLayerForAnimationLayer = layer++; Loading
services/core/java/com/android/server/wm/TaskSnapshotController.java +12 −3 Original line number Diff line number Diff line Loading @@ -157,7 +157,6 @@ class TaskSnapshotController { if (shouldDisableSnapshots()) { return; } // We need to take a snapshot of the task if and only if all activities of the task are // either closing or hidden. getClosingTasks(closingApps, mTmpTasks); Loading Loading @@ -445,10 +444,17 @@ class TaskSnapshotController { for (int i = closingApps.size() - 1; i >= 0; i--) { final ActivityRecord activity = closingApps.valueAt(i); final Task task = activity.getTask(); if (task == null) continue; // Since RecentsAnimation will handle task snapshot while switching apps with the // best capture timing (e.g. IME window capture), // No need additional task capture while task is controlled by RecentsAnimation. if (task.isAnimatingByRecents()) { mSkipClosingAppSnapshotTasks.add(task); } // If the task of the app is not visible anymore, it means no other app in that task // is opening. Thus, the task is closing. if (task != null && !task.isVisible() && !mSkipClosingAppSnapshotTasks.contains(task)) { if (!task.isVisible() && !mSkipClosingAppSnapshotTasks.contains(task)) { outClosingTasks.add(task); } } Loading Loading @@ -571,7 +577,10 @@ class TaskSnapshotController { synchronized (mService.mGlobalLock) { mTmpTasks.clear(); mService.mRoot.forAllTasks(task -> { if (task.isVisible()) { // Since RecentsAnimation will handle task snapshot while switching apps // with the best capture timing (e.g. IME window capture), No need // additional task capture while task is controlled by RecentsAnimation. if (task.isVisible() && !task.isAnimatingByRecents()) { mTmpTasks.add(task); } }); Loading
services/tests/wmtests/src/com/android/server/wm/RecentsAnimationControllerTest.java +20 −0 Original line number Diff line number Diff line Loading @@ -476,6 +476,26 @@ public class RecentsAnimationControllerTest extends WindowTestsBase { assertFalse(wallpaperWindowToken.hasFixedRotationTransform()); } @Test public void testIsAnimatingByRecents() { final ActivityRecord homeActivity = createHomeActivity(); final Task rootTask = createTaskStackOnDisplay(mDefaultDisplay); final Task childTask = createTaskInStack(rootTask, 0 /* userId */); final Task leafTask = createTaskInStack(childTask, 0 /* userId */); spyOn(leafTask); doReturn(true).when(leafTask).isVisible(); initializeRecentsAnimationController(mController, homeActivity); // Verify RecentsAnimationController will animate visible leaf task by default. verify(mController).addAnimation(eq(leafTask), anyBoolean(), anyBoolean(), eq(null)); assertTrue(leafTask.isAnimatingByRecents()); // Make sure isAnimatingByRecents will also return true when it called by the parent task. assertTrue(rootTask.isAnimatingByRecents()); assertTrue(childTask.isAnimatingByRecents()); } private ActivityRecord createHomeActivity() { final ActivityRecord homeActivity = new ActivityBuilder(mWm.mAtmService) .setStack(mRootHomeTask) Loading