Remove getLeash from WindowContainerToken
If the WindowContainer was revoked from a registered organizer, the
client could still call getLeash to system server and control the leash
for the WindowContainer. Instead, pass the leash back to the client in
onTaskAppeared and onDisplayAreaAppeared. Once the WindowContainer is
revoked from the client, the leash will reference the old
WindowContainer SurfaceControl and will not be able to control the
WindowContainer anymore.
Test: Split screen
Test: DisplayAreaOrganizerTest
Test: WindowOrganizerTest
Bug: 154558563
Change-Id: I1f6eb987a2a3fecfef912a3009ee52989c85ff4b
diff --git a/services/core/java/com/android/server/wm/DisplayAreaOrganizerController.java b/services/core/java/com/android/server/wm/DisplayAreaOrganizerController.java
index 2c8c820..b6c71bb 100644
--- a/services/core/java/com/android/server/wm/DisplayAreaOrganizerController.java
+++ b/services/core/java/com/android/server/wm/DisplayAreaOrganizerController.java
@@ -21,6 +21,7 @@
import android.os.Binder;
import android.os.IBinder;
import android.os.RemoteException;
+import android.view.SurfaceControl;
import android.window.IDisplayAreaOrganizer;
import android.window.IDisplayAreaOrganizerController;
@@ -113,7 +114,8 @@
void onDisplayAreaAppeared(IDisplayAreaOrganizer organizer, DisplayArea da) {
try {
- organizer.onDisplayAreaAppeared(da.getDisplayAreaInfo());
+ SurfaceControl outSurfaceControl = new SurfaceControl(da.getSurfaceControl());
+ organizer.onDisplayAreaAppeared(da.getDisplayAreaInfo(), outSurfaceControl);
} catch (RemoteException e) {
// Oh well...
}
diff --git a/services/core/java/com/android/server/wm/TaskOrganizerController.java b/services/core/java/com/android/server/wm/TaskOrganizerController.java
index 9d229df..83105c2 100644
--- a/services/core/java/com/android/server/wm/TaskOrganizerController.java
+++ b/services/core/java/com/android/server/wm/TaskOrganizerController.java
@@ -36,6 +36,7 @@
import android.os.RemoteException;
import android.util.Slog;
import android.util.SparseArray;
+import android.view.SurfaceControl;
import android.window.ITaskOrganizer;
import android.window.ITaskOrganizerController;
import android.window.WindowContainerToken;
@@ -112,7 +113,8 @@
final RunningTaskInfo taskInfo = task.getTaskInfo();
mDeferTaskOrgCallbacksConsumer.accept(() -> {
try {
- mTaskOrganizer.onTaskAppeared(taskInfo);
+ SurfaceControl outSurfaceControl = new SurfaceControl(task.getSurfaceControl());
+ mTaskOrganizer.onTaskAppeared(taskInfo, outSurfaceControl);
} catch (RemoteException e) {
Slog.e(TAG, "Exception sending onTaskAppeared callback", e);
}
diff --git a/services/core/java/com/android/server/wm/WindowContainer.java b/services/core/java/com/android/server/wm/WindowContainer.java
index 1155bb8..3f8d7b5 100644
--- a/services/core/java/com/android/server/wm/WindowContainer.java
+++ b/services/core/java/com/android/server/wm/WindowContainer.java
@@ -2557,16 +2557,6 @@
return (RemoteToken) binder;
}
- @Override
- public SurfaceControl getLeash() {
- final WindowContainer wc = getContainer();
- if (wc == null) return null;
- // We need to copy the SurfaceControl instead of returning the original
- // because the Parcel FLAGS PARCELABLE_WRITE_RETURN_VALUE cause SurfaceControls
- // to release themselves.
- return new SurfaceControl(wc.getSurfaceControl());
- }
-
WindowContainerToken toWindowContainerToken() {
if (mWindowContainerToken == null) {
mWindowContainerToken = new WindowContainerToken(this);