Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8503a8de authored by Gaurav Bhola's avatar Gaurav Bhola
Browse files

Add a null check for the WindowContainer for insets related ops.

- This is to prevent NPE because of race conditions where the window
  container might get destroyed while the hierarchyOp binder transaction
  is in progress.

Bug: 265446463
Test: atest WindowOrganizerTests
Change-Id: Id978adba59058f8526118a446639619d4ec7e145
parent aac4541e
Loading
Loading
Loading
Loading
+19 −6
Original line number Diff line number Diff line
@@ -1013,17 +1013,30 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
                taskDisplayArea.moveRootTaskBehindRootTask(thisTask.getRootTask(), restoreAt);
                break;
            }
            case HIERARCHY_OP_TYPE_ADD_RECT_INSETS_PROVIDER:
            case HIERARCHY_OP_TYPE_ADD_RECT_INSETS_PROVIDER: {
                final Rect insetsProviderWindowContainer = hop.getInsetsProviderFrame();
                final WindowContainer receiverWindowContainer =
                final WindowContainer container =
                        WindowContainer.fromBinder(hop.getContainer());
                receiverWindowContainer.addLocalRectInsetsSourceProvider(
                if (container == null) {
                    Slog.e(TAG, "Attempt to add local insets source provider on unknown: "
                                    + container);
                    break;
                }
                container.addLocalRectInsetsSourceProvider(
                        insetsProviderWindowContainer, hop.getInsetsTypes());
                break;
            case HIERARCHY_OP_TYPE_REMOVE_INSETS_PROVIDER:
                WindowContainer.fromBinder(hop.getContainer())
                        .removeLocalInsetsSourceProvider(hop.getInsetsTypes());
            }
            case HIERARCHY_OP_TYPE_REMOVE_INSETS_PROVIDER: {
                final WindowContainer container =
                        WindowContainer.fromBinder(hop.getContainer());
                if (container == null) {
                    Slog.e(TAG, "Attempt to remove local insets source provider from unknown: "
                                    + container);
                    break;
                }
                container.removeLocalInsetsSourceProvider(hop.getInsetsTypes());
                break;
            }
            case HIERARCHY_OP_TYPE_SET_ALWAYS_ON_TOP: {
                final WindowContainer container = WindowContainer.fromBinder(hop.getContainer());
                if (container == null || container.asDisplayArea() == null