OSDN Git Service

Only send cache event if cache is detected to be used
authorEugene Susla <eugenesusla@google.com>
Wed, 28 Dec 2016 02:02:33 +0000 (18:02 -0800)
committerEugene Susla <eugenesusla@google.com>
Wed, 4 Jan 2017 18:50:58 +0000 (10:50 -0800)
Bug: b/32642665
Test: Repeat test of Icbdb91803b646fa06aaf11996d350f6f65c1e809
Change-Id: Ibc09ea5cb25e4ac021baed5b598d6ba7a76295bc

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

index dafa3f6..167dbfb 100644 (file)
@@ -1153,8 +1153,9 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
                 if (service.mIsDefault == isDefault) {
                     if (doesServiceWantEventLocked(service, event)) {
                         service.notifyAccessibilityEvent(event, true);
-                    } else if ((AccessibilityCache.CACHE_CRITICAL_EVENTS_MASK
-                            & event.getEventType()) != 0) {
+                    } else if (service.mUsesAccessibilityCache
+                            && (AccessibilityCache.CACHE_CRITICAL_EVENTS_MASK
+                                & event.getEventType()) != 0) {
                         service.notifyAccessibilityEvent(event, false);
                     }
                 }
@@ -2281,6 +2282,9 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
 
         boolean mWasConnectedAndDied;
 
+        /** Whether this service relies on its {@link AccessibilityCache} being up to date */
+        boolean mUsesAccessibilityCache = false;
+
         // Handler only for dispatching accessibility events since we use event
         // types as message types allowing us to remove messages per event type.
         public Handler mEventDispatchHandler = new Handler(mMainHandler.getLooper()) {
@@ -2593,6 +2597,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
             IAccessibilityInteractionConnection connection = null;
             Region partialInteractiveRegion = Region.obtain();
             synchronized (mLock) {
+                mUsesAccessibilityCache = true;
                 if (!isCalledForCurrentUserLocked()) {
                     return false;
                 }
@@ -2644,6 +2649,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
             IAccessibilityInteractionConnection connection = null;
             Region partialInteractiveRegion = Region.obtain();
             synchronized (mLock) {
+                mUsesAccessibilityCache = true;
                 if (!isCalledForCurrentUserLocked()) {
                     return false;
                 }
@@ -2695,6 +2701,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
             IAccessibilityInteractionConnection connection = null;
             Region partialInteractiveRegion = Region.obtain();
             synchronized (mLock) {
+                mUsesAccessibilityCache = true;
                 if (!isCalledForCurrentUserLocked()) {
                     return false;
                 }