From 84bc8a918d8ae9c261dbe4b24fffab6dfd4f61ae Mon Sep 17 00:00:00 2001 From: Adam Bookatz Date: Wed, 31 Jan 2024 13:20:07 -0800 Subject: [PATCH] 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 --- src/com/android/settings/users/UserDetailsSettings.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/com/android/settings/users/UserDetailsSettings.java b/src/com/android/settings/users/UserDetailsSettings.java index a758e345325..a030d865a8b 100644 --- a/src/com/android/settings/users/UserDetailsSettings.java +++ b/src/com/android/settings/users/UserDetailsSettings.java @@ -476,9 +476,12 @@ public class UserDetailsSettings extends SettingsPreferenceFragment 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); + } } /**