OSDN Git Service

Fixing bug #2023024 - there is an out of bounds exception that
authorCharles Chen <clchen@google.com>
Thu, 30 Jul 2009 00:23:50 +0000 (17:23 -0700)
committerCharles Chen <clchen@google.com>
Thu, 30 Jul 2009 00:23:50 +0000 (17:23 -0700)
can happen if services are going away as the AccessibilityManagerService
is trying to dispatch notifications to these services. Catching this
exception and bailing because having this exception means that there
are no more services around that need to get this notification.

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

index 63c9eaa..55007ba 100644 (file)
@@ -323,15 +323,22 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
      */
     private void notifyAccessibilityServicesDelayedLocked(AccessibilityEvent event,
             boolean isDefault) {
-        for (int i = 0, count = mServices.size(); i < count; i++) {
-            Service service = mServices.get(i);
+        try {
+            for (int i = 0, count = mServices.size(); i < count; i++) {
+                Service service = mServices.get(i);
 
-            if (service.mIsDefault == isDefault) {
-                if (canDispathEventLocked(service, event, mHandledFeedbackTypes)) {
-                    mHandledFeedbackTypes |= service.mFeedbackType;
-                    notifyAccessibilityServiceDelayedLocked(service, event);
+                if (service.mIsDefault == isDefault) {
+                    if (canDispathEventLocked(service, event, mHandledFeedbackTypes)) {
+                        mHandledFeedbackTypes |= service.mFeedbackType;
+                        notifyAccessibilityServiceDelayedLocked(service, event);
+                    }
                 }
             }
+        } catch (IndexOutOfBoundsException oobe) {
+            // An out of bounds exception can happen if services are going away
+            // as the for loop is running. If that happens, just bail because
+            // there are no more services to notify.
+            return;
         }
     }