diff options
author | Svetoslav Ganov <svetoslavganov@google.com> | 2011-07-21 11:35:03 -0700 |
---|---|---|
committer | Svetoslav Ganov <svetoslavganov@google.com> | 2011-07-22 17:38:54 -0700 |
commit | 00aabf7d187bc05408199bd687a538b2e68bdc17 (patch) | |
tree | 3d70fecb8b5b64723b3dc2cf7250fe5f48f98b86 /services/java/com | |
parent | d24cd90486821535fb058531fac54aa5b9360693 (diff) | |
download | frameworks_base-00aabf7d187bc05408199bd687a538b2e68bdc17.zip frameworks_base-00aabf7d187bc05408199bd687a538b2e68bdc17.tar.gz frameworks_base-00aabf7d187bc05408199bd687a538b2e68bdc17.tar.bz2 |
Touch exploration state set to clients asynchronously and depended on talking service being enabled.
1. Upon registration of an accessibility client the latter received only
the accessiiblity state and waiting for the touch exploration state
to be sent by the system in async manner. This led the very first
check of touch exploration state is checked a wrong value to be reported.
Now a state of the accessibility layer is returned to the client
upon registration.
2. Removing the dependency on talking accessibility service to be enabled
for getting into touch exploration mode. What if the user wants to use
an accessibility service that shows a dialog with the text of the touched
view?
bug:5051546
Change-Id: Ib377babb3f560929ee73bd3d8b0d277341ba23f7
Diffstat (limited to 'services/java/com')
-rw-r--r-- | services/java/com/android/server/accessibility/AccessibilityManagerService.java | 95 |
1 files changed, 44 insertions, 51 deletions
diff --git a/services/java/com/android/server/accessibility/AccessibilityManagerService.java b/services/java/com/android/server/accessibility/AccessibilityManagerService.java index bb9d15b..92647e6 100644 --- a/services/java/com/android/server/accessibility/AccessibilityManagerService.java +++ b/services/java/com/android/server/accessibility/AccessibilityManagerService.java @@ -49,6 +49,7 @@ import android.util.SparseArray; import android.view.IWindow; import android.view.View; import android.view.accessibility.AccessibilityEvent; +import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityNodeInfo; import android.view.accessibility.IAccessibilityInteractionConnection; import android.view.accessibility.IAccessibilityInteractionConnectionCallback; @@ -129,10 +130,10 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub private boolean mIsAccessibilityEnabled; - private boolean mIsTouchExplorationRequested; - private AccessibilityInputFilter mInputFilter; + private boolean mHasInputFilter; + private final List<AccessibilityServiceInfo> mEnabledServicesForFeedbackTempList = new ArrayList<AccessibilityServiceInfo>(); private boolean mIsTouchExplorationEnabled; @@ -189,7 +190,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub manageServicesLocked(); } } - + @Override public boolean onHandleForceStop(Intent intent, String[] packages, int uid, boolean doit) { @@ -236,17 +237,16 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub mIsAccessibilityEnabled = Settings.Secure.getInt( mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_ENABLED, 0) == 1; - // if accessibility is enabled inform our clients we are on - if (mIsAccessibilityEnabled) { - sendAccessibilityEnabledToClientsLocked(); - } + manageServicesLocked(); // get touch exploration enabled setting on boot - mIsTouchExplorationRequested = Settings.Secure.getInt( + mIsTouchExplorationEnabled = Settings.Secure.getInt( mContext.getContentResolver(), - Settings.Secure.TOUCH_EXPLORATION_REQUESTED, 0) == 1; - updateTouchExplorationEnabledLocked(); + Settings.Secure.TOUCH_EXPLORATION_ENABLED, 0) == 1; + updateInputFilterLocked(); + + sendStateToClientsLocked(); } return; @@ -288,13 +288,13 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub } else { unbindAllServicesLocked(); } - sendAccessibilityEnabledToClientsLocked(); + sendStateToClientsLocked(); } } }); Uri touchExplorationRequestedUri = Settings.Secure.getUriFor( - Settings.Secure.TOUCH_EXPLORATION_REQUESTED); + Settings.Secure.TOUCH_EXPLORATION_ENABLED); contentResolver.registerContentObserver(touchExplorationRequestedUri, false, new ContentObserver(new Handler()) { @Override @@ -302,10 +302,11 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub super.onChange(selfChange); synchronized (mLock) { - mIsTouchExplorationRequested = Settings.Secure.getInt( + mIsTouchExplorationEnabled = Settings.Secure.getInt( mContext.getContentResolver(), - Settings.Secure.TOUCH_EXPLORATION_REQUESTED, 0) == 1; - updateTouchExplorationEnabledLocked(); + Settings.Secure.TOUCH_EXPLORATION_ENABLED, 0) == 1; + updateInputFilterLocked(); + sendStateToClientsLocked(); } } }); @@ -325,7 +326,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub }); } - public boolean addClient(IAccessibilityManagerClient client) throws RemoteException { + public int addClient(IAccessibilityManagerClient client) throws RemoteException { synchronized (mLock) { final IAccessibilityManagerClient addedClient = client; mClients.add(addedClient); @@ -338,7 +339,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub } } }, 0); - return mIsAccessibilityEnabled; + return getState(); } } @@ -628,7 +629,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub service.linkToOwnDeath(); mServices.add(service); mComponentNameToServiceMap.put(service.mComponentName, service); - updateTouchExplorationEnabledLocked(); + updateInputFilterLocked(); } catch (RemoteException e) { /* do nothing */ } @@ -648,7 +649,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub mComponentNameToServiceMap.remove(service.mComponentName); mHandler.removeMessages(service.mId); service.unlinkToOwnDeath(); - updateTouchExplorationEnabledLocked(); + updateInputFilterLocked(); return removed; } @@ -781,12 +782,13 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub } /** - * Updates the state of {@link android.view.accessibility.AccessibilityManager} clients. + * Sends the state to the clients. */ - private void sendAccessibilityEnabledToClientsLocked() { + private void sendStateToClientsLocked() { + final int state = getState(); for (int i = 0, count = mClients.size(); i < count; i++) { try { - mClients.get(i).setEnabled(mIsAccessibilityEnabled); + mClients.get(i).setState(state); } catch (RemoteException re) { mClients.remove(i); count--; @@ -796,48 +798,39 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub } /** - * Sends the touch exploration state to clients. + * Gets the current state as a set of flags. + * + * @return The state. */ - private void sendTouchExplorationEnabledToClientsLocked() { - for (int i = 0, count = mClients.size(); i < count; i++) { - try { - mClients.get(i).setTouchExplorationEnabled(mIsTouchExplorationEnabled); - } catch (RemoteException re) { - mClients.remove(i); - count--; - i--; - } + private int getState() { + int state = 0; + if (mIsAccessibilityEnabled) { + state |= AccessibilityManager.STATE_FLAG_ACCESSIBILITY_ENABLED; } + // Touch exploration relies on enabled accessibility. + if (mIsAccessibilityEnabled && mIsTouchExplorationEnabled) { + state |= AccessibilityManager.STATE_FLAG_TOUCH_EXPLORATION_ENABLED; + } + return state; } /** - * Updates the touch exploration state. Touch exploration is enabled if it - * is requested, accessibility is on and there is at least one enabled - * accessibility service providing spoken feedback. + * Updates the touch exploration state. */ - private void updateTouchExplorationEnabledLocked() { - if (mIsAccessibilityEnabled && mIsTouchExplorationRequested) { - final boolean hasSpeakingServicesEnabled = !getEnabledAccessibilityServiceList( - AccessibilityServiceInfo.FEEDBACK_SPOKEN).isEmpty(); - if (!mIsTouchExplorationEnabled) { - if (!hasSpeakingServicesEnabled) { - return; - } + private void updateInputFilterLocked() { + if (mIsAccessibilityEnabled && mIsTouchExplorationEnabled) { + if (!mHasInputFilter) { + mHasInputFilter = true; if (mInputFilter == null) { mInputFilter = new AccessibilityInputFilter(mContext); } mWindowManagerService.setInputFilter(mInputFilter); - mIsTouchExplorationEnabled = true; - sendTouchExplorationEnabledToClientsLocked(); - return; - } else if (hasSpeakingServicesEnabled) { - return; } + return; } - if (mIsTouchExplorationEnabled) { + if (mHasInputFilter) { + mHasInputFilter = false; mWindowManagerService.setInputFilter(null); - mIsTouchExplorationEnabled = false; - sendTouchExplorationEnabledToClientsLocked(); } } |