Search in sources :

Example 66 with AccessibilityServiceInfo

use of android.accessibilityservice.AccessibilityServiceInfo in project platform_frameworks_base by android.

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 67 with AccessibilityServiceInfo

use of android.accessibilityservice.AccessibilityServiceInfo in project AndroidChromium by JackyAndroid.

the class AccessibilityUtil method showWarningIfOldTalkbackRunning.

/**
     * Checks to see if an old version of TalkBack is running that Chrome doesn't support,
     * and if so, shows an alert dialog prompting the user to update the app.
     * @param context A {@link Context} instance.
     * @return        True if the dialog was shown.
     */
public static boolean showWarningIfOldTalkbackRunning(Context context) {
    AccessibilityManager manager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
    if (manager == null)
        return false;
    boolean isTalkbackRunning = false;
    try {
        List<AccessibilityServiceInfo> services = manager.getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_SPOKEN);
        for (AccessibilityServiceInfo service : services) {
            if (service.getId().contains(TALKBACK_PACKAGE_NAME))
                isTalkbackRunning = true;
        }
    } catch (NullPointerException e) {
    // getEnabledAccessibilityServiceList() can throw an NPE due to a bad
    // AccessibilityService.
    }
    if (!isTalkbackRunning)
        return false;
    if (PackageUtils.getPackageVersion(context, TALKBACK_PACKAGE_NAME) < MIN_TALKBACK_VERSION && !sOldTalkBackVersionAlertShown) {
        showOldTalkbackVersionAlertOnce(context);
        return true;
    }
    return false;
}
Also used : AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) AccessibilityManager(android.view.accessibility.AccessibilityManager)

Example 68 with AccessibilityServiceInfo

use of android.accessibilityservice.AccessibilityServiceInfo in project android_frameworks_base by ParanoidAndroid.

the class EnableAccessibilityController method getInstalledSpeakingAccessibilityServices.

private static List<AccessibilityServiceInfo> getInstalledSpeakingAccessibilityServices(Context context) {
    List<AccessibilityServiceInfo> services = new ArrayList<AccessibilityServiceInfo>();
    services.addAll(AccessibilityManager.getInstance(context).getInstalledAccessibilityServiceList());
    Iterator<AccessibilityServiceInfo> iterator = services.iterator();
    while (iterator.hasNext()) {
        AccessibilityServiceInfo service = iterator.next();
        if ((service.feedbackType & AccessibilityServiceInfo.FEEDBACK_SPOKEN) == 0) {
            iterator.remove();
        }
    }
    return services;
}
Also used : AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) ArrayList(java.util.ArrayList)

Example 69 with AccessibilityServiceInfo

use of android.accessibilityservice.AccessibilityServiceInfo in project android_frameworks_base by ParanoidAndroid.

the class AccessibilityManagerService method getInstalledAccessibilityServiceList.

public List<AccessibilityServiceInfo> getInstalledAccessibilityServiceList(int userId) {
    synchronized (mLock) {
        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<AccessibilityServiceInfo>();
            installedServices.addAll(userState.mInstalledServices);
            installedServices.remove(userState.mUiAutomationService);
            return installedServices;
        }
        return userState.mInstalledServices;
    }
}
Also used : AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) Point(android.graphics.Point)

Example 70 with AccessibilityServiceInfo

use of android.accessibilityservice.AccessibilityServiceInfo in project android_frameworks_base by ParanoidAndroid.

the class AccessibilityManagerService method readInstalledAccessibilityServiceLocked.

private boolean readInstalledAccessibilityServiceLocked(UserState userState) {
    mTempAccessibilityServiceInfoList.clear();
    List<ResolveInfo> installedServices = mPackageManager.queryIntentServicesAsUser(new Intent(AccessibilityService.SERVICE_INTERFACE), PackageManager.GET_SERVICES | PackageManager.GET_META_DATA, mCurrentUserId);
    for (int i = 0, count = installedServices.size(); i < count; i++) {
        ResolveInfo resolveInfo = installedServices.get(i);
        ServiceInfo serviceInfo = resolveInfo.serviceInfo;
        if (!android.Manifest.permission.BIND_ACCESSIBILITY_SERVICE.equals(serviceInfo.permission)) {
            Slog.w(LOG_TAG, "Skipping accessibilty service " + new ComponentName(serviceInfo.packageName, serviceInfo.name).flattenToShortString() + ": it does not require the permission " + android.Manifest.permission.BIND_ACCESSIBILITY_SERVICE);
            continue;
        }
        AccessibilityServiceInfo accessibilityServiceInfo;
        try {
            accessibilityServiceInfo = new AccessibilityServiceInfo(resolveInfo, mContext);
            mTempAccessibilityServiceInfoList.add(accessibilityServiceInfo);
        } catch (XmlPullParserException xppe) {
            Slog.e(LOG_TAG, "Error while initializing AccessibilityServiceInfo", xppe);
        } catch (IOException ioe) {
            Slog.e(LOG_TAG, "Error while initializing AccessibilityServiceInfo", ioe);
        }
    }
    if (!mTempAccessibilityServiceInfoList.equals(userState.mInstalledServices)) {
        userState.mInstalledServices.clear();
        userState.mInstalledServices.addAll(mTempAccessibilityServiceInfoList);
        mTempAccessibilityServiceInfoList.clear();
        return true;
    }
    mTempAccessibilityServiceInfoList.clear();
    return false;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) ServiceInfo(android.content.pm.ServiceInfo) AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) ComponentName(android.content.ComponentName) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) IOException(java.io.IOException) Point(android.graphics.Point)

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