Search in sources :

Example 96 with AccessibilityManager

use of android.view.accessibility.AccessibilityManager in project android_frameworks_base by DirtyUnicorns.

the class DevicePolicyManagerService method setPermittedAccessibilityServices.

@Override
public boolean setPermittedAccessibilityServices(ComponentName who, List packageList) {
    if (!mHasFeature) {
        return false;
    }
    Preconditions.checkNotNull(who, "ComponentName is null");
    if (packageList != null) {
        int userId = UserHandle.getCallingUserId();
        List<AccessibilityServiceInfo> enabledServices = null;
        long id = mInjector.binderClearCallingIdentity();
        try {
            UserInfo user = getUserInfo(userId);
            if (user.isManagedProfile()) {
                userId = user.profileGroupId;
            }
            AccessibilityManager accessibilityManager = getAccessibilityManagerForUser(userId);
            enabledServices = accessibilityManager.getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_ALL_MASK);
        } finally {
            mInjector.binderRestoreCallingIdentity(id);
        }
        if (enabledServices != null) {
            List<String> enabledPackages = new ArrayList<String>();
            for (AccessibilityServiceInfo service : enabledServices) {
                enabledPackages.add(service.getResolveInfo().serviceInfo.packageName);
            }
            if (!checkPackagesInPermittedListOrSystem(enabledPackages, packageList, userId)) {
                Slog.e(LOG_TAG, "Cannot set permitted accessibility services, " + "because it contains already enabled accesibility services.");
                return false;
            }
        }
    }
    synchronized (this) {
        ActiveAdmin admin = getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
        admin.permittedAccessiblityServices = packageList;
        saveSettingsLocked(UserHandle.getCallingUserId());
    }
    return true;
}
Also used : AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) AccessibilityManager(android.view.accessibility.AccessibilityManager) IAccessibilityManager(android.view.accessibility.IAccessibilityManager) ArrayList(java.util.ArrayList) UserInfo(android.content.pm.UserInfo) ParcelableString(com.android.internal.util.ParcelableString)

Example 97 with AccessibilityManager

use of android.view.accessibility.AccessibilityManager in project android_frameworks_base by DirtyUnicorns.

the class AccessibilityManagerTest method testSendAccessibilityEvent_AccessibilityDisabled.

@MediumTest
public void testSendAccessibilityEvent_AccessibilityDisabled() throws Exception {
    AccessibilityEvent sentEvent = AccessibilityEvent.obtain();
    AccessibilityManager manager = createManager(false);
    try {
        manager.sendAccessibilityEvent(sentEvent);
        fail("No accessibility events are sent if accessibility is disabled");
    } catch (IllegalStateException ise) {
        // check expected result
        assertEquals("Accessibility off. Did you forget to check that?", ise.getMessage());
    }
}
Also used : AccessibilityManager(android.view.accessibility.AccessibilityManager) IAccessibilityManager(android.view.accessibility.IAccessibilityManager) AccessibilityEvent(android.view.accessibility.AccessibilityEvent) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 98 with AccessibilityManager

use of android.view.accessibility.AccessibilityManager in project android_frameworks_base by DirtyUnicorns.

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)

Example 99 with AccessibilityManager

use of android.view.accessibility.AccessibilityManager in project XobotOS by xamarin.

the class TwoStatePreference method sendAccessibilityEvent.

void sendAccessibilityEvent(View view) {
    // Since the view is still not attached we create, populate,
    // and send the event directly since we do not know when it
    // will be attached and posting commands is not as clean.
    AccessibilityManager accessibilityManager = AccessibilityManager.getInstance(getContext());
    if (mSendClickAccessibilityEvent && accessibilityManager.isEnabled()) {
        AccessibilityEvent event = AccessibilityEvent.obtain();
        event.setEventType(AccessibilityEvent.TYPE_VIEW_CLICKED);
        view.onInitializeAccessibilityEvent(event);
        view.dispatchPopulateAccessibilityEvent(event);
        accessibilityManager.sendAccessibilityEvent(event);
    }
    mSendClickAccessibilityEvent = false;
}
Also used : AccessibilityManager(android.view.accessibility.AccessibilityManager) AccessibilityEvent(android.view.accessibility.AccessibilityEvent)

Example 100 with AccessibilityManager

use of android.view.accessibility.AccessibilityManager in project android_frameworks_base by AOSPA.

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

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