Throw exception if can't set default sms app on profile
Only allow settting default sms app on work profile, if all the subscriptions on the device are managed(TYPE_ALL_MANAGED_SUBSCRIPTIONS) Bug: 279560135 Test: atest android.devicepolicy.cts.DefaultSmsApplicationTest Change-Id: I3a96855f525a22f27e4ac95fd20d6a9206e1ccac
This commit is contained in:
@@ -9862,6 +9862,9 @@ public class DevicePolicyManager {
|
||||
* profile owner of an organization-owned managed profile.
|
||||
* @throws IllegalArgumentException if called on the parent profile and the package
|
||||
* provided is not a pre-installed system package.
|
||||
* @throws IllegalStateException while trying to set default sms app on the profile and
|
||||
* {@link ManagedSubscriptionsPolicy#TYPE_ALL_MANAGED_SUBSCRIPTIONS}
|
||||
* policy is not set.
|
||||
*/
|
||||
@RequiresPermission(value = MANAGE_DEVICE_POLICY_DEFAULT_SMS, conditional = true)
|
||||
public void setDefaultSmsApplication(@Nullable ComponentName admin,
|
||||
|
||||
@@ -11564,6 +11564,15 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
|
||||
Preconditions.checkCallAuthorization(isDefaultDeviceOwner(caller)
|
||||
|| isProfileOwnerOfOrganizationOwnedDevice(caller));
|
||||
}
|
||||
|
||||
if (!parent && isManagedProfile(caller.getUserId())
|
||||
&& getManagedSubscriptionsPolicy().getPolicyType()
|
||||
!= ManagedSubscriptionsPolicy.TYPE_ALL_MANAGED_SUBSCRIPTIONS) {
|
||||
throw new IllegalStateException(
|
||||
"Default sms application can only be set on the profile, when "
|
||||
+ "ManagedSubscriptions policy is set");
|
||||
}
|
||||
|
||||
if (parent) {
|
||||
userId = getProfileParentId(mInjector.userHandleGetCallingUserId());
|
||||
mInjector.binderWithCleanCallingIdentity(() -> enforcePackageIsSystemPackage(
|
||||
|
||||
Reference in New Issue
Block a user