Search in sources :

Example 11 with AccessibilityManager

use of android.view.accessibility.AccessibilityManager in project robolectric by robolectric.

the class ShadowApplicationTest method shouldCorrectlyInstantiatedAccessibilityService.

@Test
@Config(minSdk = KITKAT)
public void shouldCorrectlyInstantiatedAccessibilityService() throws Exception {
    AccessibilityManager accessibilityManager = (AccessibilityManager) RuntimeEnvironment.application.getSystemService(Context.ACCESSIBILITY_SERVICE);
    AccessibilityManager.TouchExplorationStateChangeListener listener = createTouchListener();
    assertThat(accessibilityManager.addTouchExplorationStateChangeListener(listener)).isTrue();
    assertThat(accessibilityManager.removeTouchExplorationStateChangeListener(listener)).isTrue();
}
Also used : AccessibilityManager(android.view.accessibility.AccessibilityManager) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 12 with AccessibilityManager

use of android.view.accessibility.AccessibilityManager in project robolectric by robolectric.

the class ShadowAccessibilityManager method getInstance.

@HiddenApi
@Implementation
public static AccessibilityManager getInstance(Context context) throws Exception {
    if (getApiLevel() >= KITKAT) {
        AccessibilityManager accessibilityManager = Shadow.newInstance(AccessibilityManager.class, new Class[] { Context.class, IAccessibilityManager.class, int.class }, new Object[] { context, new AccessibilityManagerService(context), 0 });
        ReflectionHelpers.setField(accessibilityManager, "mHandler", new MyHandler(context.getMainLooper(), accessibilityManager));
        return accessibilityManager;
    } else {
        AccessibilityManager accessibilityManager = Shadow.newInstance(AccessibilityManager.class, new Class[0], new Object[0]);
        ReflectionHelpers.setField(accessibilityManager, "mHandler", new MyHandler(context.getMainLooper(), accessibilityManager));
        return accessibilityManager;
    }
}
Also used : AccessibilityManagerService(com.android.server.accessibility.AccessibilityManagerService) AccessibilityManager(android.view.accessibility.AccessibilityManager) IAccessibilityManager(android.view.accessibility.IAccessibilityManager) HiddenApi(org.robolectric.annotation.HiddenApi) Implementation(org.robolectric.annotation.Implementation)

Example 13 with AccessibilityManager

use of android.view.accessibility.AccessibilityManager in project platform_frameworks_base by android.

the class EnableAccessibilityController method isAccessibilityEnabled.

public static boolean isAccessibilityEnabled(Context context) {
    final AccessibilityManager accessibilityManager = context.getSystemService(AccessibilityManager.class);
    List enabledServices = accessibilityManager.getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_SPOKEN);
    return enabledServices != null && !enabledServices.isEmpty();
}
Also used : AccessibilityManager(android.view.accessibility.AccessibilityManager) IAccessibilityManager(android.view.accessibility.IAccessibilityManager) ArrayList(java.util.ArrayList) List(java.util.List)

Example 14 with AccessibilityManager

use of android.view.accessibility.AccessibilityManager in project platform_frameworks_base by android.

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 15 with AccessibilityManager

use of android.view.accessibility.AccessibilityManager in project platform_frameworks_base by android.

the class DevicePolicyManagerService method getAccessibilityManagerForUser.

private AccessibilityManager getAccessibilityManagerForUser(int userId) {
    // Not using AccessibilityManager.getInstance because that guesses
    // at the user you require based on callingUid and caches for a given
    // process.
    IBinder iBinder = ServiceManager.getService(Context.ACCESSIBILITY_SERVICE);
    IAccessibilityManager service = iBinder == null ? null : IAccessibilityManager.Stub.asInterface(iBinder);
    return new AccessibilityManager(mContext, service, userId);
}
Also used : IAccessibilityManager(android.view.accessibility.IAccessibilityManager) IBinder(android.os.IBinder) AccessibilityManager(android.view.accessibility.AccessibilityManager) IAccessibilityManager(android.view.accessibility.IAccessibilityManager)

Aggregations

AccessibilityManager (android.view.accessibility.AccessibilityManager)118 AccessibilityEvent (android.view.accessibility.AccessibilityEvent)47 IAccessibilityManager (android.view.accessibility.IAccessibilityManager)43 MediumTest (android.test.suitebuilder.annotation.MediumTest)20 AccessibilityServiceInfo (android.accessibilityservice.AccessibilityServiceInfo)18 ArrayList (java.util.ArrayList)12 AccessibilityNodeProvider (android.view.accessibility.AccessibilityNodeProvider)7 ITransientNotification (android.app.ITransientNotification)6 Notification (android.app.Notification)6 UserInfo (android.content.pm.UserInfo)6 StatusBarNotification (android.service.notification.StatusBarNotification)6 ParcelableString (com.android.internal.util.ParcelableString)6 SuppressLint (android.annotation.SuppressLint)5 ServiceInfo (android.content.pm.ServiceInfo)5 LargeTest (android.test.suitebuilder.annotation.LargeTest)5 Context (android.content.Context)4 AttachInfo (android.view.View.AttachInfo)4 IAccessibilityManagerClient (android.view.accessibility.IAccessibilityManagerClient)4 ApplicationInfo (android.content.pm.ApplicationInfo)3 Paint (android.graphics.Paint)3