From 6dad90e5883db82c345a3ab592b26f0fd69fe28d Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Fri, 28 Jun 2019 14:43:10 -0700 Subject: [PATCH] Pre-emptively take a snapshot when finishing an activity before changing visibility - Finishing an activity in force landscape will normally trigger a visibility change and configuration change before the closing apps are handled (when snapshots are normally taken) resulting in snapshots showing for the wrong orientation. Preemptively take the screenshot if we know that we are finishing the activity and ignore the subsequent closing app snapshot. Bug: 132687470 Test: Go into forced landscape app, back out of the app, then go to Overview and ensure that the full snapshot is shown in the right orientation Change-Id: I8f9283188da00a09e499c3c16eff5b45fcaa73d1 --- .../core/java/com/android/server/wm/ActivityStack.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/services/core/java/com/android/server/wm/ActivityStack.java b/services/core/java/com/android/server/wm/ActivityStack.java index 74c3069462ea8..5591cb30c6ad9 100644 --- a/services/core/java/com/android/server/wm/ActivityStack.java +++ b/services/core/java/com/android/server/wm/ActivityStack.java @@ -164,6 +164,8 @@ import com.android.server.am.AppTimeTracker; import com.android.server.am.EventLogTags; import com.android.server.am.PendingIntentRecord; +import com.google.android.collect.Sets; + import java.io.FileDescriptor; import java.io.PrintWriter; import java.lang.ref.WeakReference; @@ -4022,6 +4024,14 @@ class ActivityStack extends ConfigurationContainer { } getDisplay().mDisplayContent.prepareAppTransition(transit, false); + // When finishing the activity pre-emptively take the snapshot before the app window + // is marked as hidden and any configuration changes take place + if (mWindowManager.mTaskSnapshotController != null) { + final ArraySet tasks = Sets.newArraySet(task.mTask); + mWindowManager.mTaskSnapshotController.snapshotTasks(tasks); + mWindowManager.mTaskSnapshotController.addSkipClosingAppSnapshotTasks(tasks); + } + // Tell window manager to prepare for this one to be removed. r.setVisibility(false);