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();
}
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;
}
}
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();
}
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;
}
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);
}
Aggregations