Search in sources :

Example 71 with AccessibilityServiceInfo

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;
}
Also used : AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) AccessibilityService(android.accessibilityservice.AccessibilityService) IStatusBarService(com.android.internal.statusbar.IStatusBarService) Point(android.graphics.Point)

Example 72 with AccessibilityServiceInfo

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

Example 73 with AccessibilityServiceInfo

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

Example 74 with AccessibilityServiceInfo

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);
}
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 75 with AccessibilityServiceInfo

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;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) ComponentName(android.content.ComponentName) HashSet(java.util.HashSet)

Aggregations

AccessibilityServiceInfo (android.accessibilityservice.AccessibilityServiceInfo)123 ComponentName (android.content.ComponentName)30 Point (android.graphics.Point)30 ServiceInfo (android.content.pm.ServiceInfo)29 ArrayList (java.util.ArrayList)26 LargeTest (android.test.suitebuilder.annotation.LargeTest)25 ResolveInfo (android.content.pm.ResolveInfo)20 AccessibilityEvent (android.view.accessibility.AccessibilityEvent)20 AccessibilityManager (android.view.accessibility.AccessibilityManager)19 IAccessibilityManager (android.view.accessibility.IAccessibilityManager)17 AccessibilityService (android.accessibilityservice.AccessibilityService)13 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)13 RemoteException (android.os.RemoteException)7 PendingIntent (android.app.PendingIntent)6 Intent (android.content.Intent)6 UserInfo (android.content.pm.UserInfo)6 ParcelableString (com.android.internal.util.ParcelableString)6 IOException (java.io.IOException)6 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)6 UserManager (android.os.UserManager)5