diff options
| author | Svet Ganov <svetoslavganov@google.com> | 2014-08-05 08:41:08 -0700 |
|---|---|---|
| committer | Svetoslav Ganov <svetoslavganov@google.com> | 2014-08-05 16:02:21 +0000 |
| commit | c946f14a67f36d398f30040976ec6e7baf2643ac (patch) | |
| tree | 16232c6c8130e8b1984dad88ed6ed14e92750057 /core/java/android/view/accessibility | |
| parent | ae9251262a99b0927c9b0f1fa9438b00989402f4 (diff) | |
| download | frameworks_base-c946f14a67f36d398f30040976ec6e7baf2643ac.zip frameworks_base-c946f14a67f36d398f30040976ec6e7baf2643ac.tar.gz frameworks_base-c946f14a67f36d398f30040976ec6e7baf2643ac.tar.bz2 | |
Properly update accessibility manager state.
Applciations that fire accessibility events have to first check
it accessibility is on and then fire the event. If the app fires
an event when the feature is off an exception is thrown. However,
due to the way accessibility state is pushed to the local
accessibility manager it was possible that the app checks that
aaccessibility is off, fires an event, then the state of the
local manager changes by the time the event is propagated up
the view tree and an exception is thrown. This is a regression.
We really want this exception to prevent apps sending events
across processes if accessibility is off, so now the state
we get from the system manager service is applied via a
message so if the app checks that accessibility is off, then
it will remain off (locally) until the event is propagated.
bug:16672964
Change-Id: Icf5d1b1bdff87b58f285f0d9e1a098552513bbe8
Diffstat (limited to 'core/java/android/view/accessibility')
| -rw-r--r-- | core/java/android/view/accessibility/AccessibilityManager.java | 58 |
1 files changed, 21 insertions, 37 deletions
diff --git a/core/java/android/view/accessibility/AccessibilityManager.java b/core/java/android/view/accessibility/AccessibilityManager.java index 94e2c0e..c3b17db 100644 --- a/core/java/android/view/accessibility/AccessibilityManager.java +++ b/core/java/android/view/accessibility/AccessibilityManager.java @@ -80,41 +80,14 @@ public final class AccessibilityManager { public static final int STATE_FLAG_HIGH_TEXT_CONTRAST_ENABLED = 0x00000004; /** @hide */ - public static final int INVERSION_DISABLED = -1; - - /** @hide */ - public static final int INVERSION_STANDARD = 0; - - /** @hide */ - public static final int INVERSION_HUE_ONLY = 1; - - /** @hide */ - public static final int INVERSION_VALUE_ONLY = 2; - - /** @hide */ public static final int DALTONIZER_DISABLED = -1; /** @hide */ public static final int DALTONIZER_SIMULATE_MONOCHROMACY = 0; /** @hide */ - public static final int DALTONIZER_SIMULATE_PROTANOMALY = 1; - - /** @hide */ - public static final int DALTONIZER_SIMULATE_DEUTERANOMALY = 2; - - /** @hide */ - public static final int DALTONIZER_SIMULATE_TRITANOMALY = 3; - - /** @hide */ - public static final int DALTONIZER_CORRECT_PROTANOMALY = 11; - - /** @hide */ public static final int DALTONIZER_CORRECT_DEUTERANOMALY = 12; - /** @hide */ - public static final int DALTONIZER_CORRECT_TRITANOMALY = 13; - static final Object sInstanceSync = new Object(); private static AccessibilityManager sInstance; @@ -134,16 +107,13 @@ public final class AccessibilityManager { boolean mIsHighTextContrastEnabled; private final CopyOnWriteArrayList<AccessibilityStateChangeListener> - mAccessibilityStateChangeListeners = new CopyOnWriteArrayList< - AccessibilityStateChangeListener>(); + mAccessibilityStateChangeListeners = new CopyOnWriteArrayList<>(); private final CopyOnWriteArrayList<TouchExplorationStateChangeListener> - mTouchExplorationStateChangeListeners = new CopyOnWriteArrayList< - TouchExplorationStateChangeListener>(); + mTouchExplorationStateChangeListeners = new CopyOnWriteArrayList<>(); private final CopyOnWriteArrayList<HighTextContrastChangeListener> - mHighTextContrastStateChangeListeners = new CopyOnWriteArrayList< - HighTextContrastChangeListener>(); + mHighTextContrastStateChangeListeners = new CopyOnWriteArrayList<>(); /** * Listener for the system accessibility state. To listen for changes to the @@ -197,9 +167,13 @@ public final class AccessibilityManager { private final IAccessibilityManagerClient.Stub mClient = new IAccessibilityManagerClient.Stub() { public void setState(int state) { - synchronized (mLock) { - setStateLocked(state); - } + // We do not want to change this immediately as the applicatoin may + // have already checked that accessibility is on and fired an event, + // that is now propagating up the view tree, Hence, if accessibility + // is now off an exception will be thrown. We want to have the exception + // enforcement to guard against apps that fire unnecessary accessibility + // events when accessibility is off. + mHandler.obtainMessage(MyHandler.MSG_SET_STATE, state, 0).sendToTarget(); } }; @@ -393,7 +367,7 @@ public final class AccessibilityManager { @Deprecated public List<ServiceInfo> getAccessibilityServiceList() { List<AccessibilityServiceInfo> infos = getInstalledAccessibilityServiceList(); - List<ServiceInfo> services = new ArrayList<ServiceInfo>(); + List<ServiceInfo> services = new ArrayList<>(); final int infoCount = infos.size(); for (int i = 0; i < infoCount; i++) { AccessibilityServiceInfo info = infos.get(i); @@ -446,6 +420,7 @@ public final class AccessibilityManager { * @see AccessibilityServiceInfo#FEEDBACK_HAPTIC * @see AccessibilityServiceInfo#FEEDBACK_SPOKEN * @see AccessibilityServiceInfo#FEEDBACK_VISUAL + * @see AccessibilityServiceInfo#FEEDBACK_BRAILLE */ public List<AccessibilityServiceInfo> getEnabledAccessibilityServiceList( int feedbackTypeFlags) { @@ -705,6 +680,7 @@ public final class AccessibilityManager { public static final int MSG_NOTIFY_ACCESSIBILITY_STATE_CHANGED = 1; public static final int MSG_NOTIFY_EXPLORATION_STATE_CHANGED = 2; public static final int MSG_NOTIFY_HIGH_TEXT_CONTRAST_STATE_CHANGED = 3; + public static final int MSG_SET_STATE = 4; public MyHandler(Looper looper) { super(looper, null, false); @@ -724,6 +700,14 @@ public final class AccessibilityManager { case MSG_NOTIFY_HIGH_TEXT_CONTRAST_STATE_CHANGED: { handleNotifyHighTextContrastStateChanged(); } break; + + case MSG_SET_STATE: { + // See comment at mClient + final int state = message.arg1; + synchronized (mLock) { + setStateLocked(state); + } + } break; } } } |
