Merge "Use ParceledListSlice to avoid binder alloc error" into main
diff --git a/framework/java/android/net/wifi/WifiManager.java b/framework/java/android/net/wifi/WifiManager.java
index f9ce049..aa6ff1f 100644
--- a/framework/java/android/net/wifi/WifiManager.java
+++ b/framework/java/android/net/wifi/WifiManager.java
@@ -4518,6 +4518,16 @@
* {@link android.Manifest.permission#ACCESS_FINE_LOCATION ACCESS_FINE_LOCATION} permission
* and {@link android.Manifest.permission#ACCESS_WIFI_STATE} permission
* in order to get valid results.
+ *
+ * <p>
+ * When an Access Point’s beacon or probe response includes a Multi-BSSID Element, the
+ * returned scan results should include separate scan result for each BSSID within the
+ * Multi-BSSID Information Element. This includes both transmitted and non-transmitted BSSIDs.
+ * Original Multi-BSSID Element will be included in the Information Elements attached to
+ * each of the scan results.
+ * Note: This is the expected behavior for devices supporting 11ax (WiFi-6) and above, and an
+ * optional requirement for devices running with older WiFi generations.
+ * </p>
*/
@RequiresPermission(allOf = {ACCESS_WIFI_STATE, ACCESS_FINE_LOCATION})
public List<ScanResult> getScanResults() {
diff --git a/framework/java/android/net/wifi/WifiScanner.java b/framework/java/android/net/wifi/WifiScanner.java
index 93ea0b0..b9c6f42 100644
--- a/framework/java/android/net/wifi/WifiScanner.java
+++ b/framework/java/android/net/wifi/WifiScanner.java
@@ -1554,6 +1554,16 @@
/**
* Retrieve the most recent scan results from a single scan request.
+ *
+ * <p>
+ * When an Access Point’s beacon or probe response includes a Multi-BSSID Element, the
+ * returned scan results should include separate scan result for each BSSID within the
+ * Multi-BSSID Information Element. This includes both transmitted and non-transmitted BSSIDs.
+ * Original Multi-BSSID Element will be included in the Information Elements attached to
+ * each of the scan results.
+ * Note: This is the expected behavior for devices supporting 11ax (WiFi-6) and above, and an
+ * optional requirement for devices running with older WiFi generations.
+ * </p>
*/
@NonNull
@RequiresPermission(android.Manifest.permission.LOCATION_HARDWARE)
@@ -1569,6 +1579,16 @@
/**
* Retrieve the scan data cached by the hardware.
*
+ * <p>
+ * When an Access Point’s beacon or probe response includes a Multi-BSSID Element, the
+ * returned scan results should include separate scan result for each BSSID within the
+ * Multi-BSSID Information Element. This includes both transmitted and non-transmitted BSSIDs.
+ * Original Multi-BSSID Element will be included in the Information Elements attached to
+ * each of the scan results.
+ * Note: This is the expected behavior for devices supporting 11ax (WiFi-6) and above, and an
+ * optional requirement for devices running with older WiFi generations.
+ * </p>
+ *
* @param executor The executor on which callback will be invoked.
* @param resultsCallback An asynchronous callback that will return the cached scan data.
*
diff --git a/framework/java/android/net/wifi/WifiUriParser.java b/framework/java/android/net/wifi/WifiUriParser.java
index 4a1d088..ada1fa9 100644
--- a/framework/java/android/net/wifi/WifiUriParser.java
+++ b/framework/java/android/net/wifi/WifiUriParser.java
@@ -65,6 +65,7 @@
static final String PREFIX_ZXING_SSID = "S:";
static final String PREFIX_ZXING_PASSWORD = "P:";
static final String PREFIX_ZXING_HIDDEN_SSID = "H:";
+ static final String PREFIX_ZXING_TRANSITION_DISABLE = "R:";
static final String DELIMITER_QR_CODE = ";";
@@ -125,7 +126,10 @@
String ssid = getValueOrNull(keyValueList, PREFIX_ZXING_SSID);
String password = getValueOrNull(keyValueList, PREFIX_ZXING_PASSWORD);
String hiddenSsidString = getValueOrNull(keyValueList, PREFIX_ZXING_HIDDEN_SSID);
+ String transitionDisabledValue = getValueOrNull(keyValueList,
+ PREFIX_ZXING_TRANSITION_DISABLE);
boolean hiddenSsid = "true".equalsIgnoreCase(hiddenSsidString);
+ boolean isTransitionDisabled = "1".equalsIgnoreCase(transitionDisabledValue);
// "\", ";", "," and ":" are escaped with a backslash "\", should remove at first
security = removeBackSlash(security);
@@ -133,7 +137,8 @@
password = removeBackSlash(password);
if (isValidConfig(security, ssid, password)) {
config = generatetWifiConfiguration(
- security, ssid, password, hiddenSsid, WifiConfiguration.INVALID_NETWORK_ID);
+ security, ssid, password, hiddenSsid, WifiConfiguration.INVALID_NETWORK_ID,
+ isTransitionDisabled);
}
if (config == null) {
@@ -232,21 +237,20 @@
* @return WifiConfiguration from parsing result
*/
private static WifiConfiguration generatetWifiConfiguration(
- String security, String ssid, String preSharedKey, boolean hiddenSsid, int networkId) {
+ String security, String ssid, String preSharedKey, boolean hiddenSsid, int networkId,
+ boolean isTransitionDisabled) {
final WifiConfiguration wifiConfiguration = new WifiConfiguration();
wifiConfiguration.SSID = addQuotationIfNeeded(ssid);
wifiConfiguration.hiddenSSID = hiddenSsid;
wifiConfiguration.networkId = networkId;
if (TextUtils.isEmpty(security) || SECURITY_NO_PASSWORD.equals(security)) {
- List<SecurityParams> securityParamsList = new ArrayList<>();
- securityParamsList.add(
- SecurityParams.createSecurityParamsBySecurityType(
- WifiConfiguration.SECURITY_TYPE_OPEN));
- securityParamsList.add(
- SecurityParams.createSecurityParamsBySecurityType(
- WifiConfiguration.SECURITY_TYPE_OWE));
- wifiConfiguration.setSecurityParams(securityParamsList);
+ wifiConfiguration.setSecurityParams(
+ Arrays.asList(
+ SecurityParams.createSecurityParamsBySecurityType(
+ WifiConfiguration.SECURITY_TYPE_OPEN),
+ SecurityParams.createSecurityParamsBySecurityType(
+ WifiConfiguration.SECURITY_TYPE_OWE)));
return wifiConfiguration;
}
@@ -262,7 +266,17 @@
wifiConfiguration.wepKeys[0] = addQuotationIfNeeded(preSharedKey);
}
} else if (security.startsWith(SECURITY_WPA_PSK)) {
- wifiConfiguration.setSecurityParams(WifiConfiguration.SECURITY_TYPE_PSK);
+ List<SecurityParams> securityParamsList = new ArrayList<>();
+ SecurityParams scannedSecurityParam = SecurityParams.createSecurityParamsBySecurityType(
+ WifiConfiguration.SECURITY_TYPE_PSK);
+ securityParamsList.add(scannedSecurityParam);
+ if (isTransitionDisabled) {
+ scannedSecurityParam.setEnabled(false);
+ securityParamsList.add(
+ SecurityParams.createSecurityParamsBySecurityType(
+ WifiConfiguration.SECURITY_TYPE_SAE));
+ }
+ wifiConfiguration.setSecurityParams(securityParamsList);
if (preSharedKey.matches("[0-9A-Fa-f]{64}")) {
wifiConfiguration.preSharedKey = preSharedKey;
diff --git a/framework/tests/src/android/net/wifi/WifiUriParserTest.java b/framework/tests/src/android/net/wifi/WifiUriParserTest.java
index 411774b..396c677 100644
--- a/framework/tests/src/android/net/wifi/WifiUriParserTest.java
+++ b/framework/tests/src/android/net/wifi/WifiUriParserTest.java
@@ -45,7 +45,6 @@
private void verifyZxParsing(
UriParserResults uri,
String expectedSSID,
- int expectedAuthType,
List<SecurityParams> expectedSecurityParamsList,
String expectedPreShareKey,
boolean isWep) {
@@ -53,7 +52,6 @@
WifiConfiguration config = uri.getWifiConfiguration();
assertNotNull(config);
assertThat(config.SSID).isEqualTo(expectedSSID);
- assertThat(config.getAuthType()).isEqualTo(expectedAuthType);
if (isWep) {
assertThat(config.wepKeys[0]).isEqualTo(expectedPreShareKey);
} else {
@@ -79,7 +77,6 @@
verifyZxParsing(
uri,
"\"testAbC\"",
- WifiConfiguration.KeyMgmt.NONE,
expectedSecurityParamsList,
null,
false);
@@ -88,7 +85,6 @@
verifyZxParsing(
uri,
"\"testAbC\"",
- WifiConfiguration.KeyMgmt.NONE,
expectedSecurityParamsList,
null,
false);
@@ -102,7 +98,6 @@
verifyZxParsing(
uri,
"\"reallyLONGone\"",
- WifiConfiguration.KeyMgmt.NONE,
expectedSecurityParamsList,
"\"somepasswo#%^**123rd\"",
true);
@@ -111,7 +106,6 @@
verifyZxParsing(
uri,
"\"reallyLONGone\"",
- WifiConfiguration.KeyMgmt.NONE,
expectedSecurityParamsList,
"\"somepassword\"",
true);
@@ -125,7 +119,6 @@
verifyZxParsing(
uri,
"\"anotherone\"",
- WifiConfiguration.KeyMgmt.WPA_PSK,
expectedSecurityParamsList,
"\"3#=3j9asicla\"",
false);
@@ -134,7 +127,6 @@
verifyZxParsing(
uri,
"\"anotherone\"",
- WifiConfiguration.KeyMgmt.WPA_PSK,
expectedSecurityParamsList,
"\"abcdefghihklmn\"",
false);
@@ -148,7 +140,6 @@
verifyZxParsing(
uri,
"\"xx\"",
- WifiConfiguration.KeyMgmt.SAE,
expectedSecurityParamsList,
"\"a\"",
false);
@@ -157,7 +148,6 @@
verifyZxParsing(
uri,
"\"xx\"",
- WifiConfiguration.KeyMgmt.SAE,
expectedSecurityParamsList,
"\"a\"",
false);
@@ -166,10 +156,36 @@
verifyZxParsing(
uri,
"\"myname\"",
- WifiConfiguration.KeyMgmt.NONE,
Collections.emptyList(),
"\"mypass\"",
false);
+ // Test transition disable value
+ expectedSecurityParamsList =
+ ImmutableList.of(
+ SecurityParams.createSecurityParamsBySecurityType(
+ WifiConfiguration.SECURITY_TYPE_PSK));
+ uri = WifiUriParser.parseUri("WIFI:S:anotherone;T:WPA;R:0;P:3#=3j9asicla");
+ verifyZxParsing(
+ uri,
+ "\"anotherone\"",
+ expectedSecurityParamsList,
+ "\"3#=3j9asicla\"",
+ false);
+
+ SecurityParams pskButDisableed = SecurityParams.createSecurityParamsBySecurityType(
+ WifiConfiguration.SECURITY_TYPE_PSK);
+ pskButDisableed.setEnabled(false);
+ expectedSecurityParamsList =
+ ImmutableList.of(pskButDisableed,
+ SecurityParams.createSecurityParamsBySecurityType(
+ WifiConfiguration.SECURITY_TYPE_SAE));
+ uri = WifiUriParser.parseUri("WIFI:S:anotherone;T:WPA;R:1;P:3#=3j9asicla");
+ verifyZxParsing(
+ uri,
+ "\"anotherone\"",
+ expectedSecurityParamsList,
+ "\"3#=3j9asicla\"",
+ false);
}
@Test
diff --git a/service/java/com/android/server/wifi/SupplicantStaIfaceHalAidlImpl.java b/service/java/com/android/server/wifi/SupplicantStaIfaceHalAidlImpl.java
index ec9a942..1bcf4b7 100644
--- a/service/java/com/android/server/wifi/SupplicantStaIfaceHalAidlImpl.java
+++ b/service/java/com/android/server/wifi/SupplicantStaIfaceHalAidlImpl.java
@@ -106,7 +106,9 @@
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
+import java.util.ArrayDeque;
import java.util.ArrayList;
+import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -152,7 +154,8 @@
private Map<String, SupplicantStaNetworkHalAidlImpl>
mCurrentNetworkRemoteHandles = new HashMap<>();
private Map<String, WifiConfiguration> mCurrentNetworkLocalConfigs = new HashMap<>();
- private Map<String, WifiSsid> mCurrentNetworkFallbackSsids = new HashMap<>();
+ private Map<String, Deque<WifiSsid>> mCurrentNetworkFallbackSsids = new HashMap<>();
+ private Map<String, WifiSsid> mCurrentNetworkFirstSsid = new HashMap<>();
private Map<String, List<Pair<SupplicantStaNetworkHalAidlImpl, WifiConfiguration>>>
mLinkedNetworkLocalAndRemoteConfigs = new HashMap<>();
@VisibleForTesting
@@ -639,18 +642,24 @@
}
/**
- * Connects to the fallback SSID (if any) of the current network upon a network not found
- * notification.
+ * Connects to the next fallback SSID (if any) of the current network upon a network not found
+ * notification. If all the fallback SSIDs have been tried, return to the first SSID and go
+ * through the fallbacks again.
+ *
+ * Returns false if there's no fallback SSID to connect to, or if we've wrapped back to the
+ * first SSID.
*/
public boolean connectToFallbackSsid(@NonNull String ifaceName) {
synchronized (mLock) {
- WifiSsid fallbackSsid = mCurrentNetworkFallbackSsids.remove(ifaceName);
- if (fallbackSsid == null) {
+ Deque<WifiSsid> fallbackSsids = mCurrentNetworkFallbackSsids.get(ifaceName);
+ if (fallbackSsids == null || fallbackSsids.isEmpty()) {
return false;
}
- Log.d(TAG, "connectToFallbackSsid " + fallbackSsid);
- return connectToNetwork(
- ifaceName, getCurrentNetworkLocalConfig(ifaceName), fallbackSsid);
+ WifiSsid nextSsid = fallbackSsids.removeFirst();
+ fallbackSsids.addLast(nextSsid);
+ Log.d(TAG, "connectToFallbackSsid " + nextSsid);
+ connectToNetwork(ifaceName, getCurrentNetworkLocalConfig(ifaceName), nextSsid);
+ return !Objects.equals(nextSsid, mCurrentNetworkFirstSsid.get(ifaceName));
}
}
@@ -697,7 +706,6 @@
mCurrentNetworkRemoteHandles.remove(ifaceName);
mCurrentNetworkLocalConfigs.remove(ifaceName);
mLinkedNetworkLocalAndRemoteConfigs.remove(ifaceName);
- mCurrentNetworkFallbackSsids.remove(ifaceName);
if (!removeAllNetworks(ifaceName)) {
Log.e(TAG, "Failed to remove existing networks");
return false;
@@ -706,25 +714,27 @@
if (actualSsid != null) {
supplicantConfig.SSID = actualSsid.toString();
} else {
+ mCurrentNetworkFallbackSsids.remove(ifaceName);
+ mCurrentNetworkFirstSsid.remove(ifaceName);
if (config.SSID != null) {
// No actual SSID supplied, so select from the network selection BSSID
// or the latest candidate BSSID.
WifiSsid configSsid = WifiSsid.fromString(config.SSID);
WifiSsid supplicantSsid = mSsidTranslator.getOriginalSsid(config);
if (supplicantSsid != null) {
- supplicantConfig.SSID = supplicantSsid.toString();
- List<WifiSsid> allPossibleSsids = mSsidTranslator
- .getAllPossibleOriginalSsids(configSsid);
- WifiSsid selectedSsid = mSsidTranslator.getOriginalSsid(config);
- allPossibleSsids.remove(selectedSsid);
- if (!allPossibleSsids.isEmpty()) {
- // Store the unused SSID to fallback on in
- // connectToFallbackSsid(String) if the chosen SSID isn't found.
- mCurrentNetworkFallbackSsids.put(
- ifaceName, allPossibleSsids.get(0));
- }
Log.d(TAG, "Selecting supplicant SSID " + supplicantSsid);
supplicantConfig.SSID = supplicantSsid.toString();
+
+ Deque<WifiSsid> fallbackSsids = new ArrayDeque<>(mSsidTranslator
+ .getAllPossibleOriginalSsids(configSsid));
+ fallbackSsids.remove(supplicantSsid);
+ if (!fallbackSsids.isEmpty()) {
+ // Store the unused SSIDs to fallback on in
+ // connectToFallbackSsid(String) if the chosen SSID isn't found.
+ fallbackSsids.addLast(supplicantSsid);
+ mCurrentNetworkFallbackSsids.put(ifaceName, fallbackSsids);
+ mCurrentNetworkFirstSsid.put(ifaceName, supplicantSsid);
+ }
}
// Set the actual translation of the original SSID in case the untranslated
// SSID has an ambiguous encoding.
diff --git a/service/java/com/android/server/wifi/SupplicantStaIfaceHalHidlImpl.java b/service/java/com/android/server/wifi/SupplicantStaIfaceHalHidlImpl.java
index 5a431b7..fbd0312 100644
--- a/service/java/com/android/server/wifi/SupplicantStaIfaceHalHidlImpl.java
+++ b/service/java/com/android/server/wifi/SupplicantStaIfaceHalHidlImpl.java
@@ -73,7 +73,9 @@
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
+import java.util.ArrayDeque;
import java.util.ArrayList;
+import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -119,7 +121,8 @@
private Map<String, SupplicantStaNetworkHalHidlImpl> mCurrentNetworkRemoteHandles =
new HashMap<>();
private Map<String, WifiConfiguration> mCurrentNetworkLocalConfigs = new HashMap<>();
- private Map<String, WifiSsid> mCurrentNetworkFallbackSsids = new HashMap<>();
+ private Map<String, Deque<WifiSsid>> mCurrentNetworkFallbackSsids = new HashMap<>();
+ private Map<String, WifiSsid> mCurrentNetworkFirstSsid = new HashMap<>();
private Map<String, List<Pair<SupplicantStaNetworkHalHidlImpl, WifiConfiguration>>>
mLinkedNetworkLocalAndRemoteConfigs = new HashMap<>();
@VisibleForTesting
@@ -973,18 +976,24 @@
}
/**
- * Connects to the fallback SSID (if any) of the current network upon a network not found
- * notification.
+ * Connects to the next fallback SSID (if any) of the current network upon a network not found
+ * notification. If all the fallback SSIDs have been tried, return to the first SSID and go
+ * through the fallbacks again.
+ *
+ * Returns false if there's no fallback SSID to connect to, or if we've wrapped back to the
+ * first SSID.
*/
public boolean connectToFallbackSsid(@NonNull String ifaceName) {
synchronized (mLock) {
- WifiSsid fallbackSsid = mCurrentNetworkFallbackSsids.remove(ifaceName);
- if (fallbackSsid == null) {
+ Deque<WifiSsid> fallbackSsids = mCurrentNetworkFallbackSsids.get(ifaceName);
+ if (fallbackSsids == null || fallbackSsids.isEmpty()) {
return false;
}
- Log.d(TAG, "connectToFallbackSsid " + fallbackSsid);
- return connectToNetwork(
- ifaceName, getCurrentNetworkLocalConfig(ifaceName), fallbackSsid);
+ WifiSsid nextSsid = fallbackSsids.removeFirst();
+ fallbackSsids.addLast(nextSsid);
+ Log.d(TAG, "connectToFallbackSsid " + nextSsid);
+ connectToNetwork(ifaceName, getCurrentNetworkLocalConfig(ifaceName), nextSsid);
+ return !Objects.equals(nextSsid, mCurrentNetworkFirstSsid.get(ifaceName));
}
}
@@ -1031,7 +1040,6 @@
mCurrentNetworkRemoteHandles.remove(ifaceName);
mCurrentNetworkLocalConfigs.remove(ifaceName);
mLinkedNetworkLocalAndRemoteConfigs.remove(ifaceName);
- mCurrentNetworkFallbackSsids.remove(ifaceName);
if (!removeAllNetworks(ifaceName)) {
loge("Failed to remove existing networks");
return false;
@@ -1040,25 +1048,27 @@
if (actualSsid != null) {
supplicantConfig.SSID = actualSsid.toString();
} else {
+ mCurrentNetworkFallbackSsids.remove(ifaceName);
+ mCurrentNetworkFirstSsid.remove(ifaceName);
if (config.SSID != null) {
// No actual SSID supplied, so select from the network selection BSSID
// or the latest candidate BSSID.
WifiSsid configSsid = WifiSsid.fromString(config.SSID);
WifiSsid supplicantSsid = mSsidTranslator.getOriginalSsid(config);
if (supplicantSsid != null) {
- supplicantConfig.SSID = supplicantSsid.toString();
- List<WifiSsid> allPossibleSsids = mSsidTranslator
- .getAllPossibleOriginalSsids(configSsid);
- WifiSsid selectedSsid = mSsidTranslator.getOriginalSsid(config);
- allPossibleSsids.remove(selectedSsid);
- if (!allPossibleSsids.isEmpty()) {
- // Store the unused SSID to fallback on in
- // connectToFallbackSsid(String) if the chosen SSID isn't found.
- mCurrentNetworkFallbackSsids.put(
- ifaceName, allPossibleSsids.get(0));
- }
Log.d(TAG, "Selecting supplicant SSID " + supplicantSsid);
supplicantConfig.SSID = supplicantSsid.toString();
+
+ Deque<WifiSsid> fallbackSsids = new ArrayDeque<>(mSsidTranslator
+ .getAllPossibleOriginalSsids(configSsid));
+ fallbackSsids.remove(supplicantSsid);
+ if (!fallbackSsids.isEmpty()) {
+ // Store the unused SSIDs to fallback on in
+ // connectToFallbackSsid(String) if the chosen SSID isn't found.
+ fallbackSsids.addLast(supplicantSsid);
+ mCurrentNetworkFallbackSsids.put(ifaceName, fallbackSsids);
+ mCurrentNetworkFirstSsid.put(ifaceName, supplicantSsid);
+ }
}
// Set the actual translation of the original SSID in case the untranslated
// SSID has an ambiguous encoding.
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index 757208b..3a329f8 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -1292,13 +1292,19 @@
return false;
}
- // If user restriction is set, only DO/PO is allowed to toggle wifi
- if (SdkLevel.isAtLeastT() && mUserManager.hasUserRestrictionForUser(
- UserManager.DISALLOW_CHANGE_WIFI_STATE,
- UserHandle.getUserHandleForUid(callingUid))
- && !isDeviceOrProfileOwner(callingUid, packageName)) {
- mLog.err("setWifiEnabled with user restriction: only DO/PO can toggle wifi").flush();
- return false;
+ long ident = Binder.clearCallingIdentity();
+ try {
+ // If user restriction is set, only DO/PO is allowed to toggle wifi
+ if (SdkLevel.isAtLeastT() && mUserManager.hasUserRestrictionForUser(
+ UserManager.DISALLOW_CHANGE_WIFI_STATE,
+ UserHandle.getUserHandleForUid(callingUid))
+ && !isDeviceOrProfileOwner(callingUid, packageName)) {
+ mLog.err(
+ "setWifiEnabled with user restriction: only DO/PO can toggle wifi").flush();
+ return false;
+ }
+ } finally {
+ Binder.restoreCallingIdentity(ident);
}
// Show a user-confirmation dialog for legacy third-party apps targeting less than Q.
@@ -2760,19 +2766,18 @@
}
}
- // verify that tethering is not disabled
- if (mUserManager.hasUserRestrictionForUser(
- UserManager.DISALLOW_CONFIG_TETHERING, UserHandle.getUserHandleForUid(uid))) {
- return LocalOnlyHotspotCallback.ERROR_TETHERING_DISALLOWED;
- }
-
- mLastCallerInfoManager.put(WifiManager.API_START_LOCAL_ONLY_HOTSPOT, Process.myTid(),
- uid, Binder.getCallingPid(), packageName, true);
-
final WorkSource requestorWs = new WorkSource(uid, packageName);
// the app should be in the foreground
long ident = Binder.clearCallingIdentity();
try {
+ // verify that tethering is not disabled
+ if (mUserManager.hasUserRestrictionForUser(
+ UserManager.DISALLOW_CONFIG_TETHERING, UserHandle.getUserHandleForUid(uid))) {
+ return LocalOnlyHotspotCallback.ERROR_TETHERING_DISALLOWED;
+ }
+
+ mLastCallerInfoManager.put(WifiManager.API_START_LOCAL_ONLY_HOTSPOT, Process.myTid(),
+ uid, Binder.getCallingPid(), packageName, true);
// also need to verify that Locations services are enabled.
// bypass shell with root uid
if (uid != Process.ROOT_UID
@@ -3882,27 +3887,38 @@
mLog.info("addOrUpdateNetwork not allowed for uid=%").c(callingUid).flush();
return -1;
}
- if (mUserManager.hasUserRestrictionForUser(UserManager.DISALLOW_CONFIG_WIFI,
- UserHandle.of(mWifiPermissionsUtil.getCurrentUser()))
- && isCamera && !isAdmin) {
- mLog.info("addOrUpdateNetwork not allowed for the camera apps and therefore the user "
- + "when DISALLOW_CONFIG_WIFI user restriction is set").flush();
- return -1;
- }
- if (SdkLevel.isAtLeastT() && mUserManager.hasUserRestrictionForUser(
- UserManager.DISALLOW_ADD_WIFI_CONFIG, UserHandle.getUserHandleForUid(callingUid))) {
- if (mWifiPermissionsUtil.isTargetSdkLessThan(
- packageName, Build.VERSION_CODES.Q, callingUid)
- && !(isPrivileged || isAdmin || isSystem)) {
- mLog.info("addOrUpdateNetwork not allowed for normal apps targeting SDK less than "
- + "Q when the DISALLOW_ADD_WIFI_CONFIG user restriction is set").flush();
+ long ident = Binder.clearCallingIdentity();
+ try {
+ if (mUserManager.hasUserRestrictionForUser(UserManager.DISALLOW_CONFIG_WIFI,
+ UserHandle.of(mWifiPermissionsUtil.getCurrentUser()))
+ && isCamera && !isAdmin) {
+ mLog.info(
+ "addOrUpdateNetwork not allowed for the camera apps and therefore the "
+ + "user when DISALLOW_CONFIG_WIFI user restriction is set").flush();
return -1;
}
- if (isCamera && !isAdmin) {
- mLog.info("addOrUpdateNetwork not allowed for camera apps and therefore the user "
- + "when the DISALLOW_ADD_WIFI_CONFIG user restriction is set").flush();
- return -1;
+ if (SdkLevel.isAtLeastT() && mUserManager.hasUserRestrictionForUser(
+ UserManager.DISALLOW_ADD_WIFI_CONFIG,
+ UserHandle.getUserHandleForUid(callingUid))) {
+ if (mWifiPermissionsUtil.isTargetSdkLessThan(
+ packageName, Build.VERSION_CODES.Q, callingUid)
+ && !(isPrivileged || isAdmin || isSystem)) {
+ mLog.info(
+ "addOrUpdateNetwork not allowed for normal apps targeting "
+ + "SDK less than Q when the DISALLOW_ADD_WIFI_CONFIG "
+ + "user restriction is set").flush();
+ return -1;
+ }
+ if (isCamera && !isAdmin) {
+ mLog.info(
+ "addOrUpdateNetwork not allowed for camera apps and therefore the "
+ + "user when the DISALLOW_ADD_WIFI_CONFIG "
+ + "user restriction is set").flush();
+ return -1;
+ }
}
+ } finally {
+ Binder.restoreCallingIdentity(ident);
}
mLog.info("addOrUpdateNetwork uid=%").c(callingUid).flush();
@@ -4643,12 +4659,18 @@
.c(callingUid).flush();
return false;
}
- if (SdkLevel.isAtLeastT() && mUserManager.hasUserRestrictionForUser(
- UserManager.DISALLOW_ADD_WIFI_CONFIG, UserHandle.getUserHandleForUid(callingUid))
- && !mWifiPermissionsUtil.isAdmin(callingUid, packageName)) {
- mLog.info("addOrUpdatePasspointConfiguration only allowed for admin"
- + "when the DISALLOW_ADD_WIFI_CONFIG user restriction is set").flush();
- return false;
+ long ident = Binder.clearCallingIdentity();
+ try {
+ if (SdkLevel.isAtLeastT() && mUserManager.hasUserRestrictionForUser(
+ UserManager.DISALLOW_ADD_WIFI_CONFIG,
+ UserHandle.getUserHandleForUid(callingUid))
+ && !mWifiPermissionsUtil.isAdmin(callingUid, packageName)) {
+ mLog.info("addOrUpdatePasspointConfiguration only allowed for admin"
+ + "when the DISALLOW_ADD_WIFI_CONFIG user restriction is set").flush();
+ return false;
+ }
+ } finally {
+ Binder.restoreCallingIdentity(ident);
}
mLog.info("addorUpdatePasspointConfiguration uid=%").c(callingUid).flush();
return mWifiThreadRunner.call(
@@ -5730,22 +5752,26 @@
int callingUid = Binder.getCallingUid();
mWifiPermissionsUtil.checkPackage(callingUid, packageName);
mLog.info("factoryReset uid=%").c(callingUid).flush();
- if (mUserManager.hasUserRestrictionForUser(
- UserManager.DISALLOW_NETWORK_RESET,
- UserHandle.getUserHandleForUid(callingUid))) {
- return;
- }
- if (!mUserManager.hasUserRestrictionForUser(
- UserManager.DISALLOW_CONFIG_TETHERING,
- UserHandle.getUserHandleForUid(callingUid))) {
- // Turn mobile hotspot off
- stopSoftApInternal(WifiManager.IFACE_IP_MODE_UNSPECIFIED);
- }
-
- if (mUserManager.hasUserRestrictionForUser(
- UserManager.DISALLOW_CONFIG_WIFI,
- UserHandle.getUserHandleForUid(callingUid))) {
- return;
+ long ident = Binder.clearCallingIdentity();
+ try {
+ if (mUserManager.hasUserRestrictionForUser(
+ UserManager.DISALLOW_NETWORK_RESET,
+ UserHandle.getUserHandleForUid(callingUid))) {
+ return;
+ }
+ if (!mUserManager.hasUserRestrictionForUser(
+ UserManager.DISALLOW_CONFIG_TETHERING,
+ UserHandle.getUserHandleForUid(callingUid))) {
+ // Turn mobile hotspot off
+ stopSoftApInternal(WifiManager.IFACE_IP_MODE_UNSPECIFIED);
+ }
+ if (mUserManager.hasUserRestrictionForUser(
+ UserManager.DISALLOW_CONFIG_WIFI,
+ UserHandle.getUserHandleForUid(callingUid))) {
+ return;
+ }
+ } finally {
+ Binder.restoreCallingIdentity(ident);
}
// Delete all Wifi SSIDs
mWifiThreadRunner.run(() -> {
@@ -6147,21 +6173,26 @@
int callingUid = Binder.getCallingUid();
int callingPid = Binder.getCallingPid();
- if (SdkLevel.isAtLeastT()) {
- boolean isUserRestrictionSet = mUserManager.hasUserRestrictionForUser(
- UserManager.DISALLOW_ADD_WIFI_CONFIG,
- UserHandle.getUserHandleForUid(callingUid));
- boolean isCarrierApp = mWifiInjector.makeTelephonyManager()
- .checkCarrierPrivilegesForPackageAnyPhone(callingPackageName)
- == TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS;
- boolean hasPermission = !isUserRestrictionSet
- || isCarrierApp
- || isPrivileged(callingPid, callingUid)
- || mWifiPermissionsUtil.isSystem(callingPackageName, callingUid)
- || mWifiPermissionsUtil.isAdmin(callingUid, callingPackageName);
- if (!hasPermission) {
- return WifiManager.STATUS_NETWORK_SUGGESTIONS_ERROR_RESTRICTED_BY_ADMIN;
+ long ident = Binder.clearCallingIdentity();
+ try {
+ if (SdkLevel.isAtLeastT()) {
+ boolean isUserRestrictionSet = mUserManager.hasUserRestrictionForUser(
+ UserManager.DISALLOW_ADD_WIFI_CONFIG,
+ UserHandle.getUserHandleForUid(callingUid));
+ boolean isCarrierApp = mWifiInjector.makeTelephonyManager()
+ .checkCarrierPrivilegesForPackageAnyPhone(callingPackageName)
+ == TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS;
+ boolean hasPermission = !isUserRestrictionSet
+ || isCarrierApp
+ || isPrivileged(callingPid, callingUid)
+ || mWifiPermissionsUtil.isSystem(callingPackageName, callingUid)
+ || mWifiPermissionsUtil.isAdmin(callingUid, callingPackageName);
+ if (!hasPermission) {
+ return WifiManager.STATUS_NETWORK_SUGGESTIONS_ERROR_RESTRICTED_BY_ADMIN;
+ }
}
+ } finally {
+ Binder.restoreCallingIdentity(ident);
}
if (mVerboseLoggingEnabled) {
diff --git a/service/java/com/android/server/wifi/aware/WifiAwareNativeManager.java b/service/java/com/android/server/wifi/aware/WifiAwareNativeManager.java
index 3ff7ffd..7cb82f0 100644
--- a/service/java/com/android/server/wifi/aware/WifiAwareNativeManager.java
+++ b/service/java/com/android/server/wifi/aware/WifiAwareNativeManager.java
@@ -132,15 +132,10 @@
}
mInterfaceDestroyedListener = new InterfaceDestroyedListener();
- if (mFeatureFlags.d2dWhenInfraStaOff()) {
- mNanIface = mWifiNative.createNanIface(mInterfaceDestroyedListener,
- mHandler, requestorWs);
- if (mNanIface != null) {
- mWifiNanIface = (WifiNanIface) mNanIface.iface;
- }
- } else {
- mWifiNanIface = mHalDeviceManager.createNanIface(mInterfaceDestroyedListener,
+ mNanIface = mWifiNative.createNanIface(mInterfaceDestroyedListener,
mHandler, requestorWs);
+ if (mNanIface != null) {
+ mWifiNanIface = (WifiNanIface) mNanIface.iface;
}
if (mWifiNanIface == null) {
Log.e(TAG, "Was not able to obtain a WifiNanIface (even though enabled!?)");
diff --git a/service/java/com/android/server/wifi/aware/WifiAwareStateManager.java b/service/java/com/android/server/wifi/aware/WifiAwareStateManager.java
index 451ec19..9d42277 100644
--- a/service/java/com/android/server/wifi/aware/WifiAwareStateManager.java
+++ b/service/java/com/android/server/wifi/aware/WifiAwareStateManager.java
@@ -785,28 +785,25 @@
intentFilter,
null,
mHandler);
- if (mFeatureFlags.d2dWhenInfraStaOff()) {
- mSettingsConfigStore.registerChangeListener(D2D_ALLOWED_WHEN_INFRA_STA_DISABLED,
- (key, value) -> {
- // Check setting & wifi enabled status only when feature is supported.
- if (mWifiGlobals.isD2dSupportedWhenInfraStaDisabled()) {
- if (mSettingsConfigStore.get(D2D_ALLOWED_WHEN_INFRA_STA_DISABLED)) {
- enableUsage();
- } else if (mWifiManager.getWifiState()
- != WifiManager.WIFI_STATE_ENABLED) {
- disableUsage(false);
- }
+ mSettingsConfigStore.registerChangeListener(D2D_ALLOWED_WHEN_INFRA_STA_DISABLED,
+ (key, value) -> {
+ // Check setting & wifi enabled status only when feature is supported.
+ if (mWifiGlobals.isD2dSupportedWhenInfraStaDisabled()) {
+ if (mSettingsConfigStore.get(D2D_ALLOWED_WHEN_INFRA_STA_DISABLED)) {
+ enableUsage();
+ } else if (mWifiManager.getWifiState()
+ != WifiManager.WIFI_STATE_ENABLED) {
+ disableUsage(false);
}
- }, mHandler);
- }
+ }
+ }, mHandler);
if (isD2dAllowedWhenStaDisabled()) {
enableUsage();
}
}
public boolean isD2dAllowedWhenStaDisabled() {
- return mFeatureFlags.d2dWhenInfraStaOff()
- && mWifiGlobals.isD2dSupportedWhenInfraStaDisabled()
+ return mWifiGlobals.isD2dSupportedWhenInfraStaDisabled()
&& mSettingsConfigStore.get(D2D_ALLOWED_WHEN_INFRA_STA_DISABLED);
}
diff --git a/service/java/com/android/server/wifi/p2p/WifiP2pNative.java b/service/java/com/android/server/wifi/p2p/WifiP2pNative.java
index c32d593..edbf956 100644
--- a/service/java/com/android/server/wifi/p2p/WifiP2pNative.java
+++ b/service/java/com/android/server/wifi/p2p/WifiP2pNative.java
@@ -96,8 +96,7 @@
public void teardownAndInvalidate(@Nullable String ifaceName) {
synchronized (mLock) {
- if (mFeatureFlags.d2dWhenInfraStaOff()
- && !mSupplicantP2pIfaceHal.deregisterDeathHandler()) {
+ if (!mSupplicantP2pIfaceHal.deregisterDeathHandler()) {
Log.i(TAG, "Failed to deregister p2p supplicant death handler");
}
if (!TextUtils.isEmpty(ifaceName)) {
@@ -186,8 +185,7 @@
* Close supplicant connection.
*/
public void stopP2pSupplicantIfNecessary() {
- if (mFeatureFlags.d2dWhenInfraStaOff()
- && mSupplicantP2pIfaceHal.isInitializationStarted()) {
+ if (mSupplicantP2pIfaceHal.isInitializationStarted()) {
mSupplicantP2pIfaceHal.terminate();
}
}
@@ -238,14 +236,10 @@
mInterfaceDestroyedListener = (null == destroyedListener)
? null
: new InterfaceDestroyedListenerInternal(destroyedListener);
- if (mFeatureFlags.d2dWhenInfraStaOff()) {
- mP2pIface = mWifiNative.createP2pIface(mInterfaceDestroyedListener, handler,
- requestorWs);
- if (mP2pIface != null) {
- mP2pIfaceName = mP2pIface.name;
- }
- } else {
- mP2pIfaceName = createP2pIface(handler, requestorWs);
+ mP2pIface = mWifiNative.createP2pIface(mInterfaceDestroyedListener, handler,
+ requestorWs);
+ if (mP2pIface != null) {
+ mP2pIfaceName = mP2pIface.name;
}
if (mP2pIfaceName == null) {
Log.e(TAG, "Failed to create P2p iface");
@@ -267,8 +261,7 @@
mWifiMetrics.incrementNumSetupP2pInterfaceFailureDueToSupplicant();
return null;
}
- if (mFeatureFlags.d2dWhenInfraStaOff()
- && !mSupplicantP2pIfaceHal.registerDeathHandler(
+ if (!mSupplicantP2pIfaceHal.registerDeathHandler(
new SupplicantDeathHandlerInternal())) {
Log.e(TAG, "Failed to register supplicant death handler"
+ "(because hidl supplicant?)");
@@ -297,11 +290,6 @@
if (mP2pIfaceName != null) {
mHalDeviceManager.removeP2pIface(mP2pIfaceName);
Log.i(TAG, "P2P interface teardown completed");
- if (!mFeatureFlags.d2dWhenInfraStaOff()) {
- if (null != mInterfaceDestroyedListener) {
- mInterfaceDestroyedListener.teardownAndInvalidate(mP2pIfaceName);
- }
- }
}
} else {
Log.i(TAG, "HAL is not supported. Destroy listener for the interface.");
diff --git a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java
index dfd03e4..cd6067f 100644
--- a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java
+++ b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java
@@ -5653,12 +5653,9 @@
public boolean isWifiP2pAvailable() {
if (mIsP2pDisallowedByAdmin) return false;
- if (mFeatureFlags.d2dWhenInfraStaOff()) {
- return mIsWifiEnabled
- || (mSettingsConfigStore.get(D2D_ALLOWED_WHEN_INFRA_STA_DISABLED)
- && mWifiGlobals.isD2dSupportedWhenInfraStaDisabled());
- }
- return mIsWifiEnabled;
+ return mIsWifiEnabled
+ || (mSettingsConfigStore.get(D2D_ALLOWED_WHEN_INFRA_STA_DISABLED)
+ && mWifiGlobals.isD2dSupportedWhenInfraStaDisabled());
}
public void checkAndSendP2pStateChangedBroadcast() {
diff --git a/service/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalAidlImplTest.java b/service/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalAidlImplTest.java
index 65bee6e..8747683 100644
--- a/service/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalAidlImplTest.java
+++ b/service/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalAidlImplTest.java
@@ -2407,11 +2407,20 @@
eq(WLAN0_IFACE_NAME), eq(TRANSLATED_SUPPLICANT_SSID.toString()));
validateConnectSequence(false, 2, SUPPLICANT_SSID);
- // Fallback SSID was not found, broadcast the network not found event now.
+ // Fallback SSID was not found, finally broadcast NETWORK_NOT_FOUND and try the first SSID
+ // again.
mISupplicantStaIfaceCallback.onNetworkNotFound(NativeUtil.byteArrayFromArrayList(
NativeUtil.decodeSsid(SUPPLICANT_SSID)));
verify(mWifiMonitor).broadcastNetworkNotFoundEvent(
eq(WLAN0_IFACE_NAME), eq(TRANSLATED_SUPPLICANT_SSID.toString()));
+ validateConnectSequence(false, 3, TRANSLATED_SUPPLICANT_SSID.toString());
+
+ // First SSID not found, try the fallback without broadcasting NETWORK_NOT_FOUND.
+ mISupplicantStaIfaceCallback.onNetworkNotFound(NativeUtil.byteArrayFromArrayList(
+ NativeUtil.decodeSsid(TRANSLATED_SUPPLICANT_SSID.toString())));
+ verify(mWifiMonitor, times(1)).broadcastNetworkNotFoundEvent(
+ eq(WLAN0_IFACE_NAME), eq(TRANSLATED_SUPPLICANT_SSID.toString()));
+ validateConnectSequence(false, 4, SUPPLICANT_SSID);
}
/**
diff --git a/service/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalHidlImplTest.java b/service/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalHidlImplTest.java
index be19bc5..5d4507c 100644
--- a/service/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalHidlImplTest.java
+++ b/service/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalHidlImplTest.java
@@ -3884,10 +3884,19 @@
eq(WLAN0_IFACE_NAME), eq(TRANSLATED_SUPPLICANT_SSID.toString()));
validateConnectSequence(false, 2, SUPPLICANT_SSID);
- // Fallback SSID was not found, broadcast the network not found event now.
+ // Fallback SSID was not found, finally broadcast NETWORK_NOT_FOUND and try the first SSID
+ // again.
mISupplicantStaIfaceCallbackV14.onNetworkNotFound(NativeUtil.decodeSsid(SUPPLICANT_SSID));
verify(mWifiMonitor).broadcastNetworkNotFoundEvent(
eq(WLAN0_IFACE_NAME), eq(TRANSLATED_SUPPLICANT_SSID.toString()));
+ validateConnectSequence(false, 3, TRANSLATED_SUPPLICANT_SSID.toString());
+
+ // First SSID not found, try the fallback without broadcasting NETWORK_NOT_FOUND.
+ mISupplicantStaIfaceCallbackV14.onNetworkNotFound(NativeUtil.decodeSsid(
+ TRANSLATED_SUPPLICANT_SSID.toString()));
+ verify(mWifiMonitor, times(1)).broadcastNetworkNotFoundEvent(
+ eq(WLAN0_IFACE_NAME), eq(TRANSLATED_SUPPLICANT_SSID.toString()));
+ validateConnectSequence(false, 4, SUPPLICANT_SSID);
}
/**
diff --git a/service/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java b/service/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java
index dd4b03f..809fa1a 100644
--- a/service/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java
+++ b/service/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java
@@ -95,7 +95,9 @@
import com.android.server.wifi.InterfaceConflictManager;
import com.android.server.wifi.MockResources;
import com.android.server.wifi.WifiBaseTest;
+import com.android.server.wifi.WifiGlobals;
import com.android.server.wifi.WifiInjector;
+import com.android.server.wifi.WifiSettingsConfigStore;
import com.android.server.wifi.aware.WifiAwareDataPathStateManager.WifiAwareNetworkAgent;
import com.android.server.wifi.hal.WifiNanIface.NanDataPathChannelCfg;
import com.android.server.wifi.hal.WifiNanIface.NanStatusCode;
@@ -163,6 +165,8 @@
@Mock private StatsManager mStatsManager;
@Mock private DeviceConfigFacade mDeviceConfigFacade;
@Mock private FeatureFlags mFeatureFlags;
+ @Mock private WifiSettingsConfigStore mWifiSettingsConfigStore;
+ @Mock private WifiGlobals mWifiGlobals;
@Rule
public ErrorCollector collector = new ErrorCollector();
@@ -213,6 +217,8 @@
}
when(mWifiInjector.getDeviceConfigFacade()).thenReturn(mDeviceConfigFacade);
when(mDeviceConfigFacade.getFeatureFlags()).thenReturn(mFeatureFlags);
+ when(mWifiInjector.getSettingsConfigStore()).thenReturn(mWifiSettingsConfigStore);
+ when(mWifiInjector.getWifiGlobals()).thenReturn(mWifiGlobals);
mDut = new WifiAwareStateManager(mWifiInjector, mPairingConfigManager);
mDut.setNative(mMockNativeManager, mMockNative);
mDut.start(mMockContext, mMockLooper.getLooper(), mAwareMetricsMock,
diff --git a/service/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareNativeManagerTest.java b/service/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareNativeManagerTest.java
index 0f0f913..c2c97a3 100644
--- a/service/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareNativeManagerTest.java
+++ b/service/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareNativeManagerTest.java
@@ -96,7 +96,6 @@
mInOrder.verify(mHalDeviceManager).initialize();
mInOrder.verify(mHalDeviceManager).registerStatusListener(
mManagerStatusListenerCaptor.capture(), any());
- when(mFeatureFlags.d2dWhenInfraStaOff()).thenReturn(true);
mWifiNativeNanIfaceMock.iface = mWifiNanIfaceMock;
}
@@ -113,13 +112,7 @@
*/
@Test
public void testControlFlowWithoutInterface() {
- testControlFlowWithoutInterface(true);
- when(mFeatureFlags.d2dWhenInfraStaOff()).thenReturn(false);
- testControlFlowWithoutInterface(false);
- }
-
- private void testControlFlowWithoutInterface(boolean isD2dEnabled) {
- when(mWifiAwareStateManagerMock.isD2dAllowedWhenStaDisabled()).thenReturn(isD2dEnabled);
+ when(mWifiAwareStateManagerMock.isD2dAllowedWhenStaDisabled()).thenReturn(true);
// configure HalDeviceManager as ready/wifi started (and to return an interface if
// requested)
when(mHalDeviceManager.isStarted()).thenReturn(true);
@@ -133,17 +126,13 @@
mManagerStatusListenerCaptor.getValue().onStatusChanged();
mInOrder.verify(mWifiAwareStateManagerMock).isD2dAllowedWhenStaDisabled();
- mInOrder.verify(mWifiAwareStateManagerMock).disableUsage(isD2dEnabled);
+ mInOrder.verify(mWifiAwareStateManagerMock).disableUsage(true);
// 3. onStatusChange (ready/started) + available -> enableUsage
when(mHalDeviceManager.isStarted()).thenReturn(true);
mManagerStatusListenerCaptor.getValue().onStatusChanged();
mInOrder.verify(mWifiAwareStateManagerMock).tryToGetAwareCapability();
- if (isD2dEnabled) {
- mInOrder.verify(mWifiNative, never()).createNanIface(any(), any(), any());
- } else {
- mInOrder.verify(mHalDeviceManager, never()).createNanIface(any(), any(), any());
- }
+ mInOrder.verify(mWifiNative, never()).createNanIface(any(), any(), any());
verifyNoMoreInteractions(mWifiAwareStateManagerMock, mWifiNanIfaceMock);
assertNull("Interface non-null!", mDut.getWifiNanIface());
}
@@ -154,22 +143,11 @@
*/
@Test
public void testReferenceCounting() throws Exception {
- testReferenceCounting(true);
- when(mFeatureFlags.d2dWhenInfraStaOff()).thenReturn(false);
- testReferenceCounting(false);
- }
-
- private void testReferenceCounting(boolean isD2dEnabled) throws Exception {
// configure HalDeviceManager as ready/wifi started (and to return an interface if
// requested)
when(mHalDeviceManager.isStarted()).thenReturn(true);
- if (isD2dEnabled) {
- when(mWifiNative.createNanIface(any(), any(), any()))
- .thenReturn(mWifiNativeNanIfaceMock);
- } else {
- when(mHalDeviceManager.createNanIface(any(), any(), any()))
- .thenReturn(mWifiNanIfaceMock);
- }
+ when(mWifiNative.createNanIface(any(), any(), any()))
+ .thenReturn(mWifiNativeNanIfaceMock);
// 1. onStatusChange (ready/started)
mManagerStatusListenerCaptor.getValue().onStatusChanged();
@@ -178,13 +156,8 @@
// 2. request (interface obtained)
mDut.tryToGetAware(TEST_WS);
- if (isD2dEnabled) {
- mInOrder.verify(mWifiNative).createNanIface(mDestroyedListenerCaptor.capture(),
- any(), eq(TEST_WS));
- } else {
- mInOrder.verify(mHalDeviceManager).createNanIface(mDestroyedListenerCaptor.capture(),
- any(), eq(TEST_WS));
- }
+ mInOrder.verify(mWifiNative).createNanIface(mDestroyedListenerCaptor.capture(),
+ any(), eq(TEST_WS));
mInOrder.verify(mWifiNanIfaceMock).registerFrameworkCallback(any());
mInOrder.verify(mWifiNanIfaceMock).enableVerboseLogging(anyBoolean());
assertEquals("Interface mismatch", mWifiNanIfaceMock, mDut.getWifiNanIface());
@@ -192,22 +165,15 @@
// 3. release (interface released)
mDut.releaseAware();
mInOrder.verify(mHalDeviceManager).removeIface(mWifiNanIfaceMock);
- if (isD2dEnabled) {
- mInOrder.verify(mWifiNative).teardownNanIface(anyInt());
- }
+ mInOrder.verify(mWifiNative).teardownNanIface(anyInt());
assertNull("Interface non-null!", mDut.getWifiNanIface());
mDestroyedListenerCaptor.getValue().onDestroyed("nan0");
// 4. request (interface obtained)
mDut.tryToGetAware(TEST_WS);
- if (isD2dEnabled) {
- mInOrder.verify(mWifiNative).createNanIface(mDestroyedListenerCaptor.capture(),
- any(), eq(TEST_WS));
- } else {
- mInOrder.verify(mHalDeviceManager).createNanIface(mDestroyedListenerCaptor.capture(),
- any(), eq(TEST_WS));
- }
+ mInOrder.verify(mWifiNative).createNanIface(mDestroyedListenerCaptor.capture(),
+ any(), eq(TEST_WS));
mInOrder.verify(mWifiNanIfaceMock).registerFrameworkCallback(any());
mInOrder.verify(mWifiNanIfaceMock).enableVerboseLogging(anyBoolean());
assertEquals("Interface mismatch", mWifiNanIfaceMock, mDut.getWifiNanIface());
@@ -223,21 +189,13 @@
// 7. release (interface released)
mDut.releaseAware();
mInOrder.verify(mHalDeviceManager).removeIface(mWifiNanIfaceMock);
- if (isD2dEnabled) {
- mInOrder.verify(mWifiNative).teardownNanIface(anyInt());
- }
+ mInOrder.verify(mWifiNative).teardownNanIface(anyInt());
assertNull("Interface non-null!", mDut.getWifiNanIface());
mDestroyedListenerCaptor.getValue().onDestroyed("nan0");
- if (isD2dEnabled) {
- mInOrder.verify(mWifiNative, never()).createNanIface(any(), any(), any());
- } else {
- mInOrder.verify(mHalDeviceManager, never()).createNanIface(any(), any(), any());
- }
+ mInOrder.verify(mWifiNative, never()).createNanIface(any(), any(), any());
mInOrder.verify(mHalDeviceManager, never()).removeIface(any());
- if (isD2dEnabled) {
- mInOrder.verify(mWifiNative, never()).teardownNanIface(anyInt());
- }
+ mInOrder.verify(mWifiNative, never()).teardownNanIface(anyInt());
verifyNoMoreInteractions(mWifiAwareStateManagerMock, mWifiNanIfaceMock);
}
@@ -246,22 +204,11 @@
*/
@Test
public void testRequestFlowWithAsyncDeletes() throws Exception {
- testRequestFlowWithAsyncDeletes(true);
- when(mFeatureFlags.d2dWhenInfraStaOff()).thenReturn(false);
- testRequestFlowWithAsyncDeletes(false);
- }
-
- private void testRequestFlowWithAsyncDeletes(boolean isD2dEnabled) throws Exception {
// configure HalDeviceManager as ready/wifi started (and to return an interface if
// requested)
when(mHalDeviceManager.isStarted()).thenReturn(true);
- if (isD2dEnabled) {
- when(mWifiNative.createNanIface(any(), any(), any()))
- .thenReturn(mWifiNativeNanIfaceMock);
- } else {
- when(mHalDeviceManager.createNanIface(any(), any(), any()))
- .thenReturn(mWifiNanIfaceMock);
- }
+ when(mWifiNative.createNanIface(any(), any(), any()))
+ .thenReturn(mWifiNativeNanIfaceMock);
// 1. onStatusChange (ready/started)
mManagerStatusListenerCaptor.getValue().onStatusChanged();
@@ -270,13 +217,8 @@
// 2. request (interface obtained)
mDut.tryToGetAware(TEST_WS);
- if (isD2dEnabled) {
- mInOrder.verify(mWifiNative).createNanIface(mDestroyedListenerCaptor.capture(),
- any(), eq(TEST_WS));
- } else {
- mInOrder.verify(mHalDeviceManager).createNanIface(mDestroyedListenerCaptor.capture(),
- any(), eq(TEST_WS));
- }
+ mInOrder.verify(mWifiNative).createNanIface(mDestroyedListenerCaptor.capture(),
+ any(), eq(TEST_WS));
mInOrder.verify(mWifiNanIfaceMock).registerFrameworkCallback(any());
mInOrder.verify(mWifiNanIfaceMock).enableVerboseLogging(anyBoolean());
assertEquals("Interface mismatch", mWifiNanIfaceMock, mDut.getWifiNanIface());
@@ -290,15 +232,9 @@
// 4. a release doesn't do much
mDut.releaseAware();
- if (isD2dEnabled) {
- mInOrder.verify(mWifiNative, never()).createNanIface(any(), any(), any());
- } else {
- mInOrder.verify(mHalDeviceManager, never()).createNanIface(any(), any(), any());
- }
+ mInOrder.verify(mWifiNative, never()).createNanIface(any(), any(), any());
mInOrder.verify(mHalDeviceManager, never()).removeIface(any());
- if (isD2dEnabled) {
- mInOrder.verify(mWifiNative, never()).teardownNanIface(anyInt());
- }
+ mInOrder.verify(mWifiNative, never()).teardownNanIface(anyInt());
verifyNoMoreInteractions(mWifiAwareStateManagerMock, mWifiNanIfaceMock);
}
}
diff --git a/service/tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pNativeInterfaceManagementTest.java b/service/tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pNativeInterfaceManagementTest.java
index 694c690..7080a1d 100644
--- a/service/tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pNativeInterfaceManagementTest.java
+++ b/service/tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pNativeInterfaceManagementTest.java
@@ -108,7 +108,6 @@
.thenReturn(TEST_P2P_IFACE_NAME);
when(mWifiInjector.getDeviceConfigFacade()).thenReturn(mDeviceConfigFacade);
when(mDeviceConfigFacade.getFeatureFlags()).thenReturn(mFeatureFlags);
- when(mFeatureFlags.d2dWhenInfraStaOff()).thenReturn(true);
mWifiP2pNative = new WifiP2pNative(mWifiNl80211Manager, mWifiNative, mWifiMetrics,
mWifiVendorHal, mSupplicantP2pIfaceHal, mHalDeviceManager, mPropertyService,
mWifiInjector);
@@ -118,15 +117,6 @@
* Verifies the setup of a p2p interface.
*/
@Test
- public void testSetUpInterfaceByHDM() throws Exception {
- when(mFeatureFlags.d2dWhenInfraStaOff()).thenReturn(false);
- testSetUpInterface(false);
- }
-
- /**
- * Verifies the setup of a p2p interface.
- */
- @Test
public void testSetUpInterfaceByWifiNative() throws Exception {
testSetUpInterface(true);
}
@@ -169,15 +159,6 @@
* Verifies the teardown of a p2p interface.
*/
@Test
- public void testTeardownInterfaceWhenD2dWithoutSTADisabled() throws Exception {
- when(mFeatureFlags.d2dWhenInfraStaOff()).thenReturn(false);
- testTeardownInterface(false);
- }
-
- /**
- * Verifies the teardown of a p2p interface.
- */
- @Test
public void testTeardownInterface() throws Exception {
testTeardownInterface(true);
}
@@ -202,14 +183,6 @@
public void testTeardownInterfaceWithNoVendorHalWhenD2dAloneFeatureEnabled() throws Exception {
testTeardownInterfaceWithNoVendorHal(true);
}
- /**
- * Verifies the teardown of a p2p interface with no HAL (HIDL) support.
- */
- @Test
- public void testTeardownInterfaceWithNoVendorHalD2dAloneFeatureDisabled() throws Exception {
- when(mFeatureFlags.d2dWhenInfraStaOff()).thenReturn(false);
- testTeardownInterfaceWithNoVendorHal(false);
- }
private void testTeardownInterfaceWithNoVendorHal(boolean isD2dAloneFeatureEnabled)
throws Exception {
diff --git a/service/tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pNativeTest.java b/service/tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pNativeTest.java
index e70588f..d271570 100644
--- a/service/tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pNativeTest.java
+++ b/service/tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pNativeTest.java
@@ -140,7 +140,6 @@
mWifiClientInterfaceNames.add("wlan1");
when(mWifiInjector.getDeviceConfigFacade()).thenReturn(mDeviceConfigFacade);
when(mDeviceConfigFacade.getFeatureFlags()).thenReturn(mFeatureFlags);
- when(mFeatureFlags.d2dWhenInfraStaOff()).thenReturn(true);
mWifiP2pNative = new WifiP2pNative(mWifiCondManager, mWifiNative, mWifiMetrics,
mWifiVendorHalMock, mSupplicantP2pIfaceHalMock, mHalDeviceManagerMock,
mPropertyServiceMock, mWifiInjector);
@@ -189,30 +188,11 @@
}
/**
- * Verifies that setupInterface by calling HalDeviceManager returns correct values
- * when successfully creating P2P Iface. (Old design, feature is disabled)
- */
- @Test
- public void testSetupInterfaceByHDMSuccessInCreatingP2pIface() {
- when(mFeatureFlags.d2dWhenInfraStaOff()).thenReturn(false);
- testSetupInterfaceSuccessInCreatingP2pIface(false);
- }
-
- /**
* Verifies that setupInterface by WifiNative returns correct values
* when successfully creating P2P Iface. (The default behavior)
*/
@Test
public void testSetupInterfaceByWifiNativeSuccessInCreatingP2pIface() {
- testSetupInterfaceSuccessInCreatingP2pIface(true);
- }
-
- private void testSetupInterfaceSuccessInCreatingP2pIface(boolean isD2dAloneFeatureEnabled) {
- if (!isD2dAloneFeatureEnabled) {
- when(mHalDeviceManagerMock.createP2pIface(
- any(HalDeviceManager.InterfaceDestroyedListener.class),
- eq(mHandlerMock), eq(mWorkSourceMock))).thenReturn(TEST_IFACE);
- }
when(mSupplicantP2pIfaceHalMock.initialize()).thenReturn(true);
when(mSupplicantP2pIfaceHalMock.isInitializationComplete()).thenReturn(true);
when(mSupplicantP2pIfaceHalMock.setupIface(eq(TEST_IFACE))).thenReturn(true);
@@ -244,33 +224,13 @@
/**
* Verifies that setupInterface returns correct values when failing in creating P2P Iface
- * by HDM.
- */
- @Test
- public void testSetupInterfaceFailureInCreatingP2pIfaceByHDM() {
- when(mFeatureFlags.d2dWhenInfraStaOff()).thenReturn(false);
- testSetupInterfaceFailureInCreatingP2pIface(false);
- }
-
- /**
- * Verifies that setupInterface returns correct values when failing in creating P2P Iface
* by WifiNative.
*/
@Test
public void testSetupInterfaceFailureInCreatingP2pIfaceByWifiNative() {
- testSetupInterfaceFailureInCreatingP2pIface(true);
- }
-
- private void testSetupInterfaceFailureInCreatingP2pIface(boolean isD2dAloneFeatureEnabled) {
- if (isD2dAloneFeatureEnabled) {
- when(mWifiNative.createP2pIface(
- any(HalDeviceManager.InterfaceDestroyedListener.class),
- eq(mHandlerMock), eq(mWorkSourceMock))).thenReturn(null);
- } else {
- when(mHalDeviceManagerMock.createP2pIface(
- any(HalDeviceManager.InterfaceDestroyedListener.class),
- eq(mHandlerMock), eq(mWorkSourceMock))).thenReturn(null);
- }
+ when(mWifiNative.createP2pIface(
+ any(HalDeviceManager.InterfaceDestroyedListener.class),
+ eq(mHandlerMock), eq(mWorkSourceMock))).thenReturn(null);
when(mHalDeviceManagerMock.isItPossibleToCreateIface(
eq(HalDeviceManager.HDM_CREATE_IFACE_P2P), eq(mWorkSourceMock))).thenReturn(true);
@@ -287,31 +247,10 @@
* HalDevMgr not possibly creating it.
*/
@Test
- public void testSetupInterfaceFailureInHDMCreatingP2pIfaceWhenHalDevMgrNotPossiblyCreate() {
- when(mFeatureFlags.d2dWhenInfraStaOff()).thenReturn(false);
- testSetupInterfaceFailureInCreatingP2pIfaceAndHalDevMgrNotPossiblyCreate(false);
- }
-
- /**
- * Verifies that Wi-Fi metrics do correct action when setting up p2p interface failed and
- * HalDevMgr not possibly creating it.
- */
- @Test
public void testSetupInterfaceFailureInCreatingP2pByWifiNativeAndHalDevMgrNotPossiblyCreate() {
- testSetupInterfaceFailureInCreatingP2pIfaceAndHalDevMgrNotPossiblyCreate(true);
- }
-
- private void testSetupInterfaceFailureInCreatingP2pIfaceAndHalDevMgrNotPossiblyCreate(
- boolean isD2dAloneFeatureEnabled) {
- if (isD2dAloneFeatureEnabled) {
- when(mWifiNative.createP2pIface(
- any(HalDeviceManager.InterfaceDestroyedListener.class),
- eq(mHandlerMock), eq(mWorkSourceMock))).thenReturn(null);
- } else {
- when(mHalDeviceManagerMock.createP2pIface(
- any(HalDeviceManager.InterfaceDestroyedListener.class),
- eq(mHandlerMock), eq(mWorkSourceMock))).thenReturn(null);
- }
+ when(mWifiNative.createP2pIface(
+ any(HalDeviceManager.InterfaceDestroyedListener.class),
+ eq(mHandlerMock), eq(mWorkSourceMock))).thenReturn(null);
when(mHalDeviceManagerMock.isItPossibleToCreateIface(
eq(HalDeviceManager.HDM_CREATE_IFACE_P2P), eq(mWorkSourceMock))).thenReturn(false);
@@ -324,27 +263,7 @@
* initialization fails.
*/
@Test
- public void testSetupInterfaceByHDMAndFailureInSupplicantConnectionInitialization() {
- when(mFeatureFlags.d2dWhenInfraStaOff()).thenReturn(false);
- testSetupInterfaceFailureInSupplicantConnectionInitialization(false);
- }
-
- /**
- * Verifies that setupInterface returns correct values when supplicant connection
- * initialization fails.
- */
- @Test
public void testSetupInterfaceByWifiNativeAndFailureInSupplicantConnectionInitialization() {
- testSetupInterfaceFailureInSupplicantConnectionInitialization(true);
- }
-
- private void testSetupInterfaceFailureInSupplicantConnectionInitialization(
- boolean isD2dAloneFeatureEnabled) {
- if (!isD2dAloneFeatureEnabled) {
- when(mHalDeviceManagerMock.createP2pIface(
- any(HalDeviceManager.InterfaceDestroyedListener.class),
- eq(mHandlerMock), eq(mWorkSourceMock))).thenReturn(TEST_IFACE);
- }
when(mSupplicantP2pIfaceHalMock.isInitializationStarted()).thenReturn(false);
when(mSupplicantP2pIfaceHalMock.initialize()).thenReturn(false);
assertEquals(
@@ -359,27 +278,7 @@
* initialization never completes.
*/
@Test
- public void testSetupInterfaceByHDMAndFailureInSupplicantConnectionInitNotCompleted() {
- when(mFeatureFlags.d2dWhenInfraStaOff()).thenReturn(false);
- testSetupInterfaceFailureInSupplicantConnectionInitNotCompleted(false);
- }
-
- /**
- * Verifies that setupInterface returns correct values when supplicant connection
- * initialization never completes.
- */
- @Test
public void testSetupInterfaceByWifiNativeAndFailureInSupplicantConnectionInitNotCompleted() {
- testSetupInterfaceFailureInSupplicantConnectionInitNotCompleted(true);
- }
-
- private void testSetupInterfaceFailureInSupplicantConnectionInitNotCompleted(
- boolean isD2dAloneFeatureEnabled) {
- if (!isD2dAloneFeatureEnabled) {
- when(mHalDeviceManagerMock.createP2pIface(
- any(HalDeviceManager.InterfaceDestroyedListener.class),
- eq(mHandlerMock), eq(mWorkSourceMock))).thenReturn(TEST_IFACE);
- }
when(mSupplicantP2pIfaceHalMock.setupIface(eq(TEST_IFACE))).thenReturn(true);
when(mSupplicantP2pIfaceHalMock.initialize()).thenReturn(true);
when(mSupplicantP2pIfaceHalMock.isInitializationComplete()).thenReturn(false);
@@ -396,26 +295,7 @@
* for supplicant.
*/
@Test
- public void testSetupInterfaceByHDMAndFailureInSettingUpP2pIfaceInSupplicant() {
- when(mFeatureFlags.d2dWhenInfraStaOff()).thenReturn(false);
- testSetupInterfaceFailureInSettingUpP2pIfaceInSupplicant(false);
- }
-
- /**
- * Verifies that setupInterface returns correct values when failing in setting up P2P Iface
- * for supplicant.
- */
- @Test
public void testSetupInterfaceByWifiNativeAndFailureInSettingUpP2pIfaceInSupplicant() {
- testSetupInterfaceFailureInSettingUpP2pIfaceInSupplicant(true);
- }
- private void testSetupInterfaceFailureInSettingUpP2pIfaceInSupplicant(
- boolean isD2dAloneFeatureEnabled) {
- if (!isD2dAloneFeatureEnabled) {
- when(mHalDeviceManagerMock.createP2pIface(
- any(HalDeviceManager.InterfaceDestroyedListener.class),
- eq(mHandlerMock), eq(mWorkSourceMock))).thenReturn(TEST_IFACE);
- }
when(mSupplicantP2pIfaceHalMock.initialize()).thenReturn(true);
when(mSupplicantP2pIfaceHalMock.isInitializationComplete()).thenReturn(true);
when(mSupplicantP2pIfaceHalMock.setupIface(eq(TEST_IFACE))).thenReturn(false);
diff --git a/service/tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pServiceImplTest.java b/service/tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pServiceImplTest.java
index f950dd4..500da18 100644
--- a/service/tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pServiceImplTest.java
+++ b/service/tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pServiceImplTest.java
@@ -8075,7 +8075,6 @@
when(mWifiSettingsConfigStore.get(eq(D2D_ALLOWED_WHEN_INFRA_STA_DISABLED)))
.thenReturn(true);
when(mWifiGlobals.isD2dSupportedWhenInfraStaDisabled()).thenReturn(true);
- when(mFeatureFlags.d2dWhenInfraStaOff()).thenReturn(true);
simulateWifiStateChange(false);
checkIsP2pInitWhenClientConnected(true, mClient1,
new WorkSource(mClient1.getCallingUid(), TEST_PACKAGE_NAME));
@@ -8148,7 +8147,6 @@
when(mWifiSettingsConfigStore.get(eq(D2D_ALLOWED_WHEN_INFRA_STA_DISABLED)))
.thenReturn(true);
when(mWifiGlobals.isD2dSupportedWhenInfraStaDisabled()).thenReturn(true);
- when(mFeatureFlags.d2dWhenInfraStaOff()).thenReturn(true);
simulateWifiStateChange(false);
checkIsP2pInitWhenClientConnected(true, mClient1,
new WorkSource(mClient1.getCallingUid(), TEST_PACKAGE_NAME));