Search in sources :

Example 61 with AccessibilityServiceInfo

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

the class AccessibilityManagerService method getEnabledAccessibilityServiceList.

@Override
public List<AccessibilityServiceInfo> getEnabledAccessibilityServiceList(int feedbackType, int userId) {
    List<AccessibilityServiceInfo> result = null;
    synchronized (mLock) {
        // We treat calls from a profile as if made by its parent as profiles
        // share the accessibility state of the parent. The call below
        // performs the current profile parent resolution.
        final int resolvedUserId = mSecurityPolicy.resolveCallingUserIdEnforcingPermissionsLocked(userId);
        // The automation service can suppress other services.
        UserState userState = getUserStateLocked(resolvedUserId);
        if (userState.isUiAutomationSuppressingOtherServices()) {
            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);
                // Don't report the UIAutomation (fake service)
                if (!sFakeAccessibilityServiceComponentName.equals(service.mComponentName) && (service.mFeedbackType & feedbackTypeBit) != 0) {
                    result.add(service.mAccessibilityServiceInfo);
                }
            }
        }
    }
    return result;
}
Also used : AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) AccessibilityService(android.accessibilityservice.AccessibilityService) Point(android.graphics.Point)

Example 62 with AccessibilityServiceInfo

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

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 | PackageManager.MATCH_DISABLED_UNTIL_USED_COMPONENTS | PackageManager.MATCH_DIRECT_BOOT_AWARE | PackageManager.MATCH_DIRECT_BOOT_UNAWARE, 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 | IOException xppe) {
            Slog.e(LOG_TAG, "Error while initializing AccessibilityServiceInfo", xppe);
        }
    }
    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)

Example 63 with AccessibilityServiceInfo

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

the class AccessibilityManagerService method updateServicesLocked.

private void updateServicesLocked(UserState userState) {
    Map<ComponentName, Service> componentNameToServiceMap = userState.mComponentNameToServiceMap;
    boolean isUnlockingOrUnlocked = mContext.getSystemService(UserManager.class).isUserUnlockingOrUnlocked(userState.mUserId);
    for (int i = 0, count = userState.mInstalledServices.size(); i < count; i++) {
        AccessibilityServiceInfo installedService = userState.mInstalledServices.get(i);
        ComponentName componentName = ComponentName.unflattenFromString(installedService.getId());
        Service service = componentNameToServiceMap.get(componentName);
        // Ignore non-encryption-aware services until user is unlocked
        if (!isUnlockingOrUnlocked && !installedService.isDirectBootAware()) {
            Slog.d(LOG_TAG, "Ignoring non-encryption-aware service " + componentName);
            continue;
        }
        // Wait for the binding if it is in process.
        if (userState.mBindingServices.contains(componentName)) {
            continue;
        }
        if (userState.mEnabledServices.contains(componentName)) {
            if (service == null) {
                service = new Service(userState.mUserId, componentName, installedService);
            } else if (userState.mBoundServices.contains(service)) {
                continue;
            }
            service.bindLocked();
        } else {
            if (service != null) {
                service.unbindLocked();
            }
        }
    }
    updateAccessibilityEnabledSetting(userState);
}
Also used : AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) UserManager(android.os.UserManager) AccessibilityService(android.accessibilityservice.AccessibilityService) ComponentName(android.content.ComponentName) Point(android.graphics.Point)

Example 64 with AccessibilityServiceInfo

use of android.accessibilityservice.AccessibilityServiceInfo in project qianghongbao by lendylongli.

the class QiangHongBaoService method isRunning.

/**
     * 判断当前服务是否正在运行
     * */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public static boolean isRunning() {
    if (service == null) {
        return false;
    }
    AccessibilityManager accessibilityManager = (AccessibilityManager) service.getSystemService(Context.ACCESSIBILITY_SERVICE);
    AccessibilityServiceInfo info = service.getServiceInfo();
    if (info == null) {
        return false;
    }
    List<AccessibilityServiceInfo> list = accessibilityManager.getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_GENERIC);
    Iterator<AccessibilityServiceInfo> iterator = list.iterator();
    boolean isConnect = false;
    while (iterator.hasNext()) {
        AccessibilityServiceInfo i = iterator.next();
        if (i.getId().equals(info.getId())) {
            isConnect = true;
            break;
        }
    }
    if (!isConnect) {
        return false;
    }
    return true;
}
Also used : AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) AccessibilityManager(android.view.accessibility.AccessibilityManager) TargetApi(android.annotation.TargetApi)

Example 65 with AccessibilityServiceInfo

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

the class UiAutomationShellWrapper method setCompressedLayoutHierarchy.

public void setCompressedLayoutHierarchy(boolean compressed) {
    AccessibilityServiceInfo info = mUiAutomation.getServiceInfo();
    if (compressed)
        info.flags &= ~AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS;
    else
        info.flags |= AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS;
    mUiAutomation.setServiceInfo(info);
}
Also used : AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo)

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