From 49d5a01e9b8ee73e8d03ae8bf0560ee15ac97e56 Mon Sep 17 00:00:00 2001 From: Fyodor Kupolov Date: Fri, 4 Mar 2016 13:41:58 -0800 Subject: [PATCH] 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 --- services/core/java/com/android/server/connectivity/Vpn.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/connectivity/Vpn.java b/services/core/java/com/android/server/connectivity/Vpn.java index f231f922a0e60..3b0b79a771efe 100644 --- a/services/core/java/com/android/server/connectivity/Vpn.java +++ b/services/core/java/com/android/server/connectivity/Vpn.java @@ -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);