OSDN Git Service

Clean up UiAutomation working alongside a11y.
authorPhil Weaver <pweaver@google.com>
Tue, 2 Feb 2016 01:01:44 +0000 (17:01 -0800)
committerPhil Weaver <pweaver@google.com>
Tue, 9 Feb 2016 00:08:59 +0000 (00:08 +0000)
Fix two bugs: one where Instrumentation did not properly
handle destroyed UiAutomations, another where UiAutomation
did not properly disable running accessibility services.

Change-Id: I1773dbd373f4d5b0e7c9917ff18d8d9b1a0e07c7
(cherry picked from commit 846522cea043d3113b3b96daa8f3a1b70e3beb5e)

core/java/android/app/Instrumentation.java
services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java

index 9a88f2c..33fd1db 100644 (file)
@@ -1842,13 +1842,10 @@ public class Instrumentation {
      * @see UiAutomation
      */
     public UiAutomation getUiAutomation() {
-        if (mUiAutomationConnection != null) {
-            if (mUiAutomation == null) {
-                return getUiAutomation(0);
-            }
-            return mUiAutomation;
+        if ((mUiAutomation == null) || (mUiAutomation.isDestroyed())) {
+            return getUiAutomation(0);
         }
-        return null;
+        return mUiAutomation;
     }
 
     /**
index 53504cc..e33e52f 100644 (file)
@@ -52,7 +52,6 @@ import android.net.Uri;
 import android.os.Binder;
 import android.os.Build;
 import android.os.Bundle;
-import android.os.Debug;
 import android.os.Handler;
 import android.os.IBinder;
 import android.os.Looper;
@@ -650,7 +649,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
             userState.mUiAutomationFlags = flags;
             userState.mIsAccessibilityEnabled = true;
             userState.mInstalledServices.add(accessibilityServiceInfo);
-            if (userState.isUiAutomationSuppressingOtherServices()) {
+            if ((flags & UiAutomation.FLAG_DONT_SUPPRESS_ACCESSIBILITY_SERVICES) == 0) {
                 // Set the temporary state.
                 userState.mIsTouchExplorationEnabled = false;
                 userState.mIsEnhancedWebAccessibilityEnabled = false;