diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2020-03-11 11:05:37 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-03-11 11:05:37 +0000 |
commit | d8e89c7580cc1b3fe4fe45f36246f4a8c69af30d (patch) | |
tree | f01cd567f0fc4be5c9a3b8f106336fe6011bbabb | |
parent | 7f39a020bc43910aedd6559fb2117494ca5a5e24 (diff) | |
parent | 661ab8b4e7ceee019fc029fc542c2d2e7c41e821 (diff) |
Merge "wifi: Check network setting permission for getSoftApConfiguration" into rvc-dev
-rw-r--r-- | service/java/com/android/server/wifi/WifiServiceImpl.java | 9 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java | 8 |
2 files changed, 7 insertions, 10 deletions
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java index d8d7672a9..e009f7257 100644 --- a/service/java/com/android/server/wifi/WifiServiceImpl.java +++ b/service/java/com/android/server/wifi/WifiServiceImpl.java @@ -1841,15 +1841,8 @@ public class WifiServiceImpl extends BaseWifiService { @NonNull @Override public SoftApConfiguration getSoftApConfiguration() { - enforceAccessPermission(); + enforceNetworkSettingsPermission(); int uid = Binder.getCallingUid(); - // only allow Settings UI to get the saved SoftApConfig - if (!mWifiPermissionsUtil.checkConfigOverridePermission(uid)) { - // random apps should not be allowed to read the user specified config - throw new SecurityException("App not allowed to read or update stored WiFi Ap config " - + "(uid = " + uid + ")"); - } - if (mVerboseLoggingEnabled) { mLog.info("getSoftApConfiguration uid=%").c(uid).flush(); } diff --git a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java index 935c52fb4..a3a19d233 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java @@ -1102,7 +1102,9 @@ public class WifiServiceImplTest extends WifiBaseTest { */ @Test public void testGetSoftApConfigurationNotReturnedWithoutPermission() throws Exception { - when(mWifiPermissionsUtil.checkConfigOverridePermission(anyInt())).thenReturn(false); + doThrow(new SecurityException()).when(mContext) + .enforceCallingOrSelfPermission(eq(android.Manifest.permission.NETWORK_SETTINGS), + eq("WifiService")); try { mWifiServiceImpl.getSoftApConfiguration(); fail("Expected a SecurityException"); @@ -1116,7 +1118,9 @@ public class WifiServiceImplTest extends WifiBaseTest { @Test public void testGetSoftApConfigurationSuccess() throws Exception { when(mSettingsStore.isWifiToggleEnabled()).thenReturn(false); - when(mWifiPermissionsUtil.checkConfigOverridePermission(anyInt())).thenReturn(true); + doNothing().when(mContext) + .enforceCallingOrSelfPermission(eq(android.Manifest.permission.NETWORK_SETTINGS), + eq("WifiService")); SoftApConfiguration apConfig = createValidSoftApConfiguration(); when(mWifiApConfigStore.getApConfiguration()).thenReturn(apConfig); |