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);
}
use of android.view.accessibility.AccessibilityManager in project HoloEverywhere by Prototik.
the class SwitchScreenPreference method sendAccessibilityEvent.
@SuppressLint("NewApi")
void sendAccessibilityEvent(View view) {
try {
AccessibilityManager accessibilityManager = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
if (mSendClickAccessibilityEvent && accessibilityManager.isEnabled()) {
AccessibilityEvent event = AccessibilityEvent.obtain();
event.setEventType(AccessibilityEvent.TYPE_VIEW_CLICKED);
if (VERSION.SDK_INT >= 14) {
view.onInitializeAccessibilityEvent(event);
}
view.dispatchPopulateAccessibilityEvent(event);
accessibilityManager.sendAccessibilityEvent(event);
}
} catch (Exception e) {
}
mSendClickAccessibilityEvent = false;
}
use of android.view.accessibility.AccessibilityManager in project Fairphone by Kwamecorp.
the class DragLayer method onInterceptHoverEvent.
@Override
public boolean onInterceptHoverEvent(MotionEvent ev) {
if (mLauncher == null || mLauncher.getWorkspace() == null) {
return false;
}
Folder currentFolder = mLauncher.getWorkspace().getOpenFolder();
if (currentFolder == null) {
return false;
} else {
AccessibilityManager accessibilityManager = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
if (accessibilityManager.isTouchExplorationEnabled()) {
final int action = ev.getAction();
boolean isOverFolder;
switch(action) {
case MotionEvent.ACTION_HOVER_ENTER:
isOverFolder = isEventOverFolder(currentFolder, ev);
if (!isOverFolder) {
sendTapOutsideFolderAccessibilityEvent(currentFolder.isEditingName());
mHoverPointClosesFolder = true;
return true;
} else if (isOverFolder) {
mHoverPointClosesFolder = false;
} else {
return true;
}
case MotionEvent.ACTION_HOVER_MOVE:
isOverFolder = isEventOverFolder(currentFolder, ev);
if (!isOverFolder && !mHoverPointClosesFolder) {
sendTapOutsideFolderAccessibilityEvent(currentFolder.isEditingName());
mHoverPointClosesFolder = true;
return true;
} else if (isOverFolder) {
mHoverPointClosesFolder = false;
} else {
return true;
}
}
}
}
return false;
}
use of android.view.accessibility.AccessibilityManager in project Fairphone by Kwamecorp.
the class DragLayer method sendTapOutsideFolderAccessibilityEvent.
private void sendTapOutsideFolderAccessibilityEvent(boolean isEditingName) {
AccessibilityManager accessibilityManager = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
if (accessibilityManager.isEnabled()) {
int stringId = isEditingName ? R.string.folder_tap_to_rename : R.string.folder_tap_to_close;
AccessibilityEvent event = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_VIEW_FOCUSED);
onInitializeAccessibilityEvent(event);
event.getText().add(getContext().getString(stringId));
accessibilityManager.sendAccessibilityEvent(event);
}
}
Aggregations