Search in sources :

Example 31 with AccessibilityServiceInfo

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);
}
Also used : AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) ServiceInfo(android.content.pm.ServiceInfo) AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 32 with AccessibilityServiceInfo

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);
}
Also used : AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) AccessibilityEvent(android.view.accessibility.AccessibilityEvent) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 33 with AccessibilityServiceInfo

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);
}
Also used : AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) ServiceInfo(android.content.pm.ServiceInfo) AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList)

Example 34 with AccessibilityServiceInfo

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;
}
Also used : AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) AccessibilityManager(android.view.accessibility.AccessibilityManager)

Example 35 with AccessibilityServiceInfo

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);
}
Also used : AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo)

Aggregations

AccessibilityServiceInfo (android.accessibilityservice.AccessibilityServiceInfo)210 ServiceInfo (android.content.pm.ServiceInfo)69 ComponentName (android.content.ComponentName)64 AccessibilityManager (android.view.accessibility.AccessibilityManager)54 ArrayList (java.util.ArrayList)50 ResolveInfo (android.content.pm.ResolveInfo)45 Point (android.graphics.Point)30 LargeTest (android.test.suitebuilder.annotation.LargeTest)25 AccessibilityEvent (android.view.accessibility.AccessibilityEvent)20 Bundle (android.os.Bundle)17 IAccessibilityManager (android.view.accessibility.IAccessibilityManager)17 AccessibilityService (android.accessibilityservice.AccessibilityService)13 Drawable (android.graphics.drawable.Drawable)13 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)13 Intent (android.content.Intent)12 HashSet (java.util.HashSet)12 RemoteException (android.os.RemoteException)9 EnforcedAdmin (com.android.settingslib.RestrictedLockUtils.EnforcedAdmin)8 RestrictedPreference (com.android.settingslib.RestrictedPreference)8 IOException (java.io.IOException)8