Add a listener when task snapshots change
Since we start recents before we take the snapshot, we need to add
a mechanism to inform recents about task snapshots changes.
We add a new method to TaskStackChangedListener,
onTaskSnapshotChanged, which gets called whenever a task snapshot
changes. Then, SystemUI registers such a listener and updates the
task thumbnail view for the specific task.
Test: Open app, press recents, make sure thumbnail is up-to-date
Bug: 31339431
Change-Id: I01e81b9cd11886da734da671c68d5732aa51009f
diff --git a/services/core/java/com/android/server/am/TaskRecord.java b/services/core/java/com/android/server/am/TaskRecord.java
index 9e22c50..c3f657e 100644
--- a/services/core/java/com/android/server/am/TaskRecord.java
+++ b/services/core/java/com/android/server/am/TaskRecord.java
@@ -52,6 +52,8 @@
import com.android.internal.util.XmlUtils;
import com.android.server.wm.TaskWindowContainerController;
+import com.android.server.wm.TaskWindowContainerListener;
+
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlSerializer;
@@ -103,7 +105,7 @@
import static com.android.server.am.ActivityRecord.STARTING_WINDOW_SHOWN;
import static com.android.server.am.ActivityStackSupervisor.PRESERVE_WINDOWS;
-final class TaskRecord extends ConfigurationContainer {
+final class TaskRecord extends ConfigurationContainer implements TaskWindowContainerListener {
private static final String TAG = TAG_WITH_CLASS_NAME ? "TaskRecord" : TAG_AM;
private static final String TAG_ADD_REMOVE = TAG + POSTFIX_ADD_REMOVE;
private static final String TAG_RECENTS = TAG + POSTFIX_RECENTS;
@@ -410,8 +412,8 @@
final Rect bounds = updateOverrideConfigurationFromLaunchBounds();
final Configuration overrideConfig = getOverrideConfiguration();
- mWindowContainerController = new TaskWindowContainerController(taskId, getStackId(), userId,
- bounds, overrideConfig, mResizeMode, isHomeTask(), isOnTopLauncher(), onTop,
+ mWindowContainerController = new TaskWindowContainerController(taskId, this, getStackId(),
+ userId, bounds, overrideConfig, mResizeMode, isHomeTask(), isOnTopLauncher(), onTop,
showForAllUsers);
}
@@ -427,6 +429,11 @@
mWindowContainerController = null;
}
+ @Override
+ public void onSnapshotChanged(TaskSnapshot snapshot) {
+ mService.mTaskChangeNotificationController.notifyTaskSnapshotChanged(taskId, snapshot);
+ }
+
void setResizeMode(int resizeMode) {
if (mResizeMode == resizeMode) {
return;