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

Commit 49d5a01e authored by Fyodor Kupolov's avatar Fyodor Kupolov
Browse files

Check VPN status when adding/removing restricted profiles

Restricted profiles are tied to a VPN of the parent user. addVpnUserLocked/
removeVpnUserLocked should not be called for restricted profiles when VPN
is not active, because they will throw an exception.

Bug: 27296721
Change-Id: Ifcfaa85c12fbca1bbad81217c2f0d07a79347547
parent c9f0a110
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -718,7 +718,8 @@ public class Vpn {
    public void onUserAdded(int userHandle) {
        // If the user is restricted tie them to the parent user's VPN
        UserInfo user = UserManager.get(mContext).getUserInfo(userHandle);
        if (user.isRestricted() && user.restrictedProfileParentId == mUserHandle) {
        if (user.isRestricted() && user.restrictedProfileParentId == mUserHandle
                && mVpnUsers != null) {
            synchronized(Vpn.this) {
                try {
                    addVpnUserLocked(userHandle);
@@ -736,7 +737,8 @@ public class Vpn {
    public void onUserRemoved(int userHandle) {
        // clean up if restricted
        UserInfo user = UserManager.get(mContext).getUserInfo(userHandle);
        if (user.isRestricted() && user.restrictedProfileParentId == mUserHandle) {
        if (user.isRestricted() && user.restrictedProfileParentId == mUserHandle
                && mVpnUsers != null) {
            synchronized(Vpn.this) {
                try {
                    removeVpnUserLocked(userHandle);