Search in sources :

Example 56 with AccessibilityServiceInfo

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

the class MockAccessibilityService method createDefaultInfo.

/**
     * Creates an {@link AccessibilityServiceInfo} populated with default
     * values.
     *
     * @return The default info.
     */
public static AccessibilityServiceInfo createDefaultInfo() {
    AccessibilityServiceInfo defaultInfo = new AccessibilityServiceInfo();
    defaultInfo.eventTypes = AccessibilityEvent.TYPE_ANNOUNCEMENT;
    defaultInfo.feedbackType = AccessibilityServiceInfo.FEEDBACK_AUDIBLE;
    defaultInfo.flags = 0;
    defaultInfo.notificationTimeout = 0;
    defaultInfo.packageNames = new String[] { "foo.bar.baz" };
    return defaultInfo;
}
Also used : AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo)

Example 57 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 58 with AccessibilityServiceInfo

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

the class EnableAccessibilityController method getInstalledSpeakingAccessibilityServiceComponent.

@Nullable
public static ComponentName getInstalledSpeakingAccessibilityServiceComponent(Context context) {
    List<AccessibilityServiceInfo> services = getInstalledSpeakingAccessibilityServices(context);
    if (services.isEmpty()) {
        return null;
    }
    ServiceInfo serviceInfo = services.get(0).getResolveInfo().serviceInfo;
    return new ComponentName(serviceInfo.packageName, serviceInfo.name);
}
Also used : AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) ServiceInfo(android.content.pm.ServiceInfo) AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) ComponentName(android.content.ComponentName) Nullable(android.annotation.Nullable)

Example 59 with AccessibilityServiceInfo

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

the class DevicePolicyManagerService method getPermittedAccessibilityServicesForUser.

@Override
public List getPermittedAccessibilityServicesForUser(int userId) {
    if (!mHasFeature) {
        return null;
    }
    synchronized (this) {
        List<String> result = null;
        // If we have multiple profiles we return the intersection of the
        // permitted lists. This can happen in cases where we have a device
        // and profile owner.
        int[] profileIds = mUserManager.getProfileIdsWithDisabled(userId);
        for (int profileId : profileIds) {
            // Just loop though all admins, only device or profiles
            // owners can have permitted lists set.
            DevicePolicyData policy = getUserDataUnchecked(profileId);
            final int N = policy.mAdminList.size();
            for (int j = 0; j < N; j++) {
                ActiveAdmin admin = policy.mAdminList.get(j);
                List<String> fromAdmin = admin.permittedAccessiblityServices;
                if (fromAdmin != null) {
                    if (result == null) {
                        result = new ArrayList<>(fromAdmin);
                    } else {
                        result.retainAll(fromAdmin);
                    }
                }
            }
        }
        // If we have a permitted list add all system accessibility services.
        if (result != null) {
            long id = mInjector.binderClearCallingIdentity();
            try {
                UserInfo user = getUserInfo(userId);
                if (user.isManagedProfile()) {
                    userId = user.profileGroupId;
                }
                AccessibilityManager accessibilityManager = getAccessibilityManagerForUser(userId);
                List<AccessibilityServiceInfo> installedServices = accessibilityManager.getInstalledAccessibilityServiceList();
                if (installedServices != null) {
                    for (AccessibilityServiceInfo service : installedServices) {
                        ServiceInfo serviceInfo = service.getResolveInfo().serviceInfo;
                        ApplicationInfo applicationInfo = serviceInfo.applicationInfo;
                        if ((applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
                            result.add(serviceInfo.packageName);
                        }
                    }
                }
            } finally {
                mInjector.binderRestoreCallingIdentity(id);
            }
        }
        return result;
    }
}
Also used : ApplicationInfo(android.content.pm.ApplicationInfo) UserInfo(android.content.pm.UserInfo) ParcelableString(com.android.internal.util.ParcelableString) AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) ServiceInfo(android.content.pm.ServiceInfo) AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) AccessibilityManager(android.view.accessibility.AccessibilityManager) IAccessibilityManager(android.view.accessibility.IAccessibilityManager)

Example 60 with AccessibilityServiceInfo

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

the class AccessibilityManagerService method getInstalledAccessibilityServiceList.

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

Aggregations

AccessibilityServiceInfo (android.accessibilityservice.AccessibilityServiceInfo)122 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)18 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