OSDN Git Service

Update active window when a11y client is removed
authorRhed Jao <rhedjao@google.com>
Mon, 25 Mar 2019 12:52:38 +0000 (20:52 +0800)
committerRhed Jao <rhedjao@google.com>
Mon, 25 Mar 2019 12:58:51 +0000 (20:58 +0800)
Bug: 119844696
Test: all a11y cts & framework tests
Change-Id: I9d826db034d2a61d61304fce9dcfc9ef4d319058

services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java

index 47cd917..904817e 100644 (file)
@@ -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<>();