summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2019-11-19 06:55:37 -0800
committerRoshan Pius <rpius@google.com>2019-11-25 20:57:06 -0800
commit5af72d01d81f092db948432d2c1e6ddd50f8af3a (patch)
treebdb2e7ba764227d8067bd6885a45be345a7fba18 /tests
parent94c0650af0dd9b8a2a0ca665800c454af79f34a0 (diff)
Revert "Create Mainline wifi stack module"
This reverts commit fa4865828574f11464b5f0c06b27e2829b3672e6 Reason for revert: Wifi services no longer plan to be a separate APK/process for mainline. Will instead become a jar loaded from Apex. Also, a) JarJar all external libraries to a separate com.android.server.x.wifi namespace. b) Use proguard to preserve all of com.android.server.wifi and only strip out unused code from the static libraries linked. Bug: 144722612 Test: Device boots up & connects to wifi networks Change-Id: I13f4cad0147e7baa028bc7cf578b72b3636d874e
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java3
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WrongPasswordNotifierTest.java2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java71
3 files changed, 27 insertions, 49 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
index e527ed05e..4bf695d77 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
@@ -114,7 +114,6 @@ import android.net.wifi.WifiManager.SoftApCallback;
import android.net.wifi.WifiNetworkScoreCache;
import android.net.wifi.WifiNetworkSuggestion;
import android.net.wifi.WifiSsid;
-import android.net.wifi.WifiStackClient;
import android.net.wifi.hotspot2.IProvisioningCallback;
import android.net.wifi.hotspot2.OsuProvider;
import android.net.wifi.hotspot2.PasspointConfiguration;
@@ -361,8 +360,6 @@ public class WifiServiceImplTest extends WifiBaseTest {
anyInt(), anyInt())).thenReturn(PackageManager.PERMISSION_DENIED);
when(mContext.checkPermission(eq(android.Manifest.permission.NETWORK_MANAGED_PROVISIONING),
anyInt(), anyInt())).thenReturn(PackageManager.PERMISSION_DENIED);
- when(mContext.checkPermission(eq(WifiStackClient.PERMISSION_MAINLINE_WIFI_STACK),
- anyInt(), anyInt())).thenReturn(PackageManager.PERMISSION_DENIED);
when(mScanRequestProxy.startScan(anyInt(), anyString())).thenReturn(true);
when(mLohsCallback.asBinder()).thenReturn(mock(IBinder.class));
diff --git a/tests/wifitests/src/com/android/server/wifi/WrongPasswordNotifierTest.java b/tests/wifitests/src/com/android/server/wifi/WrongPasswordNotifierTest.java
index ae184bec7..3b4bdfd31 100644
--- a/tests/wifitests/src/com/android/server/wifi/WrongPasswordNotifierTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WrongPasswordNotifierTest.java
@@ -71,7 +71,7 @@ public class WrongPasswordNotifierTest extends WifiBaseTest {
@Test
public void onWrongPasswordError() throws Exception {
when(mFrameworkFacade.makeNotificationBuilder(any(),
- eq(WifiStackService.NOTIFICATION_NETWORK_ALERTS))).thenReturn(mNotificationBuilder);
+ eq(WifiService.NOTIFICATION_NETWORK_ALERTS))).thenReturn(mNotificationBuilder);
mWrongPassNotifier.onWrongPasswordError(TEST_SSID);
verify(mNotificationManager).notify(eq(WrongPasswordNotifier.NOTIFICATION_ID), any());
ArgumentCaptor<Intent> intent = ArgumentCaptor.forClass(Intent.class);
diff --git a/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java b/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java
index 666028a98..d1cb3ba86 100644
--- a/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java
@@ -52,6 +52,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
+import android.Manifest;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.test.MockAnswerUtil.AnswerWithArguments;
@@ -60,7 +61,6 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiScanner;
-import android.net.wifi.WifiStackClient;
import android.os.BatteryStatsManager;
import android.os.Binder;
import android.os.Bundle;
@@ -189,7 +189,7 @@ public class WifiScanningServiceTest extends WifiBaseTest {
when(mWifiNative.getClientInterfaceNames())
.thenReturn(new ArraySet<>(Arrays.asList(TEST_IFACE_NAME_0)));
when(mWifiInjector.getWifiNative()).thenReturn(mWifiNative);
- when(mContext.checkPermission(eq(WifiStackClient.PERMISSION_MAINLINE_WIFI_STACK),
+ when(mContext.checkPermission(eq(Manifest.permission.NETWORK_STACK),
anyInt(), eq(Binder.getCallingUid())))
.thenReturn(PERMISSION_GRANTED);
mWifiScanningServiceImpl = new WifiScanningServiceImpl(mContext, mLooper.getLooper(),
@@ -759,8 +759,8 @@ public class WifiScanningServiceTest extends WifiBaseTest {
requestSettings.type = WifiScanner.TYPE_HIGH_ACCURACY;
WorkSource workSource = new WorkSource(Binder.getCallingUid()); // don't explicitly set
- when(mContext.checkPermission(eq(WifiStackClient.PERMISSION_MAINLINE_WIFI_STACK),
- anyInt(), eq(Binder.getCallingUid())))
+ when(mContext.checkPermission(
+ Manifest.permission.NETWORK_STACK, -1, Binder.getCallingUid()))
.thenReturn(PERMISSION_DENIED);
startServiceAndLoadDriver();
@@ -811,8 +811,8 @@ public class WifiScanningServiceTest extends WifiBaseTest {
};
WorkSource workSource = new WorkSource(Binder.getCallingUid()); // don't explicitly set
- when(mContext.checkPermission(eq(WifiStackClient.PERMISSION_MAINLINE_WIFI_STACK),
- anyInt(), eq(Binder.getCallingUid())))
+ when(mContext.checkPermission(
+ Manifest.permission.NETWORK_STACK, -1, Binder.getCallingUid()))
.thenReturn(PERMISSION_DENIED);
startServiceAndLoadDriver();
@@ -898,8 +898,8 @@ public class WifiScanningServiceTest extends WifiBaseTest {
@Test
public void sendSingleScanRequestWithNoPrivilegedParamsSetFromNonPrivilegedApp()
throws Exception {
- when(mContext.checkPermission(eq(WifiStackClient.PERMISSION_MAINLINE_WIFI_STACK),
- anyInt(), eq(Binder.getCallingUid())))
+ when(mContext.checkPermission(
+ Manifest.permission.NETWORK_STACK, -1, Binder.getCallingUid()))
.thenReturn(PERMISSION_DENIED);
WifiScanner.ScanSettings requestSettings = createRequest(channelsToSpec(2400, 5150, 5175),
0, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN);
@@ -2623,7 +2623,7 @@ public class WifiScanningServiceTest extends WifiBaseTest {
}
/**
- * Verifies that only clients with PERMISSION_MAINLINE_WIFI_STACK permission can issues restricted messages
+ * Verifies that only clients with NETWORK_STACK permission can issues restricted messages
* (from API's).
*/
@Test
@@ -2633,10 +2633,9 @@ public class WifiScanningServiceTest extends WifiBaseTest {
Handler handler = mock(Handler.class);
BidirectionalAsyncChannel controlChannel = connectChannel(handler);
- // Client doesn't have PERMISSION_MAINLINE_WIFI_STACK permission.
+ // Client doesn't have NETWORK_STACK permission.
doThrow(new SecurityException()).when(mContext).enforcePermission(
- eq(WifiStackClient.PERMISSION_MAINLINE_WIFI_STACK), anyInt(),
- eq(Binder.getCallingUid()), any());
+ eq(Manifest.permission.NETWORK_STACK), anyInt(), eq(Binder.getCallingUid()), any());
controlChannel.sendMessage(Message.obtain(null, WifiScanner.CMD_ENABLE));
mLooper.dispatchAll();
@@ -2674,19 +2673,13 @@ public class WifiScanningServiceTest extends WifiBaseTest {
}
/**
- * Verifies that clients without PERMISSION_MAINLINE_WIFI_STACK permission cannot issue any messages when they
+ * Verifies that clients without NETWORK_STACK permission cannot issue any messages when they
* don't have the necessary location permissions & location is enabled.
*/
@Test
public void rejectAllMessagesFromNonPrivilegedAppsWithoutLocationPermission() throws Exception {
// Start service & initialize it.
startServiceAndLoadDriver();
- doThrow(new SecurityException()).when(mContext).enforcePermission(
- eq(WifiStackClient.PERMISSION_MAINLINE_WIFI_STACK), anyInt(),
- eq(Binder.getCallingUid()), any());
- when(mContext.checkPermission(eq(WifiStackClient.PERMISSION_MAINLINE_WIFI_STACK),
- anyInt(), eq(Binder.getCallingUid())))
- .thenReturn(PERMISSION_DENIED);
// Location permission or mode check fail.
doThrow(new SecurityException()).when(mWifiPermissionsUtil)
@@ -2696,10 +2689,9 @@ public class WifiScanningServiceTest extends WifiBaseTest {
Handler handler = mock(Handler.class);
BidirectionalAsyncChannel controlChannel = connectChannel(handler);
- // Client doesn't have PERMISSION_MAINLINE_WIFI_STACK permission.
- when(mContext.checkPermission(eq(WifiStackClient.PERMISSION_MAINLINE_WIFI_STACK),
- anyInt(), eq(Binder.getCallingUid())))
- .thenReturn(PERMISSION_DENIED);
+ // Client doesn't have NETWORK_STACK permission.
+ doThrow(new SecurityException()).when(mContext).enforcePermission(
+ eq(Manifest.permission.NETWORK_STACK), anyInt(), eq(Binder.getCallingUid()), any());
controlChannel.sendMessage(Message.obtain(null, WifiScanner.CMD_START_SINGLE_SCAN));
mLooper.dispatchAll();
@@ -2741,13 +2733,9 @@ public class WifiScanningServiceTest extends WifiBaseTest {
Handler handler = mock(Handler.class);
BidirectionalAsyncChannel controlChannel = connectChannel(handler);
- // Client doesn't have PERMISSION_MAINLINE_WIFI_STACK permission.
+ // Client doesn't have NETWORK_STACK permission.
doThrow(new SecurityException()).when(mContext).enforcePermission(
- eq(WifiStackClient.PERMISSION_MAINLINE_WIFI_STACK), anyInt(),
- eq(Binder.getCallingUid()), any());
- when(mContext.checkPermission(eq(WifiStackClient.PERMISSION_MAINLINE_WIFI_STACK),
- anyInt(), eq(Binder.getCallingUid())))
- .thenReturn(PERMISSION_DENIED);
+ eq(Manifest.permission.NETWORK_STACK), anyInt(), eq(Binder.getCallingUid()), any());
Bundle bundle = new Bundle();
bundle.putString(WifiScanner.REQUEST_PACKAGE_NAME_KEY, TEST_PACKAGE_NAME);
@@ -2809,13 +2797,9 @@ public class WifiScanningServiceTest extends WifiBaseTest {
Handler handler = mock(Handler.class);
BidirectionalAsyncChannel controlChannel = connectChannel(handler);
- // Client doesn't have PERMISSION_MAINLINE_WIFI_STACK permission.
+ // Client doesn't have NETWORK_STACK permission.
doThrow(new SecurityException()).when(mContext).enforcePermission(
- eq(WifiStackClient.PERMISSION_MAINLINE_WIFI_STACK), anyInt(),
- eq(Binder.getCallingUid()), any());
- when(mContext.checkPermission(eq(WifiStackClient.PERMISSION_MAINLINE_WIFI_STACK),
- anyInt(), eq(Binder.getCallingUid())))
- .thenReturn(PERMISSION_DENIED);
+ eq(Manifest.permission.NETWORK_STACK), anyInt(), eq(Binder.getCallingUid()), any());
Bundle bundle = new Bundle();
bundle.putString(WifiScanner.REQUEST_PACKAGE_NAME_KEY, TEST_PACKAGE_NAME);
@@ -2879,10 +2863,9 @@ public class WifiScanningServiceTest extends WifiBaseTest {
Handler handler = mock(Handler.class);
BidirectionalAsyncChannel controlChannel = connectChannel(handler);
- // Client does have WIFI_STACK permission.
+ // Client does have NETWORK_STACK permission.
doNothing().when(mContext).enforcePermission(
- eq(WifiStackClient.PERMISSION_MAINLINE_WIFI_STACK), anyInt(),
- eq(Binder.getCallingUid()), any());
+ eq(Manifest.permission.NETWORK_STACK), anyInt(), eq(Binder.getCallingUid()), any());
Bundle bundle = new Bundle();
bundle.putString(WifiScanner.REQUEST_PACKAGE_NAME_KEY, TEST_PACKAGE_NAME);
@@ -3510,10 +3493,9 @@ public class WifiScanningServiceTest extends WifiBaseTest {
public void getAvailableChannels_noPermission_throwsException() throws Exception {
startServiceAndLoadDriver();
- // no MAINLINE_WIFI_STACK permission
+ // Client doesn't have NETWORK_STACK permission.
doThrow(new SecurityException()).when(mContext).enforcePermission(
- eq(WifiStackClient.PERMISSION_MAINLINE_WIFI_STACK), anyInt(),
- eq(Binder.getCallingUid()), any());
+ eq(Manifest.permission.NETWORK_STACK), anyInt(), eq(Binder.getCallingUid()), any());
// Location permission or mode check fail.
doThrow(new SecurityException())
@@ -3532,10 +3514,9 @@ public class WifiScanningServiceTest extends WifiBaseTest {
public void getAvailableChannels_hasPermission_returnsSuccessfully() throws Exception {
startServiceAndLoadDriver();
- // has MAINLINE_WIFI_STACK permission
- doNothing().when(mContext).enforcePermission(
- eq(WifiStackClient.PERMISSION_MAINLINE_WIFI_STACK), anyInt(),
- eq(Binder.getCallingUid()), any());
+ // Client doesn't have NETWORK_STACK permission.
+ doThrow(new SecurityException()).when(mContext).enforcePermission(
+ eq(Manifest.permission.NETWORK_STACK), anyInt(), eq(Binder.getCallingUid()), any());
// has access scan results permission
doNothing().when(mWifiPermissionsUtil).enforceCanAccessScanResultsForWifiScanner(