From d385a6d95fc830ecc8d55937e9f46b14165d4b34 Mon Sep 17 00:00:00 2001 From: Samuel Tan Date: Mon, 14 Mar 2016 15:57:02 -0700 Subject: [PATCH] [DO NOT MERGE] Disallow guest user from changing Wifi settings Disallow existing and newly created guest users from changing Wifi settings. BUG: 27411179 TEST: Flashed device, switched to existing guest user, and verified that Wifi settings are disabled. TEST: Flashed device, created new guest user, and verified that Wifi settings are disabled. Change-Id: Ia1bf4cce0369017b62f69d317c7ab2e30e3949b3 --- .../com/android/server/pm/UserManagerService.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java index 0cf2249396c06..8128e851e46f3 100644 --- a/services/core/java/com/android/server/pm/UserManagerService.java +++ b/services/core/java/com/android/server/pm/UserManagerService.java @@ -255,6 +255,19 @@ public class UserManagerService extends IUserManager.Stub { Log.w(LOG_TAG, "Unable to notify AppOpsService of UserRestrictions"); } } + UserInfo currentGuestUser = null; + synchronized (mPackagesLock) { + currentGuestUser = findCurrentGuestUserLocked(); + } + if (currentGuestUser != null && !hasUserRestriction( + UserManager.DISALLOW_CONFIG_WIFI, currentGuestUser.id)) { + // If a guest user currently exists, apply the DISALLOW_CONFIG_WIFI option + // to it, in case this guest was created in a previous version where this + // user restriction was not a default guest restriction. + Bundle userRestrictionsToSet = new Bundle(); + userRestrictionsToSet.putBoolean(UserManager.DISALLOW_CONFIG_WIFI, true); + setUserRestrictions(userRestrictionsToSet, currentGuestUser.id); + } } @Override @@ -468,6 +481,7 @@ public class UserManagerService extends IUserManager.Stub { */ private void initDefaultGuestRestrictions() { if (mGuestRestrictions.isEmpty()) { + mGuestRestrictions.putBoolean(UserManager.DISALLOW_CONFIG_WIFI, true); mGuestRestrictions.putBoolean(UserManager.DISALLOW_OUTGOING_CALLS, true); writeUserListLocked(); }