summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorPhil Weaver <pweaver@google.com>2016-11-02 15:40:42 -0700
committervinodkrishnan <vinodkrishnan@google.com>2016-12-15 08:06:15 +0000
commit74f9e1b867acbf248dd1640ef4c3f514b0ec9743 (patch)
tree364156a8618a3dd76a6cc55f019b33a821b2f817 /core/java
parent18382374353550fd4fd9134cf096a7c270804160 (diff)
Add null check to a11y interrupt.
Also adding same robustness to interrupt that we have for sending a11y events. Bug: 32507871 Test: Ran a11y CTS. Verified manually with sample app that sends interrupt and accessibility service that crashes when started. That case used to crash the app, and doesn't anymore. Change-Id: I5cf05dcbb54ea23ae876cb3258dd206c55dce775 (cherry picked from commit 867ad35d9c676b5ba2047b0fc9a4006737e5c4aa)
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/view/accessibility/AccessibilityManager.java13
1 files changed, 12 insertions, 1 deletions
diff --git a/core/java/android/view/accessibility/AccessibilityManager.java b/core/java/android/view/accessibility/AccessibilityManager.java
index 2dfa8cdd3db9..286f5f7c1bf9 100644
--- a/core/java/android/view/accessibility/AccessibilityManager.java
+++ b/core/java/android/view/accessibility/AccessibilityManager.java
@@ -353,7 +353,18 @@ public final class AccessibilityManager {
return;
}
if (!mIsEnabled) {
- throw new IllegalStateException("Accessibility off. Did you forget to check that?");
+ Looper myLooper = Looper.myLooper();
+ if (myLooper == Looper.getMainLooper()) {
+ throw new IllegalStateException(
+ "Accessibility off. Did you forget to check that?");
+ } else {
+ // If we're not running on the thread with the main looper, it's possible for
+ // the state of accessibility to change between checking isEnabled and
+ // calling this method. So just log the error rather than throwing the
+ // exception.
+ Log.e(LOG_TAG, "Interrupt called with accessibility disabled");
+ return;
+ }
}
userId = mUserId;
}