Search in sources :

Example 86 with AccessibilityManager

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;
}
Also used : AccessibilityManager(android.view.accessibility.AccessibilityManager)

Example 87 with AccessibilityManager

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);
    }
}
Also used : AccessibilityManager(android.view.accessibility.AccessibilityManager) AccessibilityEvent(android.view.accessibility.AccessibilityEvent)

Example 88 with AccessibilityManager

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);
}
Also used : AccessibilityManager(android.view.accessibility.AccessibilityManager) AccessibilityEvent(android.view.accessibility.AccessibilityEvent) ITransientNotification(android.app.ITransientNotification) Notification(android.app.Notification) StatusBarNotification(android.service.notification.StatusBarNotification)

Example 89 with AccessibilityManager

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);
}
Also used : AccessibilityManager(android.view.accessibility.AccessibilityManager) IAccessibilityManager(android.view.accessibility.IAccessibilityManager) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 90 with AccessibilityManager

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);
}
Also used : AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) AccessibilityManager(android.view.accessibility.AccessibilityManager) IAccessibilityManager(android.view.accessibility.IAccessibilityManager) ArrayList(java.util.ArrayList) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Aggregations

AccessibilityManager (android.view.accessibility.AccessibilityManager)170 AccessibilityServiceInfo (android.accessibilityservice.AccessibilityServiceInfo)54 AccessibilityEvent (android.view.accessibility.AccessibilityEvent)49 IAccessibilityManager (android.view.accessibility.IAccessibilityManager)43 ArrayList (java.util.ArrayList)26 ServiceInfo (android.content.pm.ServiceInfo)20 MediumTest (android.test.suitebuilder.annotation.MediumTest)20 ComponentName (android.content.ComponentName)16 Drawable (android.graphics.drawable.Drawable)10 Bundle (android.os.Bundle)9 EnforcedAdmin (com.android.settingslib.RestrictedLockUtils.EnforcedAdmin)8 RestrictedPreference (com.android.settingslib.RestrictedPreference)8 SuppressLint (android.annotation.SuppressLint)7 Context (android.content.Context)7 SwitchPreference (android.support.v14.preference.SwitchPreference)7 ListPreference (android.support.v7.preference.ListPreference)7 Preference (android.support.v7.preference.Preference)7 AccessibilityNodeProvider (android.view.accessibility.AccessibilityNodeProvider)7 ITransientNotification (android.app.ITransientNotification)6 Notification (android.app.Notification)6