use of android.accessibilityservice.AccessibilityServiceInfo in project android_frameworks_base by DirtyUnicorns.
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_CURRENT)) {
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 DirtyUnicorns.
the class AccessibilityManagerServiceTest method testSendAccessibilityEvent_OneService_NotifivationAfterTimeout.
@LargeTest
public void testSendAccessibilityEvent_OneService_NotifivationAfterTimeout() throws Exception {
// enable the mock accessibility service
ensureOnlyMockServicesEnabled(mContext, true, false);
// set the accessibility setting value
ensureAccessibilityEnabled(mContext, true);
// configure the mock service
MockAccessibilityService service = MyFirstMockAccessibilityService.sInstance;
AccessibilityServiceInfo info = MockAccessibilityService.createDefaultInfo();
info.notificationTimeout = TIMEOUT_TEST_NOTIFICATION_TIMEOUT;
service.setServiceInfo(info);
// wait for the binder call to #setService to complete
Thread.sleep(TIMEOUT_BINDER_CALL);
// create and populate the first event to be sent
AccessibilityEvent firstEvent = AccessibilityEvent.obtain();
fullyPopulateDefaultAccessibilityEvent(firstEvent);
// create and populate the second event to be sent
AccessibilityEvent secondEvent = AccessibilityEvent.obtain();
fullyPopulateDefaultAccessibilityEvent(secondEvent);
// set expectations
service.expectEvent(secondEvent);
service.replay();
// send the events
mManagerService.sendAccessibilityEvent(firstEvent, UserHandle.USER_CURRENT);
mManagerService.sendAccessibilityEvent(secondEvent, UserHandle.USER_CURRENT);
// wait for #sendAccessibilityEvent to reach the backing service
Thread.sleep(TIMEOUT_BINDER_CALL);
try {
service.verify();
fail("No events must be dispatched before the expiration of the notification timeout.");
} catch (IllegalStateException ise) {
/* expected */
}
// wait for the configured notification timeout to expire
Thread.sleep(TIMEOUT_TEST_NOTIFICATION_TIMEOUT);
// verify if all expected methods have been called
assertMockServiceVerifiedWithinTimeout(service);
}
use of android.accessibilityservice.AccessibilityServiceInfo in project android_frameworks_base by DirtyUnicorns.
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<>();
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 android_frameworks_base by ParanoidAndroid.
the class WebViewClassic method isAccessibilityInjectionEnabled.
private boolean isAccessibilityInjectionEnabled() {
final AccessibilityManager manager = AccessibilityManager.getInstance(mContext);
if (!manager.isEnabled()) {
return false;
}
// Accessibility scripts should be injected only when a speaking service
// is enabled. This may need to change later to accommodate Braille.
final List<AccessibilityServiceInfo> services = manager.getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_SPOKEN);
if (services.isEmpty()) {
return false;
}
return true;
}
use of android.accessibilityservice.AccessibilityServiceInfo in project kcanotify by antest1.
the class WindowChangeDetectingService method onServiceConnected.
@Override
protected void onServiceConnected() {
super.onServiceConnected();
//Configure these here for compatibility with API 13 and below.
AccessibilityServiceInfo config = new AccessibilityServiceInfo();
config.eventTypes = AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED;
config.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC;
if (Build.VERSION.SDK_INT >= 16)
//Just in case this helps
config.flags = AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS;
setServiceInfo(config);
}
Aggregations