Settings: Profiles inherit call restrictions
Currently, if Settings applies CALLS or SMS restrictions to a user, that
restriction doesn't propogate to its child profiles. It should.
This is actually a no-op right now, since it's not possible to have a
profile on a user that isn't the Admin user anyway. But one day such a
thing may be allowed, so this implementation is more future-proof and
safer.
Test: Manual verification that applying the restriction continues to
work properly a full user
Test: UserDetailsSettingsTest
Bug: 261469887
Change-Id: Ib19cecbd37b6efc90f9655565295e7856427f049
diff --git a/src/com/android/settings/users/UserDetailsSettings.java b/src/com/android/settings/users/UserDetailsSettings.java
index a758e34..a030d86 100644
--- a/src/com/android/settings/users/UserDetailsSettings.java
+++ b/src/com/android/settings/users/UserDetailsSettings.java
@@ -476,9 +476,12 @@
private void enableCallsAndSms(boolean enabled) {
mPhonePref.setChecked(enabled);
- UserHandle userHandle = UserHandle.of(mUserInfo.id);
- mUserManager.setUserRestriction(UserManager.DISALLOW_OUTGOING_CALLS, !enabled, userHandle);
- mUserManager.setUserRestriction(UserManager.DISALLOW_SMS, !enabled, userHandle);
+ int[] userProfiles = mUserManager.getProfileIdsWithDisabled(mUserInfo.id);
+ for (int userId : userProfiles) {
+ UserHandle user = UserHandle.of(userId);
+ mUserManager.setUserRestriction(UserManager.DISALLOW_OUTGOING_CALLS, !enabled, user);
+ mUserManager.setUserRestriction(UserManager.DISALLOW_SMS, !enabled, user);
+ }
}
/**