Merge "Add null check for RemoteToken#getContainer()"
This commit is contained in:
@@ -442,7 +442,11 @@ class TaskOrganizerController extends ITaskOrganizerController.Stub {
|
|||||||
final long origId = Binder.clearCallingIdentity();
|
final long origId = Binder.clearCallingIdentity();
|
||||||
try {
|
try {
|
||||||
synchronized (mGlobalLock) {
|
synchronized (mGlobalLock) {
|
||||||
final Task task = WindowContainer.fromBinder(token.asBinder()).asTask();
|
final WindowContainer wc = WindowContainer.fromBinder(token.asBinder());
|
||||||
|
if (wc == null) {
|
||||||
|
throw new IllegalArgumentException("Can't resolve window from token");
|
||||||
|
}
|
||||||
|
final Task task = wc.asTask();
|
||||||
if (task == null) return false;
|
if (task == null) return false;
|
||||||
if (!task.mCreatedByOrganizer) {
|
if (!task.mCreatedByOrganizer) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
@@ -563,8 +567,14 @@ class TaskOrganizerController extends ITaskOrganizerController.Stub {
|
|||||||
if (defaultTaskDisplayArea == null) {
|
if (defaultTaskDisplayArea == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Task task = token == null
|
WindowContainer wc = null;
|
||||||
? null : WindowContainer.fromBinder(token.asBinder()).asTask();
|
if (token != null) {
|
||||||
|
wc = WindowContainer.fromBinder(token.asBinder());
|
||||||
|
if (wc == null) {
|
||||||
|
throw new IllegalArgumentException("Can't resolve window from token");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
final Task task = wc == null ? null : wc.asTask();
|
||||||
if (task == null) {
|
if (task == null) {
|
||||||
defaultTaskDisplayArea.mLaunchRootTask = null;
|
defaultTaskDisplayArea.mLaunchRootTask = null;
|
||||||
return;
|
return;
|
||||||
@@ -665,7 +675,12 @@ class TaskOrganizerController extends ITaskOrganizerController.Stub {
|
|||||||
synchronized (mGlobalLock) {
|
synchronized (mGlobalLock) {
|
||||||
ProtoLog.v(WM_DEBUG_WINDOW_ORGANIZER, "Set intercept back pressed on root=%b",
|
ProtoLog.v(WM_DEBUG_WINDOW_ORGANIZER, "Set intercept back pressed on root=%b",
|
||||||
interceptBackPressed);
|
interceptBackPressed);
|
||||||
final Task task = WindowContainer.fromBinder(token.asBinder()).asTask();
|
final WindowContainer wc = WindowContainer.fromBinder(token.asBinder());
|
||||||
|
if (wc == null) {
|
||||||
|
Slog.w(TAG, "Could not resolve window from token");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final Task task = wc.asTask();
|
||||||
if (task == null) {
|
if (task == null) {
|
||||||
Slog.w(TAG, "Could not resolve task from token");
|
Slog.w(TAG, "Could not resolve task from token");
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -2878,6 +2878,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
static WindowContainer fromBinder(IBinder binder) {
|
static WindowContainer fromBinder(IBinder binder) {
|
||||||
return RemoteToken.fromBinder(binder).getContainer();
|
return RemoteToken.fromBinder(binder).getContainer();
|
||||||
}
|
}
|
||||||
@@ -2891,6 +2892,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
|
|||||||
mWeakRef = new WeakReference<>(container);
|
mWeakRef = new WeakReference<>(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
WindowContainer getContainer() {
|
WindowContainer getContainer() {
|
||||||
return mWeakRef.get();
|
return mWeakRef.get();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -249,7 +249,7 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
|
|||||||
for (int i = 0, n = hops.size(); i < n; ++i) {
|
for (int i = 0, n = hops.size(); i < n; ++i) {
|
||||||
final WindowContainerTransaction.HierarchyOp hop = hops.get(i);
|
final WindowContainerTransaction.HierarchyOp hop = hops.get(i);
|
||||||
final WindowContainer wc = WindowContainer.fromBinder(hop.getContainer());
|
final WindowContainer wc = WindowContainer.fromBinder(hop.getContainer());
|
||||||
if (!wc.isAttached()) {
|
if (wc == null || !wc.isAttached()) {
|
||||||
Slog.e(TAG, "Attempt to operate on detached container: " + wc);
|
Slog.e(TAG, "Attempt to operate on detached container: " + wc);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -260,7 +260,13 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
|
|||||||
if (transition != null) {
|
if (transition != null) {
|
||||||
transition.collect(wc);
|
transition.collect(wc);
|
||||||
if (hop.isReparent() && hop.getNewParent() != null) {
|
if (hop.isReparent() && hop.getNewParent() != null) {
|
||||||
transition.collect(WindowContainer.fromBinder(hop.getNewParent()));
|
final WindowContainer parentWc =
|
||||||
|
WindowContainer.fromBinder(hop.getNewParent());
|
||||||
|
if (parentWc == null) {
|
||||||
|
Slog.e(TAG, "Can't resolve parent window from token");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
transition.collect(parentWc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -269,7 +275,12 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
|
|||||||
entries = t.getChanges().entrySet().iterator();
|
entries = t.getChanges().entrySet().iterator();
|
||||||
while (entries.hasNext()) {
|
while (entries.hasNext()) {
|
||||||
final Map.Entry<IBinder, WindowContainerTransaction.Change> entry = entries.next();
|
final Map.Entry<IBinder, WindowContainerTransaction.Change> entry = entries.next();
|
||||||
final Task task = WindowContainer.fromBinder(entry.getKey()).asTask();
|
final WindowContainer wc = WindowContainer.fromBinder(entry.getKey());
|
||||||
|
if (wc == null || !wc.isAttached()) {
|
||||||
|
Slog.e(TAG, "Attempt to operate on detached container: " + wc);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
final Task task = wc.asTask();
|
||||||
final Rect surfaceBounds = entry.getValue().getBoundsChangeSurfaceBounds();
|
final Rect surfaceBounds = entry.getValue().getBoundsChangeSurfaceBounds();
|
||||||
if (task == null || !task.isAttached() || surfaceBounds == null) {
|
if (task == null || !task.isAttached() || surfaceBounds == null) {
|
||||||
continue;
|
continue;
|
||||||
@@ -429,6 +440,10 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
|
|||||||
WindowContainer newParent = hop.getNewParent() == null
|
WindowContainer newParent = hop.getNewParent() == null
|
||||||
? dc.getDefaultTaskDisplayArea()
|
? dc.getDefaultTaskDisplayArea()
|
||||||
: WindowContainer.fromBinder(hop.getNewParent());
|
: WindowContainer.fromBinder(hop.getNewParent());
|
||||||
|
if (newParent == null) {
|
||||||
|
Slog.e(TAG, "Can't resolve parent window from token");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if (task.getParent() != newParent) {
|
if (task.getParent() != newParent) {
|
||||||
if (newParent instanceof TaskDisplayArea) {
|
if (newParent instanceof TaskDisplayArea) {
|
||||||
// For now, reparenting to displayarea is different from other reparents...
|
// For now, reparenting to displayarea is different from other reparents...
|
||||||
|
|||||||
Reference in New Issue
Block a user