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

Commit 8bfcac52 authored by Alex Johnston's avatar Alex Johnston Committed by Android (Google) Code Review
Browse files

Merge "Make getCredentialManagerPolicy user handle aware" into main

parents 3d505196 892ba1d6
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -10335,11 +10335,14 @@ public class DevicePolicyManager {
     * @return the current credential manager policy if null then this policy has not been
     * configured.
     */
    @UserHandleAware(
            enabledSinceTargetSdkVersion = UPSIDE_DOWN_CAKE,
            requiresPermissionIfNotCaller = INTERACT_ACROSS_USERS)
    public @Nullable PackagePolicy getCredentialManagerPolicy() {
        throwIfParentInstance("getCredentialManagerPolicy");
        if (mService != null) {
            try {
                return mService.getCredentialManagerPolicy();
                return mService.getCredentialManagerPolicy(myUserId());
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
+1 −1
Original line number Diff line number Diff line
@@ -346,7 +346,7 @@ interface IDevicePolicyManager {
    boolean hasManagedProfileCallerIdAccess(int userId, String packageName);

    void setCredentialManagerPolicy(in PackagePolicy policy);
    PackagePolicy getCredentialManagerPolicy();
    PackagePolicy getCredentialManagerPolicy(int userId);

    void setManagedProfileContactsAccessPolicy(in PackagePolicy policy);
    PackagePolicy getManagedProfileContactsAccessPolicy();
+6 −2
Original line number Diff line number Diff line
@@ -16017,16 +16017,20 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
    }
    @Override
    public PackagePolicy getCredentialManagerPolicy() {
    public PackagePolicy getCredentialManagerPolicy(int userId) {
        if (!mHasFeature) {
            return null;
        }
        final CallerIdentity caller = getCallerIdentity();
        Preconditions.checkCallAuthorization(
                canWriteCredentialManagerPolicy(caller) || canQueryAdminPolicy(caller));
        if (userId != caller.getUserId()) {
            Preconditions.checkCallAuthorization(
                    hasCallingOrSelfPermission(permission.INTERACT_ACROSS_USERS));
        }
        synchronized (getLockObject()) {
            ActiveAdmin admin = getProfileOwnerOrDeviceOwnerLocked(caller.getUserId());
            ActiveAdmin admin = getProfileOwnerOrDeviceOwnerLocked(userId);
            return (admin != null) ? admin.mCredentialManagerPolicy : null;
        }
    }