Merge "Add CTS for creating keepalive offloads on cellular" am: 16174b2cff
am: e849a96874
Change-Id: Ib6b01356d785c5b7684520eef9f9d1fe48187582
diff --git a/tests/cts/hostside/OWNERS b/tests/cts/hostside/OWNERS
new file mode 100644
index 0000000..52c8053
--- /dev/null
+++ b/tests/cts/hostside/OWNERS
@@ -0,0 +1,4 @@
+# Bug component: 61373
+sudheersai@google.com
+lorenzo@google.com
+jchalard@google.com
diff --git a/tests/cts/hostside/app/AndroidManifest.xml b/tests/cts/hostside/app/AndroidManifest.xml
index ba0e242..f54b5c1 100644
--- a/tests/cts/hostside/app/AndroidManifest.xml
+++ b/tests/cts/hostside/app/AndroidManifest.xml
@@ -23,6 +23,8 @@
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
+ <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
<application>
diff --git a/tests/cts/hostside/app/src/com/android/cts/net/hostside/AbstractAppIdleTestCase.java b/tests/cts/hostside/app/src/com/android/cts/net/hostside/AbstractAppIdleTestCase.java
index 0e141c0..55bd406 100644
--- a/tests/cts/hostside/app/src/com/android/cts/net/hostside/AbstractAppIdleTestCase.java
+++ b/tests/cts/hostside/app/src/com/android/cts/net/hostside/AbstractAppIdleTestCase.java
@@ -150,6 +150,11 @@
}
public void testAppIdleNetworkAccess_whenCharging() throws Exception {
+ if (!isBatterySaverSupported()) {
+ Log.i(TAG, "Skipping " + getClass() + "." + getName()
+ + "() because device does not support Battery saver mode");
+ return;
+ }
if (!isSupported()) return;
// Check that app is paroled when charging
@@ -175,6 +180,25 @@
assertBackgroundNetworkAccess(true);
}
+ public void testAppIdleNetworkAccess_idleWhitelisted() throws Exception {
+ if (!isSupported()) return;
+
+ setAppIdle(true);
+ assertAppIdle(true);
+ assertBackgroundNetworkAccess(false);
+
+ addAppIdleWhitelist(mUid);
+ assertBackgroundNetworkAccess(true);
+
+ removeAppIdleWhitelist(mUid);
+ assertBackgroundNetworkAccess(false);
+
+ // Make sure whitelisting a random app doesn't affect the tested app.
+ addAppIdleWhitelist(mUid + 1);
+ assertBackgroundNetworkAccess(false);
+ removeAppIdleWhitelist(mUid + 1);
+ }
+
public void testAppIdle_toast() throws Exception {
if (!isSupported()) return;
diff --git a/tests/cts/hostside/app/src/com/android/cts/net/hostside/AbstractBatterySaverModeTestCase.java b/tests/cts/hostside/app/src/com/android/cts/net/hostside/AbstractBatterySaverModeTestCase.java
index 28175b8..931376b 100644
--- a/tests/cts/hostside/app/src/com/android/cts/net/hostside/AbstractBatterySaverModeTestCase.java
+++ b/tests/cts/hostside/app/src/com/android/cts/net/hostside/AbstractBatterySaverModeTestCase.java
@@ -16,6 +16,7 @@
package com.android.cts.net.hostside;
+import android.text.TextUtils;
import android.util.Log;
/**
@@ -52,12 +53,19 @@
@Override
protected boolean isSupported() throws Exception {
- boolean supported = isDozeModeEnabled();
- if (!supported) {
- Log.i(TAG, "Skipping " + getClass() + "." + getName()
- + "() because device does not support Doze Mode");
+ String unSupported = "";
+ if (!isDozeModeEnabled()) {
+ unSupported += "Doze mode,";
}
- return supported;
+ if (!isBatterySaverSupported()) {
+ unSupported += "Battery saver mode,";
+ }
+ if (!TextUtils.isEmpty(unSupported)) {
+ Log.i(TAG, "Skipping " + getClass() + "." + getName()
+ + "() because device does not support " + unSupported);
+ return false;
+ }
+ return true;
}
/**
diff --git a/tests/cts/hostside/app/src/com/android/cts/net/hostside/AbstractRestrictBackgroundNetworkTestCase.java b/tests/cts/hostside/app/src/com/android/cts/net/hostside/AbstractRestrictBackgroundNetworkTestCase.java
index bbc0354..40d7e34 100644
--- a/tests/cts/hostside/app/src/com/android/cts/net/hostside/AbstractRestrictBackgroundNetworkTestCase.java
+++ b/tests/cts/hostside/app/src/com/android/cts/net/hostside/AbstractRestrictBackgroundNetworkTestCase.java
@@ -26,10 +26,6 @@
import static com.android.compatibility.common.util.SystemUtil.runShellCommand;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.TimeUnit;
-
import android.app.ActivityManager;
import android.app.Instrumentation;
import android.app.NotificationManager;
@@ -38,6 +34,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.pm.PackageManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.NetworkInfo.DetailedState;
@@ -47,12 +44,19 @@
import android.os.Binder;
import android.os.Bundle;
import android.os.SystemClock;
+import android.os.SystemProperties;
import android.provider.Settings;
import android.service.notification.NotificationListenerService;
import android.test.InstrumentationTestCase;
import android.text.TextUtils;
import android.util.Log;
+import com.android.compatibility.common.util.BatteryUtils;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+
/**
* Superclass for tests related to background network restrictions.
*/
@@ -92,7 +96,8 @@
private static final String NETWORK_STATUS_SEPARATOR = "\\|";
private static final int SECOND_IN_MS = 1000;
static final int NETWORK_TIMEOUT_MS = 15 * SECOND_IN_MS;
- private static final int PROCESS_STATE_FOREGROUND_SERVICE = 3;
+ private static int PROCESS_STATE_FOREGROUND_SERVICE;
+
private static final int PROCESS_STATE_TOP = 2;
private static final String KEY_NETWORK_STATE_OBSERVER = TEST_PKG + ".observer";
@@ -131,6 +136,8 @@
protected void setUp() throws Exception {
super.setUp();
+ PROCESS_STATE_FOREGROUND_SERVICE = (Integer) ActivityManager.class
+ .getDeclaredField("PROCESS_STATE_FOREGROUND_SERVICE").get(null);
mInstrumentation = getInstrumentation();
mContext = mInstrumentation.getContext();
mCm = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
@@ -150,7 +157,14 @@
Log.i(TAG, "Apps status on " + getName() + ":\n"
+ "\ttest app: uid=" + mMyUid + ", state=" + getProcessStateByUid(mMyUid) + "\n"
+ "\tapp2: uid=" + mUid + ", state=" + getProcessStateByUid(mUid));
- executeShellCommand("settings get global app_idle_constants");
+
+ // app_idle_constants set in NetPolicyTestsPreparer.setUp() is not always sucessful (suspect
+ // timing issue), here we set it again to make sure.
+ final String appIdleConstants = "parole_duration=0,stable_charging_threshold=0";
+ executeShellCommand("settings put global app_idle_constants " + appIdleConstants);
+ final String currentConstants =
+ executeShellCommand("settings get global app_idle_constants");
+ assertEquals(appIdleConstants, currentConstants);
}
@Override
@@ -201,7 +215,7 @@
do {
attempts++;
count = getNumberBroadcastsReceived(receiverName, ACTION_RESTRICT_BACKGROUND_CHANGED);
- if (count == expectedCount) {
+ if (count >= expectedCount) {
break;
}
Log.d(TAG, "Expecting count " + expectedCount + " but actual is " + count + " after "
@@ -301,6 +315,10 @@
return mSupported;
}
+ protected boolean isBatterySaverSupported() {
+ return BatteryUtils.isBatterySaverSupported();
+ }
+
/**
* Asserts that an app always have access while on foreground or running a foreground service.
*
@@ -761,6 +779,20 @@
assertRestrictBackground("restrict-background-blacklist", uid, expected);
}
+ protected void addAppIdleWhitelist(int uid) throws Exception {
+ executeShellCommand("cmd netpolicy add app-idle-whitelist " + uid);
+ assertAppIdleWhitelist(uid, true);
+ }
+
+ protected void removeAppIdleWhitelist(int uid) throws Exception {
+ executeShellCommand("cmd netpolicy remove app-idle-whitelist " + uid);
+ assertAppIdleWhitelist(uid, false);
+ }
+
+ protected void assertAppIdleWhitelist(int uid, boolean expected) throws Exception {
+ assertRestrictBackground("app-idle-whitelist", uid, expected);
+ }
+
private void assertRestrictBackground(String list, int uid, boolean expected) throws Exception {
final int maxTries = 5;
boolean actual = false;
diff --git a/tests/cts/hostside/app/src/com/android/cts/net/hostside/DataSaverModeTest.java b/tests/cts/hostside/app/src/com/android/cts/net/hostside/DataSaverModeTest.java
index 72563d4..cfe6a73 100644
--- a/tests/cts/hostside/app/src/com/android/cts/net/hostside/DataSaverModeTest.java
+++ b/tests/cts/hostside/app/src/com/android/cts/net/hostside/DataSaverModeTest.java
@@ -22,6 +22,8 @@
import android.util.Log;
+import com.android.compatibility.common.util.CddTest;
+
public class DataSaverModeTest extends AbstractRestrictBackgroundNetworkTestCase {
private static final String[] REQUIRED_WHITELISTED_PACKAGES = {
@@ -35,7 +37,6 @@
super.setUp();
mIsDataSaverSupported = isDataSaverSupported();
- if (!isSupported()) return;
// Set initial state.
setRestrictBackground(false);
@@ -201,6 +202,20 @@
}
}
+ @CddTest(requirement="7.4.7/C-2-2")
+ public void testBroadcastNotSentOnUnsupportedDevices() throws Exception {
+ if (isSupported()) return;
+
+ setRestrictBackground(true);
+ assertRestrictBackgroundChangedReceived(0);
+
+ setRestrictBackground(false);
+ assertRestrictBackgroundChangedReceived(0);
+
+ setRestrictBackground(true);
+ assertRestrictBackgroundChangedReceived(0);
+ }
+
private void assertDataSaverStatusOnBackground(int expectedStatus) throws Exception {
assertRestrictBackgroundStatus(expectedStatus);
assertBackgroundNetworkAccess(expectedStatus != RESTRICT_BACKGROUND_STATUS_ENABLED);
diff --git a/tests/cts/hostside/app/src/com/android/cts/net/hostside/MixedModesTest.java b/tests/cts/hostside/app/src/com/android/cts/net/hostside/MixedModesTest.java
index 87f9d77..b1a2186 100644
--- a/tests/cts/hostside/app/src/com/android/cts/net/hostside/MixedModesTest.java
+++ b/tests/cts/hostside/app/src/com/android/cts/net/hostside/MixedModesTest.java
@@ -71,6 +71,11 @@
* Tests all DS ON and BS ON scenarios from network-policy-restrictions.md on metered networks.
*/
public void testDataAndBatterySaverModes_meteredNetwork() throws Exception {
+ if (!isBatterySaverSupported()) {
+ Log.i(TAG, "Skipping " + getClass() + "." + getName()
+ + "() because device does not support Battery saver mode");
+ return;
+ }
if (!isSupported()) return;
Log.i(TAG, "testDataAndBatterySaverModes_meteredNetwork() tests");
@@ -141,6 +146,11 @@
* networks.
*/
public void testDataAndBatterySaverModes_nonMeteredNetwork() throws Exception {
+ if (!isBatterySaverSupported()) {
+ Log.i(TAG, "Skipping " + getClass() + "." + getName()
+ + "() because device does not support Battery saver mode");
+ return;
+ }
if (!isSupported()) return;
if (!setUnmeteredNetwork()) {
@@ -206,6 +216,11 @@
* are enabled.
*/
public void testDozeAndBatterySaverMode_powerSaveWhitelists() throws Exception {
+ if (!isBatterySaverSupported()) {
+ Log.i(TAG, "Skipping " + getClass() + "." + getName()
+ + "() because device does not support Battery saver mode");
+ return;
+ }
if (!isSupported()) {
return;
}
@@ -285,6 +300,11 @@
}
public void testAppIdleAndBatterySaver_tempPowerSaveWhitelists() throws Exception {
+ if (!isBatterySaverSupported()) {
+ Log.i(TAG, "Skipping " + getClass() + "." + getName()
+ + "() because device does not support Battery saver mode");
+ return;
+ }
if (!isSupported()) {
return;
}
@@ -306,4 +326,89 @@
setBatterySaverMode(false);
}
}
+
+ /**
+ * Tests that the app idle whitelist works as expected when doze and appIdle mode are enabled.
+ */
+ public void testDozeAndAppIdle_appIdleWhitelist() throws Exception {
+ if (!isSupported()) {
+ return;
+ }
+
+ setDozeMode(true);
+ setAppIdle(true);
+
+ try {
+ assertBackgroundNetworkAccess(false);
+
+ // UID still shouldn't have access because of Doze.
+ addAppIdleWhitelist(mUid);
+ assertBackgroundNetworkAccess(false);
+
+ removeAppIdleWhitelist(mUid);
+ assertBackgroundNetworkAccess(false);
+ } finally {
+ setAppIdle(false);
+ setDozeMode(false);
+ }
+ }
+
+ public void testAppIdleAndDoze_tempPowerSaveAndAppIdleWhitelists() throws Exception {
+ if (!isSupported()) {
+ return;
+ }
+
+ setDozeMode(true);
+ setAppIdle(true);
+
+ try {
+ assertBackgroundNetworkAccess(false);
+
+ addAppIdleWhitelist(mUid);
+ assertBackgroundNetworkAccess(false);
+
+ addTempPowerSaveModeWhitelist(TEST_APP2_PKG, TEMP_POWERSAVE_WHITELIST_DURATION_MS);
+ assertBackgroundNetworkAccess(true);
+
+ // Wait until the whitelist duration is expired.
+ SystemClock.sleep(TEMP_POWERSAVE_WHITELIST_DURATION_MS);
+ assertBackgroundNetworkAccess(false);
+ } finally {
+ setAppIdle(false);
+ setDozeMode(false);
+ removeAppIdleWhitelist(mUid);
+ }
+ }
+
+ public void testAppIdleAndBatterySaver_tempPowerSaveAndAppIdleWhitelists() throws Exception {
+ if (!isBatterySaverSupported()) {
+ Log.i(TAG, "Skipping " + getClass() + "." + getName()
+ + "() because device does not support Battery saver mode");
+ return;
+ }
+ if (!isSupported()) {
+ return;
+ }
+
+ setBatterySaverMode(true);
+ setAppIdle(true);
+
+ try {
+ assertBackgroundNetworkAccess(false);
+
+ addAppIdleWhitelist(mUid);
+ assertBackgroundNetworkAccess(false);
+
+ addTempPowerSaveModeWhitelist(TEST_APP2_PKG, TEMP_POWERSAVE_WHITELIST_DURATION_MS);
+ assertBackgroundNetworkAccess(true);
+
+ // Wait until the whitelist duration is expired.
+ SystemClock.sleep(TEMP_POWERSAVE_WHITELIST_DURATION_MS);
+ assertBackgroundNetworkAccess(false);
+ } finally {
+ setAppIdle(false);
+ setBatterySaverMode(false);
+ removeAppIdleWhitelist(mUid);
+ }
+ }
}
diff --git a/tests/cts/hostside/src/com/android/cts/net/HostsideRestrictBackgroundNetworkTests.java b/tests/cts/hostside/src/com/android/cts/net/HostsideRestrictBackgroundNetworkTests.java
index fe9d36c..4598c39 100644
--- a/tests/cts/hostside/src/com/android/cts/net/HostsideRestrictBackgroundNetworkTests.java
+++ b/tests/cts/hostside/src/com/android/cts/net/HostsideRestrictBackgroundNetworkTests.java
@@ -81,6 +81,11 @@
"testGetRestrictBackgroundStatus_requiredWhitelistedPackages");
}
+ public void testDataSaverMode_broadcastNotSentOnUnsupportedDevices() throws Exception {
+ runDeviceTests(TEST_PKG, TEST_PKG + ".DataSaverModeTest",
+ "testBroadcastNotSentOnUnsupportedDevices");
+ }
+
/*****************************
* Battery Saver Mode tests. *
*****************************/
@@ -156,6 +161,11 @@
"testBackgroundNetworkAccess_enabled");
}
+ public void testAppIdleMetered_idleWhitelisted() throws Exception {
+ runDeviceTests(TEST_PKG, TEST_PKG + ".AppIdleMeteredTest",
+ "testAppIdleNetworkAccess_idleWhitelisted");
+ }
+
// TODO: currently power-save mode and idle uses the same whitelist, so this test would be
// redundant (as it would be testing the same as testBatterySaverMode_reinstall())
// public void testAppIdle_reinstall() throws Exception {
@@ -181,6 +191,11 @@
"testBackgroundNetworkAccess_enabled");
}
+ public void testAppIdleNonMetered_idleWhitelisted() throws Exception {
+ runDeviceTests(TEST_PKG, TEST_PKG + ".AppIdleNonMeteredTest",
+ "testAppIdleNetworkAccess_idleWhitelisted");
+ }
+
public void testAppIdleNonMetered_whenCharging() throws Exception {
runDeviceTests(TEST_PKG, TEST_PKG + ".AppIdleNonMeteredTest",
"testAppIdleNetworkAccess_whenCharging");
@@ -281,6 +296,21 @@
"testAppIdleAndBatterySaver_tempPowerSaveWhitelists");
}
+ public void testDozeAndAppIdle_appIdleWhitelist() throws Exception {
+ runDeviceTests(TEST_PKG, TEST_PKG + ".MixedModesTest",
+ "testDozeAndAppIdle_appIdleWhitelist");
+ }
+
+ public void testAppIdleAndDoze_tempPowerSaveAndAppIdleWhitelists() throws Exception {
+ runDeviceTests(TEST_PKG, TEST_PKG + ".MixedModesTest",
+ "testAppIdleAndDoze_tempPowerSaveAndAppIdleWhitelists");
+ }
+
+ public void testAppIdleAndBatterySaver_tempPowerSaveAndAppIdleWhitelists() throws Exception {
+ runDeviceTests(TEST_PKG, TEST_PKG + ".MixedModesTest",
+ "testAppIdleAndBatterySaver_tempPowerSaveAndAppIdleWhitelists");
+ }
+
/*******************
* Helper methods. *
*******************/
diff --git a/tests/cts/hostside/src/com/android/cts/net/NetPolicyTestsPreparer.java b/tests/cts/hostside/src/com/android/cts/net/NetPolicyTestsPreparer.java
index ca14c27..bc2ee2c 100644
--- a/tests/cts/hostside/src/com/android/cts/net/NetPolicyTestsPreparer.java
+++ b/tests/cts/hostside/src/com/android/cts/net/NetPolicyTestsPreparer.java
@@ -48,7 +48,7 @@
}
private void setAppIdleConstants(String appIdleConstants) throws DeviceNotAvailableException {
- executeCmd("settings put global app_idle_constants " + appIdleConstants);
+ executeCmd("settings put global app_idle_constants \"" + appIdleConstants + "\"");
}
private String getAppIdleConstants() throws DeviceNotAvailableException {
diff --git a/tests/cts/net/AndroidManifest.xml b/tests/cts/net/AndroidManifest.xml
index 734d9de..c2b3bf7 100644
--- a/tests/cts/net/AndroidManifest.xml
+++ b/tests/cts/net/AndroidManifest.xml
@@ -23,14 +23,17 @@
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
+ <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
+ <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
+ <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
<application android:usesCleartextTraffic="true">
<uses-library android:name="android.test.runner" />
diff --git a/tests/cts/net/AndroidTest.xml b/tests/cts/net/AndroidTest.xml
index 6a19456..1807a6b 100644
--- a/tests/cts/net/AndroidTest.xml
+++ b/tests/cts/net/AndroidTest.xml
@@ -27,5 +27,6 @@
<option name="package" value="android.net.cts" />
<option name="runtime-hint" value="9m4s" />
<option name="hidden-api-checks" value="false" />
+ <option name="isolated-storage" value="false" />
</test>
</configuration>
diff --git a/tests/cts/net/OWNERS b/tests/cts/net/OWNERS
index dc82bb0..d558556 100644
--- a/tests/cts/net/OWNERS
+++ b/tests/cts/net/OWNERS
@@ -1,2 +1,3 @@
+# Bug component: 31808
lorenzo@google.com
-satk@google.com
\ No newline at end of file
+satk@google.com
diff --git a/tests/cts/net/src/android/net/cts/SSLCertificateSocketFactoryTest.java b/tests/cts/net/src/android/net/cts/SSLCertificateSocketFactoryTest.java
index 5250450..01ac3fd 100644
--- a/tests/cts/net/src/android/net/cts/SSLCertificateSocketFactoryTest.java
+++ b/tests/cts/net/src/android/net/cts/SSLCertificateSocketFactoryTest.java
@@ -92,7 +92,7 @@
// a host and port that are expected to be available but have
// a cert with a different CN, in this case CN=mail.google.com
- private static String TEST_CREATE_SOCKET_HOST = "googlemail.com";
+ private static String TEST_CREATE_SOCKET_HOST = "www3.l.google.com";
private static int TEST_CREATE_SOCKET_PORT = 443;
/**
diff --git a/tests/cts/net/src/android/net/wifi/OWNERS b/tests/cts/net/src/android/net/wifi/OWNERS
new file mode 100644
index 0000000..4a6001b
--- /dev/null
+++ b/tests/cts/net/src/android/net/wifi/OWNERS
@@ -0,0 +1,5 @@
+etancohen@google.com
+lorenzo@google.com
+mplass@google.com
+rpius@google.com
+satk@google.com
diff --git a/tests/cts/net/src/android/net/wifi/aware/OWNERS b/tests/cts/net/src/android/net/wifi/aware/OWNERS
deleted file mode 100644
index 4afc47f..0000000
--- a/tests/cts/net/src/android/net/wifi/aware/OWNERS
+++ /dev/null
@@ -1,2 +0,0 @@
-etancohen@google.com
-satk@google.com
\ No newline at end of file
diff --git a/tests/cts/net/src/android/net/wifi/aware/cts/SingleDeviceTest.java b/tests/cts/net/src/android/net/wifi/aware/cts/SingleDeviceTest.java
index d823105..1901f02 100644
--- a/tests/cts/net/src/android/net/wifi/aware/cts/SingleDeviceTest.java
+++ b/tests/cts/net/src/android/net/wifi/aware/cts/SingleDeviceTest.java
@@ -39,9 +39,12 @@
import android.net.wifi.aware.WifiAwareSession;
import android.os.Handler;
import android.os.HandlerThread;
+import android.os.SystemClock;
import android.platform.test.annotations.AppModeFull;
import android.test.AndroidTestCase;
+import com.android.compatibility.common.util.SystemUtil;
+
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashSet;
@@ -58,8 +61,8 @@
public class SingleDeviceTest extends AndroidTestCase {
private static final String TAG = "WifiAwareCtsTests";
- // wait for Wi-Fi Aware to become available
- static private final int WAIT_FOR_AWARE_CHANGE_SECS = 10;
+ // wait for Wi-Fi Aware state changes & network requests callbacks
+ static private final int WAIT_FOR_AWARE_CHANGE_SECS = 10; // 10 seconds
private final Object mLock = new Object();
private final HandlerThread mHandlerThread = new HandlerThread("SingleDeviceTest");
@@ -365,7 +368,7 @@
mWifiLock = mWifiManager.createWifiLock(TAG);
mWifiLock.acquire();
if (!mWifiManager.isWifiEnabled()) {
- mWifiManager.setWifiEnabled(true);
+ SystemUtil.runShellCommand("svc wifi enable");
}
mConnectivityManager = (ConnectivityManager) getContext().getSystemService(
@@ -435,7 +438,7 @@
// 1. Disable Wi-Fi
WifiAwareBroadcastReceiver receiver1 = new WifiAwareBroadcastReceiver();
mContext.registerReceiver(receiver1, intentFilter);
- mWifiManager.setWifiEnabled(false);
+ SystemUtil.runShellCommand("svc wifi disable");
assertTrue("Timeout waiting for Wi-Fi Aware to change status",
receiver1.waitForStateChange());
@@ -444,7 +447,7 @@
// 2. Enable Wi-Fi
WifiAwareBroadcastReceiver receiver2 = new WifiAwareBroadcastReceiver();
mContext.registerReceiver(receiver2, intentFilter);
- mWifiManager.setWifiEnabled(true);
+ SystemUtil.runShellCommand("svc wifi enable");
assertTrue("Timeout waiting for Wi-Fi Aware to change status",
receiver2.waitForStateChange());
@@ -704,7 +707,7 @@
/**
* Request an Aware data-path (open) as a Responder with an arbitrary peer MAC address. Validate
- * that times-out.
+ * that receive an onUnavailable() callback.
*/
public void testDataPathOpenOutOfBandFail() {
if (!TestUtils.shouldTestWifiAware(getContext())) {
@@ -712,28 +715,32 @@
}
MacAddress mac = MacAddress.fromString("00:01:02:03:04:05");
+ // 1. initialize Aware: only purpose is to make sure it is available for OOB data-path
WifiAwareSession session = attachAndGetSession();
PublishConfig publishConfig = new PublishConfig.Builder().setServiceName(
"ValidName").build();
DiscoverySessionCallbackTest discoveryCb = new DiscoverySessionCallbackTest();
- NetworkCallbackTest networkCb = new NetworkCallbackTest();
+ session.publish(publishConfig, discoveryCb, mHandler);
+ assertTrue("Publish started",
+ discoveryCb.waitForCallback(DiscoverySessionCallbackTest.ON_PUBLISH_STARTED));
- // 1. request an AWARE network
+ // 2. request an AWARE network
+ NetworkCallbackTest networkCb = new NetworkCallbackTest();
NetworkRequest nr = new NetworkRequest.Builder().addTransportType(
NetworkCapabilities.TRANSPORT_WIFI_AWARE).setNetworkSpecifier(
session.createNetworkSpecifierOpen(
- WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_RESPONDER,
+ WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_INITIATOR,
mac.toByteArray())).build();
- mConnectivityManager.requestNetwork(nr, networkCb, 2000);
- assertTrue("OnUnavailable received", networkCb.waitForOnUnavailable());
+ mConnectivityManager.requestNetwork(nr, networkCb);
+ assertTrue("OnUnavailable not received", networkCb.waitForOnUnavailable());
session.close();
}
/**
* Request an Aware data-path (encrypted) as a Responder with an arbitrary peer MAC address.
- * Validate that times-out.
+ * Validate that receive an onUnavailable() callback.
*/
public void testDataPathPassphraseOutOfBandFail() {
if (!TestUtils.shouldTestWifiAware(getContext())) {
@@ -741,21 +748,25 @@
}
MacAddress mac = MacAddress.fromString("00:01:02:03:04:05");
+ // 1. initialize Aware: only purpose is to make sure it is available for OOB data-path
WifiAwareSession session = attachAndGetSession();
PublishConfig publishConfig = new PublishConfig.Builder().setServiceName(
"ValidName").build();
DiscoverySessionCallbackTest discoveryCb = new DiscoverySessionCallbackTest();
- NetworkCallbackTest networkCb = new NetworkCallbackTest();
+ session.publish(publishConfig, discoveryCb, mHandler);
+ assertTrue("Publish started",
+ discoveryCb.waitForCallback(DiscoverySessionCallbackTest.ON_PUBLISH_STARTED));
- // 1. request an AWARE network
+ // 2. request an AWARE network
+ NetworkCallbackTest networkCb = new NetworkCallbackTest();
NetworkRequest nr = new NetworkRequest.Builder().addTransportType(
NetworkCapabilities.TRANSPORT_WIFI_AWARE).setNetworkSpecifier(
session.createNetworkSpecifierPassphrase(
- WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_RESPONDER, mac.toByteArray(),
+ WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_INITIATOR, mac.toByteArray(),
"abcdefghihk")).build();
- mConnectivityManager.requestNetwork(nr, networkCb, 2000);
- assertTrue("OnUnavailable received", networkCb.waitForOnUnavailable());
+ mConnectivityManager.requestNetwork(nr, networkCb);
+ assertTrue("OnUnavailable not received", networkCb.waitForOnUnavailable());
session.close();
}
diff --git a/tests/cts/net/src/android/net/wifi/cts/ConcurrencyTest.java b/tests/cts/net/src/android/net/wifi/cts/ConcurrencyTest.java
index 2da3ffc..628571c 100644
--- a/tests/cts/net/src/android/net/wifi/cts/ConcurrencyTest.java
+++ b/tests/cts/net/src/android/net/wifi/cts/ConcurrencyTest.java
@@ -16,37 +16,68 @@
package android.net.wifi.cts;
+import static org.junit.Assert.assertNotEquals;
+
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.pm.PackageManager;
import android.net.ConnectivityManager;
import android.net.ConnectivityManager.NetworkCallback;
import android.net.Network;
import android.net.NetworkCapabilities;
+import android.net.NetworkInfo;
import android.net.NetworkRequest;
import android.net.wifi.WifiManager;
import android.net.wifi.p2p.WifiP2pManager;
-import static android.net.wifi.p2p.WifiP2pManager.WIFI_P2P_STATE_DISABLED;
-import static android.net.wifi.p2p.WifiP2pManager.WIFI_P2P_STATE_ENABLED;
-
+import android.provider.Settings;
import android.platform.test.annotations.AppModeFull;
import android.test.AndroidTestCase;
+import android.util.Log;
+import com.android.compatibility.common.util.SystemUtil;
+
+import java.util.Arrays;
+import java.util.BitSet;
+import java.util.LinkedList;
+import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
@AppModeFull(reason = "Cannot get WifiManager in instant app mode")
public class ConcurrencyTest extends AndroidTestCase {
private class MySync {
- int expectedWifiState;
- int expectedP2pState;
+ static final int WIFI_STATE = 0;
+ static final int P2P_STATE = 1;
+ static final int DISCOVERY_STATE = 2;
+ static final int NETWORK_INFO = 3;
+
+ public BitSet pendingSync = new BitSet();
+
+ public int expectedWifiState;
+ public int expectedP2pState;
+ public int expectedDiscoveryState;
+ public NetworkInfo expectedNetworkInfo;
+ }
+
+ private class MyResponse {
+ public boolean valid = false;
+
+ public boolean success;
+ public int p2pState;
+ public int discoveryState;
+ public NetworkInfo networkInfo;
}
private WifiManager mWifiManager;
+ private WifiP2pManager mWifiP2pManager;
+ private WifiP2pManager.Channel mWifiP2pChannel;
private MySync mMySync = new MySync();
+ private MyResponse mMyResponse = new MyResponse();
- private static final String TAG = "WifiInfoTest";
+ private static final String TAG = "ConcurrencyTest";
private static final int TIMEOUT_MSEC = 6000;
private static final int WAIT_MSEC = 60;
private static final int DURATION = 10000;
@@ -57,16 +88,33 @@
final String action = intent.getAction();
if (action.equals(WifiManager.WIFI_STATE_CHANGED_ACTION)) {
synchronized (mMySync) {
+ mMySync.pendingSync.set(MySync.WIFI_STATE);
mMySync.expectedWifiState = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE,
WifiManager.WIFI_STATE_DISABLED);
mMySync.notify();
}
} else if(action.equals(WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION)) {
synchronized (mMySync) {
+ mMySync.pendingSync.set(MySync.P2P_STATE);
mMySync.expectedP2pState = intent.getIntExtra(WifiP2pManager.EXTRA_WIFI_STATE,
WifiP2pManager.WIFI_P2P_STATE_DISABLED);
mMySync.notify();
}
+ } else if (action.equals(WifiP2pManager.WIFI_P2P_DISCOVERY_CHANGED_ACTION)) {
+ synchronized (mMySync) {
+ mMySync.pendingSync.set(MySync.DISCOVERY_STATE);
+ mMySync.expectedDiscoveryState = intent.getIntExtra(
+ WifiP2pManager.EXTRA_DISCOVERY_STATE,
+ WifiP2pManager.WIFI_P2P_DISCOVERY_STOPPED);
+ mMySync.notify();
+ }
+ } else if (action.equals(WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION)) {
+ synchronized (mMySync) {
+ mMySync.pendingSync.set(MySync.NETWORK_INFO);
+ mMySync.expectedNetworkInfo = (NetworkInfo) intent.getExtra(
+ WifiP2pManager.EXTRA_NETWORK_INFO, null);
+ mMySync.notify();
+ }
}
}
};
@@ -82,17 +130,21 @@
mIntentFilter = new IntentFilter();
mIntentFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
mIntentFilter.addAction(WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION);
+ mIntentFilter.addAction(WifiP2pManager.WIFI_P2P_DISCOVERY_CHANGED_ACTION);
+ mIntentFilter.addAction(WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION);
mContext.registerReceiver(mReceiver, mIntentFilter);
mWifiManager = (WifiManager) getContext().getSystemService(Context.WIFI_SERVICE);
assertNotNull(mWifiManager);
if (mWifiManager.isWifiEnabled()) {
- assertTrue(mWifiManager.setWifiEnabled(false));
+ SystemUtil.runShellCommand("svc wifi disable");
Thread.sleep(DURATION);
}
assertTrue(!mWifiManager.isWifiEnabled());
mMySync.expectedWifiState = WifiManager.WIFI_STATE_DISABLED;
mMySync.expectedP2pState = WifiP2pManager.WIFI_P2P_STATE_DISABLED;
+ mMySync.expectedDiscoveryState = WifiP2pManager.WIFI_P2P_DISCOVERY_STOPPED;
+ mMySync.expectedNetworkInfo = null;
}
@Override
@@ -109,16 +161,66 @@
super.tearDown();
}
- private void waitForBroadcasts() {
+ private boolean waitForBroadcasts(List<Integer> waitSyncList) {
synchronized (mMySync) {
long timeout = System.currentTimeMillis() + TIMEOUT_MSEC;
- while (System.currentTimeMillis() < timeout
- && (mMySync.expectedWifiState != WifiManager.WIFI_STATE_ENABLED ||
- mMySync.expectedP2pState != WifiP2pManager.WIFI_P2P_STATE_ENABLED)) {
+ while (System.currentTimeMillis() < timeout) {
+ List<Integer> handledSyncList = waitSyncList.stream()
+ .filter(w -> mMySync.pendingSync.get(w))
+ .collect(Collectors.toList());
+ handledSyncList.forEach(w -> mMySync.pendingSync.clear(w));
+ waitSyncList.removeAll(handledSyncList);
+ if (waitSyncList.isEmpty()) {
+ break;
+ }
try {
mMySync.wait(WAIT_MSEC);
} catch (InterruptedException e) { }
}
+ if (!waitSyncList.isEmpty()) {
+ Log.i(TAG, "Missing broadcast: " + waitSyncList);
+ }
+ return waitSyncList.isEmpty();
+ }
+ }
+
+ private boolean waitForBroadcasts(int waitSingleSync) {
+ return waitForBroadcasts(
+ new LinkedList<Integer>(Arrays.asList(waitSingleSync)));
+ }
+
+ private boolean waitForServiceResponse(MyResponse waitResponse) {
+ synchronized (waitResponse) {
+ long timeout = System.currentTimeMillis() + TIMEOUT_MSEC;
+ while (System.currentTimeMillis() < timeout) {
+ try {
+ waitResponse.wait(WAIT_MSEC);
+ } catch (InterruptedException e) { }
+
+ if (waitResponse.valid) {
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+
+ // Return true if location is enabled.
+ private boolean isLocationEnabled() {
+ return Settings.Secure.getInt(getContext().getContentResolver(),
+ Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_OFF)
+ != Settings.Secure.LOCATION_MODE_OFF;
+ }
+
+ // Returns true if the device has location feature.
+ private boolean hasLocationFeature() {
+ return getContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_LOCATION);
+ }
+
+ private void resetResponse(MyResponse responseObj) {
+ synchronized (responseObj) {
+ responseObj.valid = false;
+ responseObj.networkInfo = null;
}
}
@@ -127,7 +229,7 @@
*/
private void enableWifi() throws InterruptedException {
if (!mWifiManager.isWifiEnabled()) {
- assertTrue(mWifiManager.setWifiEnabled(true));
+ SystemUtil.runShellCommand("svc wifi enable");
}
ConnectivityManager cm =
@@ -149,25 +251,212 @@
cm.unregisterNetworkCallback(networkCallback);
}
- public void testConcurrency() {
+ private boolean setupWifiP2p() {
// Cannot support p2p alone
if (!WifiFeature.isWifiSupported(getContext())) {
assertTrue(!WifiFeature.isP2pSupported(getContext()));
- return;
+ return false;
}
if (!WifiFeature.isP2pSupported(getContext())) {
// skip the test if p2p is not supported
+ return false;
+ }
+
+ if (!hasLocationFeature()) {
+ Log.d(TAG, "Skipping test as location is not supported");
+ return false;
+ }
+ if (!isLocationEnabled()) {
+ fail("Please enable location for this test - since P-release WiFi Direct"
+ + " needs Location enabled.");
+ }
+
+ long timeout = System.currentTimeMillis() + TIMEOUT_MSEC;
+ while (!mWifiManager.isWifiEnabled() && System.currentTimeMillis() < timeout) {
+ try {
+ enableWifi();
+ } catch (InterruptedException e) { }
+ }
+
+ assertTrue(mWifiManager.isWifiEnabled());
+
+ assertTrue(waitForBroadcasts(
+ new LinkedList<Integer>(
+ Arrays.asList(MySync.WIFI_STATE, MySync.P2P_STATE))));
+
+ assertEquals(WifiManager.WIFI_STATE_ENABLED, mMySync.expectedWifiState);
+ assertEquals(WifiP2pManager.WIFI_P2P_STATE_ENABLED, mMySync.expectedP2pState);
+
+ mWifiP2pManager =
+ (WifiP2pManager) getContext().getSystemService(Context.WIFI_P2P_SERVICE);
+ mWifiP2pChannel = mWifiP2pManager.initialize(
+ getContext(), getContext().getMainLooper(), null);
+
+ assertNotNull(mWifiP2pManager);
+ assertNotNull(mWifiP2pChannel);
+
+ assertTrue(waitForBroadcasts(MySync.NETWORK_INFO));
+ // wait for changing to EnabledState
+ assertNotNull(mMySync.expectedNetworkInfo);
+ assertTrue(mMySync.expectedNetworkInfo.isAvailable());
+
+ return true;
+ }
+
+ public void testConcurrency() {
+ if (!setupWifiP2p()) {
return;
}
- // Enable wifi
- assertTrue(mWifiManager.setWifiEnabled(true));
+ resetResponse(mMyResponse);
+ mWifiP2pManager.requestP2pState(mWifiP2pChannel, new WifiP2pManager.P2pStateListener() {
+ @Override
+ public void onP2pStateAvailable(int state) {
+ synchronized (mMyResponse) {
+ mMyResponse.valid = true;
+ mMyResponse.p2pState = state;
+ mMyResponse.notify();
+ }
+ }
+ });
+ assertTrue(waitForServiceResponse(mMyResponse));
+ assertEquals(WifiP2pManager.WIFI_P2P_STATE_ENABLED, mMyResponse.p2pState);
+ }
- waitForBroadcasts();
+ public void testRequestDiscoveryState() {
+ if (!setupWifiP2p()) {
+ return;
+ }
- assertTrue(mMySync.expectedWifiState == WifiManager.WIFI_STATE_ENABLED);
- assertTrue(mMySync.expectedP2pState == WifiP2pManager.WIFI_P2P_STATE_ENABLED);
+ resetResponse(mMyResponse);
+ mWifiP2pManager.requestDiscoveryState(
+ mWifiP2pChannel, new WifiP2pManager.DiscoveryStateListener() {
+ @Override
+ public void onDiscoveryStateAvailable(int state) {
+ synchronized (mMyResponse) {
+ mMyResponse.valid = true;
+ mMyResponse.discoveryState = state;
+ mMyResponse.notify();
+ }
+ }
+ });
+ assertTrue(waitForServiceResponse(mMyResponse));
+ assertEquals(WifiP2pManager.WIFI_P2P_DISCOVERY_STOPPED, mMyResponse.discoveryState);
+
+ resetResponse(mMyResponse);
+ mWifiP2pManager.discoverPeers(mWifiP2pChannel, new WifiP2pManager.ActionListener() {
+ @Override
+ public void onSuccess() {
+ synchronized (mMyResponse) {
+ mMyResponse.valid = true;
+ mMyResponse.success = true;
+ mMyResponse.notify();
+ }
+ }
+
+ @Override
+ public void onFailure(int reason) {
+ synchronized (mMyResponse) {
+ Log.d(TAG, "discoveryPeers failure reason: " + reason);
+ mMyResponse.valid = true;
+ mMyResponse.success = false;
+ mMyResponse.notify();
+ }
+ }
+ });
+ assertTrue(waitForServiceResponse(mMyResponse));
+ assertTrue(mMyResponse.success);
+ assertTrue(waitForBroadcasts(MySync.DISCOVERY_STATE));
+
+ resetResponse(mMyResponse);
+ mWifiP2pManager.requestDiscoveryState(mWifiP2pChannel,
+ new WifiP2pManager.DiscoveryStateListener() {
+ @Override
+ public void onDiscoveryStateAvailable(int state) {
+ synchronized (mMyResponse) {
+ mMyResponse.valid = true;
+ mMyResponse.discoveryState = state;
+ mMyResponse.notify();
+ }
+ }
+ });
+ assertTrue(waitForServiceResponse(mMyResponse));
+ assertEquals(WifiP2pManager.WIFI_P2P_DISCOVERY_STARTED, mMyResponse.discoveryState);
+
+ mWifiP2pManager.stopPeerDiscovery(mWifiP2pChannel, null);
+ }
+
+ public void testRequestNetworkInfo() {
+ if (!setupWifiP2p()) {
+ return;
+ }
+
+ resetResponse(mMyResponse);
+ mWifiP2pManager.requestNetworkInfo(mWifiP2pChannel,
+ new WifiP2pManager.NetworkInfoListener() {
+ @Override
+ public void onNetworkInfoAvailable(NetworkInfo info) {
+ synchronized (mMyResponse) {
+ mMyResponse.valid = true;
+ mMyResponse.networkInfo = info;
+ mMyResponse.notify();
+ }
+ }
+ });
+ assertTrue(waitForServiceResponse(mMyResponse));
+ assertNotNull(mMyResponse.networkInfo);
+ // The state might be IDLE, DISCONNECTED, FAILED before a connection establishment.
+ // Just ensure the state is NOT CONNECTED.
+ assertNotEquals(NetworkInfo.DetailedState.CONNECTED,
+ mMySync.expectedNetworkInfo.getDetailedState());
+
+ resetResponse(mMyResponse);
+ mWifiP2pManager.createGroup(mWifiP2pChannel, new WifiP2pManager.ActionListener() {
+ @Override
+ public void onSuccess() {
+ synchronized (mMyResponse) {
+ mMyResponse.valid = true;
+ mMyResponse.success = true;
+ mMyResponse.notify();
+ }
+ }
+
+ @Override
+ public void onFailure(int reason) {
+ synchronized (mMyResponse) {
+ Log.d(TAG, "createGroup failure reason: " + reason);
+ mMyResponse.valid = true;
+ mMyResponse.success = false;
+ mMyResponse.notify();
+ }
+ }
+ });
+ assertTrue(waitForServiceResponse(mMyResponse));
+ assertTrue(mMyResponse.success);
+ assertTrue(waitForBroadcasts(MySync.NETWORK_INFO));
+ assertNotNull(mMySync.expectedNetworkInfo);
+ assertEquals(NetworkInfo.DetailedState.CONNECTED,
+ mMySync.expectedNetworkInfo.getDetailedState());
+
+ resetResponse(mMyResponse);
+ mWifiP2pManager.requestNetworkInfo(mWifiP2pChannel,
+ new WifiP2pManager.NetworkInfoListener() {
+ @Override
+ public void onNetworkInfoAvailable(NetworkInfo info) {
+ synchronized (mMyResponse) {
+ mMyResponse.valid = true;
+ mMyResponse.networkInfo = info;
+ mMyResponse.notify();
+ }
+ }
+ });
+ assertTrue(waitForServiceResponse(mMyResponse));
+ assertNotNull(mMyResponse.networkInfo);
+ assertEquals(NetworkInfo.DetailedState.CONNECTED,
+ mMyResponse.networkInfo.getDetailedState());
+
+ mWifiP2pManager.removeGroup(mWifiP2pChannel, null);
}
}
diff --git a/tests/cts/net/src/android/net/wifi/cts/MulticastLockTest.java b/tests/cts/net/src/android/net/wifi/cts/MulticastLockTest.java
new file mode 100644
index 0000000..71f04a3
--- /dev/null
+++ b/tests/cts/net/src/android/net/wifi/cts/MulticastLockTest.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net.wifi.cts;
+
+import android.content.Context;
+import android.net.wifi.WifiManager;
+import android.net.wifi.WifiManager.MulticastLock;
+import android.platform.test.annotations.AppModeFull;
+import android.test.AndroidTestCase;
+
+@AppModeFull(reason = "Cannot get WifiManager in instant app mode")
+public class MulticastLockTest extends AndroidTestCase {
+
+ private static final String WIFI_TAG = "MulticastLockTest";
+
+ /**
+ * Verify acquire and release of Multicast locks
+ */
+ public void testMulticastLock() {
+ if (!WifiFeature.isWifiSupported(getContext())) {
+ // skip the test if WiFi is not supported
+ return;
+ }
+ WifiManager wm = (WifiManager) getContext().getSystemService(Context.WIFI_SERVICE);
+ MulticastLock mcl = wm.createMulticastLock(WIFI_TAG);
+
+ mcl.setReferenceCounted(true);
+ assertFalse(mcl.isHeld());
+ mcl.acquire();
+ assertTrue(mcl.isHeld());
+ mcl.release();
+ assertFalse(mcl.isHeld());
+ mcl.acquire();
+ mcl.acquire();
+ assertTrue(mcl.isHeld());
+ mcl.release();
+ assertTrue(mcl.isHeld());
+ mcl.release();
+ assertFalse(mcl.isHeld());
+ assertNotNull(mcl.toString());
+ try {
+ mcl.release();
+ fail("should throw out exception because release is called"
+ +" a greater number of times than acquire");
+ } catch (RuntimeException e) {
+ // expected
+ }
+
+ mcl = wm.createMulticastLock(WIFI_TAG);
+ mcl.setReferenceCounted(false);
+ assertFalse(mcl.isHeld());
+ mcl.acquire();
+ assertTrue(mcl.isHeld());
+ mcl.release();
+ assertFalse(mcl.isHeld());
+ mcl.acquire();
+ mcl.acquire();
+ assertTrue(mcl.isHeld());
+ mcl.release();
+ assertFalse(mcl.isHeld());
+ assertNotNull(mcl.toString());
+ // releasing again after release: but ignored for non-referenced locks
+ mcl.release();
+ }
+}
diff --git a/tests/cts/net/src/android/net/wifi/cts/ScanResultTest.java b/tests/cts/net/src/android/net/wifi/cts/ScanResultTest.java
index 839881f..ccf5fe2 100644
--- a/tests/cts/net/src/android/net/wifi/cts/ScanResultTest.java
+++ b/tests/cts/net/src/android/net/wifi/cts/ScanResultTest.java
@@ -29,6 +29,8 @@
import android.test.AndroidTestCase;
import android.util.Log;
+import com.android.compatibility.common.util.SystemUtil;
+
@AppModeFull(reason = "Cannot get WifiManager in instant app mode")
public class ScanResultTest extends AndroidTestCase {
private static class MySync {
@@ -123,7 +125,11 @@
private void setWifiEnabled(boolean enable) throws Exception {
synchronized (mMySync) {
mMySync.expectedState = STATE_WIFI_CHANGING;
- assertTrue(mWifiManager.setWifiEnabled(enable));
+ if (enable) {
+ SystemUtil.runShellCommand("svc wifi enable");
+ } else {
+ SystemUtil.runShellCommand("svc wifi disable");
+ }
waitForBroadcast(TIMEOUT_MSEC, STATE_WIFI_CHANGED);
}
}
diff --git a/tests/cts/net/src/android/net/wifi/cts/WifiEnterpriseConfigTest.java b/tests/cts/net/src/android/net/wifi/cts/WifiEnterpriseConfigTest.java
index 77a2583..b592c10 100644
--- a/tests/cts/net/src/android/net/wifi/cts/WifiEnterpriseConfigTest.java
+++ b/tests/cts/net/src/android/net/wifi/cts/WifiEnterpriseConfigTest.java
@@ -18,7 +18,6 @@
import android.content.Context;
import android.content.pm.PackageManager;
-import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiEnterpriseConfig;
import android.net.wifi.WifiEnterpriseConfig.Eap;
import android.net.wifi.WifiEnterpriseConfig.Phase2;
@@ -26,6 +25,8 @@
import android.platform.test.annotations.AppModeFull;
import android.test.AndroidTestCase;
+import com.android.compatibility.common.util.SystemUtil;
+
import java.io.ByteArrayInputStream;
import java.security.KeyFactory;
import java.security.PrivateKey;
@@ -35,7 +36,7 @@
@AppModeFull(reason = "Cannot get WifiManager in instant app mode")
public class WifiEnterpriseConfigTest extends AndroidTestCase {
- private WifiManager mWifiManager;
+ private WifiManager mWifiManager;
private static final String SSID = "\"TestSSID\"";
private static final String IDENTITY = "identity";
@@ -689,7 +690,7 @@
mWifiManager = (WifiManager) mContext
.getSystemService(Context.WIFI_SERVICE);
assertNotNull(mWifiManager);
- mWifiManager.setWifiEnabled(true);
+ SystemUtil.runShellCommand("svc wifi enable");
Thread.sleep(ENABLE_DELAY);
if (hasWifi()) {
assertTrue(mWifiManager.isWifiEnabled());
@@ -776,33 +777,6 @@
assertTrue(config.getDomainSuffixMatch().equals(DOM_SUBJECT_MATCH));
}
- public void testAddEapNetwork() {
- if (!hasWifi()) {
- return;
- }
-
- WifiConfiguration config = new WifiConfiguration();
- WifiEnterpriseConfig enterpriseConfig = new WifiEnterpriseConfig();
- enterpriseConfig.setEapMethod(Eap.PWD);
- enterpriseConfig.setIdentity(IDENTITY);
- enterpriseConfig.setPassword(PASSWORD);
- config.SSID = SSID;
- config.enterpriseConfig = enterpriseConfig;
-
- int netId = mWifiManager.addNetwork(config);
- assertTrue(doesSsidExist(SSID));
- mWifiManager.removeNetwork(netId);
- assertFalse(doesSsidExist(SSID));
- }
-
- private boolean doesSsidExist(String ssid) {
- for (final WifiConfiguration w : mWifiManager.getConfiguredNetworks()) {
- if (w.SSID.equals(ssid))
- return true;
- }
- return false;
- }
-
public void testEnterpriseConfigDoesNotPrintPassword() {
WifiEnterpriseConfig enterpriseConfig = new WifiEnterpriseConfig();
final String identity = "IdentityIsOkayToBeDisplayedHere";
diff --git a/tests/cts/net/src/android/net/wifi/cts/WifiInfoTest.java b/tests/cts/net/src/android/net/wifi/cts/WifiInfoTest.java
index a05646e..5367722 100644
--- a/tests/cts/net/src/android/net/wifi/cts/WifiInfoTest.java
+++ b/tests/cts/net/src/android/net/wifi/cts/WifiInfoTest.java
@@ -30,6 +30,7 @@
import android.test.AndroidTestCase;
import com.android.compatibility.common.util.PollingCheck;
+import com.android.compatibility.common.util.SystemUtil;
import java.util.concurrent.Callable;
@@ -106,7 +107,11 @@
private void setWifiEnabled(boolean enable) throws Exception {
synchronized (mMySync) {
mMySync.expectedState = STATE_WIFI_CHANGING;
- assertTrue(mWifiManager.setWifiEnabled(enable));
+ if (enable) {
+ SystemUtil.runShellCommand("svc wifi enable");
+ } else {
+ SystemUtil.runShellCommand("svc wifi disable");
+ }
long timeout = System.currentTimeMillis() + TIMEOUT_MSEC;
while (System.currentTimeMillis() < timeout
&& mMySync.expectedState == STATE_WIFI_CHANGING)
@@ -136,6 +141,8 @@
wifiInfo.getBSSID();
wifiInfo.getIpAddress();
wifiInfo.getLinkSpeed();
+ wifiInfo.getTxLinkSpeedMbps();
+ wifiInfo.getRxLinkSpeedMbps();
wifiInfo.getRssi();
wifiInfo.getHiddenSSID();
wifiInfo.getMacAddress();
diff --git a/tests/cts/net/src/android/net/wifi/cts/WifiManager_WifiLockTest.java b/tests/cts/net/src/android/net/wifi/cts/WifiLockTest.java
similarity index 75%
rename from tests/cts/net/src/android/net/wifi/cts/WifiManager_WifiLockTest.java
rename to tests/cts/net/src/android/net/wifi/cts/WifiLockTest.java
index f7efe4c..6ac92d4 100644
--- a/tests/cts/net/src/android/net/wifi/cts/WifiManager_WifiLockTest.java
+++ b/tests/cts/net/src/android/net/wifi/cts/WifiLockTest.java
@@ -23,17 +23,31 @@
import android.test.AndroidTestCase;
@AppModeFull(reason = "Cannot get WifiManager in instant app mode")
-public class WifiManager_WifiLockTest extends AndroidTestCase {
+public class WifiLockTest extends AndroidTestCase {
- private static final String WIFI_TAG = "WifiManager_WifiLockTest";
+ private static final String WIFI_TAG = "WifiLockTest";
- public void testWifiLock() {
+ /**
+ * Verify acquire and release of High Performance wifi locks
+ */
+ public void testHiPerfWifiLock() {
+ testWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF);
+ }
+
+ /**
+ * Verify acquire and release of Low latency wifi locks
+ */
+ public void testLowLatencyWifiLock() {
+ testWifiLock(WifiManager.WIFI_MODE_FULL_LOW_LATENCY);
+ }
+
+ private void testWifiLock(int lockType) {
if (!WifiFeature.isWifiSupported(getContext())) {
// skip the test if WiFi is not supported
return;
}
WifiManager wm = (WifiManager) getContext().getSystemService(Context.WIFI_SERVICE);
- WifiLock wl = wm.createWifiLock(WIFI_TAG);
+ WifiLock wl = wm.createWifiLock(lockType, WIFI_TAG);
wl.setReferenceCounted(true);
assertFalse(wl.isHeld());
@@ -57,7 +71,7 @@
// expected
}
- wl = wm.createWifiLock(WIFI_TAG);
+ wl = wm.createWifiLock(lockType, WIFI_TAG);
wl.setReferenceCounted(false);
assertFalse(wl.isHeld());
wl.acquire();
@@ -70,7 +84,7 @@
wl.release();
assertFalse(wl.isHeld());
assertNotNull(wl.toString());
- // should be ignored
+ // releasing again after release: but ignored for non-referenced locks
wl.release();
}
}
diff --git a/tests/cts/net/src/android/net/wifi/cts/WifiManagerTest.java b/tests/cts/net/src/android/net/wifi/cts/WifiManagerTest.java
index 31c721e..0ef5cd9 100644
--- a/tests/cts/net/src/android/net/wifi/cts/WifiManagerTest.java
+++ b/tests/cts/net/src/android/net/wifi/cts/WifiManagerTest.java
@@ -21,34 +21,43 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiConfiguration;
-import android.net.wifi.WifiConfiguration.Status;
import android.net.wifi.WifiManager;
import android.net.wifi.WifiManager.TxPacketCountListener;
import android.net.wifi.WifiManager.WifiLock;
import android.net.wifi.hotspot2.PasspointConfiguration;
import android.net.wifi.hotspot2.pps.Credential;
import android.net.wifi.hotspot2.pps.HomeSp;
+import android.os.Process;
import android.os.SystemClock;
+import android.os.UserHandle;
import android.platform.test.annotations.AppModeFull;
import android.provider.Settings;
+import android.support.test.uiautomator.UiDevice;
import android.test.AndroidTestCase;
+import android.text.TextUtils;
+import android.util.ArraySet;
import android.util.Log;
-import com.android.compatibility.common.util.WifiConfigCreator;
+import androidx.test.InstrumentationRegistry;
+
+import com.android.compatibility.common.util.SystemUtil;
import java.net.HttpURLConnection;
import java.net.URL;
import java.security.MessageDigest;
import java.security.cert.X509Certificate;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
+import java.util.Objects;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
+import java.util.stream.Collectors;
@AppModeFull(reason = "Cannot get WifiManager in instant app mode")
public class WifiManagerTest extends AndroidTestCase {
@@ -62,6 +71,7 @@
private List<ScanResult> mScanResults = null;
private NetworkInfo mNetworkInfo;
private Object mLOHSLock = new Object();
+ private UiDevice mUiDevice;
// Please refer to WifiManager
private static final int MIN_RSSI = -100;
@@ -76,9 +86,6 @@
private static final String TAG = "WifiManagerTest";
private static final String SSID1 = "\"WifiManagerTest\"";
- private static final String SSID2 = "\"WifiManagerTestModified\"";
- private static final String PROXY_TEST_SSID = "SomeProxyAp";
- private static final String ADD_NETWORK_EXCEPTION_SUBSTR = "addNetwork";
// A full single scan duration is about 6-7 seconds if country code is set
// to US. If country code is set to world mode (00), we would expect a scan
// duration of roughly 8 seconds. So we set scan timeout as 9 seconds here.
@@ -86,11 +93,16 @@
private static final int TIMEOUT_MSEC = 6000;
private static final int WAIT_MSEC = 60;
private static final int DURATION = 10000;
+ private static final int DURATION_SCREEN_TOGGLE = 2000;
private static final int WIFI_SCAN_TEST_INTERVAL_MILLIS = 60 * 1000;
private static final int WIFI_SCAN_TEST_CACHE_DELAY_MILLIS = 3 * 60 * 1000;
private static final int WIFI_SCAN_TEST_ITERATIONS = 5;
+ private static final int ENFORCED_NUM_NETWORK_SUGGESTIONS_PER_APP = 50;
+
private static final String TEST_PAC_URL = "http://www.example.com/proxy.pac";
+ private static final String MANAGED_PROVISIONING_PACKAGE_NAME
+ = "com.android.managedprovisioning";
private IntentFilter mIntentFilter;
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@@ -158,6 +170,8 @@
mWifiLock.acquire();
if (!mWifiManager.isWifiEnabled())
setWifiEnabled(true);
+ mUiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
+ turnScreenOnNoDelay();
Thread.sleep(DURATION);
assertTrue(mWifiManager.isWifiEnabled());
synchronized (mMySync) {
@@ -188,8 +202,8 @@
} else {
mMySync.expectedState = (enable ? STATE_WIFI_ENABLED : STATE_WIFI_DISABLED);
}
- // now trigger the change
- assertTrue(mWifiManager.setWifiEnabled(enable));
+ // now trigger the change using shell commands.
+ SystemUtil.runShellCommand("svc wifi " + (enable ? "enable" : "disable"));
waitForExpectedWifiState(enable);
}
}
@@ -238,7 +252,6 @@
private void connectWifi() throws Exception {
synchronized (mMySync) {
if (mNetworkInfo.getState() == NetworkInfo.State.CONNECTED) return;
- assertTrue(mWifiManager.reconnect());
long timeout = System.currentTimeMillis() + TIMEOUT_MSEC;
while (System.currentTimeMillis() < timeout
&& mNetworkInfo.getState() != NetworkInfo.State.CONNECTED)
@@ -264,20 +277,13 @@
}
/**
- * test point of wifiManager actions:
- * 1.reconnect
- * 2.reassociate
- * 3.disconnect
- * 4.createWifiLock
+ * Test creation of WifiManager Lock.
*/
- public void testWifiManagerActions() throws Exception {
+ public void testWifiManagerLock() throws Exception {
if (!WifiFeature.isWifiSupported(getContext())) {
// skip the test if WiFi is not supported
return;
}
- assertTrue(mWifiManager.reconnect());
- assertTrue(mWifiManager.reassociate());
- assertTrue(mWifiManager.disconnect());
final String TAG = "Test";
assertNotNull(mWifiManager.createWifiLock(TAG));
assertNotNull(mWifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL, TAG));
@@ -398,123 +404,8 @@
return getContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_LOCATION);
}
- /**
- * test point of wifiManager NetWork:
- * 1.add NetWork
- * 2.update NetWork
- * 3.remove NetWork
- * 4.enable NetWork
- * 5.disable NetWork
- * 6.configured Networks
- * 7.save configure;
- */
- public void testWifiManagerNetWork() throws Exception {
- if (!WifiFeature.isWifiSupported(getContext())) {
- // skip the test if WiFi is not supported
- return;
- }
-
- // store the list of enabled networks, so they can be re-enabled after test completes
- Set<String> enabledSsids = getEnabledNetworks(mWifiManager.getConfiguredNetworks());
- try {
- WifiConfiguration wifiConfiguration;
- // add a WifiConfig
- final int notExist = -1;
- List<WifiConfiguration> wifiConfiguredNetworks = mWifiManager.getConfiguredNetworks();
- int pos = findConfiguredNetworks(SSID1, wifiConfiguredNetworks);
- if (notExist != pos) {
- wifiConfiguration = wifiConfiguredNetworks.get(pos);
- mWifiManager.removeNetwork(wifiConfiguration.networkId);
- }
- pos = findConfiguredNetworks(SSID1, wifiConfiguredNetworks);
- assertEquals(notExist, pos);
- final int size = wifiConfiguredNetworks.size();
-
- wifiConfiguration = new WifiConfiguration();
- wifiConfiguration.SSID = SSID1;
- wifiConfiguration.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
- int netId = mWifiManager.addNetwork(wifiConfiguration);
- assertTrue(existSSID(SSID1));
-
- wifiConfiguredNetworks = mWifiManager.getConfiguredNetworks();
- assertEquals(size + 1, wifiConfiguredNetworks.size());
- pos = findConfiguredNetworks(SSID1, wifiConfiguredNetworks);
- assertTrue(notExist != pos);
-
- // Enable & disable network
- boolean disableOthers = true;
- assertTrue(mWifiManager.enableNetwork(netId, disableOthers));
- wifiConfiguration = mWifiManager.getConfiguredNetworks().get(pos);
- assertEquals(Status.ENABLED, wifiConfiguration.status);
-
- assertTrue(mWifiManager.disableNetwork(netId));
- wifiConfiguration = mWifiManager.getConfiguredNetworks().get(pos);
- assertEquals(Status.DISABLED, wifiConfiguration.status);
-
- // Update a WifiConfig
- wifiConfiguration = wifiConfiguredNetworks.get(pos);
- wifiConfiguration.SSID = SSID2;
- netId = mWifiManager.updateNetwork(wifiConfiguration);
- assertFalse(existSSID(SSID1));
- assertTrue(existSSID(SSID2));
-
- // Remove a WifiConfig
- assertTrue(mWifiManager.removeNetwork(netId));
- assertFalse(mWifiManager.removeNetwork(notExist));
- assertFalse(existSSID(SSID1));
- assertFalse(existSSID(SSID2));
-
- assertTrue(mWifiManager.saveConfiguration());
- } finally {
- reEnableNetworks(enabledSsids, mWifiManager.getConfiguredNetworks());
- mWifiManager.saveConfiguration();
- }
- }
-
- /**
- * Verifies that addNetwork() fails for WifiConfigurations containing a non-null http proxy when
- * the caller doesn't have OVERRIDE_WIFI_CONFIG permission, DeviceOwner or ProfileOwner device
- * management policies
- */
- public void testSetHttpProxy_PermissionFail() throws Exception {
- if (!WifiFeature.isWifiSupported(getContext())) {
- // skip the test if WiFi is not supported
- return;
- }
- WifiConfigCreator configCreator = new WifiConfigCreator(getContext());
- boolean exceptionThrown = false;
- try {
- configCreator.addHttpProxyNetworkVerifyAndRemove(
- PROXY_TEST_SSID, TEST_PAC_URL);
- } catch (IllegalStateException e) {
- // addHttpProxyNetworkVerifyAndRemove throws three IllegalStateException,
- // expect it to throw for the addNetwork operation
- if (e.getMessage().contains(ADD_NETWORK_EXCEPTION_SUBSTR)) {
- exceptionThrown = true;
- }
- }
- assertTrue(exceptionThrown);
- }
-
- private Set<String> getEnabledNetworks(List<WifiConfiguration> configuredNetworks) {
- Set<String> ssids = new HashSet<String>();
- for (WifiConfiguration wifiConfig : configuredNetworks) {
- if (Status.ENABLED == wifiConfig.status || Status.CURRENT == wifiConfig.status) {
- ssids.add(wifiConfig.SSID);
- Log.i(TAG, String.format("remembering enabled network %s", wifiConfig.SSID));
- }
- }
- return ssids;
- }
-
- private void reEnableNetworks(Set<String> enabledSsids,
- List<WifiConfiguration> configuredNetworks) {
- for (WifiConfiguration wifiConfig : configuredNetworks) {
- if (enabledSsids.contains(wifiConfig.SSID)) {
- mWifiManager.enableNetwork(wifiConfig.networkId, false);
- Log.i(TAG, String.format("re-enabling network %s", wifiConfig.SSID));
- }
- }
+ private boolean hasAutomotiveFeature() {
+ return getContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE);
}
public void testSignal() {
@@ -623,164 +514,6 @@
assertTrue(i < 15);
}
- /**
- * Verify Passpoint configuration management APIs (add, remove, get) for a Passpoint
- * configuration with an user credential.
- *
- * @throws Exception
- */
- public void testAddPasspointConfigWithUserCredential() throws Exception {
- if (!WifiFeature.isWifiSupported(getContext())) {
- // skip the test if WiFi is not supported
- return;
- }
- testAddPasspointConfig(generatePasspointConfig(generateUserCredential()));
- }
-
- /**
- * Verify Passpoint configuration management APIs (add, remove, get) for a Passpoint
- * configuration with a certificate credential.
- *
- * @throws Exception
- */
- public void testAddPasspointConfigWithCertCredential() throws Exception {
- if (!WifiFeature.isWifiSupported(getContext())) {
- // skip the test if WiFi is not supported
- return;
- }
- testAddPasspointConfig(generatePasspointConfig(generateCertCredential()));
- }
-
- /**
- * Verify Passpoint configuration management APIs (add, remove, get) for a Passpoint
- * configuration with a SIm credential.
- *
- * @throws Exception
- */
- public void testAddPasspointConfigWithSimCredential() throws Exception {
- if (!WifiFeature.isWifiSupported(getContext())) {
- // skip the test if WiFi is not supported
- return;
- }
- testAddPasspointConfig(generatePasspointConfig(generateSimCredential()));
- }
-
- /**
- * Helper function for generating a {@link PasspointConfiguration} for testing.
- *
- * @return {@link PasspointConfiguration}
- */
- private PasspointConfiguration generatePasspointConfig(Credential credential) {
- PasspointConfiguration config = new PasspointConfiguration();
- config.setCredential(credential);
-
- // Setup HomeSp.
- HomeSp homeSp = new HomeSp();
- homeSp.setFqdn("Test.com");
- homeSp.setFriendlyName("Test Provider");
- homeSp.setRoamingConsortiumOis(new long[] {0x11223344});
- config.setHomeSp(homeSp);
-
- return config;
- }
-
- /**
- * Helper function for generating an user credential for testing.
- *
- * @return {@link Credential}
- */
- private Credential generateUserCredential() {
- Credential credential = new Credential();
- credential.setRealm("test.net");
- Credential.UserCredential userCred = new Credential.UserCredential();
- userCred.setEapType(21 /* EAP_TTLS */);
- userCred.setUsername("username");
- userCred.setPassword("password");
- userCred.setNonEapInnerMethod("PAP");
- credential.setUserCredential(userCred);
- credential.setCaCertificate(FakeKeys.CA_PUBLIC_CERT);
- return credential;
- }
-
- /**
- * Helper function for generating a certificate credential for testing.
- *
- * @return {@link Credential}
- */
- private Credential generateCertCredential() throws Exception {
- Credential credential = new Credential();
- credential.setRealm("test.net");
- Credential.CertificateCredential certCredential = new Credential.CertificateCredential();
- certCredential.setCertType("x509v3");
- certCredential.setCertSha256Fingerprint(
- MessageDigest.getInstance("SHA-256").digest(FakeKeys.CLIENT_CERT.getEncoded()));
- credential.setCertCredential(certCredential);
- credential.setCaCertificate(FakeKeys.CA_PUBLIC_CERT);
- credential.setClientCertificateChain(new X509Certificate[] {FakeKeys.CLIENT_CERT});
- credential.setClientPrivateKey(FakeKeys.RSA_KEY1);
- return credential;
- }
-
- /**
- * Helper function for generating a SIM credential for testing.
- *
- * @return {@link Credential}
- */
- private Credential generateSimCredential() throws Exception {
- Credential credential = new Credential();
- credential.setRealm("test.net");
- Credential.SimCredential simCredential = new Credential.SimCredential();
- simCredential.setImsi("1234*");
- simCredential.setEapType(18 /* EAP_SIM */);
- credential.setSimCredential(simCredential);
- return credential;
- }
-
- /**
- * Helper function verifying Passpoint configuration management APIs (add, remove, get) for
- * a given configuration.
- *
- * @param config The configuration to test with
- */
- private void testAddPasspointConfig(PasspointConfiguration config) throws Exception {
- try {
-
- // obtain number of passpoint networks already present in device (preloaded)
- List<PasspointConfiguration> preConfigList = mWifiManager.getPasspointConfigurations();
- int numOfNetworks = preConfigList.size();
-
- // add new (test) configuration
- mWifiManager.addOrUpdatePasspointConfiguration(config);
-
- // Certificates and keys will be set to null after it is installed to the KeyStore by
- // WifiManager. Reset them in the expected config so that it can be used to compare
- // against the retrieved config.
- config.getCredential().setCaCertificate(null);
- config.getCredential().setClientCertificateChain(null);
- config.getCredential().setClientPrivateKey(null);
-
- // retrieve the configuration and verify it. The retrieved list may not be in order -
- // check all configs to see if any match
- List<PasspointConfiguration> configList = mWifiManager.getPasspointConfigurations();
- assertEquals(numOfNetworks + 1, configList.size());
-
- boolean anyMatch = false;
- for (PasspointConfiguration passpointConfiguration : configList) {
- if (passpointConfiguration.equals(config)) {
- anyMatch = true;
- break;
- }
- }
- assertTrue(anyMatch);
-
- // remove the (test) configuration and verify number of installed configurations
- mWifiManager.removePasspointConfiguration(config.getHomeSp().getFqdn());
- assertEquals(mWifiManager.getPasspointConfigurations().size(), numOfNetworks);
- } catch (UnsupportedOperationException e) {
- // Passpoint build config |config_wifi_hotspot2_enabled| is disabled, so noop.
- }
- }
-
public class TestLocalOnlyHotspotCallback extends WifiManager.LocalOnlyHotspotCallback {
Object hotspotLock;
WifiManager.LocalOnlyHotspotReservation reservation = null;
@@ -837,6 +570,11 @@
// check if we got the callback
assertTrue(callback.onStartedCalled);
assertNotNull(callback.reservation.getWifiConfiguration());
+ if (!hasAutomotiveFeature()) {
+ assertEquals(
+ WifiConfiguration.AP_BAND_2GHZ,
+ callback.reservation.getWifiConfiguration().apBand);
+ }
assertFalse(callback.onFailedCalled);
assertFalse(callback.onStoppedCalled);
}
@@ -892,37 +630,37 @@
}
/**
- * Verify calls to setWifiEnabled from a non-settings app while softap mode is active do not
- * exit softap mode.
- *
- * This test uses the LocalOnlyHotspot API to enter softap mode. This should also be true when
- * tethering is started.
- * Note: Location mode must be enabled for this test.
+ * Verify calls to deprecated API's all fail for non-settings apps targeting >= Q SDK.
*/
- public void testSetWifiEnabledByAppDoesNotStopHotspot() throws Exception {
+ public void testDeprecatedApis() throws Exception {
if (!WifiFeature.isWifiSupported(getContext())) {
// skip the test if WiFi is not supported
return;
}
- // check that softap mode is supported by the device
- if (!mWifiManager.isPortableHotspotSupported()) {
- return;
- }
+ setWifiEnabled(true);
+ connectWifi(); // ensures that there is at-least 1 saved network on the device.
+
+ WifiConfiguration wifiConfiguration = new WifiConfiguration();
+ wifiConfiguration.SSID = SSID1;
+ wifiConfiguration.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
+
+ assertEquals(WifiConfiguration.INVALID_NETWORK_ID,
+ mWifiManager.addNetwork(wifiConfiguration));
+ assertEquals(WifiConfiguration.INVALID_NETWORK_ID,
+ mWifiManager.updateNetwork(wifiConfiguration));
+ assertFalse(mWifiManager.enableNetwork(0, true));
+ assertFalse(mWifiManager.disableNetwork(0));
+ assertFalse(mWifiManager.removeNetwork(0));
+ assertFalse(mWifiManager.disconnect());
+ assertFalse(mWifiManager.reconnect());
+ assertFalse(mWifiManager.reassociate());
+ assertTrue(mWifiManager.getConfiguredNetworks().isEmpty());
boolean wifiEnabled = mWifiManager.isWifiEnabled();
-
- if (wifiEnabled) {
- // disable wifi so we have something to turn on (some devices may be able to run
- // simultaneous modes)
- setWifiEnabled(false);
- }
-
- TestLocalOnlyHotspotCallback callback = startLocalOnlyHotspot();
-
- // now we should fail to turn on wifi
- assertFalse(mWifiManager.setWifiEnabled(true));
-
- stopLocalOnlyHotspot(callback, wifiEnabled);
+ // now we should fail to toggle wifi state.
+ assertFalse(mWifiManager.setWifiEnabled(!wifiEnabled));
+ Thread.sleep(DURATION);
+ assertEquals(wifiEnabled, mWifiManager.isWifiEnabled());
}
/**
@@ -971,4 +709,343 @@
stopLocalOnlyHotspot(callback, wifiEnabled);
}
+
+ /**
+ * Verify that the {@link android.Manifest.permission#NETWORK_STACK} permission is never held by
+ * any package.
+ * <p>
+ * No apps should <em>ever</em> attempt to acquire this permission, since it would give those
+ * apps extremely broad access to connectivity functionality.
+ */
+ public void testNetworkStackPermission() {
+ final PackageManager pm = getContext().getPackageManager();
+
+ final List<PackageInfo> holding = pm.getPackagesHoldingPermissions(new String[] {
+ android.Manifest.permission.NETWORK_STACK
+ }, PackageManager.MATCH_UNINSTALLED_PACKAGES);
+ for (PackageInfo pi : holding) {
+ fail("The NETWORK_STACK permission must not be held by " + pi.packageName
+ + " and must be revoked for security reasons");
+ }
+ }
+
+ /**
+ * Verify that the {@link android.Manifest.permission#NETWORK_SETTINGS} permission is
+ * never held by any package.
+ * <p>
+ * Only Settings, SysUi, NetworkStack and shell apps should <em>ever</em> attempt to acquire
+ * this permission, since it would give those apps extremely broad access to connectivity
+ * functionality. The permission is intended to be granted to only those apps with direct user
+ * access and no others.
+ */
+ public void testNetworkSettingsPermission() {
+ final PackageManager pm = getContext().getPackageManager();
+
+ final ArraySet<String> allowedPackages = new ArraySet();
+ final ArraySet<Integer> allowedUIDs = new ArraySet();
+ // explicitly add allowed UIDs
+ allowedUIDs.add(Process.SYSTEM_UID);
+ allowedUIDs.add(Process.SHELL_UID);
+ allowedUIDs.add(Process.PHONE_UID);
+ allowedUIDs.add(Process.NETWORK_STACK_UID);
+ allowedUIDs.add(Process.NFC_UID);
+
+ // only quick settings is allowed to bind to the BIND_QUICK_SETTINGS_TILE permission, using
+ // this fact to determined allowed package name for sysui. This is a signature permission,
+ // so allow any package with this permission.
+ final List<PackageInfo> sysuiPackages = pm.getPackagesHoldingPermissions(new String[] {
+ android.Manifest.permission.BIND_QUICK_SETTINGS_TILE
+ }, PackageManager.MATCH_UNINSTALLED_PACKAGES);
+ for (PackageInfo info : sysuiPackages) {
+ allowedPackages.add(info.packageName);
+ }
+
+ // the captive portal flow also currently holds the NETWORK_SETTINGS permission
+ final Intent intent = new Intent(ConnectivityManager.ACTION_CAPTIVE_PORTAL_SIGN_IN);
+ final ResolveInfo ri = pm.resolveActivity(intent, PackageManager.MATCH_DISABLED_COMPONENTS);
+ if (ri != null) {
+ allowedPackages.add(ri.activityInfo.packageName);
+ }
+
+ final List<PackageInfo> holding = pm.getPackagesHoldingPermissions(new String[] {
+ android.Manifest.permission.NETWORK_SETTINGS
+ }, PackageManager.MATCH_UNINSTALLED_PACKAGES);
+ for (PackageInfo pi : holding) {
+ String packageName = pi.packageName;
+
+ // this is an explicitly allowed package
+ if (allowedPackages.contains(packageName)) continue;
+
+ // now check if the packages are from allowed UIDs
+ int uid = -1;
+ try {
+ uid = pm.getPackageUidAsUser(packageName, UserHandle.USER_SYSTEM);
+ } catch (PackageManager.NameNotFoundException e) {
+ continue;
+ }
+ if (!allowedUIDs.contains(uid)) {
+ fail("The NETWORK_SETTINGS permission must not be held by " + packageName
+ + ":" + uid + " and must be revoked for security reasons");
+ }
+ }
+ }
+
+ /**
+ * Verify that the {@link android.Manifest.permission#NETWORK_SETUP_WIZARD} permission is
+ * only held by the device setup wizard application.
+ * <p>
+ * Only the SetupWizard app should <em>ever</em> attempt to acquire this
+ * permission, since it would give those apps extremely broad access to connectivity
+ * functionality. The permission is intended to be granted to only the device setup wizard.
+ */
+ public void testNetworkSetupWizardPermission() {
+ final ArraySet<String> allowedPackages = new ArraySet();
+
+ final PackageManager pm = getContext().getPackageManager();
+
+ final Intent intent = new Intent(Intent.ACTION_MAIN);
+ intent.addCategory(Intent.CATEGORY_SETUP_WIZARD);
+ final ResolveInfo ri = pm.resolveActivity(intent, PackageManager.MATCH_DISABLED_COMPONENTS);
+ String validPkg = "";
+ if (ri != null) {
+ allowedPackages.add(ri.activityInfo.packageName);
+ validPkg = ri.activityInfo.packageName;
+ }
+
+ final Intent preIntent = new Intent("com.android.setupwizard.OEM_PRE_SETUP");
+ preIntent.addCategory(Intent.CATEGORY_DEFAULT);
+ final ResolveInfo preRi = pm
+ .resolveActivity(preIntent, PackageManager.MATCH_DISABLED_COMPONENTS);
+ String prePackageName = "";
+ if (null != preRi) {
+ prePackageName = preRi.activityInfo.packageName;
+ }
+
+ final Intent postIntent = new Intent("com.android.setupwizard.OEM_POST_SETUP");
+ postIntent.addCategory(Intent.CATEGORY_DEFAULT);
+ final ResolveInfo postRi = pm
+ .resolveActivity(postIntent, PackageManager.MATCH_DISABLED_COMPONENTS);
+ String postPackageName = "";
+ if (null != postRi) {
+ postPackageName = postRi.activityInfo.packageName;
+ }
+ if (!TextUtils.isEmpty(prePackageName) && !TextUtils.isEmpty(postPackageName)
+ && prePackageName.equals(postPackageName)) {
+ allowedPackages.add(prePackageName);
+ }
+
+ final List<PackageInfo> holding = pm.getPackagesHoldingPermissions(new String[]{
+ android.Manifest.permission.NETWORK_SETUP_WIZARD
+ }, PackageManager.MATCH_UNINSTALLED_PACKAGES);
+ for (PackageInfo pi : holding) {
+ if (!allowedPackages.contains(pi.packageName)) {
+ fail("The NETWORK_SETUP_WIZARD permission must not be held by " + pi.packageName
+ + " and must be revoked for security reasons [" + validPkg + "]");
+ }
+ }
+ }
+
+ /**
+ * Verify that the {@link android.Manifest.permission#NETWORK_MANAGED_PROVISIONING} permission
+ * is only held by the device managed provisioning application.
+ * <p>
+ * Only the ManagedProvisioning app should <em>ever</em> attempt to acquire this
+ * permission, since it would give those apps extremely broad access to connectivity
+ * functionality. The permission is intended to be granted to only the device managed
+ * provisioning.
+ */
+ public void testNetworkManagedProvisioningPermission() {
+ final PackageManager pm = getContext().getPackageManager();
+
+ // TODO(b/115980767): Using hardcoded package name. Need a better mechanism to find the
+ // managed provisioning app.
+ // Ensure that the package exists.
+ final Intent intent = new Intent(Intent.ACTION_MAIN);
+ intent.setPackage(MANAGED_PROVISIONING_PACKAGE_NAME);
+ final ResolveInfo ri = pm.resolveActivity(intent, PackageManager.MATCH_DISABLED_COMPONENTS);
+ String validPkg = "";
+ if (ri != null) {
+ validPkg = ri.activityInfo.packageName;
+ }
+
+ final List<PackageInfo> holding = pm.getPackagesHoldingPermissions(new String[] {
+ android.Manifest.permission.NETWORK_MANAGED_PROVISIONING
+ }, PackageManager.MATCH_UNINSTALLED_PACKAGES);
+ for (PackageInfo pi : holding) {
+ if (!Objects.equals(pi.packageName, validPkg)) {
+ fail("The NETWORK_MANAGED_PROVISIONING permission must not be held by "
+ + pi.packageName + " and must be revoked for security reasons ["
+ + validPkg +"]");
+ }
+ }
+ }
+
+ /**
+ * Verify that the {@link android.Manifest.permission#WIFI_SET_DEVICE_MOBILITY_STATE} permission
+ * is held by at most one application.
+ */
+ public void testWifiSetDeviceMobilityStatePermission() {
+ final PackageManager pm = getContext().getPackageManager();
+
+ final List<PackageInfo> holding = pm.getPackagesHoldingPermissions(new String[] {
+ android.Manifest.permission.WIFI_SET_DEVICE_MOBILITY_STATE
+ }, PackageManager.MATCH_UNINSTALLED_PACKAGES);
+
+ List<String> uniquePackageNames = holding
+ .stream()
+ .map(pi -> pi.packageName)
+ .distinct()
+ .collect(Collectors.toList());
+
+ if (uniquePackageNames.size() > 1) {
+ fail("The WIFI_SET_DEVICE_MOBILITY_STATE permission must not be held by more than one "
+ + "application, but is held by " + uniquePackageNames.size() + " applications: "
+ + String.join(", ", uniquePackageNames));
+ }
+ }
+
+ /**
+ * Verify that the {@link android.Manifest.permission#NETWORK_CARRIER_PROVISIONING} permission
+ * is held by at most one application.
+ */
+ public void testNetworkCarrierProvisioningPermission() {
+ final PackageManager pm = getContext().getPackageManager();
+
+ final List<PackageInfo> holding = pm.getPackagesHoldingPermissions(new String[] {
+ android.Manifest.permission.NETWORK_CARRIER_PROVISIONING
+ }, PackageManager.MATCH_UNINSTALLED_PACKAGES);
+
+ List<String> uniquePackageNames = holding
+ .stream()
+ .map(pi -> pi.packageName)
+ .distinct()
+ .collect(Collectors.toList());
+
+ if (uniquePackageNames.size() > 1) {
+ fail("The NETWORK_CARRIER_PROVISIONING permission must not be held by more than one "
+ + "application, but is held by " + uniquePackageNames.size() + " applications: "
+ + String.join(", ", uniquePackageNames));
+ }
+ }
+
+ /**
+ * Verify that the {@link android.Manifest.permission#WIFI_UPDATE_USABILITY_STATS_SCORE}
+ * permission is held by at most one application.
+ */
+ public void testUpdateWifiUsabilityStatsScorePermission() {
+ final PackageManager pm = getContext().getPackageManager();
+
+ final List<PackageInfo> holding = pm.getPackagesHoldingPermissions(new String[] {
+ android.Manifest.permission.WIFI_UPDATE_USABILITY_STATS_SCORE
+ }, PackageManager.MATCH_UNINSTALLED_PACKAGES);
+
+ List<String> uniquePackageNames = holding
+ .stream()
+ .map(pi -> pi.packageName)
+ .distinct()
+ .collect(Collectors.toList());
+
+ if (uniquePackageNames.size() > 1) {
+ fail("The WIFI_UPDATE_USABILITY_STATS_SCORE permission must not be held by more than "
+ + "one application, but is held by " + uniquePackageNames.size() + " applications: "
+ + String.join(", ", uniquePackageNames));
+ }
+ }
+
+ private void turnScreenOnNoDelay() throws Exception {
+ mUiDevice.executeShellCommand("input keyevent KEYCODE_WAKEUP");
+ mUiDevice.executeShellCommand("wm dismiss-keyguard");
+ }
+
+ private void turnScreenOn() throws Exception {
+ turnScreenOnNoDelay();
+ // Since the screen on/off intent is ordered, they will not be sent right now.
+ Thread.sleep(DURATION_SCREEN_TOGGLE);
+ }
+
+ private void turnScreenOff() throws Exception {
+ mUiDevice.executeShellCommand("input keyevent KEYCODE_SLEEP");
+ // Since the screen on/off intent is ordered, they will not be sent right now.
+ Thread.sleep(DURATION_SCREEN_TOGGLE);
+ }
+
+ /**
+ * Verify that Wi-Fi scanning is not turned off when the screen turns off while wifi is disabled
+ * but location is on.
+ * @throws Exception
+ */
+ public void testScreenOffDoesNotTurnOffWifiScanningWhenWifiDisabled() throws Exception {
+ if (!WifiFeature.isWifiSupported(getContext())) {
+ // skip the test if WiFi is not supported
+ return;
+ }
+ if (!hasLocationFeature()) {
+ // skip the test if location is not supported
+ return;
+ }
+ if (!isLocationEnabled()) {
+ fail("Please enable location for this test - since Marshmallow WiFi scan results are"
+ + " empty when location is disabled!");
+ }
+ if(!mWifiManager.isScanAlwaysAvailable()) {
+ fail("Please enable Wi-Fi scanning for this test!");
+ }
+ setWifiEnabled(false);
+ turnScreenOn();
+ assertWifiScanningIsOn();
+ // Toggle screen and verify Wi-Fi scanning is still on.
+ turnScreenOff();
+ assertWifiScanningIsOn();
+ turnScreenOn();
+ assertWifiScanningIsOn();
+ }
+
+ /**
+ * Verify that Wi-Fi scanning is not turned off when the screen turns off while wifi is enabled.
+ * @throws Exception
+ */
+ public void testScreenOffDoesNotTurnOffWifiScanningWhenWifiEnabled() throws Exception {
+ if (!WifiFeature.isWifiSupported(getContext())) {
+ // skip the test if WiFi is not supported
+ return;
+ }
+ if (!hasLocationFeature()) {
+ // skip the test if location is not supported
+ return;
+ }
+ if (!isLocationEnabled()) {
+ fail("Please enable location for this test - since Marshmallow WiFi scan results are"
+ + " empty when location is disabled!");
+ }
+ if(!mWifiManager.isScanAlwaysAvailable()) {
+ fail("Please enable Wi-Fi scanning for this test!");
+ }
+ setWifiEnabled(true);
+ turnScreenOn();
+ assertWifiScanningIsOn();
+ // Toggle screen and verify Wi-Fi scanning is still on.
+ turnScreenOff();
+ assertWifiScanningIsOn();
+ turnScreenOn();
+ assertWifiScanningIsOn();
+ }
+
+ /**
+ * Verify that the platform supports a reasonable number of suggestions per app.
+ * @throws Exception
+ */
+ public void testMaxNumberOfNetworkSuggestionsPerApp() throws Exception {
+ if (!WifiFeature.isWifiSupported(getContext())) {
+ // skip the test if WiFi is not supported
+ return;
+ }
+ assertTrue(mWifiManager.getMaxNumberOfNetworkSuggestionsPerApp()
+ > ENFORCED_NUM_NETWORK_SUGGESTIONS_PER_APP);
+ }
+
+ private void assertWifiScanningIsOn() {
+ if(!mWifiManager.isScanAlwaysAvailable()) {
+ fail("Wi-Fi scanning should be on.");
+ }
+ }
}
diff --git a/tests/cts/net/src/android/net/wifi/p2p/cts/WifiP2pConfigTest.java b/tests/cts/net/src/android/net/wifi/p2p/cts/WifiP2pConfigTest.java
new file mode 100644
index 0000000..639db8a
--- /dev/null
+++ b/tests/cts/net/src/android/net/wifi/p2p/cts/WifiP2pConfigTest.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net.wifi.p2p.cts;
+
+import android.net.MacAddress;
+import android.net.wifi.p2p.WifiP2pConfig;
+import android.net.wifi.p2p.WifiP2pGroup;
+import android.test.AndroidTestCase;
+
+public class WifiP2pConfigTest extends AndroidTestCase {
+ static final String TEST_NETWORK_NAME = "DIRECT-xy-Hello";
+ static final String TEST_PASSPHRASE = "8etterW0r1d";
+ static final int TEST_OWNER_BAND = WifiP2pConfig.GROUP_OWNER_BAND_5GHZ;
+ static final int TEST_OWNER_FREQ = 2447;
+ static final String TEST_DEVICE_ADDRESS = "aa:bb:cc:dd:ee:ff";
+
+ public void testWifiP2pConfigBuilderForPersist() {
+ WifiP2pConfig.Builder builder = new WifiP2pConfig.Builder();
+ builder.setNetworkName(TEST_NETWORK_NAME)
+ .setPassphrase(TEST_PASSPHRASE)
+ .setGroupOperatingBand(TEST_OWNER_BAND)
+ .setDeviceAddress(MacAddress.fromString(TEST_DEVICE_ADDRESS))
+ .enablePersistentMode(true);
+ WifiP2pConfig config = builder.build();
+
+ assertTrue(config.deviceAddress.equals(TEST_DEVICE_ADDRESS));
+ assertTrue(config.networkName.equals(TEST_NETWORK_NAME));
+ assertTrue(config.passphrase.equals(TEST_PASSPHRASE));
+ assertEquals(config.groupOwnerBand, TEST_OWNER_BAND);
+ assertEquals(config.netId, WifiP2pGroup.PERSISTENT_NET_ID);
+ }
+
+ public void testWifiP2pConfigBuilderForNonPersist() {
+ WifiP2pConfig.Builder builder = new WifiP2pConfig.Builder();
+ builder.setNetworkName(TEST_NETWORK_NAME)
+ .setPassphrase(TEST_PASSPHRASE)
+ .setGroupOperatingFrequency(TEST_OWNER_FREQ)
+ .setDeviceAddress(MacAddress.fromString(TEST_DEVICE_ADDRESS))
+ .enablePersistentMode(false);
+ WifiP2pConfig config = builder.build();
+
+ assertTrue(config.deviceAddress.equals(TEST_DEVICE_ADDRESS));
+ assertTrue(config.networkName.equals(TEST_NETWORK_NAME));
+ assertTrue(config.passphrase.equals(TEST_PASSPHRASE));
+ assertEquals(config.groupOwnerBand, TEST_OWNER_FREQ);
+ assertEquals(config.netId, WifiP2pGroup.TEMPORARY_NET_ID);
+ }
+}
diff --git a/tests/cts/net/src/android/net/wifi/rtt/OWNERS b/tests/cts/net/src/android/net/wifi/rtt/OWNERS
deleted file mode 100644
index 4afc47f..0000000
--- a/tests/cts/net/src/android/net/wifi/rtt/OWNERS
+++ /dev/null
@@ -1,2 +0,0 @@
-etancohen@google.com
-satk@google.com
\ No newline at end of file
diff --git a/tests/cts/net/src/android/net/wifi/rtt/cts/TestBase.java b/tests/cts/net/src/android/net/wifi/rtt/cts/TestBase.java
index 57ea2a5..07d5718 100644
--- a/tests/cts/net/src/android/net/wifi/rtt/cts/TestBase.java
+++ b/tests/cts/net/src/android/net/wifi/rtt/cts/TestBase.java
@@ -32,6 +32,8 @@
import android.os.HandlerThread;
import android.test.AndroidTestCase;
+import com.android.compatibility.common.util.SystemUtil;
+
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executor;
@@ -93,7 +95,7 @@
mWifiLock = mWifiManager.createWifiLock(TAG);
mWifiLock.acquire();
if (!mWifiManager.isWifiEnabled()) {
- mWifiManager.setWifiEnabled(true);
+ SystemUtil.runShellCommand("svc wifi enable");
}
IntentFilter intentFilter = new IntentFilter();
diff --git a/tests/cts/net/src/android/net/wifi/rtt/cts/WifiRttTest.java b/tests/cts/net/src/android/net/wifi/rtt/cts/WifiRttTest.java
index adb4ce8..f71cadb 100644
--- a/tests/cts/net/src/android/net/wifi/rtt/cts/WifiRttTest.java
+++ b/tests/cts/net/src/android/net/wifi/rtt/cts/WifiRttTest.java
@@ -64,7 +64,10 @@
// Scan for IEEE 802.11mc supporting APs
ScanResult testAp = scanForTestAp(NUM_SCANS_SEARCHING_FOR_IEEE80211MC_AP);
- assertTrue("Cannot find test AP", testAp != null);
+ assertTrue(
+ "Cannot find any test APs which support RTT / IEEE 802.11mc - please verify that "
+ + "your test setup includes them!",
+ testAp != null);
// Perform RTT operations
RangingRequest request = new RangingRequest.Builder().addAccessPoint(testAp).build();