diff options
author | Rebecca Silberstein <silberst@google.com> | 2017-08-18 09:14:27 -0700 |
---|---|---|
committer | Rebecca Silberstein <silberst@google.com> | 2017-08-23 17:38:55 +0000 |
commit | 4faa2de343ff7ef3deb2f313cd60365d9a487f03 (patch) | |
tree | 5fc34183c3ebc07c7344756e5ffccab2759a09f8 /service | |
parent | 529bed806618e5232cad35492307796cf1165dac (diff) |
WifiServiceImpl: use context to check network settings
Instead of using the ActivityManager to check the NETWORK_SETTINGS
permission by uid, use the context. This will allow the shell
to pass the permission check.
To limit the scope of this change, the check is fixed locally in
WifiServiceImpl. WifiConfigManager also uses the WifiPermissionsUtil
helper method that checks the permission via the ActivityManager.
Switching the helper method will be a much bigger change since it would
involve plumbing the pid through several layers of calls and it is not
triggered via a shell command, so the existing permission check will
work as is.
Bug: 64683466
Test: manually verified wifi can be toggled when airplane mode is active
Change-Id: I198b364fcc9c08f4f0dc6f89141b55c9a668bb75
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/WifiServiceImpl.java | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java index 6ef102066..81abc3435 100644 --- a/service/java/com/android/server/wifi/WifiServiceImpl.java +++ b/service/java/com/android/server/wifi/WifiServiceImpl.java @@ -713,6 +713,11 @@ public class WifiServiceImpl extends IWifiManager.Stub { } } + private boolean checkNetworkSettingsPermission(int pid, int uid) { + return mContext.checkPermission(android.Manifest.permission.NETWORK_SETTINGS, pid, uid) + == PackageManager.PERMISSION_GRANTED; + } + private void enforceNetworkSettingsPermission() { mContext.enforceCallingOrSelfPermission(android.Manifest.permission.NETWORK_SETTINGS, "WifiService"); @@ -780,8 +785,8 @@ public class WifiServiceImpl extends IWifiManager.Stub { mLog.trace("setWifiEnabled package=% uid=% enable=%").c(packageName) .c(Binder.getCallingUid()).c(enable).flush(); - boolean isFromSettings = - mWifiPermissionsUtil.checkNetworkSettingsPermission(Binder.getCallingUid()); + boolean isFromSettings = checkNetworkSettingsPermission( + Binder.getCallingPid(), Binder.getCallingUid()); // If Airplane mode is enabled, only Settings is allowed to toggle Wifi if (mSettingsStore.isAirplaneModeOn() && !isFromSettings) { |