diff options
author | Roshan Pius <rpius@google.com> | 2019-10-21 20:23:54 -0700 |
---|---|---|
committer | Roshan Pius <rpius@google.com> | 2019-10-30 20:01:34 -0700 |
commit | e564ad666f3e5f2aab07d1e158ace5a9179bcf43 (patch) | |
tree | 5799f0392dbcfdae76e47626000c290488582b38 /service | |
parent | 9cc29b34b202db69c255e6d035646d791dc925cb (diff) |
WifiStack: Use new hasUserRestrictionForUser @SystemApi
Wifi stack needs a multi-user version of
UserManager.hasUserRestriction().
Bug: 142888959
Test: atest com.android.server.wifi
Change-Id: I0d9668194fa45b48235ee819b01e17fa8cbeda34
Diffstat (limited to 'service')
3 files changed, 19 insertions, 8 deletions
diff --git a/service/java/com/android/server/wifi/AvailableNetworkNotifier.java b/service/java/com/android/server/wifi/AvailableNetworkNotifier.java index 7af22934f..bbfedaf91 100644 --- a/service/java/com/android/server/wifi/AvailableNetworkNotifier.java +++ b/service/java/com/android/server/wifi/AvailableNetworkNotifier.java @@ -261,7 +261,8 @@ public class AvailableNetworkNotifier { private boolean isControllerEnabled() { return mSettingEnabled && !mContext.getSystemService(UserManager.class) // TODO (b/142234604): This will not work on multi-user device scenarios. - .hasUserRestriction(UserManager.DISALLOW_CONFIG_WIFI, UserHandle.CURRENT_OR_SELF); + .hasUserRestrictionForUser(UserManager.DISALLOW_CONFIG_WIFI, + UserHandle.CURRENT_OR_SELF); } /** diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java index d2a4678ad..b459bb2f6 100644 --- a/service/java/com/android/server/wifi/WifiServiceImpl.java +++ b/service/java/com/android/server/wifi/WifiServiceImpl.java @@ -1373,7 +1373,8 @@ public class WifiServiceImpl extends BaseWifiService { } // verify that tethering is not disabled - if (mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_TETHERING)) { + if (mUserManager.hasUserRestrictionForUser( + UserManager.DISALLOW_CONFIG_TETHERING, UserHandle.getUserHandleForUid(uid))) { return LocalOnlyHotspotCallback.ERROR_TETHERING_DISALLOWED; } @@ -2747,15 +2748,21 @@ public class WifiServiceImpl extends BaseWifiService { return; } mLog.info("factoryReset uid=%").c(Binder.getCallingUid()).flush(); - if (mUserManager.hasUserRestriction(UserManager.DISALLOW_NETWORK_RESET)) { + if (mUserManager.hasUserRestrictionForUser( + UserManager.DISALLOW_NETWORK_RESET, + UserHandle.getUserHandleForUid(Binder.getCallingUid()))) { return; } - if (!mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_TETHERING)) { + if (!mUserManager.hasUserRestrictionForUser( + UserManager.DISALLOW_CONFIG_TETHERING, + UserHandle.getUserHandleForUid(Binder.getCallingUid()))) { // Turn mobile hotspot off stopSoftApInternal(WifiManager.IFACE_IP_MODE_UNSPECIFIED); } - if (mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_WIFI)) { + if (mUserManager.hasUserRestrictionForUser( + UserManager.DISALLOW_CONFIG_WIFI, + UserHandle.getUserHandleForUid(Binder.getCallingUid()))) { return; } // Delete all Wifi SSIDs diff --git a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java index dfbc45f8a..783dac970 100644 --- a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java +++ b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java @@ -4121,9 +4121,12 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub { if (!mWifiPermissionsUtil.checkNetworkSettingsPermission(uid)) return false; - if (userManager.hasUserRestriction(UserManager.DISALLOW_NETWORK_RESET)) return false; - - if (userManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_WIFI)) return false; + if (userManager.hasUserRestrictionForUser( + UserManager.DISALLOW_NETWORK_RESET, UserHandle.getUserHandleForUid(uid)) + || userManager.hasUserRestrictionForUser( + UserManager.DISALLOW_CONFIG_WIFI, UserHandle.getUserHandleForUid(uid))) { + return false; + } Log.i(TAG, "factoryReset uid=" + uid + " pkg=" + pkgName); |