Use ACCESS_WIFI_STATE when clearing wifi blacklist

Some tests using CtsNetUtils, like tethering CTS tests, do not hold
ACCESS_WIFI_STATE at install time. Use shell permissions to allow the
utility to work in such configurations.

Bug: 171621759
Test: atest CtsTetheringTest:TetheringManagerTest
Original-Change: https://android-review.googlesource.com/1490016
Merged-In: I63e76918421e5deb59fe67a64674348fb8d20265
Change-Id: I63e76918421e5deb59fe67a64674348fb8d20265
This commit is contained in:
Treehugger Robot
2020-11-12 06:10:21 +00:00
committed by Remi NGUYEN VAN
parent b896220cda
commit 65ee636efd

View File

@@ -16,6 +16,7 @@
package android.net.cts.util;
import static android.Manifest.permission.ACCESS_WIFI_STATE;
import static android.Manifest.permission.NETWORK_SETTINGS;
import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_OPPORTUNISTIC;
import static android.net.NetworkCapabilities.NET_CAPABILITY_INTERNET;
@@ -331,7 +332,7 @@ public final class CtsNetUtils {
* to them.
*/
private void clearWifiBlacklist() {
runAsShell(NETWORK_SETTINGS, () -> {
runAsShell(NETWORK_SETTINGS, ACCESS_WIFI_STATE, () -> {
for (WifiConfiguration cfg : mWifiManager.getConfiguredNetworks()) {
assertTrue(mWifiManager.enableNetwork(cfg.networkId, false /* attemptConnect */));
}