Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ec4f233d authored by Menghan Li's avatar Menghan Li Committed by Automerger Merge Worker
Browse files

Merge "Fix SecurityException when need permissions for...

Merge "Fix SecurityException when need permissions for AccessibilityServicesTest" into udc-dev am: d4e30692

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22119698



Change-Id: I3f1321b065f93bae8ade49146ee2351dc6666031
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents efc2f2c0 d4e30692
Loading
Loading
Loading
Loading
+20 −18
Original line number Diff line number Diff line
@@ -11780,22 +11780,9 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
        final CallerIdentity caller = getCallerIdentity();
        Preconditions.checkCallAuthorization(canManageUsers(caller) || canQueryAdminPolicy(caller));
        // Move AccessibilityManager out of lock to prevent potential deadlock
        final List<AccessibilityServiceInfo> installedServices;
        long id = mInjector.binderClearCallingIdentity();
        try {
            UserInfo user = getUserInfo(userId);
            if (user.isManagedProfile()) {
                userId = user.profileGroupId;
            }
            installedServices = withAccessibilityManager(userId,
                    AccessibilityManager::getInstalledAccessibilityServiceList);
        } finally {
            mInjector.binderRestoreCallingIdentity(id);
        }
        List<String> result = null;
        synchronized (getLockObject()) {
            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.
@@ -11817,9 +11804,22 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
                    }
                }
            }
        }
        // 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;
                }
                // Move AccessibilityManager out of {@link getLockObject} to prevent potential
                // deadlock.
                final List<AccessibilityServiceInfo> installedServices =
                        withAccessibilityManager(userId,
                                AccessibilityManager::getInstalledAccessibilityServiceList);
                if (installedServices != null) {
                    for (AccessibilityServiceInfo service : installedServices) {
                        ServiceInfo serviceInfo = service.getResolveInfo().serviceInfo;
@@ -11829,11 +11829,13 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
                        }
                    }
                }
            } finally {
                mInjector.binderRestoreCallingIdentity(id);
            }
        }
        return result;
    }
    }
    @Override
    public boolean isAccessibilityServicePermittedByAdmin(ComponentName who, String packageName,