use of android.accessibilityservice.AccessibilityServiceInfo in project android_frameworks_base by ParanoidAndroid.
the class AccessibilityManagerService method getEnabledAccessibilityServiceList.
public List<AccessibilityServiceInfo> getEnabledAccessibilityServiceList(int feedbackType, int userId) {
List<AccessibilityServiceInfo> result = null;
synchronized (mLock) {
final int resolvedUserId = mSecurityPolicy.resolveCallingUserIdEnforcingPermissionsLocked(userId);
// The automation service is a fake one and should not be reported
// to clients as being enabled. The automation service is always the
// only active one, if it exists.
UserState userState = getUserStateLocked(resolvedUserId);
if (userState.mUiAutomationService != null) {
return Collections.emptyList();
}
result = mEnabledServicesForFeedbackTempList;
result.clear();
List<Service> services = userState.mBoundServices;
while (feedbackType != 0) {
final int feedbackTypeBit = (1 << Integer.numberOfTrailingZeros(feedbackType));
feedbackType &= ~feedbackTypeBit;
final int serviceCount = services.size();
for (int i = 0; i < serviceCount; i++) {
Service service = services.get(i);
if ((service.mFeedbackType & feedbackTypeBit) != 0) {
result.add(service.mAccessibilityServiceInfo);
}
}
}
}
return result;
}
use of android.accessibilityservice.AccessibilityServiceInfo in project android_frameworks_base by ParanoidAndroid.
the class AccessibilityManagerServiceTest method testGetAccessibilityServicesList.
@LargeTest
public void testGetAccessibilityServicesList() throws Exception {
boolean firstMockServiceInstalled = false;
boolean secondMockServiceInstalled = false;
String packageName = getContext().getPackageName();
String firstMockServiceClassName = MyFirstMockAccessibilityService.class.getName();
String secondMockServiceClassName = MySecondMockAccessibilityService.class.getName();
// look for the two mock services
for (AccessibilityServiceInfo info : mManagerService.getInstalledAccessibilityServiceList(UserHandle.USER_OWNER)) {
ServiceInfo serviceInfo = info.getResolveInfo().serviceInfo;
if (packageName.equals(serviceInfo.packageName)) {
if (firstMockServiceClassName.equals(serviceInfo.name)) {
firstMockServiceInstalled = true;
} else if (secondMockServiceClassName.equals(serviceInfo.name)) {
secondMockServiceInstalled = true;
}
}
}
// check expected result
assertTrue("First mock service must be installed", firstMockServiceInstalled);
assertTrue("Second mock service must be installed", secondMockServiceInstalled);
}
use of android.accessibilityservice.AccessibilityServiceInfo in project android_frameworks_base by ParanoidAndroid.
the class AccessibilityManagerServiceTest method testSendAccessibilityEvent_TwoServices_MatchingPackageAndEventType_DiffFeedback.
@LargeTest
public void testSendAccessibilityEvent_TwoServices_MatchingPackageAndEventType_DiffFeedback() throws Exception {
// set the accessibility setting value
ensureAccessibilityEnabled(mContext, true);
// enable the mock accessibility services
ensureOnlyMockServicesEnabled(mContext, true, true);
// configure the first mock service
MockAccessibilityService firstService = MyFirstMockAccessibilityService.sInstance;
AccessibilityServiceInfo firstInfo = MockAccessibilityService.createDefaultInfo();
firstInfo.feedbackType = AccessibilityServiceInfo.FEEDBACK_AUDIBLE;
firstService.setServiceInfo(firstInfo);
// configure the second mock service
MockAccessibilityService secondService = MySecondMockAccessibilityService.sInstance;
AccessibilityServiceInfo secondInfo = MockAccessibilityService.createDefaultInfo();
secondInfo.feedbackType = AccessibilityServiceInfo.FEEDBACK_HAPTIC;
secondService.setServiceInfo(secondInfo);
// wait for the binder calls to #setService to complete
Thread.sleep(TIMEOUT_BINDER_CALL);
// create and populate an event to be sent
AccessibilityEvent sentEvent = AccessibilityEvent.obtain();
fullyPopulateDefaultAccessibilityEvent(sentEvent);
// set expectations for the first mock service
firstService.expectEvent(sentEvent);
firstService.replay();
// set expectations for the second mock service
secondService.expectEvent(sentEvent);
secondService.replay();
// send the event
mManagerService.sendAccessibilityEvent(sentEvent, UserHandle.USER_OWNER);
// verify if all expected methods have been called
assertMockServiceVerifiedWithinTimeout(firstService);
assertMockServiceVerifiedWithinTimeout(secondService);
}
use of android.accessibilityservice.AccessibilityServiceInfo in project android_frameworks_base by ParanoidAndroid.
the class AccessibilityManager method getAccessibilityServiceList.
/**
* Returns the {@link ServiceInfo}s of the installed accessibility services.
*
* @return An unmodifiable list with {@link ServiceInfo}s.
*
* @deprecated Use {@link #getInstalledAccessibilityServiceList()}
*/
@Deprecated
public List<ServiceInfo> getAccessibilityServiceList() {
List<AccessibilityServiceInfo> infos = getInstalledAccessibilityServiceList();
List<ServiceInfo> services = new ArrayList<ServiceInfo>();
final int infoCount = infos.size();
for (int i = 0; i < infoCount; i++) {
AccessibilityServiceInfo info = infos.get(i);
services.add(info.getResolveInfo().serviceInfo);
}
return Collections.unmodifiableList(services);
}
use of android.accessibilityservice.AccessibilityServiceInfo in project platform_frameworks_base by android.
the class AccessibilityUtils method getInstalledServices.
private static Set<ComponentName> getInstalledServices(Context context) {
final Set<ComponentName> installedServices = new HashSet<>();
installedServices.clear();
final List<AccessibilityServiceInfo> installedServiceInfos = AccessibilityManager.getInstance(context).getInstalledAccessibilityServiceList();
if (installedServiceInfos == null) {
return installedServices;
}
for (final AccessibilityServiceInfo info : installedServiceInfos) {
final ResolveInfo resolveInfo = info.getResolveInfo();
final ComponentName installedService = new ComponentName(resolveInfo.serviceInfo.packageName, resolveInfo.serviceInfo.name);
installedServices.add(installedService);
}
return installedServices;
}
Aggregations