diff options
author | Svetoslav Ganov <svetoslavganov@google.com> | 2011-07-25 12:08:08 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-07-25 12:08:08 -0700 |
commit | 71f14a4e23c0b6eb60a81fd9a1be86dc441d051a (patch) | |
tree | 4e140ffde55af598803f8398e9ecf761e8a672d3 | |
parent | c018496ab220158741488a67d3aed87abd6bf232 (diff) | |
parent | 00aabf7d187bc05408199bd687a538b2e68bdc17 (diff) | |
download | frameworks_base-71f14a4e23c0b6eb60a81fd9a1be86dc441d051a.zip frameworks_base-71f14a4e23c0b6eb60a81fd9a1be86dc441d051a.tar.gz frameworks_base-71f14a4e23c0b6eb60a81fd9a1be86dc441d051a.tar.bz2 |
Merge "Touch exploration state set to clients asynchronously and depended on talking service being enabled."
12 files changed, 121 insertions, 100 deletions
diff --git a/api/current.txt b/api/current.txt index 9b0f520..a71c866 100644 --- a/api/current.txt +++ b/api/current.txt @@ -1828,6 +1828,7 @@ package android.accessibilityservice { method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator CREATOR; field public static final int DEFAULT = 1; // 0x1 + field public static final int FEEDBACK_ALL_MASK = -1; // 0xffffffff field public static final int FEEDBACK_AUDIBLE = 4; // 0x4 field public static final int FEEDBACK_GENERIC = 16; // 0x10 field public static final int FEEDBACK_HAPTIC = 2; // 0x2 @@ -16710,7 +16711,7 @@ package android.provider { field public static final java.lang.String SELECTED_INPUT_METHOD_SUBTYPE = "selected_input_method_subtype"; field public static final java.lang.String SETTINGS_CLASSNAME = "settings_classname"; field public static final java.lang.String SYS_PROP_SETTING_VERSION = "sys.settings_secure_version"; - field public static final java.lang.String TOUCH_EXPLORATION_REQUESTED = "touch_exploration_requested"; + field public static final java.lang.String TOUCH_EXPLORATION_ENABLED = "touch_exploration_enabled"; field public static final java.lang.String TTS_DEFAULT_COUNTRY = "tts_default_country"; field public static final java.lang.String TTS_DEFAULT_LANG = "tts_default_lang"; field public static final java.lang.String TTS_DEFAULT_PITCH = "tts_default_pitch"; diff --git a/core/java/android/accessibilityservice/AccessibilityServiceInfo.java b/core/java/android/accessibilityservice/AccessibilityServiceInfo.java index a09607a..41a3eac 100644 --- a/core/java/android/accessibilityservice/AccessibilityServiceInfo.java +++ b/core/java/android/accessibilityservice/AccessibilityServiceInfo.java @@ -75,6 +75,17 @@ public class AccessibilityServiceInfo implements Parcelable { public static final int FEEDBACK_GENERIC = 0x0000010; /** + * Mask for all feedback types. + * + * @see #FEEDBACK_SPOKEN + * @see #FEEDBACK_HAPTIC + * @see #FEEDBACK_AUDIBLE + * @see #FEEDBACK_VISUAL + * @see #FEEDBACK_GENERIC + */ + public static final int FEEDBACK_ALL_MASK = 0xFFFFFFFF; + + /** * If an {@link AccessibilityService} is the default for a given type. * Default service is invoked only if no package specific one exists. In case of * more than one package specific service only the earlier registered is notified. diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 6ebbe7c..cd4e32e 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -2688,11 +2688,9 @@ public final class Settings { public static final String ACCESSIBILITY_ENABLED = "accessibility_enabled"; /** - * If touch exploration is requested. Touch exploration is enabled if it is - * requested by this setting, accessibility is enabled and there is at least - * one enabled accessibility serivce that provides spoken feedback. + * If touch exploration is enabled. */ - public static final String TOUCH_EXPLORATION_REQUESTED = "touch_exploration_requested"; + public static final String TOUCH_EXPLORATION_ENABLED = "touch_exploration_enabled"; /** * List of the enabled accessibility providers. diff --git a/core/java/android/view/accessibility/AccessibilityManager.java b/core/java/android/view/accessibility/AccessibilityManager.java index 83c73cb..a80c2a7 100644 --- a/core/java/android/view/accessibility/AccessibilityManager.java +++ b/core/java/android/view/accessibility/AccessibilityManager.java @@ -67,13 +67,17 @@ public final class AccessibilityManager { private static final String LOG_TAG = "AccessibilityManager"; + /** @hide */ + public static final int STATE_FLAG_ACCESSIBILITY_ENABLED = 0x00000001; + + /** @hide */ + public static final int STATE_FLAG_TOUCH_EXPLORATION_ENABLED = 0x00000002; + static final Object sInstanceSync = new Object(); private static AccessibilityManager sInstance; - private static final int DO_SET_ACCESSIBILITY_ENABLED = 10; - - private static final int DO_SET_TOUCH_EXPLORATION_ENABLED = 20; + private static final int DO_SET_STATE = 10; final IAccessibilityManager mService; @@ -100,13 +104,8 @@ public final class AccessibilityManager { } final IAccessibilityManagerClient.Stub mClient = new IAccessibilityManagerClient.Stub() { - public void setEnabled(boolean enabled) { - mHandler.obtainMessage(DO_SET_ACCESSIBILITY_ENABLED, enabled ? 1 : 0, 0).sendToTarget(); - } - - public void setTouchExplorationEnabled(boolean enabled) { - mHandler.obtainMessage(DO_SET_TOUCH_EXPLORATION_ENABLED, - enabled ? 1 : 0, 0).sendToTarget(); + public void setState(int state) { + mHandler.obtainMessage(DO_SET_STATE, state, 0).sendToTarget(); } }; @@ -119,14 +118,8 @@ public final class AccessibilityManager { @Override public void handleMessage(Message message) { switch (message.what) { - case DO_SET_ACCESSIBILITY_ENABLED : - final boolean isAccessibilityEnabled = (message.arg1 == 1); - setAccessibilityState(isAccessibilityEnabled); - return; - case DO_SET_TOUCH_EXPLORATION_ENABLED : - synchronized (mHandler) { - mIsTouchExplorationEnabled = (message.arg1 == 1); - } + case DO_SET_STATE : + setState(message.arg1); return; default : Log.w(LOG_TAG, "Unknown message type: " + message.what); @@ -163,8 +156,8 @@ public final class AccessibilityManager { mService = service; try { - final boolean isEnabled = mService.addClient(mClient); - setAccessibilityState(isEnabled); + final int stateFlags = mService.addClient(mClient); + setState(stateFlags); } catch (RemoteException re) { Log.e(LOG_TAG, "AccessibilityManagerService is dead", re); } @@ -341,6 +334,17 @@ public final class AccessibilityManager { } /** + * Sets the current state. + * + * @param stateFlags The state flags. + */ + private void setState(int stateFlags) { + final boolean accessibilityEnabled = (stateFlags & STATE_FLAG_ACCESSIBILITY_ENABLED) != 0; + setAccessibilityState(accessibilityEnabled); + mIsTouchExplorationEnabled = (stateFlags & STATE_FLAG_TOUCH_EXPLORATION_ENABLED) != 0; + } + + /** * Sets the enabled state. * * @param isEnabled The accessibility state. diff --git a/core/java/android/view/accessibility/AccessibilityNodeInfo.java b/core/java/android/view/accessibility/AccessibilityNodeInfo.java index 0e04471..6469b35 100644 --- a/core/java/android/view/accessibility/AccessibilityNodeInfo.java +++ b/core/java/android/view/accessibility/AccessibilityNodeInfo.java @@ -294,14 +294,14 @@ public class AccessibilityNodeInfo implements Parcelable { } /** - * Gets the unique id identifying this node's parent. + * Gets the parent. * <p> * <strong>Note:</strong> It is a client responsibility to recycle the * received info by calling {@link AccessibilityNodeInfo#recycle()} * to avoid creating of multiple instances. * </p> * - * @return The node's patent id. + * @return The parent. */ public AccessibilityNodeInfo getParent() { enforceSealed(); diff --git a/core/java/android/view/accessibility/IAccessibilityManager.aidl b/core/java/android/view/accessibility/IAccessibilityManager.aidl index b14f02a..c621ff6 100644 --- a/core/java/android/view/accessibility/IAccessibilityManager.aidl +++ b/core/java/android/view/accessibility/IAccessibilityManager.aidl @@ -34,7 +34,7 @@ import android.view.IWindow; */ interface IAccessibilityManager { - boolean addClient(IAccessibilityManagerClient client); + int addClient(IAccessibilityManagerClient client); boolean sendAccessibilityEvent(in AccessibilityEvent uiEvent); diff --git a/core/java/android/view/accessibility/IAccessibilityManagerClient.aidl b/core/java/android/view/accessibility/IAccessibilityManagerClient.aidl index 4e69692..5e7e813 100644 --- a/core/java/android/view/accessibility/IAccessibilityManagerClient.aidl +++ b/core/java/android/view/accessibility/IAccessibilityManagerClient.aidl @@ -24,7 +24,5 @@ package android.view.accessibility; */ oneway interface IAccessibilityManagerClient { - void setEnabled(boolean enabled); - - void setTouchExplorationEnabled(boolean enabled); + void setState(int stateFlags); } diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index 7d7aea9..b5fc55e 100755 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -2278,6 +2278,8 @@ <flag name="feedbackVisual" value="0x00000008" /> <!-- Provides {@link android.accessibilityservice.AccessibilityServiceInfo#FEEDBACK_GENERIC} feedback. --> <flag name="feedbackGeneric" value="0x00000010" /> + <!-- Provides {@link android.accessibilityservice.AccessibilityServiceInfo#FEEDBACK_ALL_MASK} feedback. --> + <flag name="feedbackAllMask" value="0xffffffff" /> </attr> <!-- The minimal period in milliseconds between two accessibility events of the same type are sent to this serivce. This setting can be changed at runtime by calling diff --git a/core/tests/coretests/src/android/view/accessibility/RecycleAccessibilityEventTest.java b/core/tests/coretests/src/android/view/accessibility/RecycleAccessibilityEventTest.java index bbf1696..4814c61 100644 --- a/core/tests/coretests/src/android/view/accessibility/RecycleAccessibilityEventTest.java +++ b/core/tests/coretests/src/android/view/accessibility/RecycleAccessibilityEventTest.java @@ -65,13 +65,13 @@ public class RecycleAccessibilityEventTest extends TestCase { assertEquals(0, first.getText().size()); assertFalse(first.isChecked()); assertNull(first.getContentDescription()); - assertEquals(0, first.getItemCount()); + assertEquals(-1, first.getItemCount()); assertEquals(AccessibilityEvent.INVALID_POSITION, first.getCurrentItemIndex()); assertFalse(first.isEnabled()); assertFalse(first.isPassword()); - assertEquals(0, first.getFromIndex()); - assertEquals(0, first.getAddedCount()); - assertEquals(0, first.getRemovedCount()); + assertEquals(-1, first.getFromIndex()); + assertEquals(-1, first.getAddedCount()); + assertEquals(-1, first.getRemovedCount()); // get another event from the pool (this must be the recycled first) AccessibilityEvent second = AccessibilityEvent.obtain(); 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(); } } diff --git a/services/tests/servicestests/src/com/android/server/AccessibilityManagerServiceTest.java b/services/tests/servicestests/src/com/android/server/AccessibilityManagerServiceTest.java index 1234bfd..46bcc4a 100644 --- a/services/tests/servicestests/src/com/android/server/AccessibilityManagerServiceTest.java +++ b/services/tests/servicestests/src/com/android/server/AccessibilityManagerServiceTest.java @@ -29,12 +29,13 @@ import android.provider.Settings; import android.test.AndroidTestCase; import android.test.suitebuilder.annotation.LargeTest; import android.view.accessibility.AccessibilityEvent; +import android.view.accessibility.AccessibilityManager; import android.view.accessibility.IAccessibilityManager; import android.view.accessibility.IAccessibilityManagerClient; /** * This test exercises the - * {@link com.android.server.AccessibilityManagerService} by mocking the + * {@link com.android.server.accessibility.AccessibilityManagerService} by mocking the * {@link android.view.accessibility.AccessibilityManager} which talks to to the * service. The service itself is interacting with the platform. Note: Testing * the service in full isolation would require significant amount of work for @@ -97,7 +98,9 @@ public class AccessibilityManagerServiceTest extends AndroidTestCase { MyMockAccessibilityManagerClient mockClient = new MyMockAccessibilityManagerClient(); // invoke the method under test - boolean enabledAccessibilityDisabled = mManagerService.addClient(mockClient); + final int stateFlagsDisabled = mManagerService.addClient(mockClient); + boolean enabledAccessibilityDisabled = + (stateFlagsDisabled & AccessibilityManager.STATE_FLAG_ACCESSIBILITY_ENABLED) != 0; // check expected result assertFalse("The client must be disabled since accessibility is disabled.", @@ -107,7 +110,10 @@ public class AccessibilityManagerServiceTest extends AndroidTestCase { ensureAccessibilityEnabled(mContext, true); // invoke the method under test - boolean enabledAccessibilityEnabled = mManagerService.addClient(mockClient); + final int stateFlagsEnabled = mManagerService.addClient(mockClient); + boolean enabledAccessibilityEnabled = + (stateFlagsEnabled & AccessibilityManager.STATE_FLAG_ACCESSIBILITY_ENABLED) != 0; + // check expected result assertTrue("The client must be enabled since accessibility is enabled.", @@ -123,7 +129,9 @@ public class AccessibilityManagerServiceTest extends AndroidTestCase { MyMockAccessibilityManagerClient mockClient = new MyMockAccessibilityManagerClient(); // invoke the method under test - boolean enabledAccessibilityEnabled = mManagerService.addClient(mockClient); + final int stateFlagsEnabled = mManagerService.addClient(mockClient); + boolean enabledAccessibilityEnabled = + (stateFlagsEnabled & AccessibilityManager.STATE_FLAG_ACCESSIBILITY_ENABLED) != 0; // check expected result assertTrue("The client must be enabled since accessibility is enabled.", @@ -133,7 +141,9 @@ public class AccessibilityManagerServiceTest extends AndroidTestCase { ensureAccessibilityEnabled(mContext, false); // invoke the method under test - boolean enabledAccessibilityDisabled = mManagerService.addClient(mockClient); + final int stateFlagsDisabled = mManagerService.addClient(mockClient); + boolean enabledAccessibilityDisabled = + (stateFlagsDisabled & AccessibilityManager.STATE_FLAG_ACCESSIBILITY_ENABLED) != 0; // check expected result assertFalse("The client must be disabled since accessibility is disabled.", @@ -537,10 +547,10 @@ public class AccessibilityManagerServiceTest extends AndroidTestCase { * This class is a mock {@link IAccessibilityManagerClient}. */ public class MyMockAccessibilityManagerClient extends IAccessibilityManagerClient.Stub { - boolean mIsEnabled; + int mState; - public void setEnabled(boolean enabled) { - mIsEnabled = enabled; + public void setState(int state) { + mState = state; } public void setTouchExplorationEnabled(boolean enabled) { diff --git a/services/tests/servicestests/src/com/android/server/AccessibilityManagerTest.java b/services/tests/servicestests/src/com/android/server/AccessibilityManagerTest.java index 1463d30..e083815 100644 --- a/services/tests/servicestests/src/com/android/server/AccessibilityManagerTest.java +++ b/services/tests/servicestests/src/com/android/server/AccessibilityManagerTest.java @@ -70,7 +70,8 @@ public class AccessibilityManagerTest extends AndroidTestCase { // configure the mock service behavior IAccessibilityManager mockServiceInterface = mMockServiceInterface; - expect(mockServiceInterface.addClient(anyIAccessibilityManagerClient())).andReturn(true); + expect(mockServiceInterface.addClient(anyIAccessibilityManagerClient())).andReturn( + AccessibilityManager.STATE_FLAG_ACCESSIBILITY_ENABLED); expect(mockServiceInterface.getInstalledAccessibilityServiceList()).andReturn( expectedServices); replay(mockServiceInterface); @@ -91,7 +92,8 @@ public class AccessibilityManagerTest extends AndroidTestCase { public void testInterrupt() throws Exception { // configure the mock service behavior IAccessibilityManager mockServiceInterface = mMockServiceInterface; - expect(mockServiceInterface.addClient(anyIAccessibilityManagerClient())).andReturn(true); + expect(mockServiceInterface.addClient(anyIAccessibilityManagerClient())).andReturn( + AccessibilityManager.STATE_FLAG_ACCESSIBILITY_ENABLED); mockServiceInterface.interrupt(); replay(mockServiceInterface); @@ -107,7 +109,8 @@ public class AccessibilityManagerTest extends AndroidTestCase { public void testIsEnabled() throws Exception { // configure the mock service behavior IAccessibilityManager mockServiceInterface = mMockServiceInterface; - expect(mockServiceInterface.addClient(anyIAccessibilityManagerClient())).andReturn(true); + expect(mockServiceInterface.addClient(anyIAccessibilityManagerClient())).andReturn( + AccessibilityManager.STATE_FLAG_ACCESSIBILITY_ENABLED); replay(mockServiceInterface); // invoke the method under test @@ -118,7 +121,7 @@ public class AccessibilityManagerTest extends AndroidTestCase { assertTrue("Must be enabled since the mock service is enabled", isEnabledServiceEnabled); // disable accessibility - manager.getClient().setEnabled(false); + manager.getClient().setState(0); // wait for the asynchronous IBinder call to complete Thread.sleep(TIMEOUT_BINDER_CALL); @@ -141,7 +144,8 @@ public class AccessibilityManagerTest extends AndroidTestCase { // configure the mock service behavior IAccessibilityManager mockServiceInterface = mMockServiceInterface; - expect(mockServiceInterface.addClient(anyIAccessibilityManagerClient())).andReturn(true); + expect(mockServiceInterface.addClient(anyIAccessibilityManagerClient())).andReturn( + AccessibilityManager.STATE_FLAG_ACCESSIBILITY_ENABLED); expect(mockServiceInterface.sendAccessibilityEvent(eqAccessibilityEvent(sentEvent))) .andReturn(true); expect(mockServiceInterface.sendAccessibilityEvent(eqAccessibilityEvent(sentEvent))) @@ -176,7 +180,7 @@ public class AccessibilityManagerTest extends AndroidTestCase { // configure the mock service behavior IAccessibilityManager mockServiceInterface = mMockServiceInterface; - expect(mockServiceInterface.addClient(anyIAccessibilityManagerClient())).andReturn(false); + expect(mockServiceInterface.addClient(anyIAccessibilityManagerClient())).andReturn(0); replay(mockServiceInterface); // invoke the method under test (accessibility disabled) |