Fix crashes related to WCT for ARC T

- Add two more null checks as we already do in other places in
 the class.
- Don't let Task#setDragResizing() throw an exception based on
 win mode as the win mode Shell is seeing can be different from
 that in Core depending on the timing.

Bug: 294163171
Bug: 294163886
Bug: 294162591
Test: WM CTS
Change-Id: I207f5a5c9301ccebe7311b72c93cf54f98fe6933
This commit is contained in:
Kazuki Takise
2023-08-02 16:40:02 +09:00
parent 4aaf6ab22d
commit a1151deb6c
2 changed files with 20 additions and 6 deletions

View File

@@ -2878,8 +2878,8 @@ class Task extends TaskFragment {
// No need to check if allowed if it's leaving dragResize
if (dragResizing
&& !(getRootTask().getWindowingMode() == WINDOWING_MODE_FREEFORM)) {
throw new IllegalArgumentException("Drag resize not allow for root task id="
+ getRootTaskId());
Slog.e(TAG, "Drag resize isn't allowed for root task id=" + getRootTaskId());
return;
}
mDragResizing = dragResizing;
resetDragResizingChangeReported();

View File

@@ -1615,9 +1615,18 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
}
private int setAdjacentRootsHierarchyOp(WindowContainerTransaction.HierarchyOp hop) {
final TaskFragment root1 = WindowContainer.fromBinder(hop.getContainer()).asTaskFragment();
final TaskFragment root2 =
WindowContainer.fromBinder(hop.getAdjacentRoot()).asTaskFragment();
final WindowContainer wc1 = WindowContainer.fromBinder(hop.getContainer());
if (wc1 == null || !wc1.isAttached()) {
Slog.e(TAG, "Attempt to operate on unknown or detached container: " + wc1);
return TRANSACT_EFFECTS_NONE;
}
final TaskFragment root1 = wc1.asTaskFragment();
final WindowContainer wc2 = WindowContainer.fromBinder(hop.getAdjacentRoot());
if (wc2 == null || !wc2.isAttached()) {
Slog.e(TAG, "Attempt to operate on unknown or detached container: " + wc2);
return TRANSACT_EFFECTS_NONE;
}
final TaskFragment root2 = wc2.asTaskFragment();
if (!root1.mCreatedByOrganizer || !root2.mCreatedByOrganizer) {
throw new IllegalArgumentException("setAdjacentRootsHierarchyOp: Not created by"
+ " organizer root1=" + root1 + " root2=" + root2);
@@ -1630,7 +1639,12 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
}
private int clearAdjacentRootsHierarchyOp(WindowContainerTransaction.HierarchyOp hop) {
final TaskFragment root = WindowContainer.fromBinder(hop.getContainer()).asTaskFragment();
final WindowContainer wc = WindowContainer.fromBinder(hop.getContainer());
if (wc == null || !wc.isAttached()) {
Slog.e(TAG, "Attempt to operate on unknown or detached container: " + wc);
return TRANSACT_EFFECTS_NONE;
}
final TaskFragment root = wc.asTaskFragment();
if (!root.mCreatedByOrganizer) {
throw new IllegalArgumentException("clearAdjacentRootsHierarchyOp: Not created by"
+ " organizer root=" + root);