use of android.view.accessibility.AccessibilityManager in project Launcher3 by chislon.
the class Folder method sendCustomAccessibilityEvent.
private void sendCustomAccessibilityEvent(int type, String text) {
AccessibilityManager accessibilityManager = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
if (accessibilityManager.isEnabled()) {
AccessibilityEvent event = AccessibilityEvent.obtain(type);
onInitializeAccessibilityEvent(event);
event.getText().add(text);
accessibilityManager.sendAccessibilityEvent(event);
}
}
use of android.view.accessibility.AccessibilityManager in project Launcher3 by chislon.
the class Workspace method getPageIndicatorClickListener.
@Override
protected OnClickListener getPageIndicatorClickListener() {
AccessibilityManager am = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
if (!am.isTouchExplorationEnabled()) {
return null;
}
OnClickListener listener = new OnClickListener() {
@Override
public void onClick(View arg0) {
enterOverviewMode();
}
};
return listener;
}
use of android.view.accessibility.AccessibilityManager in project android_frameworks_base by ParanoidAndroid.
the class TouchExplorer method sendAccessibilityEvent.
/**
* Sends an accessibility event of the given type.
*
* @param type The event type.
*/
private void sendAccessibilityEvent(int type) {
AccessibilityManager accessibilityManager = AccessibilityManager.getInstance(mContext);
if (accessibilityManager.isEnabled()) {
AccessibilityEvent event = AccessibilityEvent.obtain(type);
accessibilityManager.sendAccessibilityEvent(event);
switch(type) {
case AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_START:
{
mTouchExplorationInProgress = true;
}
break;
case AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_END:
{
mTouchExplorationInProgress = false;
}
break;
}
}
}
use of android.view.accessibility.AccessibilityManager in project android_frameworks_base by ParanoidAndroid.
the class AccessibilityManagerTest method testGetAccessibilityServiceList.
@MediumTest
public void testGetAccessibilityServiceList() throws Exception {
// create a list of installed accessibility services the mock service returns
List<AccessibilityServiceInfo> expectedServices = new ArrayList<AccessibilityServiceInfo>();
AccessibilityServiceInfo accessibilityServiceInfo = new AccessibilityServiceInfo();
accessibilityServiceInfo.packageNames = new String[] { "foo.bar" };
expectedServices.add(accessibilityServiceInfo);
// configure the mock service behavior
IAccessibilityManager mockServiceInterface = mMockServiceInterface;
expect(mockServiceInterface.addClient(anyIAccessibilityManagerClient(), UserHandle.USER_OWNER)).andReturn(AccessibilityManager.STATE_FLAG_ACCESSIBILITY_ENABLED);
expect(mockServiceInterface.getInstalledAccessibilityServiceList(UserHandle.USER_OWNER)).andReturn(expectedServices);
replay(mockServiceInterface);
// invoke the method under test
AccessibilityManager manager = new AccessibilityManager(mContext, mockServiceInterface, UserHandle.USER_OWNER);
List<AccessibilityServiceInfo> receivedServices = manager.getInstalledAccessibilityServiceList();
// check expected result (list equals() compares it contents as well)
assertEquals("All expected services must be returned", receivedServices, expectedServices);
// verify the mock service was properly called
verify(mockServiceInterface);
}
use of android.view.accessibility.AccessibilityManager in project android_frameworks_base by ParanoidAndroid.
the class AccessibilityManagerTest method testIsEnabled.
@LargeTest
public void testIsEnabled() throws Exception {
// configure the mock service behavior
IAccessibilityManager mockServiceInterface = mMockServiceInterface;
expect(mockServiceInterface.addClient(anyIAccessibilityManagerClient(), UserHandle.USER_OWNER)).andReturn(AccessibilityManager.STATE_FLAG_ACCESSIBILITY_ENABLED);
replay(mockServiceInterface);
// invoke the method under test
AccessibilityManager manager = new AccessibilityManager(mContext, mockServiceInterface, UserHandle.USER_OWNER);
boolean isEnabledServiceEnabled = manager.isEnabled();
// check expected result
assertTrue("Must be enabled since the mock service is enabled", isEnabledServiceEnabled);
// disable accessibility
manager.getClient().setState(0);
// wait for the asynchronous IBinder call to complete
Thread.sleep(TIMEOUT_BINDER_CALL);
// invoke the method under test
boolean isEnabledServcieDisabled = manager.isEnabled();
// check expected result
assertFalse("Must be disabled since the mock service is disabled", isEnabledServcieDisabled);
// verify the mock service was properly called
verify(mockServiceInterface);
}
Aggregations