summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--service/java/com/android/server/wifi/WifiServiceImpl.java12
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java15
2 files changed, 19 insertions, 8 deletions
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index cf5dcea97..685bb479e 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -58,6 +58,7 @@ import android.database.ContentObserver;
import android.net.DhcpInfo;
import android.net.DhcpResults;
import android.net.Network;
+import android.net.NetworkStack;
import android.net.NetworkUtils;
import android.net.Uri;
import android.net.ip.IpClientUtil;
@@ -785,8 +786,15 @@ public class WifiServiceImpl extends BaseWifiService {
}
private void enforceNetworkStackPermission() {
- mContext.enforceCallingOrSelfPermission(android.Manifest.permission.NETWORK_STACK,
- "WifiService");
+ // TODO(b/142554155): Only check for MAINLINE_NETWORK_STACK permission
+ boolean granted = mContext.checkCallingOrSelfPermission(
+ android.Manifest.permission.NETWORK_STACK)
+ == PackageManager.PERMISSION_GRANTED;
+ if (granted) {
+ return;
+ }
+ mContext.enforceCallingOrSelfPermission(
+ NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, "WifiService");
}
private void enforceAccessPermission() {
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
index e286e339b..a92043624 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
@@ -85,6 +85,7 @@ import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ParceledListSlice;
import android.content.res.Resources;
+import android.net.NetworkStack;
import android.net.Uri;
import android.net.wifi.IDppCallback;
import android.net.wifi.INetworkRequestMatchCallback;
@@ -1127,9 +1128,10 @@ public class WifiServiceImplTest {
*/
@Test(expected = SecurityException.class)
public void testStartSoftApWithoutPermissionThrowsException() throws Exception {
- doThrow(new SecurityException()).when(mContext)
- .enforceCallingOrSelfPermission(eq(android.Manifest.permission.NETWORK_STACK),
- eq("WifiService"));
+ when(mContext.checkCallingOrSelfPermission(android.Manifest.permission.NETWORK_STACK))
+ .thenReturn(PackageManager.PERMISSION_DENIED);
+ doThrow(new SecurityException()).when(mContext).enforceCallingOrSelfPermission(
+ eq(NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK), any());
mWifiServiceImpl.startSoftAp(null);
}
@@ -1150,9 +1152,10 @@ public class WifiServiceImplTest {
*/
@Test(expected = SecurityException.class)
public void testStopSoftApWithoutPermissionThrowsException() throws Exception {
- doThrow(new SecurityException()).when(mContext)
- .enforceCallingOrSelfPermission(eq(android.Manifest.permission.NETWORK_STACK),
- eq("WifiService"));
+ when(mContext.checkCallingOrSelfPermission(android.Manifest.permission.NETWORK_STACK))
+ .thenReturn(PackageManager.PERMISSION_DENIED);
+ doThrow(new SecurityException()).when(mContext).enforceCallingOrSelfPermission(
+ eq(NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK), any());
mWifiServiceImpl.stopSoftAp();
}