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

Commit 84bc8a91 authored by Adam Bookatz's avatar Adam Bookatz
Browse files

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
parent 5fa73d14
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -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);
        }
    }

    /**