use of android.view.accessibility.AccessibilityManager in project android_frameworks_base by ParanoidAndroid.
the class View method requestAccessibilityFocus.
/**
* Call this to try to give accessibility focus to this view.
*
* A view will not actually take focus if {@link AccessibilityManager#isEnabled()}
* returns false or the view is no visible or the view already has accessibility
* focus.
*
* See also {@link #focusSearch(int)}, which is what you call to say that you
* have focus, and you want your parent to look for the next one.
*
* @return Whether this view actually took accessibility focus.
*
* @hide
*/
public boolean requestAccessibilityFocus() {
AccessibilityManager manager = AccessibilityManager.getInstance(mContext);
if (!manager.isEnabled() || !manager.isTouchExplorationEnabled()) {
return false;
}
if ((mViewFlags & VISIBILITY_MASK) != VISIBLE) {
return false;
}
if ((mPrivateFlags2 & PFLAG2_ACCESSIBILITY_FOCUSED) == 0) {
mPrivateFlags2 |= PFLAG2_ACCESSIBILITY_FOCUSED;
ViewRootImpl viewRootImpl = getViewRootImpl();
if (viewRootImpl != null) {
viewRootImpl.setAccessibilityFocus(this, null);
}
invalidate();
sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
notifyAccessibilityStateChanged();
return true;
}
return false;
}
use of android.view.accessibility.AccessibilityManager in project android_packages_apps_Launcher2 by CyanogenMod.
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);
}
}
use of android.view.accessibility.AccessibilityManager in project platform_frameworks_base by android.
the class NotificationManagerService method sendAccessibilityEvent.
void sendAccessibilityEvent(Notification notification, CharSequence packageName) {
AccessibilityManager manager = AccessibilityManager.getInstance(getContext());
if (!manager.isEnabled()) {
return;
}
AccessibilityEvent event = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED);
event.setPackageName(packageName);
event.setClassName(Notification.class.getName());
event.setParcelableData(notification);
CharSequence tickerText = notification.tickerText;
if (!TextUtils.isEmpty(tickerText)) {
event.getText().add(tickerText);
}
manager.sendAccessibilityEvent(event);
}
use of android.view.accessibility.AccessibilityManager in project platform_frameworks_base by android.
the class AccessibilityManagerTest method testInterrupt.
@MediumTest
public void testInterrupt() throws Exception {
AccessibilityManager manager = createManager(true);
manager.interrupt();
verify(mMockService).interrupt(UserHandle.USER_CURRENT);
}
use of android.view.accessibility.AccessibilityManager in project platform_frameworks_base by android.
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 = new AccessibilityServiceInfo();
accessibilityServiceInfo.packageNames = new String[] { "foo.bar" };
expectedServices.add(accessibilityServiceInfo);
// configure the mock service behavior
when(mMockService.getInstalledAccessibilityServiceList(anyInt())).thenReturn(expectedServices);
// invoke the method under test
AccessibilityManager manager = createManager(true);
List<AccessibilityServiceInfo> receivedServices = manager.getInstalledAccessibilityServiceList();
verify(mMockService).getInstalledAccessibilityServiceList(UserHandle.USER_CURRENT);
// check expected result (list equals() compares it contents as well)
assertEquals("All expected services must be returned", expectedServices, receivedServices);
}
Aggregations