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

Commit 6c8a43b6 authored by Rhed Jao's avatar Rhed Jao
Browse files

Update active window when a11y client is removed

Bug: 119844696
Test: all a11y cts & framework tests
Change-Id: I9d826db034d2a61d61304fce9dcfc9ef4d319058
parent efd7f18d
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -777,6 +777,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
            final int removedWindowId = removeAccessibilityInteractionConnectionInternalLocked(
                    token, mGlobalWindowTokens, mGlobalInteractionConnections);
            if (removedWindowId >= 0) {
                mSecurityPolicy.onAccessibilityClientRemovedLocked(removedWindowId);
                if (DEBUG) {
                    Slog.i(LOG_TAG, "Removed global connection for pid:" + Binder.getCallingPid()
                            + " with windowId: " + removedWindowId + " and token: " + window.asBinder());
@@ -790,6 +791,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
                        removeAccessibilityInteractionConnectionInternalLocked(
                        token, userState.mWindowTokens, userState.mInteractionConnections);
                if (removedWindowIdForUser >= 0) {
                    mSecurityPolicy.onAccessibilityClientRemovedLocked(removedWindowIdForUser);
                    if (DEBUG) {
                        Slog.i(LOG_TAG, "Removed user connection for pid:" + Binder.getCallingPid()
                                + " with windowId: " + removedWindowIdForUser + " and userId:"
@@ -1332,6 +1334,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
            userState.mWindowTokens.remove(windowId);
            userState.mInteractionConnections.remove(windowId);
        }
        mSecurityPolicy.onAccessibilityClientRemovedLocked(windowId);
        if (DEBUG) {
            Slog.i(LOG_TAG, "Removing interaction connection to windowId: " + windowId);
        }
@@ -3266,6 +3269,18 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
            mWindows = null;
        }

        /**
         * A callback when accessibility interaction client is removed.
         */
        public void onAccessibilityClientRemovedLocked(int windowId) {
            // Active window cannot update immediately, if windows callback is unregistered.
            // Update active window to invalid, when its a11y interaction client is removed.
            if (mWindowsForAccessibilityCallback == null && windowId >= 0
                    && mActiveWindowId == windowId) {
                mActiveWindowId = INVALID_WINDOW_ID;
            }
        }

        public void updateWindowsLocked(List<WindowInfo> windows) {
            if (mWindows == null) {
                mWindows = new ArrayList<>();