use of android.accessibilityservice.AccessibilityServiceInfo in project android_frameworks_base by crdroidandroid.
the class MockAccessibilityService method createDefaultInfo.
/**
* Creates an {@link AccessibilityServiceInfo} populated with default
* values.
*
* @return The default info.
*/
public static AccessibilityServiceInfo createDefaultInfo() {
AccessibilityServiceInfo defaultInfo = new AccessibilityServiceInfo();
defaultInfo.eventTypes = AccessibilityEvent.TYPE_ANNOUNCEMENT;
defaultInfo.feedbackType = AccessibilityServiceInfo.FEEDBACK_AUDIBLE;
defaultInfo.flags = 0;
defaultInfo.notificationTimeout = 0;
defaultInfo.packageNames = new String[] { "foo.bar.baz" };
return defaultInfo;
}
use of android.accessibilityservice.AccessibilityServiceInfo in project qianghongbao by lendylongli.
the class QiangHongBaoService method isRunning.
/**
* 判断当前服务是否正在运行
* */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public static boolean isRunning() {
if (service == null) {
return false;
}
AccessibilityManager accessibilityManager = (AccessibilityManager) service.getSystemService(Context.ACCESSIBILITY_SERVICE);
AccessibilityServiceInfo info = service.getServiceInfo();
if (info == null) {
return false;
}
List<AccessibilityServiceInfo> list = accessibilityManager.getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_GENERIC);
Iterator<AccessibilityServiceInfo> iterator = list.iterator();
boolean isConnect = false;
while (iterator.hasNext()) {
AccessibilityServiceInfo i = iterator.next();
if (i.getId().equals(info.getId())) {
isConnect = true;
break;
}
}
if (!isConnect) {
return false;
}
return true;
}
use of android.accessibilityservice.AccessibilityServiceInfo in project platform_frameworks_base by android.
the class EnableAccessibilityController method getInstalledSpeakingAccessibilityServiceComponent.
@Nullable
public static ComponentName getInstalledSpeakingAccessibilityServiceComponent(Context context) {
List<AccessibilityServiceInfo> services = getInstalledSpeakingAccessibilityServices(context);
if (services.isEmpty()) {
return null;
}
ServiceInfo serviceInfo = services.get(0).getResolveInfo().serviceInfo;
return new ComponentName(serviceInfo.packageName, serviceInfo.name);
}
use of android.accessibilityservice.AccessibilityServiceInfo in project platform_frameworks_base by android.
the class DevicePolicyManagerService method getPermittedAccessibilityServicesForUser.
@Override
public List getPermittedAccessibilityServicesForUser(int userId) {
if (!mHasFeature) {
return null;
}
synchronized (this) {
List<String> result = null;
// If we have multiple profiles we return the intersection of the
// permitted lists. This can happen in cases where we have a device
// and profile owner.
int[] profileIds = mUserManager.getProfileIdsWithDisabled(userId);
for (int profileId : profileIds) {
// Just loop though all admins, only device or profiles
// owners can have permitted lists set.
DevicePolicyData policy = getUserDataUnchecked(profileId);
final int N = policy.mAdminList.size();
for (int j = 0; j < N; j++) {
ActiveAdmin admin = policy.mAdminList.get(j);
List<String> fromAdmin = admin.permittedAccessiblityServices;
if (fromAdmin != null) {
if (result == null) {
result = new ArrayList<>(fromAdmin);
} else {
result.retainAll(fromAdmin);
}
}
}
}
// If we have a permitted list add all system accessibility services.
if (result != null) {
long id = mInjector.binderClearCallingIdentity();
try {
UserInfo user = getUserInfo(userId);
if (user.isManagedProfile()) {
userId = user.profileGroupId;
}
AccessibilityManager accessibilityManager = getAccessibilityManagerForUser(userId);
List<AccessibilityServiceInfo> installedServices = accessibilityManager.getInstalledAccessibilityServiceList();
if (installedServices != null) {
for (AccessibilityServiceInfo service : installedServices) {
ServiceInfo serviceInfo = service.getResolveInfo().serviceInfo;
ApplicationInfo applicationInfo = serviceInfo.applicationInfo;
if ((applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
result.add(serviceInfo.packageName);
}
}
}
} finally {
mInjector.binderRestoreCallingIdentity(id);
}
}
return result;
}
}
use of android.accessibilityservice.AccessibilityServiceInfo in project platform_frameworks_base by android.
the class AccessibilityManagerService method getInstalledAccessibilityServiceList.
@Override
public List<AccessibilityServiceInfo> getInstalledAccessibilityServiceList(int userId) {
synchronized (mLock) {
// We treat calls from a profile as if made by its parent as profiles
// share the accessibility state of the parent. The call below
// performs the current profile parent resolution.
final int resolvedUserId = mSecurityPolicy.resolveCallingUserIdEnforcingPermissionsLocked(userId);
// The automation service is a fake one and should not be reported
// to clients as being installed - it really is not.
UserState userState = getUserStateLocked(resolvedUserId);
if (userState.mUiAutomationService != null) {
List<AccessibilityServiceInfo> installedServices = new ArrayList<>();
installedServices.addAll(userState.mInstalledServices);
installedServices.remove(userState.mUiAutomationService.mAccessibilityServiceInfo);
return installedServices;
}
return userState.mInstalledServices;
}
}
Aggregations