diff options
3 files changed, 23 insertions, 18 deletions
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java index a331b404047b..024141777604 100644 --- a/core/java/android/app/admin/DevicePolicyManager.java +++ b/core/java/android/app/admin/DevicePolicyManager.java @@ -5462,7 +5462,8 @@ public class DevicePolicyManager { public boolean isActivePasswordSufficient() { if (mService != null) { try { - return mService.isActivePasswordSufficient(myUserId(), mParentInstance); + return mService.isActivePasswordSufficient( + mContext.getPackageName(), myUserId(), mParentInstance); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -5619,7 +5620,8 @@ public class DevicePolicyManager { } try { - return mService.getRequiredPasswordComplexity(mParentInstance); + return mService.getRequiredPasswordComplexity( + mContext.getPackageName(), mParentInstance); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -5743,7 +5745,8 @@ public class DevicePolicyManager { public int getCurrentFailedPasswordAttempts(int userHandle) { if (mService != null) { try { - return mService.getCurrentFailedPasswordAttempts(userHandle, mParentInstance); + return mService.getCurrentFailedPasswordAttempts( + mContext.getPackageName(), userHandle, mParentInstance); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -16643,7 +16646,7 @@ public class DevicePolicyManager { return null; } try { - return mService.getWifiSsidPolicy(); + return mService.getWifiSsidPolicy(mContext.getPackageName()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl index 3a75da340745..51aff9ef71ba 100644 --- a/core/java/android/app/admin/IDevicePolicyManager.aidl +++ b/core/java/android/app/admin/IDevicePolicyManager.aidl @@ -96,15 +96,15 @@ interface IDevicePolicyManager { long getPasswordExpiration(in ComponentName who, int userHandle, boolean parent); - boolean isActivePasswordSufficient(int userHandle, boolean parent); + boolean isActivePasswordSufficient(String callerPackageName, int userHandle, boolean parent); boolean isActivePasswordSufficientForDeviceRequirement(); boolean isPasswordSufficientAfterProfileUnification(int userHandle, int profileUser); int getPasswordComplexity(boolean parent); void setRequiredPasswordComplexity(String callerPackageName, int passwordComplexity, boolean parent); - int getRequiredPasswordComplexity(boolean parent); + int getRequiredPasswordComplexity(String callerPackageName, boolean parent); int getAggregatedPasswordComplexityForUser(int userId, boolean deviceWideOnly); boolean isUsingUnifiedPassword(in ComponentName admin); - int getCurrentFailedPasswordAttempts(int userHandle, boolean parent); + int getCurrentFailedPasswordAttempts(String callerPackageName, int userHandle, boolean parent); int getProfileWithMinimumFailedPasswordsForWipe(int userHandle, boolean parent); void setMaximumFailedPasswordsForWipe( @@ -572,7 +572,7 @@ interface IDevicePolicyManager { int getMinimumRequiredWifiSecurityLevel(); void setWifiSsidPolicy(String callerPackageName, in WifiSsidPolicy policy); - WifiSsidPolicy getWifiSsidPolicy(); + WifiSsidPolicy getWifiSsidPolicy(String callerPackageName); List<UserHandle> listForegroundAffiliatedUsers(); void setDrawables(in List<DevicePolicyDrawableResource> drawables); diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index 821a5f667b7b..5535eb6848d9 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -5010,7 +5010,8 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } @Override - public boolean isActivePasswordSufficient(int userHandle, boolean parent) { + public boolean isActivePasswordSufficient( + String callerPackageName, int userHandle, boolean parent) { if (!mHasFeature) { return true; } @@ -5024,7 +5025,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { if (isPermissionCheckFlagEnabled()) { int affectedUser = parent ? getProfileParentId(userHandle) : userHandle; enforcePermission(MANAGE_DEVICE_POLICY_LOCK_CREDENTIALS, - /*callerPackageName=*/ null, affectedUser); + callerPackageName, affectedUser); } else { // This API can only be called by an active device admin, // so try to retrieve it to check that the caller is one. @@ -5305,7 +5306,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } @Override - public int getRequiredPasswordComplexity(boolean calledOnParent) { + public int getRequiredPasswordComplexity(String callerPackageName, boolean calledOnParent) { if (!mHasFeature) { return PASSWORD_COMPLEXITY_NONE; } @@ -5316,7 +5317,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { int affectedUser = calledOnParent ? getProfileParentId(caller.getUserId()) : caller.getUserId(); enforcePermission(MANAGE_DEVICE_POLICY_LOCK_CREDENTIALS, - /*callerPackageName=*/ null, affectedUser); + callerPackageName, affectedUser); } else { Preconditions.checkCallAuthorization( isDefaultDeviceOwner(caller) || isProfileOwner(caller)); @@ -5347,7 +5348,8 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { @Override - public int getCurrentFailedPasswordAttempts(int userHandle, boolean parent) { + public int getCurrentFailedPasswordAttempts( + String callerPackageName, int userHandle, boolean parent) { if (!mLockPatternUtils.hasSecureLockScreen()) { return 0; } @@ -5363,7 +5365,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { if (isPermissionCheckFlagEnabled()) { int affectedUser = parent ? getProfileParentId(userHandle) : userHandle; enforcePermission(MANAGE_DEVICE_POLICY_LOCK_CREDENTIALS, - /*callerPackageName=*/ null, affectedUser); + callerPackageName, affectedUser); } else { getActiveAdminForCallerLocked( null, DeviceAdminInfo.USES_POLICY_WATCH_LOGIN, parent); @@ -14198,7 +14200,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { mDevicePolicyEngine.setLocalPolicy( PolicyDefinition.LOCK_TASK, - EnforcingAdmin.createEnterpriseEnforcingAdmin(who, caller.getUserId()), + enforcingAdmin, policy, caller.getUserId()); } @@ -14549,7 +14551,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } CallerIdentity caller = getCallerIdentity(who); if (isPermissionCheckFlagEnabled()) { - enforcePermission(MANAGE_DEVICE_POLICY_WIFI, /*callerPackageName=*/ null, + enforcePermission(MANAGE_DEVICE_POLICY_WIFI, who.getPackageName(), UserHandle.USER_ALL); } else { Preconditions.checkNotNull(who, "ComponentName is null"); @@ -21435,10 +21437,10 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } @Override - public WifiSsidPolicy getWifiSsidPolicy() { + public WifiSsidPolicy getWifiSsidPolicy(String callerPackageName) { final CallerIdentity caller = getCallerIdentity(); if (isPermissionCheckFlagEnabled()) { - enforcePermission(MANAGE_DEVICE_POLICY_WIFI, /*callerPackageName=*/ null, + enforcePermission(MANAGE_DEVICE_POLICY_WIFI, callerPackageName, caller.getUserId()); } else { Preconditions.checkCallAuthorization( |