When app dies, destroy snapshot
Also destroy snapshot when we remove the AppWindowToken.
Test: runtest frameworks-services -c
com.android.server.wm.SnapshotCacheTest
Test: Open app, go home, kill app, make sure snapshots are
destroyed.
Change-Id: I532c2d7499a86164175f9fcbc8b77c6eb6bfeae6
diff --git a/services/core/java/com/android/server/wm/TaskSnapshotController.java b/services/core/java/com/android/server/wm/TaskSnapshotController.java
index 4421d61..efa72a6 100644
--- a/services/core/java/com/android/server/wm/TaskSnapshotController.java
+++ b/services/core/java/com/android/server/wm/TaskSnapshotController.java
@@ -34,6 +34,8 @@
import com.android.internal.annotations.VisibleForTesting;
+import java.io.PrintWriter;
+
/**
* When an app token becomes invisible, we take a snapshot (bitmap) of the corresponding task and
* put it into our cache. Internally we use gralloc buffers to be able to draw them wherever we
@@ -92,7 +94,7 @@
}
private TaskSnapshot snapshotTask(Task task) {
- final AppWindowToken top = (AppWindowToken) task.getTop();
+ final AppWindowToken top = task.getTopChild();
if (top == null) {
return null;
}
@@ -131,4 +133,25 @@
private boolean canSnapshotTask(Task task) {
return !StackId.isHomeOrRecentsStack(task.mStack.mStackId);
}
+
+ /**
+ * Called when an {@link AppWindowToken} has been removed.
+ */
+ void onAppRemoved(AppWindowToken wtoken) {
+ // TODO: Clean from both recents and running cache.
+ mCache.cleanCache(wtoken);
+ }
+
+ /**
+ * Called when the process of an {@link AppWindowToken} has died.
+ */
+ void onAppDied(AppWindowToken wtoken) {
+
+ // TODO: Only clean from running cache.
+ mCache.cleanCache(wtoken);
+ }
+
+ void dump(PrintWriter pw, String prefix) {
+ mCache.dump(pw, prefix);
+ }
}