From 661ab8b4e7ceee019fc029fc542c2d2e7c41e821 Mon Sep 17 00:00:00 2001 From: lesl Date: Mon, 9 Mar 2020 16:56:34 +0800 Subject: wifi: Check network setting permission for getSoftApConfiguration Align permission between getSoftApConfiguration and setSoftApConfiguration. Bug: 151060777 Test: atest frameworks/opt/net/wifi/tests/wifitests/ Change-Id: I760f6d9c6188673488f6a0688e7c38d8a60f4b8d --- service/java/com/android/server/wifi/WifiServiceImpl.java | 9 +-------- .../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 5c384f595..c663b30e6 100644 --- a/service/java/com/android/server/wifi/WifiServiceImpl.java +++ b/service/java/com/android/server/wifi/WifiServiceImpl.java @@ -1821,15 +1821,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 8ecac08bc..ff52b55b8 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); -- cgit v1.2.3