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

Commit e97db706 authored by Jackal Guo's avatar Jackal Guo
Browse files

Add null check for WindowInfo

The WindowInfo may be null if the target window can't be found in
current mWindowInfoById. Add null guard to prevent from NPE here.

Bug: 116652152
Test: atest CtsAccessibilityServiceTestCases
Test: atest CtsAccessibilityTestCases
Change-Id: Iaf2446e66420289be4154e90fbe213bbca9fd41f
parent 72621aeb
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -2630,7 +2630,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
        final List<Integer> outsideWindowsIds;
        final List<RemoteAccessibilityConnection> connectionList = new ArrayList<>();
        synchronized (mLock) {
            outsideWindowsIds = mSecurityPolicy.getWatchOutsideTouchWindowId(targetWindowId);
            outsideWindowsIds = mSecurityPolicy.getWatchOutsideTouchWindowIdLocked(targetWindowId);
            for (int i = 0; i < outsideWindowsIds.size(); i++) {
                connectionList.add(getConnectionLocked(outsideWindowsIds.get(i)));
            }
@@ -3684,13 +3684,13 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
            return mWindowInfoById.get(windowId);
        }

        private List<Integer> getWatchOutsideTouchWindowId(int targetWindowId) {
            if (mWindowInfoById != null && mHasWatchOutsideTouchWindow) {
                final List<Integer> outsideWindowsId = new ArrayList<>();
        private List<Integer> getWatchOutsideTouchWindowIdLocked(int targetWindowId) {
            final WindowInfo targetWindow = mWindowInfoById.get(targetWindowId);
            if (targetWindow != null && mWindowInfoById != null && mHasWatchOutsideTouchWindow) {
                final List<Integer> outsideWindowsId = new ArrayList<>();
                for (int i = 0; i < mWindowInfoById.size(); i++) {
                    WindowInfo window = mWindowInfoById.valueAt(i);
                    if (window.layer < targetWindow.layer
                    if (window != null && window.layer < targetWindow.layer
                            && window.hasFlagWatchOutsideTouch) {
                        outsideWindowsId.add(mWindowInfoById.keyAt(i));
                    }