summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--flags/Android.bp1
-rw-r--r--framework/java/android/net/wifi/IWifiScannerListener.aidl10
-rw-r--r--framework/java/android/net/wifi/ScanResult.java6
-rw-r--r--framework/java/android/net/wifi/WifiScanner.java15
-rw-r--r--framework/java/android/net/wifi/rtt/PasnConfig.java39
-rw-r--r--framework/java/android/net/wifi/rtt/RangingResult.java18
-rw-r--r--framework/java/android/net/wifi/rtt/ResponderConfig.java2
-rw-r--r--framework/tests/src/android/net/wifi/rtt/PasnConfigTest.java21
l---------service/ServiceWifiResources/res/values-mcc310-mnc9501
-rw-r--r--service/ServiceWifiResources/res/values-mcc310-mnc950/config.xml28
l---------service/ServiceWifiResources/res/values-mcc311-mnc1802
-rw-r--r--service/ServiceWifiResources/res/values-mcc312-mnc670/config.xml27
l---------service/ServiceWifiResources/res/values-mcc313-mnc1401
-rw-r--r--service/java/com/android/server/wifi/ClientModeImpl.java4
-rw-r--r--service/java/com/android/server/wifi/HalDeviceManager.java2
-rw-r--r--service/java/com/android/server/wifi/LastMileLogger.java29
-rw-r--r--service/java/com/android/server/wifi/SarManager.java22
-rw-r--r--service/java/com/android/server/wifi/WifiConfigManager.java25
-rw-r--r--service/java/com/android/server/wifi/WifiInjector.java3
-rw-r--r--service/java/com/android/server/wifi/WifiNetworkFactory.java33
-rw-r--r--service/java/com/android/server/wifi/WifiP2pConnection.java14
-rw-r--r--service/java/com/android/server/wifi/WifiShellCommand.java45
-rw-r--r--service/java/com/android/server/wifi/aware/WifiAwareStateManager.java2
-rw-r--r--service/java/com/android/server/wifi/hal/WifiRttControllerAidlImpl.java3
-rw-r--r--service/java/com/android/server/wifi/mainline_supplicant/MainlineSupplicant.java356
-rw-r--r--service/java/com/android/server/wifi/mainline_supplicant/MainlineSupplicantStaIfaceCallback.java210
-rw-r--r--service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java8
-rw-r--r--service/java/com/android/server/wifi/rtt/RttService.java3
-rw-r--r--service/java/com/android/server/wifi/rtt/RttServiceImpl.java86
-rw-r--r--service/java/com/android/server/wifi/scanner/WifiScannerInternal.java7
-rw-r--r--service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java27
-rw-r--r--service/java/com/android/server/wifi/util/InformationElementUtil.java9
-rw-r--r--service/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java8
-rw-r--r--service/tests/wifitests/src/com/android/server/wifi/LastMileLoggerTest.java43
-rw-r--r--service/tests/wifitests/src/com/android/server/wifi/SarManagerTest.java41
-rw-r--r--service/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java30
-rw-r--r--service/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java138
-rw-r--r--service/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java4
-rw-r--r--service/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareStateManagerTest.java3
-rw-r--r--service/tests/wifitests/src/com/android/server/wifi/hal/WifiRttControllerAidlImplTest.java78
-rw-r--r--service/tests/wifitests/src/com/android/server/wifi/mainline_supplicant/MainlineSupplicantTest.java38
-rw-r--r--service/tests/wifitests/src/com/android/server/wifi/rtt/RttServiceImplTest.java67
-rw-r--r--service/tests/wifitests/src/com/android/server/wifi/rtt/RttTestUtils.java35
-rw-r--r--service/tests/wifitests/src/com/android/server/wifi/scanner/WificondScannerTest.java19
-rw-r--r--service/tests/wifitests/src/com/android/server/wifi/util/InformationElementUtilTest.java122
-rw-r--r--tests/hostsidetests/multidevices/test/Android.bp7
-rw-r--r--tests/hostsidetests/multidevices/test/aware/AndroidTestNew.xml6
-rw-r--r--tests/hostsidetests/multidevices/test/aware/wifi_aware_discovery_ranging_test.py27
-rw-r--r--tests/hostsidetests/multidevices/test/aware/wifi_aware_network_test.py29
-rw-r--r--tests/hostsidetests/multidevices/test/direct/AndroidTest.xml10
-rw-r--r--tests/hostsidetests/multidevices/test/direct/wifi_direct_test_suite.py (renamed from tests/hostsidetests/multidevices/test/direct/cts_wifi_direct_test_suite.py)6
-rw-r--r--tests/hostsidetests/multidevices/test/softap/AndroidTest.xml6
52 files changed, 1378 insertions, 398 deletions
diff --git a/flags/Android.bp b/flags/Android.bp
index 99ba39a590..3052a39aef 100644
--- a/flags/Android.bp
+++ b/flags/Android.bp
@@ -37,6 +37,7 @@ java_aconfig_library {
"//frameworks/opt/net/wifi/libs/WifiTrackerLib:__subpackages__",
"//packages/modules/Wifi:__subpackages__",
"//cts/tests/tests/wifi:__subpackages__",
+ "//cts/tests/tests/security",
],
}
diff --git a/framework/java/android/net/wifi/IWifiScannerListener.aidl b/framework/java/android/net/wifi/IWifiScannerListener.aidl
index bd19ac2d0f..74b22a1bbf 100644
--- a/framework/java/android/net/wifi/IWifiScannerListener.aidl
+++ b/framework/java/android/net/wifi/IWifiScannerListener.aidl
@@ -15,14 +15,14 @@
package android.net.wifi;
-import android.net.wifi.WifiScanner;
import android.net.wifi.ScanResult;
+import android.net.wifi.WifiScanner;
+import com.android.modules.utils.ParceledListSlice;
/**
* @hide
*/
-oneway interface IWifiScannerListener
-{
+oneway interface IWifiScannerListener {
void onSuccess();
void onFailure(int reason, String description);
@@ -46,5 +46,5 @@ oneway interface IWifiScannerListener
/**
* reports full scan result for all access points found in scan
*/
- void onFullResults(in List<ScanResult> scanResult);
-} \ No newline at end of file
+ void onFullResults(in ParceledListSlice<ScanResult> scanResult);
+}
diff --git a/framework/java/android/net/wifi/ScanResult.java b/framework/java/android/net/wifi/ScanResult.java
index 6954590ae9..e4c91c4c75 100644
--- a/framework/java/android/net/wifi/ScanResult.java
+++ b/framework/java/android/net/wifi/ScanResult.java
@@ -442,6 +442,12 @@ public final class ScanResult implements Parcelable {
*/
@SystemApi
public static final int CIPHER_BIP_CMAC_256 = 9;
+ /**
+ * @hide
+ * Cipher suite: CCMP_256
+ */
+ public static final int CIPHER_CCMP_256 = 10;
+
/**
* The detected signal level in dBm, also known as the RSSI.
diff --git a/framework/java/android/net/wifi/WifiScanner.java b/framework/java/android/net/wifi/WifiScanner.java
index fd9676e0e4..b5cc3b0976 100644
--- a/framework/java/android/net/wifi/WifiScanner.java
+++ b/framework/java/android/net/wifi/WifiScanner.java
@@ -45,6 +45,7 @@ import android.util.Log;
import androidx.annotation.RequiresApi;
import com.android.internal.util.Protocol;
+import com.android.modules.utils.ParceledListSlice;
import com.android.modules.utils.build.SdkLevel;
import com.android.wifi.flags.Flags;
@@ -387,14 +388,14 @@ public class WifiScanner {
* reports full scan result for all access points found in scan
*/
@Override
- public void onFullResults(List<ScanResult> fullScanResult) {
+ public void onFullResults(ParceledListSlice<ScanResult> fullScanResult) {
Log.i(TAG, "onFullResults");
if (mActionListener == null) return;
if (!(mActionListener instanceof ScanListener)) return;
ScanListener scanListener = (ScanListener) mActionListener;
Binder.clearCallingIdentity();
mExecutor.execute(
- () -> fullScanResult.forEach(scanListener::onFullResult));
+ () -> fullScanResult.getList().forEach(scanListener::onFullResult));
}
@Override
@@ -1021,7 +1022,8 @@ public class WifiScanner {
dest.writeInt(mFlags);
dest.writeInt(mBucketsScanned);
dest.writeInt(mScannedBands);
- dest.writeParcelableList(mResults, 0);
+ ParceledListSlice<ScanResult> parceledListSlice = new ParceledListSlice<>(mResults);
+ parceledListSlice.writeToParcel(dest, flags);
}
/** Implement the Parcelable interface {@hide} */
@@ -1032,9 +1034,10 @@ public class WifiScanner {
int flags = in.readInt();
int bucketsScanned = in.readInt();
int bandsScanned = in.readInt();
- List<ScanResult> results = new ArrayList<>();
- in.readParcelableList(results, ScanResult.class.getClassLoader());
- return new ScanData(id, flags, bucketsScanned, bandsScanned, results);
+ ParceledListSlice<ScanResult> parceledListSlice =
+ ParceledListSlice.CREATOR.createFromParcel(in);
+ return new ScanData(id, flags, bucketsScanned, bandsScanned,
+ parceledListSlice.getList());
}
public ScanData[] newArray(int size) {
diff --git a/framework/java/android/net/wifi/rtt/PasnConfig.java b/framework/java/android/net/wifi/rtt/PasnConfig.java
index d420154cba..291a963f5b 100644
--- a/framework/java/android/net/wifi/rtt/PasnConfig.java
+++ b/framework/java/android/net/wifi/rtt/PasnConfig.java
@@ -120,17 +120,14 @@ public final class PasnConfig implements Parcelable {
static {
sStringToAkm.put("None", AKM_NONE);
- sStringToAkm.put("PASN-", AKM_PASN);
- // Transition mode. e.g. "[RSN-SAE+SAE_EXT_KEY-CCMP]"
- sStringToAkm.put("SAE+", AKM_SAE);
- // SAE mode only. e.g. "[RSN-PSK+SAE-CCMP]"
- sStringToAkm.put("SAE-", AKM_SAE);
- sStringToAkm.put("EAP-FILS-SHA256-", AKM_FILS_EAP_SHA256);
- sStringToAkm.put("EAP-FILS-SHA384-", AKM_FILS_EAP_SHA384);
- sStringToAkm.put("FT/EAP-", AKM_FT_EAP_SHA256);
- sStringToAkm.put("FT/PSK-", AKM_FT_PSK_SHA256);
- sStringToAkm.put("EAP-FT-SHA384-", AKM_FT_EAP_SHA384);
- sStringToAkm.put("FT/PSK-SHA384-", AKM_FT_PSK_SHA384);
+ sStringToAkm.put("PASN", AKM_PASN);
+ sStringToAkm.put("SAE", AKM_SAE);
+ sStringToAkm.put("EAP-FILS-SHA256", AKM_FILS_EAP_SHA256);
+ sStringToAkm.put("EAP-FILS-SHA384", AKM_FILS_EAP_SHA384);
+ sStringToAkm.put("FT/EAP", AKM_FT_EAP_SHA256);
+ sStringToAkm.put("FT/PSK", AKM_FT_PSK_SHA256);
+ sStringToAkm.put("EAP-FT-SHA384", AKM_FT_EAP_SHA384);
+ sStringToAkm.put("FT/PSK-SHA384", AKM_FT_PSK_SHA384);
}
/**
@@ -174,17 +171,17 @@ public final class PasnConfig implements Parcelable {
static {
sStringToCipher.put("None", CIPHER_NONE);
- sStringToCipher.put("-CCMP]", CIPHER_CCMP_128);
- sStringToCipher.put("-CCMP-256]", CIPHER_CCMP_256);
- sStringToCipher.put("-GCMP-128]", CIPHER_GCMP_128);
- sStringToCipher.put("-GCMP-256]", CIPHER_GCMP_256);
+ sStringToCipher.put("CCMP-128", CIPHER_CCMP_128);
+ sStringToCipher.put("CCMP-256", CIPHER_CCMP_256);
+ sStringToCipher.put("GCMP-128", CIPHER_GCMP_128);
+ sStringToCipher.put("GCMP-256", CIPHER_GCMP_256);
}
@AkmType
private final int mBaseAkms;
@Cipher
private final int mCiphers;
- private final String mPassword;
+ private String mPassword;
private final WifiSsid mWifiSsid;
private final byte[] mPasnComebackCookie;
@@ -213,6 +210,13 @@ public final class PasnConfig implements Parcelable {
}
/**
+ * @hide
+ */
+ public void setPassword(String password) {
+ mPassword = password;
+ }
+
+ /**
* Get Wifi SSID which is used to retrieve saved network profile if {@link #getPassword()}
* is null. If Wifi SSID and password are not set and there is no saved profile corresponding to
* the responder, unauthenticated PASN will be used if {@link RangingRequest#getSecurityMode()}
@@ -426,8 +430,9 @@ public final class PasnConfig implements Parcelable {
@Override
public String toString() {
+ String password = (mPassword != null ? "*" : "null");
return "PasnConfig{" + "mBaseAkms=" + mBaseAkms + ", mCiphers=" + mCiphers + ", mPassword='"
- + mPassword + '\'' + ", mWifiSsid=" + mWifiSsid + ", mPasnComebackCookie="
+ + password + '\'' + ", mWifiSsid=" + mWifiSsid + ", mPasnComebackCookie="
+ Arrays.toString(mPasnComebackCookie) + '}';
}
}
diff --git a/framework/java/android/net/wifi/rtt/RangingResult.java b/framework/java/android/net/wifi/rtt/RangingResult.java
index 166a13b1d9..09d196ab44 100644
--- a/framework/java/android/net/wifi/rtt/RangingResult.java
+++ b/framework/java/android/net/wifi/rtt/RangingResult.java
@@ -197,6 +197,14 @@ public final class RangingResult implements Parcelable {
mR2iTxLtfRepetitions = other.mR2iTxLtfRepetitions;
mNumTxSpatialStreams = other.mNumTxSpatialStreams;
mNumRxSpatialStreams = other.mNumRxSpatialStreams;
+ mIsRangingAuthenticated = other.mIsRangingAuthenticated;
+ mIsRangingFrameProtected = other.mIsRangingFrameProtected;
+ mIsSecureHeLtfEnabled = other.mIsSecureHeLtfEnabled;
+ mSecureHeLtfProtocolVersion = other.mSecureHeLtfProtocolVersion;
+ if (other.mPasnComebackCookie != null) {
+ mPasnComebackCookie = other.mPasnComebackCookie.clone();
+ mPasnComebackAfterMillis = other.mPasnComebackAfterMillis;
+ }
mVendorData = new ArrayList<>(other.mVendorData);
}
@@ -1251,11 +1259,11 @@ public final class RangingResult implements Parcelable {
.append(", numTxSpatialStreams=").append(mNumTxSpatialStreams)
.append(", numRxSpatialStreams=").append(mNumRxSpatialStreams)
.append(", vendorData=").append(mVendorData)
- .append(", isRangingAuthenticated").append(mIsRangingAuthenticated)
- .append(", isRangingFrameProtected").append(mIsRangingFrameProtected)
- .append(", isSecureHeLtfEnabled").append(mIsSecureHeLtfEnabled)
- .append(", pasnComebackCookie").append(Arrays.toString(mPasnComebackCookie))
- .append(", pasnComebackAfterMillis").append(mPasnComebackAfterMillis)
+ .append(", isRangingAuthenticated=").append(mIsRangingAuthenticated)
+ .append(", isRangingFrameProtected=").append(mIsRangingFrameProtected)
+ .append(", isSecureHeLtfEnabled=").append(mIsSecureHeLtfEnabled)
+ .append(", pasnComebackCookie=").append(Arrays.toString(mPasnComebackCookie))
+ .append(", pasnComebackAfterMillis=").append(mPasnComebackAfterMillis)
.append("]").toString();
}
diff --git a/framework/java/android/net/wifi/rtt/ResponderConfig.java b/framework/java/android/net/wifi/rtt/ResponderConfig.java
index ffa98499ed..7d950eeabd 100644
--- a/framework/java/android/net/wifi/rtt/ResponderConfig.java
+++ b/framework/java/android/net/wifi/rtt/ResponderConfig.java
@@ -1074,7 +1074,7 @@ public final class ResponderConfig implements Parcelable {
if (secureRangingConfig != null) {
builder.setSecureRangingConfig(secureRangingConfig);
}
- return builder.build();
+ return new ResponderConfig(builder);
}
};
diff --git a/framework/tests/src/android/net/wifi/rtt/PasnConfigTest.java b/framework/tests/src/android/net/wifi/rtt/PasnConfigTest.java
index d986e251f3..d6a52be8c8 100644
--- a/framework/tests/src/android/net/wifi/rtt/PasnConfigTest.java
+++ b/framework/tests/src/android/net/wifi/rtt/PasnConfigTest.java
@@ -41,6 +41,7 @@ public class PasnConfigTest {
private static final int TEST_CIPHER = PasnConfig.CIPHER_CCMP_128;
private static final String TEST_SSID = "\"Test_SSID\"";
private static final String TEST_PASSWORD = "password";
+ private static final String TEST_PASSWORD_MASKED = "*";
private static final byte[] TEST_COOKIE = new byte[]{1, 2, 3};
/**
@@ -134,8 +135,8 @@ public class PasnConfigTest {
.build();
String expectedString = "PasnConfig{" + "mBaseAkms=" + TEST_AKM + ", mCiphers="
- + TEST_CIPHER + ", mPassword='" + TEST_PASSWORD + '\'' + ", mWifiSsid=" + ssid
- + ", mPasnComebackCookie=" + Arrays.toString(TEST_COOKIE) + '}';
+ + TEST_CIPHER + ", mPassword='" + TEST_PASSWORD_MASKED + '\'' + ", mWifiSsid="
+ + ssid + ", mPasnComebackCookie=" + Arrays.toString(TEST_COOKIE) + '}';
assertEquals(expectedString, config.toString());
}
@@ -183,11 +184,13 @@ public class PasnConfigTest {
assertEquals(PasnConfig.AKM_NONE, PasnConfig.getBaseAkmsFromCapabilities(null));
assertEquals(PasnConfig.AKM_NONE, PasnConfig.getBaseAkmsFromCapabilities(""));
assertEquals(PasnConfig.AKM_SAE,
- PasnConfig.getBaseAkmsFromCapabilities("[RSN-SAE+SAE_EXT_KEY-CCMP]"));
+ PasnConfig.getBaseAkmsFromCapabilities("[RSN-SAE+SAE_EXT_KEY-CCMP-128]"));
assertEquals(PasnConfig.AKM_SAE,
- PasnConfig.getBaseAkmsFromCapabilities("[RSN-PSK+SAE-CCMP]"));
+ PasnConfig.getBaseAkmsFromCapabilities("[RSN-PSK+SAE-CCMP-128]"));
assertEquals(PasnConfig.AKM_FT_PSK_SHA256,
- PasnConfig.getBaseAkmsFromCapabilities("[RSN-FT/PSK-CCMP]"));
+ PasnConfig.getBaseAkmsFromCapabilities("[RSN-FT/PSK-CCMP-128]"));
+ assertEquals(PasnConfig.AKM_SAE | PasnConfig.AKM_PASN,
+ PasnConfig.getBaseAkmsFromCapabilities("[RSN-PSK+SAE+PASN-CCMP-128]"));
}
/**
@@ -198,9 +201,15 @@ public class PasnConfigTest {
assertEquals(PasnConfig.CIPHER_NONE, PasnConfig.getCiphersFromCapabilities(null));
assertEquals(PasnConfig.CIPHER_NONE, PasnConfig.getCiphersFromCapabilities(""));
assertEquals(PasnConfig.CIPHER_CCMP_128,
- PasnConfig.getCiphersFromCapabilities("[RSN-SAE+SAE_EXT_KEY-CCMP]"));
+ PasnConfig.getCiphersFromCapabilities("[RSN-SAE+SAE_EXT_KEY-CCMP-128]"));
+ assertEquals(PasnConfig.CIPHER_CCMP_256,
+ PasnConfig.getCiphersFromCapabilities("[RSN-SAE+SAE_EXT_KEY-CCMP-256]"));
assertEquals(PasnConfig.CIPHER_GCMP_128,
PasnConfig.getCiphersFromCapabilities("[RSN-SAE+SAE_EXT_KEY-GCMP-128]"));
+ assertEquals(PasnConfig.CIPHER_GCMP_256,
+ PasnConfig.getCiphersFromCapabilities("[RSN-SAE+SAE_EXT_KEY-GCMP-256]"));
+ assertEquals(PasnConfig.CIPHER_GCMP_256 | PasnConfig.CIPHER_CCMP_128,
+ PasnConfig.getCiphersFromCapabilities("[RSN-SAE+SAE_EXT_KEY-GCMP-256+CCMP-128]"));
}
/**
diff --git a/service/ServiceWifiResources/res/values-mcc310-mnc950 b/service/ServiceWifiResources/res/values-mcc310-mnc950
deleted file mode 120000
index 179ce02a94..0000000000
--- a/service/ServiceWifiResources/res/values-mcc310-mnc950
+++ /dev/null
@@ -1 +0,0 @@
-values-mcc310-mnc030 \ No newline at end of file
diff --git a/service/ServiceWifiResources/res/values-mcc310-mnc950/config.xml b/service/ServiceWifiResources/res/values-mcc310-mnc950/config.xml
new file mode 100644
index 0000000000..c6fdb89325
--- /dev/null
+++ b/service/ServiceWifiResources/res/values-mcc310-mnc950/config.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2025 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.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <integer name="config_wifiFrameworkSecureNetworkBonus">540</integer>
+
+ <string-array translatable="false" name="config_wifiOobPseudonymEnabled_carrier_overrides">
+ <item><xliff:g id="carrier_id_prefix">:::1187:::</xliff:g>true</item>
+ </string-array>
+
+ <!-- Carrier specific override for the URL of entitlement server retrieving OOB pseudonym. -->
+ <string-array translatable="false" name="config_wifiOobPseudonymEntitlementServerUrl_carrier_overrides">
+ <item><xliff:g id="carrier_id_prefix">:::1187:::</xliff:g>https://sentitlement2.npc.mobilephone.net/WFC</item>
+ </string-array>
+</resources>
diff --git a/service/ServiceWifiResources/res/values-mcc311-mnc180 b/service/ServiceWifiResources/res/values-mcc311-mnc180
index 179ce02a94..c885455563 120000
--- a/service/ServiceWifiResources/res/values-mcc311-mnc180
+++ b/service/ServiceWifiResources/res/values-mcc311-mnc180
@@ -1 +1 @@
-values-mcc310-mnc030 \ No newline at end of file
+values-mcc310-mnc950 \ No newline at end of file
diff --git a/service/ServiceWifiResources/res/values-mcc312-mnc670/config.xml b/service/ServiceWifiResources/res/values-mcc312-mnc670/config.xml
new file mode 100644
index 0000000000..a605db28c3
--- /dev/null
+++ b/service/ServiceWifiResources/res/values-mcc312-mnc670/config.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2025 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.
+ -->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string-array translatable="false" name="config_wifiOobPseudonymEnabled_carrier_overrides">
+ <item><xliff:g id="carrier_id_prefix">:::2119:::</xliff:g>true</item>
+ </string-array>
+
+ <!-- Carrier specific override for the URL of entitlement server retrieving OOB pseudonym. -->
+ <string-array translatable="false" name="config_wifiOobPseudonymEntitlementServerUrl_carrier_overrides">
+ <item><xliff:g id="carrier_id_prefix">:::2119:::</xliff:g>https://sentitlement2.npc.mobilephone.net/WFC</item>
+ </string-array>
+</resources>
diff --git a/service/ServiceWifiResources/res/values-mcc313-mnc140 b/service/ServiceWifiResources/res/values-mcc313-mnc140
new file mode 120000
index 0000000000..2d21ee5bae
--- /dev/null
+++ b/service/ServiceWifiResources/res/values-mcc313-mnc140
@@ -0,0 +1 @@
+values-mcc313-mnc100 \ No newline at end of file
diff --git a/service/java/com/android/server/wifi/ClientModeImpl.java b/service/java/com/android/server/wifi/ClientModeImpl.java
index 99a6880b30..08e93bdf7f 100644
--- a/service/java/com/android/server/wifi/ClientModeImpl.java
+++ b/service/java/com/android/server/wifi/ClientModeImpl.java
@@ -219,7 +219,7 @@ public class ClientModeImpl extends StateMachine implements ClientMode {
private static final int IPCLIENT_SHUTDOWN_TIMEOUT_MS = 60_000; // 60 seconds
private static final int NETWORK_AGENT_TEARDOWN_DELAY_MS = 5_000; // Max teardown delay.
private static final int DISASSOC_AP_BUSY_DISABLE_DURATION_MS = 5 * 60 * 1000; // 5 minutes
- @VisibleForTesting public static final long CONNECTING_WATCHDOG_TIMEOUT_MS = 30_000; // 30 secs.
+ @VisibleForTesting public static final long CONNECTING_WATCHDOG_TIMEOUT_MS = 8_000; // 8 secs.
public static final int PROVISIONING_TIMEOUT_FILS_CONNECTION_MS = 36_000; // 36 secs.
@VisibleForTesting
public static final String ARP_TABLE_PATH = "/proc/net/arp";
@@ -3659,7 +3659,7 @@ public class ClientModeImpl extends StateMachine implements ClientMode {
// Update link layer stats
getWifiLinkLayerStats();
- if (mWifiP2pConnection.isConnected() && !mWifiP2pConnection.isP2pInWaitingState()) {
+ if (mWifiP2pConnection.isConnected() && !mWifiP2pConnection.isP2pInDisabledState()) {
// P2P discovery breaks DHCP, so shut it down in order to get through this.
// Once P2P service receives this message and processes it accordingly, it is supposed
// to send arg2 (i.e. CMD_PRE_DHCP_ACTION_COMPLETE) in a new Message.what back to
diff --git a/service/java/com/android/server/wifi/HalDeviceManager.java b/service/java/com/android/server/wifi/HalDeviceManager.java
index 227ca28f13..9a0bf0ae64 100644
--- a/service/java/com/android/server/wifi/HalDeviceManager.java
+++ b/service/java/com/android/server/wifi/HalDeviceManager.java
@@ -1584,7 +1584,7 @@ public class HalDeviceManager {
@Override
public void onSubsystemRestart(int status) {
Log.i(TAG, "onSubsystemRestart");
- mEventHandler.post(() -> {
+ mEventHandler.postAtFrontOfQueue(() -> {
Log.i(TAG, "IWifiEventCallback.onSubsystemRestart. Status: " + status);
synchronized (mLock) {
Log.i(TAG, "Attempting to invoke mSubsystemRestartListener");
diff --git a/service/java/com/android/server/wifi/LastMileLogger.java b/service/java/com/android/server/wifi/LastMileLogger.java
index 0c9c0addcf..49c506ed62 100644
--- a/service/java/com/android/server/wifi/LastMileLogger.java
+++ b/service/java/com/android/server/wifi/LastMileLogger.java
@@ -17,6 +17,7 @@
package com.android.server.wifi;
+import android.os.Handler;
import android.util.ArrayMap;
import com.android.internal.annotations.VisibleForTesting;
@@ -34,7 +35,9 @@ import java.util.Map;
* Provides a facility for capturing kernel trace events related to Wifi control and data paths.
*/
public class LastMileLogger {
- public LastMileLogger(WifiInjector injector) {
+ private final Handler mBackgroundHandler;
+ public LastMileLogger(WifiInjector injector, Handler handler) {
+ mBackgroundHandler = handler;
File tracefsEnablePath = new File(WIFI_EVENT_ENABLE_PATH);
if (tracefsEnablePath.exists()) {
initLastMileLogger(injector, WIFI_EVENT_BUFFER_PATH, WIFI_EVENT_ENABLE_PATH,
@@ -47,7 +50,8 @@ public class LastMileLogger {
@VisibleForTesting
public LastMileLogger(WifiInjector injector, String bufferPath, String enablePath,
- String releasePath) {
+ String releasePath, Handler handler) {
+ mBackgroundHandler = handler;
initLastMileLogger(injector, bufferPath, enablePath, releasePath);
}
@@ -62,16 +66,17 @@ public class LastMileLogger {
boolean shouldTracingBeEnabled = anyConnectionInProgress();
- if (!wasTracingEnabled && shouldTracingBeEnabled) {
- enableTracing();
- } else if (wasTracingEnabled && !shouldTracingBeEnabled) {
- disableTracing();
- }
-
- if (event == WifiDiagnostics.CONNECTION_EVENT_FAILED
- || event == WifiDiagnostics.CONNECTION_EVENT_TIMEOUT) {
- mLastMileLogForLastFailure = readTrace();
- }
+ mBackgroundHandler.post(() -> {
+ if (!wasTracingEnabled && shouldTracingBeEnabled) {
+ enableTracing();
+ } else if (wasTracingEnabled && !shouldTracingBeEnabled) {
+ disableTracing();
+ }
+ if (event == WifiDiagnostics.CONNECTION_EVENT_FAILED
+ || event == WifiDiagnostics.CONNECTION_EVENT_TIMEOUT) {
+ mLastMileLogForLastFailure = readTrace();
+ }
+ });
}
private boolean anyConnectionInProgress() {
diff --git a/service/java/com/android/server/wifi/SarManager.java b/service/java/com/android/server/wifi/SarManager.java
index a454dfe96c..9d6a992f57 100644
--- a/service/java/com/android/server/wifi/SarManager.java
+++ b/service/java/com/android/server/wifi/SarManager.java
@@ -72,7 +72,7 @@ public class SarManager {
private static final String TAG = "WifiSarManager";
private boolean mVerboseLoggingEnabled = true;
- private SarInfo mSarInfo;
+ private final SarInfo mSarInfo;
/* Configuration for SAR support */
private boolean mSupportSarTxPowerLimit;
@@ -106,6 +106,7 @@ public class SarManager {
mAudioManager = mContext.getSystemService(AudioManager.class);
mHandler = new Handler(looper);
mPhoneStateListener = new WifiPhoneStateListener(looper);
+ mSarInfo = new SarInfo();
wifiDeviceStateChangeManager.registerStateChangeCallback(
new WifiDeviceStateChangeManager.StateChangeCallback() {
@Override
@@ -121,9 +122,9 @@ public class SarManager {
public void handleBootCompleted() {
readSarConfigs();
if (mSupportSarTxPowerLimit) {
- mSarInfo = new SarInfo();
setSarConfigsInInfo();
registerListeners();
+ updateSarScenario();
}
}
@@ -302,11 +303,6 @@ public class SarManager {
*/
public void setClientWifiState(int state) {
boolean newIsEnabled;
- /* No action is taken if SAR is not supported */
- if (!mSupportSarTxPowerLimit) {
- return;
- }
-
if (state == WifiManager.WIFI_STATE_DISABLED) {
newIsEnabled = false;
} else if (state == WifiManager.WIFI_STATE_ENABLED) {
@@ -328,10 +324,6 @@ public class SarManager {
*/
public void setSapWifiState(int state) {
boolean newIsEnabled;
- /* No action is taken if SAR is not supported */
- if (!mSupportSarTxPowerLimit) {
- return;
- }
if (state == WifiManager.WIFI_AP_STATE_DISABLED) {
newIsEnabled = false;
@@ -354,10 +346,6 @@ public class SarManager {
*/
public void setScanOnlyWifiState(int state) {
boolean newIsEnabled;
- /* No action is taken if SAR is not supported */
- if (!mSupportSarTxPowerLimit) {
- return;
- }
if (state == WifiManager.WIFI_STATE_DISABLED) {
newIsEnabled = false;
@@ -459,6 +447,10 @@ public class SarManager {
* Update HAL with the new SAR scenario if needed.
*/
private void updateSarScenario() {
+ /* No action is taken if SAR is not supported */
+ if (!mSupportSarTxPowerLimit) {
+ return;
+ }
if (!mSarInfo.shouldReport()) {
return;
}
diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java
index 3eb3d0ed49..c996782c11 100644
--- a/service/java/com/android/server/wifi/WifiConfigManager.java
+++ b/service/java/com/android/server/wifi/WifiConfigManager.java
@@ -817,6 +817,31 @@ public class WifiConfigManager {
}
/**
+ * Retrieves the configured network corresponding to the provided SSID and security type. The
+ * WifiConfiguration object will have the password in plain text.
+ *
+ * WARNING: Don't use this to pass network configurations to external apps. Should only be
+ * sent to system apps/wifi stack, when there is a need for passwords in plaintext.
+ *
+ * @param ssid SSID of the requested network.
+ * @param securityType security type of the requested network.
+ * @return WifiConfiguration object if found, null otherwise.
+ */
+ public @Nullable WifiConfiguration getConfiguredNetworkWithPassword(@NonNull WifiSsid ssid,
+ @WifiConfiguration.SecurityType int securityType) {
+ List<WifiConfiguration> wifiConfigurations = getConfiguredNetworks(false, false,
+ Process.WIFI_UID);
+ for (WifiConfiguration wifiConfiguration : wifiConfigurations) {
+ // Match ssid and security type
+ if (ssid.equals(WifiSsid.fromString(wifiConfiguration.SSID))
+ && wifiConfiguration.isSecurityType(securityType)) {
+ return new WifiConfiguration(wifiConfiguration);
+ }
+ }
+ return null;
+ }
+
+ /**
* Retrieves the list of all configured networks with the passwords masked.
*
* @return List of WifiConfiguration objects representing the networks.
diff --git a/service/java/com/android/server/wifi/WifiInjector.java b/service/java/com/android/server/wifi/WifiInjector.java
index 300f850d51..dcf4388095 100644
--- a/service/java/com/android/server/wifi/WifiInjector.java
+++ b/service/java/com/android/server/wifi/WifiInjector.java
@@ -418,7 +418,8 @@ public class WifiInjector {
: maxLinesHighRam);
mWifiDiagnostics = new WifiDiagnostics(
mContext, this, mWifiNative, mBuildProperties,
- new LastMileLogger(this), mClock, mWifiDiagnosticsHandlerThread.getLooper());
+ new LastMileLogger(this, BackgroundThread.getHandler()), mClock,
+ mWifiDiagnosticsHandlerThread.getLooper());
mWifiLastResortWatchdog = new WifiLastResortWatchdog(this, mContext, mClock,
mWifiMetrics, mWifiDiagnostics, wifiLooper,
mDeviceConfigFacade, mWifiThreadRunner, mWifiMonitor);
diff --git a/service/java/com/android/server/wifi/WifiNetworkFactory.java b/service/java/com/android/server/wifi/WifiNetworkFactory.java
index a4b876dfb0..ec4a5ca353 100644
--- a/service/java/com/android/server/wifi/WifiNetworkFactory.java
+++ b/service/java/com/android/server/wifi/WifiNetworkFactory.java
@@ -109,8 +109,6 @@ public class WifiNetworkFactory extends NetworkFactory {
@VisibleForTesting
public static final int PERIODIC_SCAN_INTERVAL_MS = 10 * 1000; // 10 seconds
@VisibleForTesting
- public static final int NETWORK_CONNECTION_TIMEOUT_MS = 30 * 1000; // 30 seconds
- @VisibleForTesting
public static final int USER_SELECTED_NETWORK_CONNECT_RETRY_MAX = 3; // max of 3 retries.
@VisibleForTesting
public static final int USER_APPROVED_SCAN_RETRY_MAX = 3; // max of 3 retries.
@@ -1125,9 +1123,6 @@ public class WifiNetworkFactory extends NetworkFactory {
// Helper method to trigger a connection request & schedule a timeout alarm to track the
// connection request.
private void connectToNetwork(@NonNull WifiConfiguration network) {
- // Cancel connection timeout alarm for any previous connection attempts.
- cancelConnectionTimeout();
-
// First add the network to WifiConfigManager and then use the obtained networkId
// in the CONNECT_NETWORK request.
// Note: We don't do any error checks on the networkId because ClientModeImpl will do the
@@ -1151,9 +1146,6 @@ public class WifiNetworkFactory extends NetworkFactory {
new ActionListenerWrapper(listener),
mActiveSpecificNetworkRequest.getRequestorUid(),
mActiveSpecificNetworkRequest.getRequestorPackageName(), null);
-
- // Post an alarm to handle connection timeout.
- scheduleConnectionTimeout();
}
private void handleConnectToNetworkUserSelectionInternal(WifiConfiguration network,
@@ -1355,6 +1347,14 @@ public class WifiNetworkFactory extends NetworkFactory {
// If there is no active request or if the user has already selected a network,
// ignore screen state changes.
if (mActiveSpecificNetworkRequest == null || !mIsPeriodicScanEnabled) return;
+ if (mSkipUserDialogue) {
+ // Allow App which bypass the user approval to fulfill the request during screen off.
+ return;
+ }
+ if (screenOn != mIsPeriodicScanPaused) {
+ // already at the expected state
+ return;
+ }
// Pause periodic scans when the screen is off & resume when the screen is on.
if (screenOn) {
@@ -1389,7 +1389,6 @@ public class WifiNetworkFactory extends NetworkFactory {
}
// Cancel periodic scan, connection timeout alarm.
cancelPeriodicScans();
- cancelConnectionTimeout();
// Reset the active network request.
mActiveSpecificNetworkRequest = null;
mActiveSpecificNetworkRequestSpecifier = null;
@@ -1471,8 +1470,6 @@ public class WifiNetworkFactory extends NetworkFactory {
mClientModeManager.updateCapabilities();
return;
}
- // Cancel connection timeout alarm.
- cancelConnectionTimeout();
mConnectionStartTimeMillis = mClock.getElapsedSinceBootMillis();
if (mClientModeManagerRole == ROLE_CLIENT_PRIMARY) {
@@ -1735,20 +1732,6 @@ public class WifiNetworkFactory extends NetworkFactory {
mRegisteredCallbacks.finishBroadcast();
}
- private void cancelConnectionTimeout() {
- if (mConnectionTimeoutSet) {
- mAlarmManager.cancel(mConnectionTimeoutAlarmListener);
- mConnectionTimeoutSet = false;
- }
- }
-
- private void scheduleConnectionTimeout() {
- mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
- mClock.getElapsedSinceBootMillis() + NETWORK_CONNECTION_TIMEOUT_MS,
- TAG, mConnectionTimeoutAlarmListener, mHandler);
- mConnectionTimeoutSet = true;
- }
-
private @NonNull CharSequence getAppName(@NonNull String packageName, int uid) {
ApplicationInfo applicationInfo = null;
try {
diff --git a/service/java/com/android/server/wifi/WifiP2pConnection.java b/service/java/com/android/server/wifi/WifiP2pConnection.java
index 907ab0d197..f1c665dd01 100644
--- a/service/java/com/android/server/wifi/WifiP2pConnection.java
+++ b/service/java/com/android/server/wifi/WifiP2pConnection.java
@@ -45,8 +45,8 @@ public class WifiP2pConnection {
private AsyncChannel mWifiP2pChannel;
private boolean mTemporarilyDisconnectWifi = false;
- /** Used to check if P2P state machine is in waitingState */
- private boolean mWaitingState = false;
+ /** Used to check if P2P state machine is in DisabledState */
+ private boolean mDisabledState = false;
public WifiP2pConnection(Context context, Looper looper, ActiveModeWarden activeModeWarden) {
mContext = context;
@@ -191,12 +191,12 @@ public class WifiP2pConnection {
return mTemporarilyDisconnectWifi;
}
- public void setP2pInWaitingState(boolean inWaitingState) {
- mWaitingState = inWaitingState;
+ public void setP2pInDisabledState(boolean inDisabledState) {
+ mDisabledState = inDisabledState;
}
- /** whether the P2P state machine is in waitingState for user response to create interface */
- public boolean isP2pInWaitingState() {
- return mWaitingState;
+ /** whether the P2P state machine is in disabled state */
+ public boolean isP2pInDisabledState() {
+ return mDisabledState;
}
}
diff --git a/service/java/com/android/server/wifi/WifiShellCommand.java b/service/java/com/android/server/wifi/WifiShellCommand.java
index aad4de03ca..bd49b590ab 100644
--- a/service/java/com/android/server/wifi/WifiShellCommand.java
+++ b/service/java/com/android/server/wifi/WifiShellCommand.java
@@ -1256,6 +1256,10 @@ public class WifiShellCommand extends BasicShellCommandHandler {
new ParceledListSlice<>(Collections.emptyList()), SHELL_PACKAGE_NAME,
WifiManager.ACTION_REMOVE_SUGGESTION_DISCONNECT);
return 0;
+ case "clear-all-suggestions":
+ mWifiThreadRunner.post(() -> mWifiNetworkSuggestionsManager.clear(),
+ "shell#clear-all-suggestions");
+ return 0;
case "list-suggestions": {
List<WifiNetworkSuggestion> suggestions =
mWifiService.getNetworkSuggestions(SHELL_PACKAGE_NAME).getList();
@@ -3268,6 +3272,8 @@ public class WifiShellCommand extends BasicShellCommandHandler {
pw.println(" Lists all suggested networks on this device");
pw.println(" list-suggestions-from-app <package name>");
pw.println(" Lists the suggested networks from the app");
+ pw.println(" clear-all-suggestions");
+ pw.println(" Clear all suggestions added into this device");
pw.println(" set-emergency-callback-mode enabled|disabled");
pw.println(" Sets whether Emergency Callback Mode (ECBM) is enabled.");
pw.println(" Equivalent to receiving the "
@@ -3442,15 +3448,36 @@ public class WifiShellCommand extends BasicShellCommandHandler {
if (suggestions == null || suggestions.isEmpty()) {
pw.println("No suggestions on this device");
} else {
- pw.println("SSID Security type(s)");
- for (WifiNetworkSuggestion suggestion : suggestions) {
- pw.println(String.format("%-32s %-4s",
- WifiInfo.sanitizeSsid(suggestion.getWifiConfiguration().SSID),
- suggestion.getWifiConfiguration().getSecurityParamsList().stream()
- .map(p -> WifiConfiguration.getSecurityTypeName(
- p.getSecurityType())
- + (p.isAddedByAutoUpgrade() ? "^" : ""))
- .collect(Collectors.joining("/"))));
+ if (SdkLevel.isAtLeastS()) {
+ /*
+ * Print out SubId on S and above because WifiNetworkSuggestion.getSubscriptionId()
+ * is supported from Android S and above.
+ */
+ String format = "%-24s %-24s %-12s %-12s";
+ pw.println(String.format(format, "SSID", "Security type(s)", "CarrierId", "SubId"));
+ for (WifiNetworkSuggestion suggestion : suggestions) {
+ pw.println(String.format(format,
+ WifiInfo.sanitizeSsid(suggestion.getWifiConfiguration().SSID),
+ suggestion.getWifiConfiguration().getSecurityParamsList().stream()
+ .map(p -> WifiConfiguration.getSecurityTypeName(
+ p.getSecurityType())
+ + (p.isAddedByAutoUpgrade() ? "^" : ""))
+ .collect(Collectors.joining("/")),
+ suggestion.getCarrierId(), suggestion.getSubscriptionId()));
+ }
+ } else {
+ String format = "%-24s %-24s %-12s";
+ pw.println(String.format(format, "SSID", "Security type(s)", "CarrierId"));
+ for (WifiNetworkSuggestion suggestion : suggestions) {
+ pw.println(String.format(format,
+ WifiInfo.sanitizeSsid(suggestion.getWifiConfiguration().SSID),
+ suggestion.getWifiConfiguration().getSecurityParamsList().stream()
+ .map(p -> WifiConfiguration.getSecurityTypeName(
+ p.getSecurityType())
+ + (p.isAddedByAutoUpgrade() ? "^" : ""))
+ .collect(Collectors.joining("/")),
+ suggestion.getCarrierId()));
+ }
}
}
}
diff --git a/service/java/com/android/server/wifi/aware/WifiAwareStateManager.java b/service/java/com/android/server/wifi/aware/WifiAwareStateManager.java
index 19047477dc..3f4460ed8b 100644
--- a/service/java/com/android/server/wifi/aware/WifiAwareStateManager.java
+++ b/service/java/com/android/server/wifi/aware/WifiAwareStateManager.java
@@ -2661,8 +2661,8 @@ public class WifiAwareStateManager implements WifiAwareShellCommand.DelegatedShe
onAwareDownLocal();
if (reason != NanStatusCode.SUCCESS) {
sendAwareStateChangedBroadcast(false);
+ releaseAwareInterface();
}
- releaseAwareInterface();
break;
}
case NOTIFICATION_TYPE_ON_MESSAGE_SEND_SUCCESS: {
diff --git a/service/java/com/android/server/wifi/hal/WifiRttControllerAidlImpl.java b/service/java/com/android/server/wifi/hal/WifiRttControllerAidlImpl.java
index fd76503220..674e1558a3 100644
--- a/service/java/com/android/server/wifi/hal/WifiRttControllerAidlImpl.java
+++ b/service/java/com/android/server/wifi/hal/WifiRttControllerAidlImpl.java
@@ -298,7 +298,8 @@ public class WifiRttControllerAidlImpl implements IWifiRttController {
.set80211mcMeasurement(rttResult.type == RttType.TWO_SIDED_11MC)
.setMeasurementChannelFrequencyMHz(rttResult.channelFreqMHz)
.setMeasurementBandwidth(halToFrameworkChannelBandwidth(rttResult.packetBw))
- .set80211azNtbMeasurement(rttResult.type == RttType.TWO_SIDED_11AZ_NTB)
+ .set80211azNtbMeasurement(rttResult.type == RttType.TWO_SIDED_11AZ_NTB
+ || rttResult.type == RttType.TWO_SIDED_11AZ_NTB_SECURE)
.setMinTimeBetweenNtbMeasurementsMicros(rttResult.ntbMinMeasurementTime
* CONVERSION_MICROS_TO_100_MICROS)
.setMaxTimeBetweenNtbMeasurementsMicros(rttResult.ntbMaxMeasurementTime
diff --git a/service/java/com/android/server/wifi/mainline_supplicant/MainlineSupplicant.java b/service/java/com/android/server/wifi/mainline_supplicant/MainlineSupplicant.java
index 6310577077..1ac2ad8f64 100644
--- a/service/java/com/android/server/wifi/mainline_supplicant/MainlineSupplicant.java
+++ b/service/java/com/android/server/wifi/mainline_supplicant/MainlineSupplicant.java
@@ -18,6 +18,10 @@ package com.android.server.wifi.mainline_supplicant;
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.net.MacAddress;
+import android.net.wifi.usd.Config;
+import android.net.wifi.usd.PublishConfig;
+import android.net.wifi.usd.SubscribeConfig;
import android.net.wifi.util.Environment;
import android.os.IBinder;
import android.os.RemoteException;
@@ -25,13 +29,18 @@ import android.os.ServiceSpecificException;
import android.system.wifi.mainline_supplicant.IMainlineSupplicant;
import android.system.wifi.mainline_supplicant.IStaInterface;
import android.system.wifi.mainline_supplicant.IStaInterfaceCallback;
+import android.system.wifi.mainline_supplicant.UsdMessageInfo;
+import android.system.wifi.mainline_supplicant.UsdServiceProtoType;
import android.util.Log;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.server.wifi.SupplicantStaIfaceHal;
import com.android.server.wifi.WifiNative;
import com.android.server.wifi.WifiThreadRunner;
+import com.android.server.wifi.usd.UsdNativeManager;
import com.android.wifi.flags.Flags;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
@@ -47,6 +56,7 @@ public class MainlineSupplicant {
private static final String TAG = "MainlineSupplicant";
private static final String MAINLINE_SUPPLICANT_SERVICE_NAME = "wifi_mainline_supplicant";
private static final long WAIT_FOR_DEATH_TIMEOUT_MS = 50L;
+ protected static final int DEFAULT_USD_FREQ_MHZ = 2437;
private IMainlineSupplicant mIMainlineSupplicant;
private final Object mLock = new Object();
@@ -57,6 +67,7 @@ public class MainlineSupplicant {
private final boolean mIsServiceAvailable;
private Map<String, IStaInterface> mActiveStaIfaces = new HashMap<>();
private Map<String, IStaInterfaceCallback> mStaIfaceCallbacks = new HashMap<>();
+ private UsdNativeManager.UsdEventsCallback mUsdEventsCallback = null;
public MainlineSupplicant(@NonNull WifiThreadRunner wifiThreadRunner) {
mWifiThreadRunner = wifiThreadRunner;
@@ -281,6 +292,22 @@ public class MainlineSupplicant {
}
/**
+ * Register a framework callback to receive USD events.
+ */
+ public void registerUsdEventsCallback(
+ @NonNull UsdNativeManager.UsdEventsCallback usdEventsCallback) {
+ mUsdEventsCallback = usdEventsCallback;
+ }
+
+ /**
+ * Get the registered USD events callback. Method should only be used
+ * by {@link MainlineSupplicantStaIfaceCallback}.
+ */
+ protected @Nullable UsdNativeManager.UsdEventsCallback getUsdEventsCallback() {
+ return mUsdEventsCallback;
+ }
+
+ /**
* Stop the mainline supplicant process.
*/
public void stopService() {
@@ -342,6 +369,324 @@ public class MainlineSupplicant {
}
}
+ private static byte frameworkToHalUsdTransmissionType(
+ @Config.TransmissionType int transmissionType) {
+ switch (transmissionType) {
+ case Config.TRANSMISSION_TYPE_MULTICAST:
+ return IStaInterface.UsdPublishTransmissionType.MULTICAST;
+ case Config.TRANSMISSION_TYPE_UNICAST:
+ default:
+ return IStaInterface.UsdPublishTransmissionType.UNICAST;
+ }
+ }
+
+ private static byte frameworkToHalUsdProtoType(
+ @Config.ServiceProtoType int protoType) {
+ switch (protoType) {
+ case Config.SERVICE_PROTO_TYPE_GENERIC:
+ return UsdServiceProtoType.GENERIC;
+ case Config.SERVICE_PROTO_TYPE_CSA_MATTER:
+ return UsdServiceProtoType.CSA_MATTER;
+ default:
+ return UsdServiceProtoType.UNKNOWN;
+ }
+ }
+
+ @VisibleForTesting
+ protected static IStaInterface.UsdPublishConfig frameworkToHalUsdPublishConfig(
+ PublishConfig frameworkConfig) {
+ IStaInterface.UsdPublishConfig aidlConfig = new IStaInterface.UsdPublishConfig();
+ // USD publisher is always solicited and unsolicited
+ aidlConfig.publishType = IStaInterface.UsdPublishType.SOLICITED_AND_UNSOLICITED;
+ // FSD is always enabled for USD
+ aidlConfig.isFsd = true;
+ aidlConfig.transmissionType = frameworkToHalUsdTransmissionType(
+ frameworkConfig.getSolicitedTransmissionType());
+ aidlConfig.announcementPeriodMillis = frameworkConfig.getAnnouncementPeriodMillis();
+ aidlConfig.baseConfig = new IStaInterface.UsdBaseConfig();
+ aidlConfig.baseConfig.ttlSec = frameworkConfig.getTtlSeconds();
+ int[] freqs = frameworkConfig.getOperatingFrequenciesMhz();
+ aidlConfig.baseConfig.defaultFreqMhz = (freqs == null || freqs.length == 0)
+ ? DEFAULT_USD_FREQ_MHZ : freqs[0];
+ aidlConfig.baseConfig.freqsMhz = (freqs == null || freqs.length <= 1)
+ ? new int[0] : Arrays.copyOfRange(freqs, 1, freqs.length);
+ aidlConfig.baseConfig.serviceName = Arrays.toString(frameworkConfig.getServiceName());
+ aidlConfig.baseConfig.serviceSpecificInfo =
+ frameworkConfig.getServiceSpecificInfo() != null
+ ? frameworkConfig.getServiceSpecificInfo() : new byte[0];
+ aidlConfig.baseConfig.rxMatchFilter = frameworkConfig.getRxMatchFilterTlv() != null
+ ? frameworkConfig.getRxMatchFilterTlv() : new byte[0];
+ aidlConfig.baseConfig.txMatchFilter = frameworkConfig.getTxMatchFilterTlv() != null
+ ? frameworkConfig.getTxMatchFilterTlv() : new byte[0];
+ aidlConfig.baseConfig.serviceProtoType = frameworkToHalUsdProtoType(
+ frameworkConfig.getServiceProtoType());
+ return aidlConfig;
+ }
+
+ /**
+ * Start a USD publish operation.
+ *
+ * @param ifaceName Name of the interface
+ * @param cmdId An id for this command
+ * @param publishConfig Publish configuration
+ * @return true if successful, false otherwise
+ */
+ public boolean startUsdPublish(@NonNull String ifaceName, int cmdId,
+ @NonNull PublishConfig publishConfig) {
+ synchronized (mLock) {
+ final String methodName = "startUsdPublish";
+ if (ifaceName == null || publishConfig == null) {
+ return false;
+ }
+ IStaInterface iface = getStaIfaceOrLogError(ifaceName, methodName);
+ if (iface == null) {
+ return false;
+ }
+ try {
+ iface.startUsdPublish(cmdId, frameworkToHalUsdPublishConfig(publishConfig));
+ return true;
+ } catch (ServiceSpecificException e) {
+ handleServiceSpecificException(e, methodName);
+ } catch (RemoteException e) {
+ handleRemoteException(e, methodName);
+ }
+ return false;
+ }
+ }
+
+ private static byte frameworkToHalUsdSubscribeType(
+ @Config.SubscribeType int subscribeType) {
+ switch (subscribeType) {
+ case Config.SUBSCRIBE_TYPE_ACTIVE:
+ return IStaInterface.UsdSubscribeType.ACTIVE_MODE;
+ case Config.SUBSCRIBE_TYPE_PASSIVE:
+ default:
+ return IStaInterface.UsdSubscribeType.PASSIVE_MODE;
+ }
+ }
+
+ @VisibleForTesting
+ protected static IStaInterface.UsdSubscribeConfig frameworkToHalUsdSubscribeConfig(
+ SubscribeConfig frameworkConfig) {
+ IStaInterface.UsdSubscribeConfig aidlConfig = new IStaInterface.UsdSubscribeConfig();
+ aidlConfig.subscribeType =
+ frameworkToHalUsdSubscribeType(frameworkConfig.getSubscribeType());
+ aidlConfig.queryPeriodMillis = frameworkConfig.getQueryPeriodMillis();
+ aidlConfig.baseConfig = new IStaInterface.UsdBaseConfig();
+ aidlConfig.baseConfig.ttlSec = frameworkConfig.getTtlSeconds();
+ int[] freqs = frameworkConfig.getOperatingFrequenciesMhz();
+ aidlConfig.baseConfig.defaultFreqMhz = (freqs == null || freqs.length == 0)
+ ? DEFAULT_USD_FREQ_MHZ : freqs[0];
+ aidlConfig.baseConfig.freqsMhz = (freqs == null || freqs.length <= 1)
+ ? new int[0] : Arrays.copyOfRange(freqs, 1, freqs.length);
+ aidlConfig.baseConfig.serviceName = Arrays.toString(frameworkConfig.getServiceName());
+ aidlConfig.baseConfig.serviceSpecificInfo =
+ frameworkConfig.getServiceSpecificInfo() != null
+ ? frameworkConfig.getServiceSpecificInfo() : new byte[0];
+ aidlConfig.baseConfig.rxMatchFilter = frameworkConfig.getRxMatchFilterTlv() != null
+ ? frameworkConfig.getRxMatchFilterTlv() : new byte[0];
+ aidlConfig.baseConfig.txMatchFilter = frameworkConfig.getTxMatchFilterTlv() != null
+ ? frameworkConfig.getTxMatchFilterTlv() : new byte[0];
+ aidlConfig.baseConfig.serviceProtoType = frameworkToHalUsdProtoType(
+ frameworkConfig.getServiceProtoType());
+ return aidlConfig;
+ }
+
+ /**
+ * Start a USD subscribe operation.
+ *
+ * @param ifaceName Name of the interface
+ * @param cmdId An id for this command
+ * @param subscribeConfig Subscribe configuration
+ * @return true if successful, false otherwise
+ */
+ public boolean startUsdSubscribe(@NonNull String ifaceName, int cmdId,
+ @NonNull SubscribeConfig subscribeConfig) {
+ synchronized (mLock) {
+ final String methodName = "startUsdSubscribe";
+ if (ifaceName == null || subscribeConfig == null) {
+ return false;
+ }
+ IStaInterface iface = getStaIfaceOrLogError(ifaceName, methodName);
+ if (iface == null) {
+ return false;
+ }
+ try {
+ iface.startUsdSubscribe(cmdId, frameworkToHalUsdSubscribeConfig(subscribeConfig));
+ return true;
+ } catch (ServiceSpecificException e) {
+ handleServiceSpecificException(e, methodName);
+ } catch (RemoteException e) {
+ handleRemoteException(e, methodName);
+ }
+ return false;
+ }
+ }
+
+ /**
+ * Get the USD capabilities for the interface.
+ *
+ * @param ifaceName Name of the interface
+ * @return UsdCapabilities if available, otherwise null
+ */
+ public @Nullable SupplicantStaIfaceHal.UsdCapabilitiesInternal getUsdCapabilities(
+ @NonNull String ifaceName) {
+ synchronized (mLock) {
+ final String methodName = "getUsdCapabilities";
+ if (ifaceName == null) {
+ return null;
+ }
+ IStaInterface iface = getStaIfaceOrLogError(ifaceName, methodName);
+ if (iface == null) {
+ return null;
+ }
+ try {
+ IStaInterface.UsdCapabilities aidlCaps = iface.getUsdCapabilities();
+ if (aidlCaps == null) {
+ Log.e(TAG, "Received null USD capabilities from the HAL");
+ return null;
+ }
+ return new SupplicantStaIfaceHal.UsdCapabilitiesInternal(
+ aidlCaps.isUsdPublisherSupported,
+ aidlCaps.isUsdSubscriberSupported,
+ aidlCaps.maxLocalSsiLengthBytes,
+ aidlCaps.maxServiceNameLengthBytes,
+ aidlCaps.maxMatchFilterLengthBytes,
+ aidlCaps.maxNumPublishSessions,
+ aidlCaps.maxNumSubscribeSessions);
+ } catch (ServiceSpecificException e) {
+ handleServiceSpecificException(e, methodName);
+ } catch (RemoteException e) {
+ handleRemoteException(e, methodName);
+ }
+ return null;
+ }
+ }
+
+ /**
+ * Update an ongoing USD publish operation.
+ *
+ * @param ifaceName Name of the interface
+ * @param publishId Publish id for this session
+ * @param ssi Service specific info
+ */
+ public void updateUsdPublish(@NonNull String ifaceName, int publishId,
+ @NonNull byte[] ssi) {
+ synchronized (mLock) {
+ final String methodName = "updateUsdPublish";
+ if (ifaceName == null || ssi == null) {
+ return;
+ }
+ IStaInterface iface = getStaIfaceOrLogError(ifaceName, methodName);
+ if (iface == null) {
+ return;
+ }
+ try {
+ iface.updateUsdPublish(publishId, ssi);
+ } catch (ServiceSpecificException e) {
+ handleServiceSpecificException(e, methodName);
+ } catch (RemoteException e) {
+ handleRemoteException(e, methodName);
+ }
+ }
+ }
+
+ /**
+ * Cancel an ongoing USD publish session.
+ *
+ * @param ifaceName Name of the interface
+ * @param publishId Publish id for the session
+ */
+ public void cancelUsdPublish(@NonNull String ifaceName, int publishId) {
+ synchronized (mLock) {
+ final String methodName = "cancelUsdPublish";
+ if (ifaceName == null) {
+ return;
+ }
+ IStaInterface iface = getStaIfaceOrLogError(ifaceName, methodName);
+ if (iface == null) {
+ return;
+ }
+ try {
+ iface.cancelUsdPublish(publishId);
+ } catch (ServiceSpecificException e) {
+ handleServiceSpecificException(e, methodName);
+ } catch (RemoteException e) {
+ handleRemoteException(e, methodName);
+ }
+ }
+ }
+
+ /**
+ * Cancel an ongoing USD subscribe session.
+ *
+ * @param ifaceName Name of the interface
+ * @param subscribeId Subscribe id for the session
+ */
+ public void cancelUsdSubscribe(@NonNull String ifaceName, int subscribeId) {
+ synchronized (mLock) {
+ final String methodName = "cancelUsdSubscribe";
+ if (ifaceName == null) {
+ return;
+ }
+ IStaInterface iface = getStaIfaceOrLogError(ifaceName, methodName);
+ if (iface == null) {
+ return;
+ }
+ try {
+ iface.cancelUsdSubscribe(subscribeId);
+ } catch (ServiceSpecificException e) {
+ handleServiceSpecificException(e, methodName);
+ } catch (RemoteException e) {
+ handleRemoteException(e, methodName);
+ }
+ }
+ }
+
+ private static UsdMessageInfo createUsdMessageInfo(int ownId, int peerId,
+ MacAddress peerMacAddress, byte[] message) {
+ UsdMessageInfo messageInfo = new UsdMessageInfo();
+ messageInfo.ownId = ownId;
+ messageInfo.peerId = peerId;
+ messageInfo.message = message;
+ messageInfo.peerMacAddress = peerMacAddress.toByteArray();
+ return messageInfo;
+ }
+
+ /**
+ * Send a message to an ongoing USD publish or subscribe session.
+ *
+ * @param ifaceName Name of the interface
+ * @param ownId Id for the session
+ * @param peerId Id for the peer session
+ * @param peerMacAddress Mac address of the peer session
+ * @param message Data to send
+ * @return true if successful, false otherwise
+ */
+ public boolean sendUsdMessage(@NonNull String ifaceName, int ownId, int peerId,
+ @NonNull MacAddress peerMacAddress, @NonNull byte[] message) {
+ synchronized (mLock) {
+ final String methodName = "sendUsdMessage";
+ if (ifaceName == null || peerMacAddress == null || message == null) {
+ return false;
+ }
+ IStaInterface iface = getStaIfaceOrLogError(ifaceName, methodName);
+ if (iface == null) {
+ return false;
+ }
+ try {
+ iface.sendUsdMessage(
+ createUsdMessageInfo(ownId, peerId, peerMacAddress, message));
+ return true;
+ } catch (ServiceSpecificException e) {
+ handleServiceSpecificException(e, methodName);
+ } catch (RemoteException e) {
+ handleRemoteException(e, methodName);
+ }
+ return false;
+ }
+ }
+
private void handleServiceSpecificException(ServiceSpecificException e, String methodName) {
Log.e(TAG, methodName + " encountered ServiceSpecificException " + e);
}
@@ -354,6 +699,17 @@ public class MainlineSupplicant {
return true;
}
+ private @Nullable IStaInterface getStaIfaceOrLogError(String ifaceName, String methodName) {
+ synchronized (mLock) {
+ if (!mActiveStaIfaces.containsKey(ifaceName)) {
+ Log.e(TAG, "Unable to call " + methodName + " since iface "
+ + ifaceName + " does not exist");
+ return null;
+ }
+ return mActiveStaIfaces.get(ifaceName);
+ }
+ }
+
private void handleRemoteException(RemoteException e, String methodName) {
synchronized (mLock) {
Log.e(TAG, methodName + " encountered RemoteException " + e);
diff --git a/service/java/com/android/server/wifi/mainline_supplicant/MainlineSupplicantStaIfaceCallback.java b/service/java/com/android/server/wifi/mainline_supplicant/MainlineSupplicantStaIfaceCallback.java
index 20cda62861..4d6207357e 100644
--- a/service/java/com/android/server/wifi/mainline_supplicant/MainlineSupplicantStaIfaceCallback.java
+++ b/service/java/com/android/server/wifi/mainline_supplicant/MainlineSupplicantStaIfaceCallback.java
@@ -17,15 +17,26 @@
package com.android.server.wifi.mainline_supplicant;
import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.annotation.SuppressLint;
+import android.net.MacAddress;
+import android.net.wifi.usd.Config;
+import android.net.wifi.usd.SessionCallback;
import android.system.wifi.mainline_supplicant.IStaInterfaceCallback;
import android.system.wifi.mainline_supplicant.UsdMessageInfo;
+import android.system.wifi.mainline_supplicant.UsdServiceProtoType;
+import android.util.Log;
import com.android.server.wifi.WifiThreadRunner;
+import com.android.server.wifi.usd.UsdNativeManager;
+import com.android.server.wifi.usd.UsdRequestManager;
/**
* Implementation of the mainline supplicant {@link IStaInterfaceCallback}.
*/
public class MainlineSupplicantStaIfaceCallback extends IStaInterfaceCallback.Stub {
+ private static final String TAG = "MainlineSupplicantStaIfaceCallback";
+
private final MainlineSupplicant mMainlineSupplicant;
private final String mIfaceName;
private final WifiThreadRunner mWifiThreadRunner;
@@ -45,7 +56,17 @@ public class MainlineSupplicantStaIfaceCallback extends IStaInterfaceCallback.St
* @param publishId Identifier for the publish session.
*/
@Override
- public void onUsdPublishStarted(int cmdId, int publishId) { }
+ public void onUsdPublishStarted(int cmdId, int publishId) {
+ mWifiThreadRunner.post(() -> {
+ UsdNativeManager.UsdEventsCallback usdCallback =
+ mMainlineSupplicant.getUsdEventsCallback();
+ if (usdCallback == null) {
+ Log.e(TAG, "UsdEventsCallback callback is null");
+ return;
+ }
+ usdCallback.onUsdPublishStarted(cmdId, publishId);
+ });
+ }
/**
* Called in response to startUsdSubscribe to indicate that the subscribe session
@@ -55,7 +76,30 @@ public class MainlineSupplicantStaIfaceCallback extends IStaInterfaceCallback.St
* @param subscribeId Identifier for the subscribe session.
*/
@Override
- public void onUsdSubscribeStarted(int cmdId, int subscribeId) { }
+ public void onUsdSubscribeStarted(int cmdId, int subscribeId) {
+ mWifiThreadRunner.post(() -> {
+ UsdNativeManager.UsdEventsCallback usdCallback =
+ mMainlineSupplicant.getUsdEventsCallback();
+ if (usdCallback == null) {
+ Log.e(TAG, "UsdEventsCallback callback is null");
+ return;
+ }
+ usdCallback.onUsdSubscribeStarted(cmdId, subscribeId);
+ });
+ }
+
+ @SuppressLint("NewApi")
+ private static @SessionCallback.FailureCode int
+ convertHalToFrameworkUsdConfigErrorCode(int errorCode) {
+ switch (errorCode) {
+ case UsdConfigErrorCode.FAILURE_TIMEOUT:
+ return SessionCallback.FAILURE_TIMEOUT;
+ case UsdConfigErrorCode.FAILURE_NOT_AVAILABLE:
+ return SessionCallback.FAILURE_NOT_AVAILABLE;
+ default:
+ return SessionCallback.FAILURE_UNKNOWN;
+ }
+ }
/**
* Called in response to startUsdPublish to indicate that the publish session
@@ -64,7 +108,18 @@ public class MainlineSupplicantStaIfaceCallback extends IStaInterfaceCallback.St
* @param cmdId Identifier for the original request.
* @param errorCode Code indicating the failure reason.
*/
- @Override public void onUsdPublishConfigFailed(int cmdId, int errorCode) { }
+ @Override public void onUsdPublishConfigFailed(int cmdId, int errorCode) {
+ mWifiThreadRunner.post(() -> {
+ UsdNativeManager.UsdEventsCallback usdCallback =
+ mMainlineSupplicant.getUsdEventsCallback();
+ if (usdCallback == null) {
+ Log.e(TAG, "UsdEventsCallback callback is null");
+ return;
+ }
+ usdCallback.onUsdPublishConfigFailed(cmdId,
+ convertHalToFrameworkUsdConfigErrorCode(errorCode));
+ });
+ }
/**
* Called in response to startUsdSubscribe to indicate that the subscribe session
@@ -74,7 +129,29 @@ public class MainlineSupplicantStaIfaceCallback extends IStaInterfaceCallback.St
* @param errorCode Code indicating the failure reason.
*/
@Override
- public void onUsdSubscribeConfigFailed(int cmdId, int errorCode) { }
+ public void onUsdSubscribeConfigFailed(int cmdId, int errorCode) {
+ mWifiThreadRunner.post(() -> {
+ UsdNativeManager.UsdEventsCallback usdCallback =
+ mMainlineSupplicant.getUsdEventsCallback();
+ if (usdCallback == null) {
+ Log.e(TAG, "UsdEventsCallback callback is null");
+ return;
+ }
+ usdCallback.onUsdSubscribeConfigFailed(cmdId,
+ convertHalToFrameworkUsdConfigErrorCode(errorCode));
+ });
+ }
+
+ @SuppressLint("NewApi")
+ private static @SessionCallback.TerminationReasonCode int
+ convertHalToFrameworkUsdTerminateReasonCode(int reasonCode) {
+ switch (reasonCode) {
+ case UsdTerminateReasonCode.USER_REQUESTED:
+ return SessionCallback.TERMINATION_REASON_USER_INITIATED;
+ default:
+ return SessionCallback.TERMINATION_REASON_UNKNOWN;
+ }
+ }
/**
* Called in response to cancelUsdPublish to indicate that the session was cancelled
@@ -84,7 +161,18 @@ public class MainlineSupplicantStaIfaceCallback extends IStaInterfaceCallback.St
* @param reasonCode Code indicating the reason for the session cancellation.
*/
@Override
- public void onUsdPublishTerminated(int publishId, int reasonCode) { }
+ public void onUsdPublishTerminated(int publishId, int reasonCode) {
+ mWifiThreadRunner.post(() -> {
+ UsdNativeManager.UsdEventsCallback usdCallback =
+ mMainlineSupplicant.getUsdEventsCallback();
+ if (usdCallback == null) {
+ Log.e(TAG, "UsdEventsCallback callback is null");
+ return;
+ }
+ usdCallback.onUsdPublishTerminated(publishId,
+ convertHalToFrameworkUsdTerminateReasonCode(reasonCode));
+ });
+ }
/**
* Called in response to cancelUsdSubscribe to indicate that the session was cancelled
@@ -94,7 +182,59 @@ public class MainlineSupplicantStaIfaceCallback extends IStaInterfaceCallback.St
* @param reasonCode Code indicating the reason for the session cancellation.
*/
@Override
- public void onUsdSubscribeTerminated(int subscribeId, int reasonCode) { }
+ public void onUsdSubscribeTerminated(int subscribeId, int reasonCode) {
+ mWifiThreadRunner.post(() -> {
+ UsdNativeManager.UsdEventsCallback usdCallback =
+ mMainlineSupplicant.getUsdEventsCallback();
+ if (usdCallback == null) {
+ Log.e(TAG, "UsdEventsCallback callback is null");
+ return;
+ }
+ usdCallback.onUsdSubscribeTerminated(subscribeId,
+ convertHalToFrameworkUsdTerminateReasonCode(reasonCode));
+ });
+ }
+
+ private static @Config.ServiceProtoType int
+ convertHalToFrameworkUsdProtocolType(int protocolType) {
+ switch (protocolType) {
+ case UsdServiceProtoType.CSA_MATTER:
+ return Config.SERVICE_PROTO_TYPE_CSA_MATTER;
+ default:
+ return Config.SERVICE_PROTO_TYPE_GENERIC;
+ }
+ }
+
+ private static @Nullable MacAddress safeConvertMacAddress(byte[] macAddrBytes) {
+ if (macAddrBytes == null) return null;
+ try {
+ return MacAddress.fromBytes(macAddrBytes);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ private static UsdRequestManager.UsdHalDiscoveryInfo
+ convertHalToFrameworkUsdDiscoveryInfo(UsdServiceDiscoveryInfo discoveryInfo) {
+ if (discoveryInfo.peerMacAddress == null
+ || discoveryInfo.serviceSpecificInfo == null
+ || discoveryInfo.matchFilter == null) {
+ Log.e(TAG, "USD discovery info contains a null parameter");
+ return null;
+ }
+ MacAddress peerAddress = safeConvertMacAddress(discoveryInfo.peerMacAddress);
+ if (peerAddress == null) {
+ Log.e(TAG, "USD discovery info contains an invalid peer address");
+ return null;
+ }
+ return new UsdRequestManager.UsdHalDiscoveryInfo(discoveryInfo.ownId,
+ discoveryInfo.peerId,
+ peerAddress,
+ discoveryInfo.serviceSpecificInfo,
+ convertHalToFrameworkUsdProtocolType(discoveryInfo.serviceProtoType),
+ discoveryInfo.isFsd,
+ discoveryInfo.matchFilter);
+ }
/**
* Indicates that the publisher sent a solicited publish message to the subscriber.
@@ -102,7 +242,22 @@ public class MainlineSupplicantStaIfaceCallback extends IStaInterfaceCallback.St
* @param info Instance of |UsdServiceDiscoveryInfo| containing information about the reply.
*/
@Override
- public void onUsdPublishReplied(UsdServiceDiscoveryInfo info) { }
+ public void onUsdPublishReplied(UsdServiceDiscoveryInfo info) {
+ mWifiThreadRunner.post(() -> {
+ UsdNativeManager.UsdEventsCallback usdCallback =
+ mMainlineSupplicant.getUsdEventsCallback();
+ if (usdCallback == null) {
+ Log.e(TAG, "UsdEventsCallback callback is null");
+ return;
+ }
+ UsdRequestManager.UsdHalDiscoveryInfo convertedInfo =
+ convertHalToFrameworkUsdDiscoveryInfo(info);
+ if (convertedInfo == null) {
+ return;
+ }
+ usdCallback.onUsdPublishReplied(convertedInfo);
+ });
+ }
/**
* Indicates that a publisher was discovered. Only called if this device is acting as a
@@ -111,7 +266,22 @@ public class MainlineSupplicantStaIfaceCallback extends IStaInterfaceCallback.St
* @param info Instance of |UsdServiceDiscoveryInfo| containing information about the service.
*/
@Override
- public void onUsdServiceDiscovered(UsdServiceDiscoveryInfo info) { }
+ public void onUsdServiceDiscovered(UsdServiceDiscoveryInfo info) {
+ mWifiThreadRunner.post(() -> {
+ UsdNativeManager.UsdEventsCallback usdCallback =
+ mMainlineSupplicant.getUsdEventsCallback();
+ if (usdCallback == null) {
+ Log.e(TAG, "UsdEventsCallback callback is null");
+ return;
+ }
+ UsdRequestManager.UsdHalDiscoveryInfo convertedInfo =
+ convertHalToFrameworkUsdDiscoveryInfo(info);
+ if (convertedInfo == null) {
+ return;
+ }
+ usdCallback.onUsdServiceDiscovered(convertedInfo);
+ });
+ }
/**
* Indicates that a message was received on an active USD link.
@@ -119,5 +289,27 @@ public class MainlineSupplicantStaIfaceCallback extends IStaInterfaceCallback.St
* @param messageInfo Information about the message that was received.
*/
@Override
- public void onUsdMessageReceived(UsdMessageInfo messageInfo) { }
+ public void onUsdMessageReceived(UsdMessageInfo messageInfo) {
+ mWifiThreadRunner.post(() -> {
+ UsdNativeManager.UsdEventsCallback usdCallback =
+ mMainlineSupplicant.getUsdEventsCallback();
+ if (usdCallback == null) {
+ Log.e(TAG, "UsdEventsCallback callback is null");
+ return;
+ }
+ MacAddress peerAddress = safeConvertMacAddress(messageInfo.peerMacAddress);
+ if (peerAddress == null) {
+ Log.e(TAG, "USD message info contains an invalid peer address");
+ return;
+ }
+ if (messageInfo.message == null) {
+ Log.e(TAG, "USD message info contains a null message");
+ return;
+ }
+ usdCallback.onUsdMessageReceived(messageInfo.ownId,
+ messageInfo.peerId,
+ peerAddress,
+ messageInfo.message);
+ });
+ }
}
diff --git a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java
index 450f3b4ec7..05a21be4a3 100644
--- a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java
+++ b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java
@@ -3026,12 +3026,12 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
@Override
public void enterImpl() {
-
+ mWifiInjector.getWifiP2pConnection().setP2pInDisabledState(true);
}
@Override
public void exitImpl() {
-
+ mWifiInjector.getWifiP2pConnection().setP2pInDisabledState(false);
}
@Override
@@ -3055,14 +3055,12 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
Log.i(TAG, "No valid package name, ignore ENABLE_P2P");
break;
}
- mWifiInjector.getWifiP2pConnection().setP2pInWaitingState(true);
int proceedWithOperation =
mInterfaceConflictManager.manageInterfaceConflictForStateMachine(
TAG, message, mP2pStateMachine, mWaitingState,
mP2pDisabledState, HalDeviceManager.HDM_CREATE_IFACE_P2P,
createRequestorWs(message.sendingUid, packageName),
false /* bypassDialog */);
- mWifiInjector.getWifiP2pConnection().setP2pInWaitingState(false);
if (proceedWithOperation == InterfaceConflictManager.ICM_ABORT_COMMAND) {
Log.e(TAG, "User refused to set up P2P");
updateThisDevice(WifiP2pDevice.UNAVAILABLE);
@@ -3131,14 +3129,12 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
Log.i(TAG, "No valid package name, do not set up the P2P interface");
return NOT_HANDLED;
}
- mWifiInjector.getWifiP2pConnection().setP2pInWaitingState(true);
int proceedWithOperation =
mInterfaceConflictManager.manageInterfaceConflictForStateMachine(
TAG, message, mP2pStateMachine, mWaitingState,
mP2pDisabledState, HalDeviceManager.HDM_CREATE_IFACE_P2P,
createRequestorWs(message.sendingUid, packageName),
false /* bypassDialog */);
- mWifiInjector.getWifiP2pConnection().setP2pInWaitingState(false);
if (proceedWithOperation == InterfaceConflictManager.ICM_ABORT_COMMAND) {
Log.e(TAG, "User refused to set up P2P");
updateThisDevice(WifiP2pDevice.UNAVAILABLE);
diff --git a/service/java/com/android/server/wifi/rtt/RttService.java b/service/java/com/android/server/wifi/rtt/RttService.java
index aa13c0b6c0..9242992a08 100644
--- a/service/java/com/android/server/wifi/rtt/RttService.java
+++ b/service/java/com/android/server/wifi/rtt/RttService.java
@@ -62,7 +62,8 @@ public class RttService extends SystemService {
mImpl.start(handlerThread.getLooper(), wifiInjector.getClock(), awareManager,
rttMetrics, wifiPermissionsUtil, wifiInjector.getSettingsConfigStore(),
- wifiInjector.getHalDeviceManager());
+ wifiInjector.getHalDeviceManager(), wifiInjector.getWifiConfigManager(),
+ wifiInjector.getSsidTranslator());
} else if (phase == SystemService.PHASE_BOOT_COMPLETED) {
mImpl.handleBootCompleted();
}
diff --git a/service/java/com/android/server/wifi/rtt/RttServiceImpl.java b/service/java/com/android/server/wifi/rtt/RttServiceImpl.java
index 930368e1b0..10cbe18e11 100644
--- a/service/java/com/android/server/wifi/rtt/RttServiceImpl.java
+++ b/service/java/com/android/server/wifi/rtt/RttServiceImpl.java
@@ -38,17 +38,21 @@ import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.location.LocationManager;
import android.net.MacAddress;
+import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
+import android.net.wifi.WifiSsid;
import android.net.wifi.aware.IWifiAwareMacAddressProvider;
import android.net.wifi.aware.MacAddrMapping;
import android.net.wifi.aware.WifiAwareManager;
import android.net.wifi.rtt.IRttCallback;
import android.net.wifi.rtt.IWifiRttManager;
+import android.net.wifi.rtt.PasnConfig;
import android.net.wifi.rtt.RangingRequest;
import android.net.wifi.rtt.RangingResult;
import android.net.wifi.rtt.RangingResultCallback;
import android.net.wifi.rtt.ResponderConfig;
import android.net.wifi.rtt.ResponderLocation;
+import android.net.wifi.rtt.SecureRangingConfig;
import android.net.wifi.rtt.WifiRttManager;
import android.os.Binder;
import android.os.Bundle;
@@ -73,7 +77,9 @@ import com.android.server.wifi.BuildProperties;
import com.android.server.wifi.Clock;
import com.android.server.wifi.FrameworkFacade;
import com.android.server.wifi.HalDeviceManager;
+import com.android.server.wifi.SsidTranslator;
import com.android.server.wifi.SystemBuildProperties;
+import com.android.server.wifi.WifiConfigManager;
import com.android.server.wifi.WifiSettingsConfigStore;
import com.android.server.wifi.hal.WifiRttController;
import com.android.server.wifi.proto.nano.WifiMetricsProto;
@@ -116,8 +122,8 @@ public class RttServiceImpl extends IWifiRttManager.Stub {
private final BuildProperties mBuildProperties;
private FrameworkFacade mFrameworkFacade;
private WifiRttController.Capabilities mCapabilities;
-
private RttServiceSynchronized mRttServiceSynchronized;
+ private SsidTranslator mWifiSsidTranslator;
/* package */ static final String HAL_RANGING_TIMEOUT_TAG = TAG + " HAL Ranging Timeout";
@@ -128,6 +134,7 @@ public class RttServiceImpl extends IWifiRttManager.Stub {
// arbitrary, larger than anything reasonable
/* package */ static final int MAX_QUEUED_PER_UID = 20;
+ private WifiConfigManager mWifiConfigManager;
private final WifiRttController.RttControllerRangingResultsCallback mRangingResultsCallback =
new WifiRttController.RttControllerRangingResultsCallback() {
@@ -311,10 +318,14 @@ public class RttServiceImpl extends IWifiRttManager.Stub {
* @param wifiPermissionsUtil Utility for permission checks.
* @param settingsConfigStore Used for retrieving verbose logging level.
* @param halDeviceManager The HAL device manager object.
+ * @param wifiConfigManager The Wi-Fi configuration manager used to retrieve credentials for
+ * secure ranging
+ * @param ssidTranslator SSID translator
*/
public void start(Looper looper, Clock clock, WifiAwareManager awareManager,
RttMetrics rttMetrics, WifiPermissionsUtil wifiPermissionsUtil,
- WifiSettingsConfigStore settingsConfigStore, HalDeviceManager halDeviceManager) {
+ WifiSettingsConfigStore settingsConfigStore, HalDeviceManager halDeviceManager,
+ WifiConfigManager wifiConfigManager, SsidTranslator ssidTranslator) {
mClock = clock;
mAwareManager = awareManager;
mHalDeviceManager = halDeviceManager;
@@ -323,6 +334,8 @@ public class RttServiceImpl extends IWifiRttManager.Stub {
mRttServiceSynchronized = new RttServiceSynchronized(looper);
mActivityManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
mPowerManager = mContext.getSystemService(PowerManager.class);
+ mWifiConfigManager = wifiConfigManager;
+ mWifiSsidTranslator = ssidTranslator;
mRttServiceSynchronized.mHandler.post(() -> {
IntentFilter intentFilter = new IntentFilter();
@@ -516,6 +529,63 @@ public class RttServiceImpl extends IWifiRttManager.Stub {
}
}
+ private @WifiConfiguration.SecurityType int getSecurityTypeFromPasnAkms(
+ @PasnConfig.AkmType int akms) {
+ @WifiConfiguration.SecurityType int securityType;
+ // IEEE 802.11az supports PASN authentication with FT, PASN authentication with SAE and
+ // PASN authentication with FILS shared key. On FT PSK and SAE needs pre-shared key or
+ // password.
+ if (akms == PasnConfig.AKM_PASN) {
+ securityType = WifiConfiguration.SECURITY_TYPE_OPEN;
+ } else if ((akms & PasnConfig.AKM_SAE) != 0) {
+ securityType = WifiConfiguration.SECURITY_TYPE_SAE;
+ } else if ((akms & PasnConfig.AKM_FT_PSK_SHA256) != 0
+ || (akms & PasnConfig.AKM_FT_PSK_SHA384) != 0) {
+ // Note: WifiConfiguration is created as PSK. The fast transition (FT) flag is added
+ // before saving to wpa_supplicant. So check for SECURITY_TYPE_PSK.
+ securityType = WifiConfiguration.SECURITY_TYPE_PSK;
+ } else {
+ securityType = WifiConfiguration.SECURITY_TYPE_EAP;
+ }
+ return securityType;
+ }
+
+ /**
+ * Update the PASN password from WifiConfiguration.
+ */
+ private void updatePasswordIfRequired(@NonNull PasnConfig pasnConfig) {
+ if (pasnConfig.getPassword() != null || pasnConfig.getWifiSsid() == null) {
+ return;
+ }
+ int securityType = getSecurityTypeFromPasnAkms(pasnConfig.getBaseAkms());
+ if (securityType == WifiConfiguration.SECURITY_TYPE_SAE
+ || securityType == WifiConfiguration.SECURITY_TYPE_PSK) {
+ // The SSID within PasnConfig is supplied by an 11az secure ranging application,
+ // which doesn't guarantee UTF-8 encoding. Therefore, a UTF-8 conversion step is
+ // necessary before the SSID can be reliably used by service code.
+ WifiSsid translatedSsid = mWifiSsidTranslator.getTranslatedSsid(
+ pasnConfig.getWifiSsid());
+ WifiConfiguration wifiConfiguration =
+ mWifiConfigManager.getConfiguredNetworkWithPassword(translatedSsid,
+ securityType);
+ if (wifiConfiguration != null) {
+ pasnConfig.setPassword(wifiConfiguration.preSharedKey);
+ }
+ }
+ }
+
+ /**
+ * Update the secure ranging parameters if required.
+ */
+ private void updateSecureRangingParams(RangingRequest request) {
+ for (ResponderConfig rttPeer : request.mRttPeers) {
+ SecureRangingConfig secureRangingConfig = rttPeer.getSecureRangingConfig();
+ if (secureRangingConfig != null) {
+ updatePasswordIfRequired(secureRangingConfig.getPasnConfig());
+ }
+ }
+ }
+
/**
* Binder interface API to start a ranging operation. Called on binder thread, operations needs
* to be posted to handler thread.
@@ -620,6 +690,7 @@ public class RttServiceImpl extends IWifiRttManager.Stub {
}
override11azOverlays(request);
+ updateSecureRangingParams(request);
mRttServiceSynchronized.mHandler.post(() -> {
WorkSource sourceToUse = ws;
@@ -1381,6 +1452,17 @@ public class RttServiceImpl extends IWifiRttManager.Stub {
&& !resultForRequest.getVendorData().isEmpty()) {
builder.setVendorData(resultForRequest.getVendorData());
}
+ // set secure ranging fields
+ builder.setRangingFrameProtected(resultForRequest.isRangingFrameProtected())
+ .setRangingAuthenticated(resultForRequest.isRangingAuthenticated())
+ .setSecureHeLtfEnabled(resultForRequest.isSecureHeLtfEnabled())
+ .setSecureHeLtfProtocolVersion(
+ resultForRequest.getSecureHeLtfProtocolVersion());
+ if (resultForRequest.getPasnComebackCookie() != null) {
+ builder.setPasnComebackCookie(resultForRequest.getPasnComebackCookie());
+ builder.setPasnComebackAfterMillis(
+ resultForRequest.getPasnComebackAfterMillis());
+ }
finalResults.add(builder.build());
}
}
diff --git a/service/java/com/android/server/wifi/scanner/WifiScannerInternal.java b/service/java/com/android/server/wifi/scanner/WifiScannerInternal.java
index 713edd792e..7dac6f1264 100644
--- a/service/java/com/android/server/wifi/scanner/WifiScannerInternal.java
+++ b/service/java/com/android/server/wifi/scanner/WifiScannerInternal.java
@@ -26,6 +26,7 @@ import android.os.WorkSource;
import android.util.Log;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.modules.utils.ParceledListSlice;
import com.android.server.wifi.WifiThreadRunner;
import java.util.Collections;
@@ -93,9 +94,9 @@ public abstract class WifiScannerInternal {
}
@Override
- public void onFullResults(List<ScanResult> fullScanResult) {
- mWifiThreadRunner.post(() -> fullScanResult.forEach(mScanListener::onFullResult),
- TAG + "#onFullResults");
+ public void onFullResults(ParceledListSlice<ScanResult> fullScanResult) {
+ mWifiThreadRunner.post(() -> fullScanResult.getList()
+ .forEach(mScanListener::onFullResult), TAG + "#onFullResults");
}
@Override
diff --git a/service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java b/service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java
index 5392d1a0fa..e8c37cf1b3 100644
--- a/service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java
+++ b/service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java
@@ -61,6 +61,7 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.Protocol;
import com.android.internal.util.State;
import com.android.internal.util.StateMachine;
+import com.android.modules.utils.ParceledListSlice;
import com.android.modules.utils.build.SdkLevel;
import com.android.server.wifi.ClientModeImpl;
import com.android.server.wifi.Clock;
@@ -1740,9 +1741,10 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub {
}
entry.clientInfo.reportEvent((listener) -> {
try {
- listener.onFullResults(new ArrayList<>(matchedScanResults));
+ listener.onFullResults(
+ new ParceledListSlice<>(new ArrayList<>(matchedScanResults)));
} catch (RemoteException e) {
- loge("Failed to call onFullResult: " + entry.clientInfo);
+ loge("Failed to call onFullResults: " + entry.clientInfo);
}
});
matchedScanResults.clear();
@@ -1751,9 +1753,9 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub {
for (RequestInfo<Void> entry : mSingleScanListeners) {
entry.clientInfo.reportEvent((listener) -> {
try {
- listener.onFullResults(results);
+ listener.onFullResults(new ParceledListSlice<>(results));
} catch (RemoteException e) {
- loge("Failed to call onFullResult: " + entry.clientInfo);
+ loge("Failed to call onFullResults: " + entry.clientInfo);
}
});
}
@@ -1779,7 +1781,7 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub {
// make sure the handler is removed
listener.onSingleScanCompleted();
} catch (RemoteException e) {
- loge("Failed to call onResult: " + entry.clientInfo);
+ loge("Failed to call onResults: " + entry.clientInfo);
}
});
}
@@ -1791,7 +1793,7 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub {
try {
listener.onResults(allResults);
} catch (RemoteException e) {
- loge("Failed to call onResult: " + entry.clientInfo);
+ loge("Failed to call onResults: " + entry.clientInfo);
}
});
}
@@ -2314,9 +2316,10 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub {
}
entry.clientInfo.reportEvent((listener) -> {
try {
- listener.onFullResults(new ArrayList<>(matchedResults));
+ listener.onFullResults(
+ new ParceledListSlice<>(new ArrayList<>(matchedResults)));
} catch (RemoteException e) {
- loge("Failed to call onFullResult: " + ci);
+ loge("Failed to call onFullResults: " + ci);
}
});
}
@@ -2350,7 +2353,7 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub {
try {
listener.onResults(resultsToDeliver);
} catch (RemoteException e) {
- loge("Failed to call onFullResult: " + ci);
+ loge("Failed to call onResults: " + ci);
}
});
}
@@ -2364,7 +2367,7 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub {
try {
listener.onFailure(reason, description);
} catch (RemoteException e) {
- loge("Failed to call onFullResult: " + ci);
+ loge("Failed to call onFailure: " + ci);
}
});
}
@@ -3229,7 +3232,7 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub {
try {
listener.onPnoNetworkFound(results);
} catch (RemoteException e) {
- loge("Failed to call onFullResult: " + ci);
+ loge("Failed to call onPnoNetworkFound: " + ci);
}
});
}
@@ -3242,7 +3245,7 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub {
try {
listener.onFailure(reason, description);
} catch (RemoteException e) {
- loge("Failed to call onFullResult: " + ci);
+ loge("Failed to call onFailure: " + ci);
}
});
}
diff --git a/service/java/com/android/server/wifi/util/InformationElementUtil.java b/service/java/com/android/server/wifi/util/InformationElementUtil.java
index 37a07a5ca8..9ac19d6283 100644
--- a/service/java/com/android/server/wifi/util/InformationElementUtil.java
+++ b/service/java/com/android/server/wifi/util/InformationElementUtil.java
@@ -1895,6 +1895,7 @@ public class InformationElementUtil {
private static final int RSN_CIPHER_CCMP = 0x04ac0f00;
private static final int RSN_CIPHER_NO_GROUP_ADDRESSED = 0x07ac0f00;
private static final int RSN_CIPHER_GCMP_256 = 0x09ac0f00;
+ private static final int RSN_CIPHER_CCMP_256 = 0x0aac0f00;
private static final int RSN_CIPHER_GCMP_128 = 0x08ac0f00;
private static final int RSN_CIPHER_BIP_GMAC_128 = 0x0bac0f00;
private static final int RSN_CIPHER_BIP_GMAC_256 = 0x0cac0f00;
@@ -2129,6 +2130,8 @@ public class InformationElementUtil {
return ScanResult.CIPHER_TKIP;
case RSN_CIPHER_CCMP:
return ScanResult.CIPHER_CCMP;
+ case RSN_CIPHER_CCMP_256:
+ return ScanResult.CIPHER_CCMP_256;
case RSN_CIPHER_GCMP_256:
return ScanResult.CIPHER_GCMP_256;
case RSN_CIPHER_NO_GROUP_ADDRESSED:
@@ -2489,7 +2492,11 @@ public class InformationElementUtil {
case ScanResult.CIPHER_NONE:
return "None";
case ScanResult.CIPHER_CCMP:
- return "CCMP";
+ return "CCMP-128";
+ case ScanResult.CIPHER_CCMP_256:
+ return "CCMP-256";
+ case ScanResult.CIPHER_GCMP_128:
+ return "GCMP-128";
case ScanResult.CIPHER_GCMP_256:
return "GCMP-256";
case ScanResult.CIPHER_TKIP:
diff --git a/service/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java b/service/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
index 19f15a21a7..37ae9aa13e 100644
--- a/service/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
+++ b/service/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
@@ -11126,8 +11126,8 @@ public class ClientModeImplTest extends WifiBaseTest {
}
/**
- * Verify that during DHCP process, 1. If P2P is in waiting state, clientModeImpl doesn't send a
- * message to block P2P discovery. 2. If P2P is not in waiting state, clientModeImpl sends a
+ * Verify that during DHCP process, 1. If P2P is in disabled state, clientModeImpl doesn't send
+ * a message to block P2P discovery. 2. If P2P is not in disabled state, clientModeImpl sends a
* message to block P2P discovery. 3. On DHCP completion, clientModeImpl sends a message to
* unblock P2P discovery.
*/
@@ -11162,7 +11162,7 @@ public class ClientModeImplTest extends WifiBaseTest {
assertEquals("L3ProvisioningState", getCurrentState().getName());
when(mWifiP2pConnection.isConnected()).thenReturn(true);
- when(mWifiP2pConnection.isP2pInWaitingState()).thenReturn(true);
+ when(mWifiP2pConnection.isP2pInDisabledState()).thenReturn(true);
mIpClientCallback.onPreDhcpAction();
mLooper.dispatchAll();
@@ -11170,7 +11170,7 @@ public class ClientModeImplTest extends WifiBaseTest {
verify(mIpClient).completedPreDhcpAction();
when(mWifiP2pConnection.isConnected()).thenReturn(true);
- when(mWifiP2pConnection.isP2pInWaitingState()).thenReturn(false);
+ when(mWifiP2pConnection.isP2pInDisabledState()).thenReturn(false);
mIpClientCallback.onPreDhcpAction();
mLooper.dispatchAll();
diff --git a/service/tests/wifitests/src/com/android/server/wifi/LastMileLoggerTest.java b/service/tests/wifitests/src/com/android/server/wifi/LastMileLoggerTest.java
index 158e35bb9c..ab181f693a 100644
--- a/service/tests/wifitests/src/com/android/server/wifi/LastMileLoggerTest.java
+++ b/service/tests/wifitests/src/com/android/server/wifi/LastMileLoggerTest.java
@@ -24,6 +24,9 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
+import android.os.Handler;
+import android.os.test.TestLooper;
+
import androidx.test.filters.SmallTest;
import com.android.server.wifi.util.FileUtils;
@@ -52,6 +55,8 @@ public class LastMileLoggerTest extends WifiBaseTest {
@Mock WifiInjector mWifiInjector;
@Spy FakeWifiLog mLog;
+ private TestLooper mLooper;
+
@Before
public void setUp() throws Exception {
@@ -64,8 +69,10 @@ public class LastMileLoggerTest extends WifiBaseTest {
mTraceEnableFile.deleteOnExit();
mTraceReleaseFile.deleteOnExit();
FileUtils.stringToFile(mTraceEnableFile.getPath(), "0");
+ mLooper = new TestLooper();
+ Handler backgroundHandler = new Handler(mLooper.getLooper());
mLastMileLogger = new LastMileLogger(mWifiInjector, mTraceDataFile.getPath(),
- mTraceEnableFile.getPath(), mTraceReleaseFile.getPath());
+ mTraceEnableFile.getPath(), mTraceReleaseFile.getPath(), backgroundHandler);
}
private static String readFileAsString(File file) throws IOException {
@@ -75,13 +82,15 @@ public class LastMileLoggerTest extends WifiBaseTest {
@Test
public void ctorDoesNotCrash() throws Exception {
new LastMileLogger(mWifiInjector, mTraceDataFile.getPath(), mTraceEnableFile.getPath(),
- mTraceReleaseFile.getPath());
+ mTraceReleaseFile.getPath(), new Handler(mLooper.getLooper()));
+ mLooper.dispatchAll();
verifyNoMoreInteractions(mLog);
}
@Test
public void connectionEventStartedEnablesTracing() throws Exception {
mLastMileLogger.reportConnectionEvent(WLAN0, WifiDiagnostics.CONNECTION_EVENT_STARTED);
+ mLooper.dispatchAll();
assertEquals("1", readFileAsString(mTraceEnableFile));
}
@@ -89,6 +98,7 @@ public class LastMileLoggerTest extends WifiBaseTest {
public void connectionEventStartedDoesNotCrashIfReleaseFileIsMissing() throws Exception {
mTraceReleaseFile.delete();
mLastMileLogger.reportConnectionEvent(WLAN0, WifiDiagnostics.CONNECTION_EVENT_STARTED);
+ mLooper.dispatchAll();
verify(mLog).warn(contains("Failed to open free_buffer"));
}
@@ -97,13 +107,14 @@ public class LastMileLoggerTest extends WifiBaseTest {
throws Exception {
mTraceReleaseFile.delete();
mLastMileLogger.reportConnectionEvent(WLAN0, WifiDiagnostics.CONNECTION_EVENT_STARTED);
+ mLooper.dispatchAll();
assertEquals("0", readFileAsString(mTraceEnableFile));
}
@Test
public void connectionEventStartedDoesNotAttemptToReopenReleaseFile() throws Exception {
mLastMileLogger.reportConnectionEvent(WLAN0, WifiDiagnostics.CONNECTION_EVENT_STARTED);
-
+ mLooper.dispatchAll();
// This is a rather round-about way of verifying that we don't attempt to re-open
// the file. Namely: if we delete the |release| file, and CONNECTION_EVENT_STARTED
// _did_ re-open the file, then we'd log an error message. Since the test is deleting the
@@ -114,6 +125,7 @@ public class LastMileLoggerTest extends WifiBaseTest {
// FileInputStream.
mTraceReleaseFile.delete();
mLastMileLogger.reportConnectionEvent(WLAN0, WifiDiagnostics.CONNECTION_EVENT_STARTED);
+ mLooper.dispatchAll();
verifyNoMoreInteractions(mLog);
}
@@ -121,36 +133,42 @@ public class LastMileLoggerTest extends WifiBaseTest {
public void connectionEventStartedDoesNotCrashIfEnableFileIsMissing() throws Exception {
mTraceEnableFile.delete();
mLastMileLogger.reportConnectionEvent(WLAN0, WifiDiagnostics.CONNECTION_EVENT_STARTED);
+ mLooper.dispatchAll();
}
@Test
public void connectionEventStartedDoesNotCrashOnRepeatedCalls() throws Exception {
mLastMileLogger.reportConnectionEvent(WLAN0, WifiDiagnostics.CONNECTION_EVENT_STARTED);
mLastMileLogger.reportConnectionEvent(WLAN0, WifiDiagnostics.CONNECTION_EVENT_STARTED);
+ mLooper.dispatchAll();
}
@Test
public void connectionEventSucceededDisablesTracing() throws Exception {
mLastMileLogger.reportConnectionEvent(WLAN0, WifiDiagnostics.CONNECTION_EVENT_SUCCEEDED);
assertEquals("0", readFileAsString(mTraceEnableFile));
+ mLooper.dispatchAll();
}
@Test
public void connectionEventSucceededDoesNotCrashIfEnableFileIsMissing() throws Exception {
mTraceEnableFile.delete();
mLastMileLogger.reportConnectionEvent(WLAN0, WifiDiagnostics.CONNECTION_EVENT_SUCCEEDED);
+ mLooper.dispatchAll();
}
@Test
public void connectionEventSucceededDoesNotCrashOnRepeatedCalls() throws Exception {
mLastMileLogger.reportConnectionEvent(WLAN0, WifiDiagnostics.CONNECTION_EVENT_SUCCEEDED);
mLastMileLogger.reportConnectionEvent(WLAN0, WifiDiagnostics.CONNECTION_EVENT_SUCCEEDED);
+ mLooper.dispatchAll();
}
@Test
public void connectionEventFailedDisablesTracingWhenPendingFails() throws Exception {
mLastMileLogger.reportConnectionEvent(WLAN0, WifiDiagnostics.CONNECTION_EVENT_STARTED);
mLastMileLogger.reportConnectionEvent(WLAN0, WifiDiagnostics.CONNECTION_EVENT_FAILED);
+ mLooper.dispatchAll();
assertEquals("0", readFileAsString(mTraceEnableFile));
}
@@ -158,25 +176,30 @@ public class LastMileLoggerTest extends WifiBaseTest {
public void connectionEventTimeoutDisablesTracing() throws Exception {
mLastMileLogger.reportConnectionEvent(WLAN0, WifiDiagnostics.CONNECTION_EVENT_STARTED);
mLastMileLogger.reportConnectionEvent(WLAN0, WifiDiagnostics.CONNECTION_EVENT_TIMEOUT);
+ mLooper.dispatchAll();
assertEquals("0", readFileAsString(mTraceEnableFile));
}
@Test
public void multipleIfaces() throws Exception {
mLastMileLogger.reportConnectionEvent(WLAN0, WifiDiagnostics.CONNECTION_EVENT_STARTED);
+ mLooper.dispatchAll();
assertEquals("1", readFileAsString(mTraceEnableFile));
mLastMileLogger.reportConnectionEvent(WLAN1, WifiDiagnostics.CONNECTION_EVENT_STARTED);
+ mLooper.dispatchAll();
assertEquals("1", readFileAsString(mTraceEnableFile));
FileUtils.stringToFile(mTraceDataFile.getPath(), "rdev_connect");
mLastMileLogger.reportConnectionEvent(WLAN0, WifiDiagnostics.CONNECTION_EVENT_TIMEOUT);
+ mLooper.dispatchAll();
assertEquals("1", readFileAsString(mTraceEnableFile));
String dumpString = getDumpString();
assertTrue(dumpString.contains("--- Last failed"));
assertTrue(dumpString.contains("rdev_connect"));
mLastMileLogger.reportConnectionEvent(WLAN1, WifiDiagnostics.CONNECTION_EVENT_SUCCEEDED);
+ mLooper.dispatchAll();
assertEquals("0", readFileAsString(mTraceEnableFile));
}
@@ -184,25 +207,30 @@ public class LastMileLoggerTest extends WifiBaseTest {
public void connectionEventFailedDoesNotCrashIfEnableFileIsMissing() throws Exception {
mTraceEnableFile.delete();
mLastMileLogger.reportConnectionEvent(WLAN0, WifiDiagnostics.CONNECTION_EVENT_FAILED);
+ mLooper.dispatchAll();
}
@Test
public void connectionEventFailedDoesNotCrashIfDataFileIsMissing() throws Exception {
mTraceDataFile.delete();
mLastMileLogger.reportConnectionEvent(WLAN0, WifiDiagnostics.CONNECTION_EVENT_FAILED);
+ mLooper.dispatchAll();
}
@Test
public void connectionEventFailedDoesNotCrashOnRepeatedCalls() throws Exception {
mLastMileLogger.reportConnectionEvent(WLAN0, WifiDiagnostics.CONNECTION_EVENT_FAILED);
mLastMileLogger.reportConnectionEvent(WLAN0, WifiDiagnostics.CONNECTION_EVENT_FAILED);
+ mLooper.dispatchAll();
}
@Test
public void dumpShowsFailureTrace() throws Exception {
mLastMileLogger.reportConnectionEvent(WLAN0, WifiDiagnostics.CONNECTION_EVENT_STARTED);
+ mLooper.dispatchAll();
FileUtils.stringToFile(mTraceDataFile.getPath(), "rdev_connect");
mLastMileLogger.reportConnectionEvent(WLAN0, WifiDiagnostics.CONNECTION_EVENT_FAILED);
+ mLooper.dispatchAll();
assertTrue(getDumpString().contains("--- Last failed"));
assertTrue(getDumpString().contains("rdev_connect"));
}
@@ -211,6 +239,7 @@ public class LastMileLoggerTest extends WifiBaseTest {
@Test
public void dumpShowsPendingConnectionTrace() throws Exception {
mLastMileLogger.reportConnectionEvent(WLAN0, WifiDiagnostics.CONNECTION_EVENT_STARTED);
+ mLooper.dispatchAll();
FileUtils.stringToFile(mTraceDataFile.getPath(), "rdev_connect");
assertTrue(getDumpString().contains("No last mile log for \"Last failed"));
assertTrue(getDumpString().contains("--- Latest"));
@@ -220,9 +249,11 @@ public class LastMileLoggerTest extends WifiBaseTest {
@Test
public void dumpShowsLastFailureTraceAndPendingConnectionTrace() throws Exception {
mLastMileLogger.reportConnectionEvent(WLAN0, WifiDiagnostics.CONNECTION_EVENT_STARTED);
+ mLooper.dispatchAll();
FileUtils.stringToFile(mTraceDataFile.getPath(), "rdev_connect try #1");
mLastMileLogger.reportConnectionEvent(WLAN0, WifiDiagnostics.CONNECTION_EVENT_FAILED);
mLastMileLogger.reportConnectionEvent(WLAN0, WifiDiagnostics.CONNECTION_EVENT_STARTED);
+ mLooper.dispatchAll();
FileUtils.stringToFile(mTraceDataFile.getPath(), "rdev_connect try #2");
String dumpString = getDumpString();
@@ -233,11 +264,14 @@ public class LastMileLoggerTest extends WifiBaseTest {
@Test
public void dumpShowsLastFailureTraceAndCurrentConnectionTrace() throws Exception {
mLastMileLogger.reportConnectionEvent(WLAN0, WifiDiagnostics.CONNECTION_EVENT_STARTED);
+ mLooper.dispatchAll();
FileUtils.stringToFile(mTraceDataFile.getPath(), "rdev_connect try #1");
mLastMileLogger.reportConnectionEvent(WLAN0, WifiDiagnostics.CONNECTION_EVENT_FAILED);
mLastMileLogger.reportConnectionEvent(WLAN0, WifiDiagnostics.CONNECTION_EVENT_STARTED);
+ mLooper.dispatchAll();
FileUtils.stringToFile(mTraceDataFile.getPath(), "rdev_connect try #2");
mLastMileLogger.reportConnectionEvent(WLAN0, WifiDiagnostics.CONNECTION_EVENT_SUCCEEDED);
+ mLooper.dispatchAll();
String dumpString = getDumpString();
assertTrue(dumpString.contains("rdev_connect try #1"));
@@ -247,8 +281,10 @@ public class LastMileLoggerTest extends WifiBaseTest {
@Test
public void dumpDoesNotClearLastFailureData() throws Exception {
mLastMileLogger.reportConnectionEvent(WLAN0, WifiDiagnostics.CONNECTION_EVENT_STARTED);
+ mLooper.dispatchAll();
FileUtils.stringToFile(mTraceDataFile.getPath(), "rdev_connect");
mLastMileLogger.reportConnectionEvent(WLAN0, WifiDiagnostics.CONNECTION_EVENT_FAILED);
+ mLooper.dispatchAll();
getDumpString();
String dumpString = getDumpString();
@@ -258,6 +294,7 @@ public class LastMileLoggerTest extends WifiBaseTest {
@Test
public void dumpDoesNotClearPendingConnectionTrace() throws Exception {
mLastMileLogger.reportConnectionEvent(WLAN0, WifiDiagnostics.CONNECTION_EVENT_STARTED);
+ mLooper.dispatchAll();
FileUtils.stringToFile(mTraceDataFile.getPath(), "rdev_connect");
getDumpString();
diff --git a/service/tests/wifitests/src/com/android/server/wifi/SarManagerTest.java b/service/tests/wifitests/src/com/android/server/wifi/SarManagerTest.java
index 867396da1d..fe582e3521 100644
--- a/service/tests/wifitests/src/com/android/server/wifi/SarManagerTest.java
+++ b/service/tests/wifitests/src/com/android/server/wifi/SarManagerTest.java
@@ -133,7 +133,6 @@ public class SarManagerTest extends WifiBaseTest {
mWifiDeviceStateChangeManager);
mSarMgr.handleBootCompleted();
-
if (isSarEnabled) {
/* Capture the PhoneStateListener */
ArgumentCaptor<PhoneStateListener> phoneStateListenerCaptor =
@@ -573,4 +572,44 @@ public class SarManagerTest extends WifiBaseTest {
assertTrue(mSarInfo.isWifiScanOnlyEnabled);
assertFalse(mSarInfo.isWifiClientEnabled);
}
+
+ /**
+ * Test that for devices that support setting/resetting Tx Power limits, device sets wifi enable
+ * first then finish the boot up. Verify device will change the power scenario.
+ */
+ @Test
+ public void testSarMgr_enabledTxPowerScenario_wifiOn_before_boot_completed_offHook() {
+ mResources.setBoolean(
+ R.bool.config_wifi_framework_enable_sar_tx_power_limit, true);
+ mResources.setBoolean(
+ R.bool.config_wifi_framework_enable_soft_ap_sar_tx_power_limit,
+ false);
+
+ mSarMgr = new SarManager(mContext, mTelephonyManager, mLooper.getLooper(), mWifiNative,
+ mWifiDeviceStateChangeManager);
+ /* Enable logs from SarManager */
+ enableDebugLogs();
+
+ InOrder inOrder = inOrder(mWifiNative);
+ // Enable wifi first, should be no change to the WifiNative
+ mSarMgr.setClientWifiState(WifiManager.WIFI_STATE_ENABLED);
+ inOrder.verify(mWifiNative, never()).selectTxPowerScenario(any());
+
+ mSarMgr.handleBootCompleted();
+ ArgumentCaptor<PhoneStateListener> phoneStateListenerCaptor =
+ ArgumentCaptor.forClass(PhoneStateListener.class);
+ verify(mTelephonyManager).listen(phoneStateListenerCaptor.capture(),
+ eq(PhoneStateListener.LISTEN_CALL_STATE));
+ mPhoneStateListener = phoneStateListenerCaptor.getValue();
+ assertNotNull(mPhoneStateListener);
+ captureSarInfo(mWifiNative);
+ assertFalse(mSarInfo.isVoiceCall);
+ inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
+
+ /* Set phone state to OFFHOOK */
+ mPhoneStateListener.onCallStateChanged(CALL_STATE_OFFHOOK, "");
+
+ inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo));
+ assertTrue(mSarInfo.isVoiceCall);
+ }
}
diff --git a/service/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/service/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
index 83cff646df..3d25fdada6 100644
--- a/service/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
+++ b/service/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
@@ -17,6 +17,7 @@
package com.android.server.wifi;
import static android.net.wifi.WifiConfiguration.SECURITY_TYPE_PSK;
+import static android.net.wifi.WifiConfiguration.SECURITY_TYPE_SAE;
import static android.net.wifi.WifiManager.AddNetworkResult.STATUS_INVALID_CONFIGURATION_ENTERPRISE;
import static com.android.server.wifi.TestUtil.createCapabilityBitset;
@@ -8502,4 +8503,33 @@ public class WifiConfigManagerTest extends WifiBaseTest {
result = updateNetworkToWifiConfigManager(config);
assertFalse(result.isSuccess());
}
+
+ /**
+ * Verify that the configured network with password is correctly retrieved using SSID and Key
+ * management.
+ */
+ @Test
+ public void testConfiguredNetworkWithPassword() {
+
+ NetworkSelectionStatus.Builder builder = new NetworkSelectionStatus.Builder();
+ NetworkSelectionStatus networkSelectionStatus = builder.build();
+ SecurityParams params = SecurityParams.createSecurityParamsBySecurityType(
+ SECURITY_TYPE_SAE);
+ networkSelectionStatus.setCandidateSecurityParams(params);
+ WifiConfiguration saeNetwork = WifiConfigurationTestUtil.createSaeNetwork(TEST_SSID);
+ saeNetwork.setNetworkSelectionStatus(networkSelectionStatus);
+ NetworkUpdateResult result = verifyAddNetworkToWifiConfigManager(saeNetwork);
+
+ // Get the configured network with password
+ WifiConfiguration wifiConfig = mWifiConfigManager.getConfiguredNetworkWithPassword(
+ WifiSsid.fromString(TEST_SSID), SECURITY_TYPE_SAE);
+ // Test the retrieved network is the same network that was added for TEST_SSID and SAE
+ assertNotNull(wifiConfig);
+ assertEquals(saeNetwork.networkId, result.getNetworkId());
+ assertEquals(WifiConfigurationTestUtil.TEST_PSK, wifiConfig.preSharedKey);
+ wifiConfig = mWifiConfigManager.getConfiguredNetworkWithPassword(
+ WifiSsid.fromString(TEST_SSID), SECURITY_TYPE_PSK);
+ // Test there is no network with TEST_SSID and FT_PSK
+ assertNull(wifiConfig);
+ }
}
diff --git a/service/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java b/service/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java
index cebb2b6864..329a7a8ef0 100644
--- a/service/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java
+++ b/service/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java
@@ -1736,34 +1736,6 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
}
/**
- * Verify handling of connection timeout.
- * The timeouts should trigger connection retries until we hit the max.
- */
- @Test
- public void testNetworkSpecifierHandleConnectionTimeout() throws Exception {
- sendNetworkRequestAndSetupForConnectionStatus();
-
- // Simulate connection timeout beyond the retry limit to trigger the failure handling.
- for (int i = 0; i <= WifiNetworkFactory.USER_SELECTED_NETWORK_CONNECT_RETRY_MAX; i++) {
- mConnectionTimeoutAlarmListenerArgumentCaptor.getValue().onAlarm();
- mLooper.dispatchAll();
- }
-
- mInOrder = inOrder(mAlarmManager, mClientModeManager, mConnectHelper);
- validateConnectionRetryAttempts(true);
-
- // Fail the request after all the retries are exhausted.
- verify(mNetworkRequestMatchCallback).onAbort();
- // Verify that we sent the connection failure callback.
- verify(mNetworkRequestMatchCallback).onUserSelectionConnectFailure(
- argThat(new WifiConfigMatcher(mSelectedNetwork)));
- // Verify we reset the network request handling.
- verify(mWifiConnectivityManager).setSpecificNetworkRequestInProgress(false);
- verify(mActiveModeWarden).removeClientModeManager(any());
- verify(mConnectivityManager).declareNetworkRequestUnfulfillable(eq(mNetworkRequest));
- }
-
- /**
* Verify handling of connection trigger failure.
* The trigger failures should trigger connection retries until we hit the max.
*/
@@ -1773,23 +1745,19 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
// Send failure message beyond the retry limit to trigger the failure handling.
for (int i = 0; i <= WifiNetworkFactory.USER_SELECTED_NETWORK_CONNECT_RETRY_MAX; i++) {
- assertNotNull(mConnectionTimeoutAlarmListenerArgumentCaptor.getValue());
mConnectListenerArgumentCaptor.getValue()
.sendFailure(WifiManager.ActionListener.FAILURE_INTERNAL_ERROR);
}
mLooper.dispatchAll();
mInOrder = inOrder(mAlarmManager, mClientModeManager, mConnectHelper);
- validateConnectionRetryAttempts(false);
+ validateConnectionRetryAttempts();
// Fail the request after all the retries are exhausted.
verify(mNetworkRequestMatchCallback).onAbort();
// Verify that we sent the connection failure callback.
verify(mNetworkRequestMatchCallback).onUserSelectionConnectFailure(
argThat(new WifiConfigMatcher(mSelectedNetwork)));
- // verify we canceled the timeout alarm.
- mInOrder.verify(mAlarmManager).cancel(
- mConnectionTimeoutAlarmListenerArgumentCaptor.getValue());
// Verify we reset the network request handling.
verify(mWifiConnectivityManager).setSpecificNetworkRequestInProgress(false);
verify(mActiveModeWarden).removeClientModeManager(any());
@@ -1818,15 +1786,12 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
}
mInOrder = inOrder(mAlarmManager, mClientModeManager, mConnectHelper);
- validateConnectionRetryAttempts(false);
+ validateConnectionRetryAttempts();
verify(mNetworkRequestMatchCallback).onAbort();
// Verify that we sent the connection failure callback.
verify(mNetworkRequestMatchCallback).onUserSelectionConnectFailure(
argThat(new WifiConfigMatcher(mSelectedNetwork)));
- // verify we canceled the timeout alarm.
- mInOrder.verify(mAlarmManager).cancel(
- mConnectionTimeoutAlarmListenerArgumentCaptor.getValue());
// Verify we reset the network request handling.
verify(mWifiConnectivityManager).setSpecificNetworkRequestInProgress(false);
verify(mActiveModeWarden).removeClientModeManager(any());
@@ -1859,9 +1824,6 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
// Verify that we sent the connection failure callback.
verify(mNetworkRequestMatchCallback).onUserSelectionConnectFailure(
argThat(new WifiConfigMatcher(mSelectedNetwork)));
- // verify we canceled the timeout alarm.
- mInOrder.verify(mAlarmManager).cancel(
- mConnectionTimeoutAlarmListenerArgumentCaptor.getValue());
// Verify we reset the network request handling.
verify(mWifiConnectivityManager).setSpecificNetworkRequestInProgress(false);
verify(mActiveModeWarden).removeClientModeManager(any());
@@ -1887,9 +1849,6 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
// Verify that we did not send the connection failure callback.
verify(mNetworkRequestMatchCallback, never()).onUserSelectionConnectFailure(any());
- // verify we canceled the timeout alarm.
- verify(mAlarmManager, never())
- .cancel(mConnectionTimeoutAlarmListenerArgumentCaptor.getValue());
// Verify we don't reset the network request handling.
verify(mWifiConnectivityManager, never())
.setSpecificNetworkRequestInProgress(false);
@@ -1903,14 +1862,11 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
}
mInOrder = inOrder(mAlarmManager, mClientModeManager, mConnectHelper);
- validateConnectionRetryAttempts(false);
+ validateConnectionRetryAttempts();
// Verify that we sent the connection failure callback.
verify(mNetworkRequestMatchCallback).onUserSelectionConnectFailure(
argThat(new WifiConfigMatcher(mSelectedNetwork)));
- // verify we canceled the timeout alarm.
- mInOrder.verify(mAlarmManager).cancel(
- mConnectionTimeoutAlarmListenerArgumentCaptor.getValue());
// Verify we reset the network request handling.
verify(mWifiConnectivityManager).setSpecificNetworkRequestInProgress(false);
verify(mActiveModeWarden).removeClientModeManager(any());
@@ -1931,9 +1887,6 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
// Verify that we did not send the connection failure callback.
verify(mNetworkRequestMatchCallback, never()).onUserSelectionConnectFailure(any());
- // verify we canceled the timeout alarm.
- verify(mAlarmManager, never())
- .cancel(mConnectionTimeoutAlarmListenerArgumentCaptor.getValue());
// Verify we don't reset the network request handling.
verify(mWifiConnectivityManager, never())
.setSpecificNetworkRequestInProgress(false);
@@ -1947,14 +1900,11 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
}
mInOrder = inOrder(mAlarmManager, mClientModeManager, mConnectHelper);
- validateConnectionRetryAttempts(false);
+ validateConnectionRetryAttempts();
// Verify that we sent the connection failure callback.
verify(mNetworkRequestMatchCallback).onUserSelectionConnectFailure(
argThat(new WifiConfigMatcher(mSelectedNetwork)));
- // verify we canceled the timeout alarm.
- mInOrder.verify(mAlarmManager).cancel(
- mConnectionTimeoutAlarmListenerArgumentCaptor.getValue());
// Verify we reset the network request handling.
verify(mWifiConnectivityManager).setSpecificNetworkRequestInProgress(false);
verify(mActiveModeWarden).removeClientModeManager(any());
@@ -1976,8 +1926,6 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
// Verify that we sent the connection success callback.
verify(mNetworkRequestMatchCallback).onUserSelectionConnectSuccess(
argThat(new WifiConfigMatcher(mSelectedNetwork)));
- // verify we canceled the timeout alarm.
- verify(mAlarmManager).cancel(mConnectionTimeoutAlarmListenerArgumentCaptor.getValue());
// Verify we disabled fw roaming.
verify(mClientModeManager).enableRoaming(false);
@@ -2010,8 +1958,6 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
// Verify that we sent the connection success callback.
verify(mNetworkRequestMatchCallback).onUserSelectionConnectSuccess(
argThat(new WifiConfigMatcher(mSelectedNetwork)));
- // verify we canceled the timeout alarm.
- verify(mAlarmManager).cancel(mConnectionTimeoutAlarmListenerArgumentCaptor.getValue());
// Verify we disabled fw roaming.
verify(mClientModeManager, never()).enableRoaming(false);
@@ -2042,8 +1988,6 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
// Verify that we sent the connection success callback.
verify(mNetworkRequestMatchCallback).onUserSelectionConnectSuccess(
argThat(new WifiConfigMatcher(mSelectedNetwork)));
- // verify we canceled the timeout alarm.
- verify(mAlarmManager).cancel(mConnectionTimeoutAlarmListenerArgumentCaptor.getValue());
// Verify we disabled fw roaming.
verify(mClientModeManager).enableRoaming(false);
@@ -2073,8 +2017,6 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
// Verify that we sent the connection success callback.
verify(mNetworkRequestMatchCallback).onUserSelectionConnectSuccess(
argThat(new WifiConfigMatcher(mSelectedNetwork)));
- // verify we canceled the timeout alarm.
- verify(mAlarmManager).cancel(mConnectionTimeoutAlarmListenerArgumentCaptor.getValue());
// Verify we disabled fw roaming.
verify(mClientModeManager).enableRoaming(false);
verify(mWifiMetrics).incrementNetworkRequestApiNumConnectSuccessOnSecondaryIface();
@@ -2111,8 +2053,6 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
// Verify that we sent the connection success callback.
verify(mNetworkRequestMatchCallback).onUserSelectionConnectSuccess(
argThat(new WifiConfigMatcher(mSelectedNetwork)));
- // verify we canceled the timeout alarm.
- verify(mAlarmManager).cancel(mConnectionTimeoutAlarmListenerArgumentCaptor.getValue());
verify(mWifiMetrics).incrementNetworkRequestApiNumConnectSuccessOnPrimaryIface();
verify(mNetworkRequestMatchCallback, atLeastOnce()).asBinder();
@@ -2140,8 +2080,6 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
// verify that we did not send out the success callback and did not stop the alarm timeout.
verify(mNetworkRequestMatchCallback, never()).onUserSelectionConnectSuccess(any());
- verify(mAlarmManager, never())
- .cancel(mConnectionTimeoutAlarmListenerArgumentCaptor.getValue());
// Send network connection success to the correct network indication.
mWifiNetworkFactory.handleConnectionAttemptEnded(
@@ -2150,8 +2088,6 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
// Verify that we sent the connection success callback.
verify(mNetworkRequestMatchCallback).onUserSelectionConnectSuccess(
argThat(new WifiConfigMatcher(mSelectedNetwork)));
- // verify we canceled the timeout alarm.
- verify(mAlarmManager).cancel(mConnectionTimeoutAlarmListenerArgumentCaptor.getValue());
}
/**
@@ -2168,8 +2104,6 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
// verify that we did not send out the success callback and did not stop the alarm timeout.
verify(mNetworkRequestMatchCallback, never()).onUserSelectionConnectSuccess(any());
- verify(mAlarmManager, never())
- .cancel(mConnectionTimeoutAlarmListenerArgumentCaptor.getValue());
// Send network connection success to the correct network indication.
mWifiNetworkFactory.handleConnectionAttemptEnded(
@@ -2178,8 +2112,6 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
// Verify that we sent the connection success callback.
verify(mNetworkRequestMatchCallback).onUserSelectionConnectSuccess(
argThat(new WifiConfigMatcher(mSelectedNetwork)));
- // verify we canceled the timeout alarm.
- verify(mAlarmManager).cancel(mConnectionTimeoutAlarmListenerArgumentCaptor.getValue());
}
/**
@@ -2202,8 +2134,6 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
when(mWifiConfigManager.getConfiguredNetwork(wcmNetwork.getProfileKey()))
.thenReturn(wcmNetwork);
mWifiNetworkFactory.releaseNetworkFor(mNetworkRequest);
- // verify we canceled the timeout alarm.
- verify(mAlarmManager).cancel(mConnectionTimeoutAlarmListenerArgumentCaptor.getValue());
// Verify that we triggered a disconnect.
verify(mClientModeManager, times(2)).disconnect();
verify(mWifiConfigManager).removeNetwork(
@@ -2229,8 +2159,6 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
// Verify that we sent the connection success callback.
verify(mNetworkRequestMatchCallback).onUserSelectionConnectSuccess(
argThat(new WifiConfigMatcher(mSelectedNetwork)));
- // verify we canceled the timeout alarm.
- verify(mAlarmManager).cancel(mConnectionTimeoutAlarmListenerArgumentCaptor.getValue());
verify(mWifiMetrics).incrementNetworkRequestApiNumConnectSuccessOnPrimaryIface();
long connectionDurationMillis = 5665L;
@@ -2276,8 +2204,6 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
// Verify that we sent the connection success callback.
verify(mNetworkRequestMatchCallback).onUserSelectionConnectSuccess(
argThat(new WifiConfigMatcher(mSelectedNetwork)));
- // verify we canceled the timeout alarm.
- verify(mAlarmManager).cancel(mConnectionTimeoutAlarmListenerArgumentCaptor.getValue());
verify(mWifiMetrics).incrementNetworkRequestApiNumConnectSuccessOnSecondaryIface();
// Now release the network request.
@@ -2323,8 +2249,6 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
// Verify that we sent the connection success callback.
verify(mNetworkRequestMatchCallback).onUserSelectionConnectSuccess(
argThat(new WifiConfigMatcher(mSelectedNetwork)));
- // verify we canceled the timeout alarm.
- verify(mAlarmManager).cancel(mConnectionTimeoutAlarmListenerArgumentCaptor.getValue());
verify(mWifiMetrics).incrementNetworkRequestApiNumConnectSuccessOnSecondaryIface();
// Indicate secondary connection via CMI listener.
@@ -2607,7 +2531,6 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
verify(mWifiConnectivityManager, times(1)).setSpecificNetworkRequestInProgress(true);
verify(mWifiScanner, times(2)).getSingleScanResults();
verify(mWifiScanner, times(2)).startScan(any(), any(), any(), any());
- verify(mAlarmManager).cancel(mConnectionTimeoutAlarmListenerArgumentCaptor.getValue());
verify(mClientModeManager, times(3)).getRole();
// Remove the stale request1 & ensure nothing happens.
@@ -2637,8 +2560,6 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
assertNotNull(mSelectedNetwork);
mWifiNetworkFactory.handleConnectionAttemptEnded(
WifiMetrics.ConnectionEvent.FAILURE_NONE, mSelectedNetwork, TEST_BSSID_1, WifiMetricsProto.ConnectionEvent.FAILURE_REASON_UNKNOWN);
- // Cancel the connection timeout.
- verify(mAlarmManager).cancel(mConnectionTimeoutAlarmListenerArgumentCaptor.getValue());
verify(mClientModeManager).enableRoaming(false);
NetworkRequest oldRequest = new NetworkRequest(mNetworkRequest);
@@ -2687,8 +2608,6 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
assertNotNull(mSelectedNetwork);
mWifiNetworkFactory.handleConnectionAttemptEnded(
WifiMetrics.ConnectionEvent.FAILURE_NONE, mSelectedNetwork, TEST_BSSID_1, WifiMetricsProto.ConnectionEvent.FAILURE_REASON_UNKNOWN);
- // Cancel the connection timeout.
- verify(mAlarmManager).cancel(mConnectionTimeoutAlarmListenerArgumentCaptor.getValue());
clearInvocations(mWifiConnectivityManager, mWifiScanner, mClientModeManager, mAlarmManager);
@@ -2713,8 +2632,6 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
assertNotNull(mSelectedNetwork);
mWifiNetworkFactory.handleConnectionAttemptEnded(
WifiMetrics.ConnectionEvent.FAILURE_NONE, mSelectedNetwork, TEST_BSSID_1, WifiMetricsProto.ConnectionEvent.FAILURE_REASON_UNKNOWN);
- // Cancel the connection timeout.
- verify(mAlarmManager).cancel(mConnectionTimeoutAlarmListenerArgumentCaptor.getValue());
verify(mClientModeManager).enableRoaming(false);
// Send second request & we simulate the user selecting the request & connecting to it.
@@ -2726,8 +2643,6 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
mWifiNetworkFactory.handleConnectionAttemptEnded(
WifiMetrics.ConnectionEvent.FAILURE_NONE, mSelectedNetwork, TEST_BSSID_2, WifiMetricsProto.ConnectionEvent.FAILURE_REASON_UNKNOWN);
verify(mClientModeManager, times(2)).enableRoaming(false);
- // Cancel the connection timeout.
- verify(mAlarmManager).cancel(mConnectionTimeoutAlarmListenerArgumentCaptor.getValue());
// We shouldn't explicitly disconnect, the new connection attempt will implicitly disconnect
// from the connected network.
@@ -2769,8 +2684,6 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
assertNotNull(mSelectedNetwork);
mWifiNetworkFactory.handleConnectionAttemptEnded(
WifiMetrics.ConnectionEvent.FAILURE_NONE, mSelectedNetwork, TEST_BSSID_1, WifiMetricsProto.ConnectionEvent.FAILURE_REASON_UNKNOWN);
- // Cancel the connection timeout.
- verify(mAlarmManager).cancel(mConnectionTimeoutAlarmListenerArgumentCaptor.getValue());
// Send second request & we simulate the user rejecting the request.
reset(mNetworkRequestMatchCallback, mWifiScanner, mAlarmManager);
@@ -2923,7 +2836,6 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
mModeChangeCallbackCaptor.getValue().onActiveModeManagerRemoved(mClientModeManager);
mLooper.dispatchAll();
- verify(mAlarmManager).cancel(mConnectionTimeoutAlarmListenerArgumentCaptor.getValue());
verify(mNetworkRequestMatchCallback).onAbort();
verify(mWifiConnectivityManager).setSpecificNetworkRequestInProgress(false);
verify(mConnectivityManager).declareNetworkRequestUnfulfillable(eq(mNetworkRequest));
@@ -3430,6 +3342,7 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
WifiConfigurationTestUtil.createPskNetwork(), TEST_UID_1, TEST_PACKAGE_NAME_1,
new int[0]);
mWifiNetworkFactory.needNetworkFor(mNetworkRequest);
+ setScreenState(false);
// Verify we did not trigger the UI for the second request.
verify(mContext, never()).startActivityAsUser(any(), any());
@@ -3758,11 +3671,6 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
mConnectListenerArgumentCaptor.capture(), anyInt(), any(), any());
verify(mWifiMetrics, atLeastOnce()).incrementNetworkRequestApiNumConnectOnPrimaryIface();
- // Start the connection timeout alarm.
- mInOrder.verify(mAlarmManager).set(eq(AlarmManager.ELAPSED_REALTIME_WAKEUP),
- eq((long) WifiNetworkFactory.NETWORK_CONNECTION_TIMEOUT_MS), any(),
- mConnectionTimeoutAlarmListenerArgumentCaptor.capture(), any());
- assertNotNull(mConnectionTimeoutAlarmListenerArgumentCaptor.getValue());
assertTrue(mWifiNetworkFactory.shouldHaveInternetCapabilities());
}
@@ -3827,12 +3735,6 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
verify(mWifiMetrics, atLeastOnce())
.incrementNetworkRequestApiNumConnectOnSecondaryIface();
}
-
- // Start the connection timeout alarm.
- mInOrder.verify(mAlarmManager).set(eq(AlarmManager.ELAPSED_REALTIME_WAKEUP),
- eq((long) WifiNetworkFactory.NETWORK_CONNECTION_TIMEOUT_MS), any(),
- mConnectionTimeoutAlarmListenerArgumentCaptor.capture(), any());
- assertNotNull(mConnectionTimeoutAlarmListenerArgumentCaptor.getValue());
}
private void sendNetworkRequestAndSetupForUserSelection() throws RemoteException {
@@ -4055,27 +3957,15 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
}
}
- private void validateConnectionRetryAttempts(boolean onTimeout) {
- for (int i = 0; i < WifiNetworkFactory.USER_SELECTED_NETWORK_CONNECT_RETRY_MAX; i++) {
- if (!onTimeout) {
- // Cancel the existing connection timeout.
- mInOrder.verify(mAlarmManager).cancel(
- mConnectionTimeoutAlarmListenerArgumentCaptor.getValue());
- }
-
- // Trigger new connection.
- mInOrder.verify(mConnectHelper).connectToNetwork(
- eq(mClientModeManager),
- eq(new NetworkUpdateResult(TEST_NETWORK_ID_1)),
- mConnectListenerArgumentCaptor.capture(),
- anyInt(), any(), any());
-
- // Start the new connection timeout alarm.
- mInOrder.verify(mAlarmManager).set(eq(AlarmManager.ELAPSED_REALTIME_WAKEUP),
- eq((long) WifiNetworkFactory.NETWORK_CONNECTION_TIMEOUT_MS), any(),
- mConnectionTimeoutAlarmListenerArgumentCaptor.capture(), any());
- assertNotNull(mConnectionTimeoutAlarmListenerArgumentCaptor.getValue());
- }
+ private void validateConnectionRetryAttempts() {
+ // Trigger new connection.
+ mInOrder.verify(mConnectHelper,
+ times(WifiNetworkFactory.USER_SELECTED_NETWORK_CONNECT_RETRY_MAX + 1))
+ .connectToNetwork(
+ eq(mClientModeManager),
+ eq(new NetworkUpdateResult(TEST_NETWORK_ID_1)),
+ mConnectListenerArgumentCaptor.capture(),
+ anyInt(), any(), any());
}
private void validateScanSettings(@Nullable String hiddenSsid, int[] channels) {
diff --git a/service/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java b/service/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
index 97d11c99a5..0b6181aa89 100644
--- a/service/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
+++ b/service/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
@@ -1842,7 +1842,7 @@ public class WifiServiceImplTest extends WifiBaseTest {
public void testSetWifiApConfigurationNullConfigNotSaved() throws Exception {
when(mWifiPermissionsUtil.checkConfigOverridePermission(anyInt())).thenReturn(true);
assertFalse(mWifiServiceImpl.setWifiApConfiguration(null, TEST_PACKAGE_NAME));
- verify(mWifiApConfigStore, never()).setApConfiguration(isNull(SoftApConfiguration.class));
+ verify(mWifiApConfigStore, never()).setApConfiguration(isNull());
}
/**
@@ -1903,7 +1903,7 @@ public class WifiServiceImplTest extends WifiBaseTest {
public void testSetSoftApConfigurationNullConfigNotSaved() throws Exception {
when(mWifiPermissionsUtil.checkConfigOverridePermission(anyInt())).thenReturn(true);
assertFalse(mWifiServiceImpl.setSoftApConfiguration(null, TEST_PACKAGE_NAME));
- verify(mWifiApConfigStore, never()).setApConfiguration(isNull(SoftApConfiguration.class));
+ verify(mWifiApConfigStore, never()).setApConfiguration(isNull());
verify(mActiveModeWarden, never()).updateSoftApConfiguration(any());
verify(mWifiPermissionsUtil).checkConfigOverridePermission(anyInt());
}
diff --git a/service/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareStateManagerTest.java b/service/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareStateManagerTest.java
index 55f63e1513..a4ebf7b185 100644
--- a/service/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareStateManagerTest.java
+++ b/service/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareStateManagerTest.java
@@ -2971,7 +2971,7 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
null, messageId, 0);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).sendMessage(transactionId.capture(), eq(subscribeId),
- eq(requestorId), eq(peerMac), isNull(byte[].class), eq(messageId));
+ eq(requestorId), eq(peerMac), isNull(), eq(messageId));
short tid = transactionId.getValue();
mDut.onMessageSendQueuedSuccessResponse(tid);
mMockLooper.dispatchAll();
@@ -3873,6 +3873,7 @@ public class WifiAwareStateManagerTest extends WifiBaseTest {
validateCorrectAwareStatusChangeBroadcast(inOrder);
inOrder.verify(mMockNative).disable(transactionId.capture());
mDut.onDisableResponse(transactionId.getValue(), NanStatusCode.SUCCESS);
+ mDut.onAwareDownNotification(NanStatusCode.SUCCESS);
mMockLooper.dispatchAll();
assertFalse(mDut.isDeviceAttached());
collector.checkThat("usage disabled", mDut.isUsageEnabled(), equalTo(false));
diff --git a/service/tests/wifitests/src/com/android/server/wifi/hal/WifiRttControllerAidlImplTest.java b/service/tests/wifitests/src/com/android/server/wifi/hal/WifiRttControllerAidlImplTest.java
index d2be3f163c..16eec8465d 100644
--- a/service/tests/wifitests/src/com/android/server/wifi/hal/WifiRttControllerAidlImplTest.java
+++ b/service/tests/wifitests/src/com/android/server/wifi/hal/WifiRttControllerAidlImplTest.java
@@ -554,6 +554,84 @@ public class WifiRttControllerAidlImplTest extends WifiBaseTest {
equalTo(ScanResult.CHANNEL_WIDTH_80MHZ));
verifyNoMoreInteractions(mIWifiRttControllerMock);
}
+
+ /**
+ * Validate correct 11az NTB secure result conversion from HAL to framework.
+ */
+ @Test
+ public void test11azNtbSecureRangeResults() throws Exception {
+ int cmdId = 55;
+ RttResult[] results = new RttResult[1];
+ RttResult res = createRttResult();
+ res.type = RttType.TWO_SIDED_11AZ_NTB_SECURE;
+ res.addr = MacAddress.byteAddrFromStringAddr("05:06:07:08:09:0A");
+ res.ntbMaxMeasurementTime = 10; // 10 * 10000 us = 100000 us
+ res.ntbMinMeasurementTime = 100; // 100 * 100 us = 10000 us
+ res.numRxSpatialStreams = 2;
+ res.numTxSpatialStreams = 3;
+ res.i2rTxLtfRepetitionCount = 3;
+ res.r2iTxLtfRepetitionCount = 2;
+ res.status = RttStatus.SUCCESS;
+ res.distanceInMm = 1500;
+ res.timeStampInUs = 6000;
+ res.packetBw = RttBw.BW_80MHZ;
+ // Fill in secure ranging results
+ res.pasnComebackAfterMillis = 1000;
+ res.baseAkm = Akm.PASN | Akm.SAE;
+ res.isRangingFrameProtectionEnabled = true;
+ res.isSecureLtfEnabled = true;
+ res.secureHeLtfProtocolVersion = 1;
+ res.pasnComebackCookie = new byte[] {1, 2, 3};
+ results[0] = res;
+
+ // (1) have the HAL call us with results
+ mEventCallbackCaptor.getValue().onResults(cmdId, results);
+
+ // (2) verify call to framework
+ verify(mRangingResultsCallbackMock).onRangingResults(eq(cmdId), mRttResultCaptor.capture());
+
+ // verify contents of the framework results
+ List<RangingResult> rttR = mRttResultCaptor.getValue();
+
+ collector.checkThat("number of entries", rttR.size(), equalTo(1));
+
+ RangingResult rttResult = rttR.get(0);
+ collector.checkThat("Type", rttResult.is80211azNtbMeasurement(), equalTo(true));
+ collector.checkThat("status", rttResult.getStatus(),
+ equalTo(WifiRttController.FRAMEWORK_RTT_STATUS_SUCCESS));
+ collector.checkThat("mac", rttResult.getMacAddress().toByteArray(),
+ equalTo(MacAddress.fromString("05:06:07:08:09:0A").toByteArray()));
+ collector.checkThat("ntbMaxMeasurementTime",
+ rttResult.getMaxTimeBetweenNtbMeasurementsMicros(), equalTo(100000L));
+ collector.checkThat("ntbMinMeasurementTime",
+ rttResult.getMinTimeBetweenNtbMeasurementsMicros(), equalTo(10000L));
+ collector.checkThat("numRxSpatialStreams", rttResult.get80211azNumberOfRxSpatialStreams(),
+ equalTo(2));
+ collector.checkThat("numTxSpatialStreams", rttResult.get80211azNumberOfTxSpatialStreams(),
+ equalTo(3));
+ collector.checkThat("i2rTxLtfRepetitionCount",
+ rttResult.get80211azInitiatorTxLtfRepetitionsCount(), equalTo(3));
+ collector.checkThat("r2iTxLtfRepetitionCount",
+ rttResult.get80211azResponderTxLtfRepetitionsCount(), equalTo(2));
+ collector.checkThat("distanceCm", rttResult.getDistanceMm(), equalTo(1500));
+ collector.checkThat("timestamp", rttResult.getRangingTimestampMillis(), equalTo(6L));
+ collector.checkThat("channelBw", rttResult.getMeasurementBandwidth(),
+ equalTo(ScanResult.CHANNEL_WIDTH_80MHZ));
+ // check secure ranging parameters
+ collector.checkThat("pasnComebackAfterMillis", rttResult.getPasnComebackAfterMillis(),
+ equalTo(1000L));
+ collector.checkThat("baseAkm", rttResult.isRangingAuthenticated(), equalTo(true));
+ collector.checkThat("isRangingFrameProtectionEnabled", rttResult.isRangingFrameProtected(),
+ equalTo(true));
+ collector.checkThat("isSecureLtfEnabled", rttResult.isSecureHeLtfEnabled(), equalTo(true));
+ collector.checkThat("secureHeLtfProtocolVersion", rttResult.getSecureHeLtfProtocolVersion(),
+ equalTo(1));
+ collector.checkThat("pasnComebackCookie", rttResult.getPasnComebackCookie(),
+ equalTo(new byte[]{1, 2, 3}));
+ verifyNoMoreInteractions(mIWifiRttControllerMock);
+ }
+
+
/**
* Validate correct cleanup when a null array of results is provided by HAL.
*/
diff --git a/service/tests/wifitests/src/com/android/server/wifi/mainline_supplicant/MainlineSupplicantTest.java b/service/tests/wifitests/src/com/android/server/wifi/mainline_supplicant/MainlineSupplicantTest.java
index d1c25a5078..2312fc6c33 100644
--- a/service/tests/wifitests/src/com/android/server/wifi/mainline_supplicant/MainlineSupplicantTest.java
+++ b/service/tests/wifitests/src/com/android/server/wifi/mainline_supplicant/MainlineSupplicantTest.java
@@ -16,7 +16,9 @@
package com.android.server.wifi.mainline_supplicant;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeTrue;
import static org.mockito.ArgumentMatchers.anyInt;
@@ -27,6 +29,8 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import android.net.wifi.usd.PublishConfig;
+import android.net.wifi.usd.SubscribeConfig;
import android.net.wifi.util.Environment;
import android.os.Handler;
import android.os.IBinder;
@@ -48,6 +52,7 @@ import org.mockito.MockitoAnnotations;
*/
public class MainlineSupplicantTest {
private static final String IFACE_NAME = "wlan0";
+ private static final String USD_SERVICE_NAME = "usd_service";
private @Mock IMainlineSupplicant mIMainlineSupplicantMock;
private @Mock IBinder mIBinderMock;
@@ -176,4 +181,37 @@ public class MainlineSupplicantTest {
// Only the valid remove request should reach have reached the service
verify(mIMainlineSupplicantMock, times(1)).removeStaInterface(anyString());
}
+
+ private void verifyUsdBaseConfigDefaultValues(IStaInterface.UsdBaseConfig baseConfig) {
+ assertNotNull(baseConfig.serviceName);
+ assertNotNull(baseConfig.freqsMhz);
+ assertNotNull(baseConfig.serviceSpecificInfo);
+ assertNotNull(baseConfig.rxMatchFilter);
+ assertNotNull(baseConfig.txMatchFilter);
+ assertEquals(MainlineSupplicant.DEFAULT_USD_FREQ_MHZ, baseConfig.defaultFreqMhz);
+ }
+
+ /**
+ * Verify that the proper default values are assigned during the
+ * USD Publish Config conversion.
+ */
+ @Test
+ public void testUsdPublishConfigConversionDefaultValues() {
+ PublishConfig frameworkConfig = new PublishConfig.Builder(USD_SERVICE_NAME).build();
+ IStaInterface.UsdPublishConfig aidlConfig =
+ MainlineSupplicant.frameworkToHalUsdPublishConfig(frameworkConfig);
+ verifyUsdBaseConfigDefaultValues(aidlConfig.baseConfig);
+ }
+
+ /**
+ * Verify that the proper default values are assigned during the
+ * USD Subscribe Config conversion.
+ */
+ @Test
+ public void testUsdSubscribeConfigConversionDefaultValues() {
+ SubscribeConfig frameworkConfig = new SubscribeConfig.Builder(USD_SERVICE_NAME).build();
+ IStaInterface.UsdSubscribeConfig aidlConfig =
+ MainlineSupplicant.frameworkToHalUsdSubscribeConfig(frameworkConfig);
+ verifyUsdBaseConfigDefaultValues(aidlConfig.baseConfig);
+ }
}
diff --git a/service/tests/wifitests/src/com/android/server/wifi/rtt/RttServiceImplTest.java b/service/tests/wifitests/src/com/android/server/wifi/rtt/RttServiceImplTest.java
index cc570c77c7..e63c67512f 100644
--- a/service/tests/wifitests/src/com/android/server/wifi/rtt/RttServiceImplTest.java
+++ b/service/tests/wifitests/src/com/android/server/wifi/rtt/RttServiceImplTest.java
@@ -23,10 +23,12 @@ import static android.net.wifi.rtt.WifiRttManager.CHARACTERISTICS_KEY_BOOLEAN_ON
import static com.android.server.wifi.WifiSettingsConfigStore.WIFI_VERBOSE_LOGGING_ENABLED;
import static com.android.server.wifi.rtt.RttTestUtils.compareListContentsNoOrdering;
+import static com.android.server.wifi.rtt.RttTestUtils.getDummyRangingResults;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeTrue;
import static org.mockito.ArgumentMatchers.any;
@@ -55,7 +57,9 @@ import android.content.Intent;
import android.content.pm.PackageManager;
import android.location.LocationManager;
import android.net.MacAddress;
+import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
+import android.net.wifi.WifiSsid;
import android.net.wifi.aware.IWifiAwareMacAddressProvider;
import android.net.wifi.aware.MacAddrMapping;
import android.net.wifi.aware.PeerHandle;
@@ -84,7 +88,9 @@ import com.android.modules.utils.build.SdkLevel;
import com.android.server.wifi.Clock;
import com.android.server.wifi.HalDeviceManager;
import com.android.server.wifi.MockResources;
+import com.android.server.wifi.SsidTranslator;
import com.android.server.wifi.WifiBaseTest;
+import com.android.server.wifi.WifiConfigManager;
import com.android.server.wifi.WifiSettingsConfigStore;
import com.android.server.wifi.hal.WifiRttController;
import com.android.server.wifi.proto.nano.WifiMetricsProto;
@@ -178,6 +184,11 @@ public class RttServiceImplTest extends WifiBaseTest {
@Mock
WifiSettingsConfigStore mWifiSettingsConfigStore;
+ @Mock
+ WifiConfigManager mWifiConfigManager;
+ WifiConfiguration mWifiConfiguration = new WifiConfiguration();
+ @Mock
+ SsidTranslator mSsidTranslator;
/**
* Using instead of spy to avoid native crash failures - possibly due to
@@ -248,7 +259,8 @@ public class RttServiceImplTest extends WifiBaseTest {
doAnswer(mBinderUnlinkToDeathCounter).when(mockIbinder).unlinkToDeath(any(), anyInt());
mDut.start(mMockLooper.getLooper(), mockClock, mockAwareManager, mockMetrics,
- mockPermissionUtil, mWifiSettingsConfigStore, mockHalDeviceManager);
+ mockPermissionUtil, mWifiSettingsConfigStore, mockHalDeviceManager,
+ mWifiConfigManager, mSsidTranslator);
mMockLooper.dispatchAll();
ArgumentCaptor<BroadcastReceiver> bcastRxCaptor = ArgumentCaptor.forClass(
BroadcastReceiver.class);
@@ -371,6 +383,59 @@ public class RttServiceImplTest extends WifiBaseTest {
}
/**
+ * Validate a successful secure ranging flow.
+ */
+ @Test
+ public void testSecureRanging() throws RemoteException {
+ RangingRequest request = RttTestUtils.getDummySecureRangingRequest(
+ RangingRequest.SECURITY_MODE_OPPORTUNISTIC);
+ mWifiConfiguration.preSharedKey = "TEST_PASSWORD";
+ WifiSsid ssid = request.mRttPeers.get(
+ 1).getSecureRangingConfig().getPasnConfig().getWifiSsid();
+ when(mWifiConfigManager.getConfiguredNetworkWithPassword(eq(ssid),
+ eq(WifiConfiguration.SECURITY_TYPE_SAE))).thenReturn(mWifiConfiguration);
+ when(mSsidTranslator.getTranslatedSsid(eq(ssid))).thenReturn(ssid);
+
+ // Make sure the second peer is configured with no password for SAE.
+ assertNull(request.mRttPeers.get(1).getSecureRangingConfig().getPasnConfig().getPassword());
+
+ ClockAnswer clock = new ClockAnswer();
+ doAnswer(clock).when(mockClock).getWallClockMillis();
+ clock.time = 100;
+ mDut.startRanging(mockIbinder, mPackageName, mFeatureId, null, request, mockCallback,
+ mExtras);
+ mMockLooper.dispatchAll();
+ verify(mockRttControllerHal).rangeRequest(mIntCaptor.capture(), mRequestCaptor.capture());
+ verifyWakeupSet(false, 0);
+ RangingRequest halRequest = mRequestCaptor.getValue();
+ assertNotEquals("Request to WifiRttController is not null", null, halRequest);
+ assertEquals("Size of request", request.mRttPeers.size(), halRequest.mRttPeers.size());
+
+ for (int i = 0; i < request.mRttPeers.size(); ++i) {
+ assertEquals("SecureRangingConfig is not same",
+ request.mRttPeers.get(i).getSecureRangingConfig(),
+ halRequest.mRttPeers.get(i).getSecureRangingConfig());
+ }
+
+ // Make sure password is set for second peer from WifiConfiguration for the SAE.
+ assertEquals("Password is not set", "TEST_PASSWORD", halRequest.mRttPeers.get(
+ 1).getSecureRangingConfig().getPasnConfig().getPassword());
+
+ // Verify ranging results are processed correctly
+ Pair<List<RangingResult>, List<RangingResult>> resultsPair = getDummyRangingResults(
+ halRequest);
+ mRangingResultsCbCaptor.getValue().onRangingResults(mIntCaptor.getValue(),
+ resultsPair.first);
+ mMockLooper.dispatchAll();
+ verify(mockCallback).onRangingResults(mListCaptor.capture());
+ assertTrue(compareListContentsNoOrdering(resultsPair.second, mListCaptor.getValue()));
+
+ verifyWakeupCancelled();
+ verifyNoMoreInteractions(mockRttControllerHal, mockCallback,
+ mAlarmManager.getAlarmManager());
+ }
+
+ /**
* Validate a successful ranging flow with PeerHandles (i.e. verify translations)
*/
@Test
diff --git a/service/tests/wifitests/src/com/android/server/wifi/rtt/RttTestUtils.java b/service/tests/wifitests/src/com/android/server/wifi/rtt/RttTestUtils.java
index d7e8afbf40..d19f79b851 100644
--- a/service/tests/wifitests/src/com/android/server/wifi/rtt/RttTestUtils.java
+++ b/service/tests/wifitests/src/com/android/server/wifi/rtt/RttTestUtils.java
@@ -114,6 +114,7 @@ public class RttTestUtils {
// SAE with no password configured
pasnConfig = new PasnConfig
.Builder(PasnConfig.AKM_SAE, PasnConfig.CIPHER_GCMP_256)
+ .setWifiSsid(WifiSsid.fromString("\"TEST_SSID\""))
.build();
secureRangingConfig = new SecureRangingConfig
.Builder(pasnConfig)
@@ -121,7 +122,7 @@ public class RttTestUtils {
.setSecureHeLtfEnabled(true)
.build();
config = new ResponderConfig.Builder()
- .setMacAddress(MacAddress.fromString("00:11:22:33:44:55"))
+ .setMacAddress(MacAddress.fromString("00:11:22:33:44:56"))
.setResponderType(ResponderConfig.RESPONDER_AP)
.setChannelWidth(ScanResult.CHANNEL_WIDTH_80MHZ)
.setPreamble(ScanResult.PREAMBLE_HE)
@@ -139,7 +140,7 @@ public class RttTestUtils {
.build();
config = new ResponderConfig
.Builder()
- .setMacAddress(MacAddress.fromString("00:11:22:33:44:56"))
+ .setMacAddress(MacAddress.fromString("00:11:22:33:44:57"))
.setResponderType(ResponderConfig.RESPONDER_AP)
.setChannelWidth(ScanResult.CHANNEL_WIDTH_80MHZ)
.setPreamble(ScanResult.PREAMBLE_HE)
@@ -151,7 +152,7 @@ public class RttTestUtils {
// Open mode
config = new ResponderConfig
.Builder()
- .setMacAddress(MacAddress.fromString("00:11:22:33:44:57"))
+ .setMacAddress(MacAddress.fromString("00:11:22:33:44:58"))
.setResponderType(ResponderConfig.RESPONDER_AP)
.setChannelWidth(ScanResult.CHANNEL_WIDTH_80MHZ)
.setPreamble(ScanResult.PREAMBLE_HE)
@@ -269,19 +270,6 @@ public class RttTestUtils {
if (request != null) {
for (ResponderConfig peer : request.mRttPeers) {
- halResults.add(new RangingResult.Builder()
- .setStatus(RangingResult.STATUS_SUCCESS)
- .setMacAddress(peer.getMacAddress())
- .setDistanceMm(rangeCmBase)
- .setDistanceStdDevMm(rangeStdDevCmBase)
- .setRssi(rssiBase)
- .setNumAttemptedMeasurements(8)
- .setNumSuccessfulMeasurements(5)
- .setRangingTimestampMillis(rangeTimestampBase)
- .set80211mcMeasurement(true)
- .setMeasurementChannelFrequencyMHz(5180)
- .setMeasurementBandwidth(ScanResult.CHANNEL_WIDTH_40MHZ)
- .build());
RangingResult.Builder builder = new RangingResult.Builder()
.setStatus(RangingResult.STATUS_SUCCESS)
.setDistanceMm(rangeCmBase++)
@@ -293,13 +281,24 @@ public class RttTestUtils {
.set80211mcMeasurement(true)
.setMeasurementChannelFrequencyMHz(5180)
.setMeasurementBandwidth(ScanResult.CHANNEL_WIDTH_40MHZ);
+ if (peer.getSecureRangingConfig() != null) {
+ builder.setRangingAuthenticated(true);
+ builder.setRangingFrameProtected(true);
+ builder.setSecureHeLtfEnabled(true);
+ builder.setSecureHeLtfProtocolVersion(1);
+ }
+ halResults.add(builder.setMacAddress(peer.getMacAddress()).build());
if (peer.peerHandle == null) {
builder.setMacAddress(peer.getMacAddress());
} else {
+ // Make sure MAC address null when peer handle is set.
+ builder.setMacAddress(null);
builder.setPeerHandle(peer.peerHandle);
}
- RangingResult rangingResult = builder.build();
- results.add(rangingResult);
+ results.add(builder.build());
+ rangeCmBase++;
+ rangeStdDevCmBase++;
+ rssiBase++;
}
} else {
results.add(new RangingResult.Builder()
diff --git a/service/tests/wifitests/src/com/android/server/wifi/scanner/WificondScannerTest.java b/service/tests/wifitests/src/com/android/server/wifi/scanner/WificondScannerTest.java
index b037b168ee..18eb867784 100644
--- a/service/tests/wifitests/src/com/android/server/wifi/scanner/WificondScannerTest.java
+++ b/service/tests/wifitests/src/com/android/server/wifi/scanner/WificondScannerTest.java
@@ -141,12 +141,9 @@ public class WificondScannerTest extends BaseWifiScannerImplTest {
public void externalScanResultsDoNotCauseSpuriousTimerCancellationOrCrash() {
mWifiMonitor.sendMessage(IFACE_NAME, WifiMonitor.SCAN_RESULTS_EVENT);
mLooper.dispatchAll();
- verify(mAlarmManager.getAlarmManager(), never()).cancel(any(PendingIntent.class));
+ verify(mAlarmManager.getAlarmManager(), never()).cancel(nullable(PendingIntent.class));
verify(mAlarmManager.getAlarmManager(), never())
- .cancel(any(AlarmManager.OnAlarmListener.class));
- verify(mAlarmManager.getAlarmManager(), never()).cancel(isNull(PendingIntent.class));
- verify(mAlarmManager.getAlarmManager(), never())
- .cancel(isNull(AlarmManager.OnAlarmListener.class));
+ .cancel(nullable(AlarmManager.OnAlarmListener.class));
}
@Test
@@ -166,12 +163,11 @@ public class WificondScannerTest extends BaseWifiScannerImplTest {
mWifiMonitor.sendMessage(IFACE_NAME, WifiMonitor.SCAN_RESULTS_EVENT);
mLooper.dispatchAll();
- verify(mAlarmManager.getAlarmManager(), never()).cancel(any(PendingIntent.class));
+ verify(mAlarmManager.getAlarmManager(), never()).cancel(nullable(PendingIntent.class));
verify(mAlarmManager.getAlarmManager(), times(1))
.cancel(any(AlarmManager.OnAlarmListener.class));
- verify(mAlarmManager.getAlarmManager(), never()).cancel(isNull(PendingIntent.class));
verify(mAlarmManager.getAlarmManager(), never())
- .cancel(isNull(AlarmManager.OnAlarmListener.class));
+ .cancel((AlarmManager.OnAlarmListener)isNull());
}
@Test
@@ -198,12 +194,9 @@ public class WificondScannerTest extends BaseWifiScannerImplTest {
mWifiMonitor.sendMessage(IFACE_NAME, WifiMonitor.SCAN_RESULTS_EVENT);
mLooper.dispatchAll();
- verify(mAlarmManager.getAlarmManager(), never()).cancel(any(PendingIntent.class));
- verify(mAlarmManager.getAlarmManager(), never())
- .cancel(any(AlarmManager.OnAlarmListener.class));
- verify(mAlarmManager.getAlarmManager(), never()).cancel(isNull(PendingIntent.class));
+ verify(mAlarmManager.getAlarmManager(), never()).cancel(nullable(PendingIntent.class));
verify(mAlarmManager.getAlarmManager(), never())
- .cancel(isNull(AlarmManager.OnAlarmListener.class));
+ .cancel(nullable(AlarmManager.OnAlarmListener.class));
}
/**
diff --git a/service/tests/wifitests/src/com/android/server/wifi/util/InformationElementUtilTest.java b/service/tests/wifitests/src/com/android/server/wifi/util/InformationElementUtilTest.java
index eb9083acd3..0c6dfe15ce 100644
--- a/service/tests/wifitests/src/com/android/server/wifi/util/InformationElementUtilTest.java
+++ b/service/tests/wifitests/src/com/android/server/wifi/util/InformationElementUtilTest.java
@@ -515,7 +515,7 @@ public class InformationElementUtilTest extends WifiBaseTest {
(byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x0F,
(byte) 0xAC, (byte) 0x02, (byte) 0x00, (byte) 0x00 };
verifyCapabilityStringFromIeWithoutOweSupported(ie,
- "[WPA2-PSK-CCMP+TKIP][RSN-PSK-CCMP+TKIP]");
+ "[WPA2-PSK-CCMP-128+TKIP][RSN-PSK-CCMP-128+TKIP]");
}
/**
@@ -537,7 +537,7 @@ public class InformationElementUtilTest extends WifiBaseTest {
(byte) 0x00, (byte) 0x00 // RSN capabilities
};
verifyCapabilityStringFromIeWithoutOweSupported(ie,
- "[RSN-?-CCMP+TKIP]");
+ "[RSN-?-CCMP-128+TKIP]");
}
/**
@@ -576,7 +576,7 @@ public class InformationElementUtilTest extends WifiBaseTest {
(byte) 0x00, (byte) 0x0F, (byte) 0xAC, (byte) 0x0c,
};
verifyCapabilityStringFromIeWithoutOweSupported(ie,
- "[WPA2-EAP/SHA1-CCMP+TKIP][RSN-EAP/SHA1-CCMP+TKIP][MFPR]");
+ "[WPA2-EAP/SHA1-CCMP-128+TKIP][RSN-EAP/SHA1-CCMP-128+TKIP][MFPR]");
}
/**
@@ -608,8 +608,8 @@ public class InformationElementUtilTest extends WifiBaseTest {
(byte) 0x00, (byte) 0x0F, (byte) 0xAC, (byte) 0x0c,
};
verifyCapabilityStringFromIeWithoutOweSupported(ie,
- "[WPA2-EAP/SHA256-CCMP]"
- + "[RSN-EAP/SHA256-CCMP][MFPR][MFPC]");
+ "[WPA2-EAP/SHA256-CCMP-128]"
+ + "[RSN-EAP/SHA256-CCMP-128][MFPR][MFPC]");
}
/**
@@ -637,8 +637,8 @@ public class InformationElementUtilTest extends WifiBaseTest {
(byte) 0xc0, (byte) 0x00,
};
verifyCapabilityStringFromIeWithoutOweSupported(ie,
- "[WPA2-EAP/SHA256-CCMP]"
- + "[RSN-EAP/SHA256-CCMP][MFPR][MFPC]");
+ "[WPA2-EAP/SHA256-CCMP-128]"
+ + "[RSN-EAP/SHA256-CCMP-128][MFPR][MFPC]");
}
/**
@@ -672,8 +672,8 @@ public class InformationElementUtilTest extends WifiBaseTest {
(byte) 0x00, (byte) 0x0F, (byte) 0xAC, (byte) 0x0c,
};
verifyCapabilityStringFromIeWithoutOweSupported(ie,
- "[WPA2-EAP/SHA1+EAP/SHA256-CCMP]"
- + "[RSN-EAP/SHA1+EAP/SHA256-CCMP][MFPC]");
+ "[WPA2-EAP/SHA1+EAP/SHA256-CCMP-128]"
+ + "[RSN-EAP/SHA1+EAP/SHA256-CCMP-128][MFPC]");
}
/**
@@ -703,7 +703,7 @@ public class InformationElementUtilTest extends WifiBaseTest {
(byte) 0x40, (byte) 0x00,
};
verifyCapabilityStringFromIeWithoutOweSupported(ie,
- "[WPA2-EAP/SHA1-CCMP+TKIP][RSN-EAP/SHA1-CCMP+TKIP][MFPR]");
+ "[WPA2-EAP/SHA1-CCMP-128+TKIP][RSN-EAP/SHA1-CCMP-128+TKIP][MFPR]");
}
/**
@@ -736,7 +736,7 @@ public class InformationElementUtilTest extends WifiBaseTest {
(byte) 0x00, (byte) 0x50, (byte) 0xF2, (byte) 0x02,
(byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x50,
(byte) 0xF2, (byte) 0x02, (byte) 0x00, (byte) 0x00 };
- verifyCapabilityStringFromIeWithoutOweSupported(ie, "[WPA-PSK-CCMP+TKIP]");
+ verifyCapabilityStringFromIeWithoutOweSupported(ie, "[WPA-PSK-CCMP-128+TKIP]");
}
/**
@@ -757,7 +757,7 @@ public class InformationElementUtilTest extends WifiBaseTest {
(byte) 0x01, (byte) 0x00, // AKM count
(byte) 0x00, (byte) 0x50, (byte) 0x99, (byte) 0x99, // Unknown AKM
(byte) 0x00, (byte) 0x00};
- verifyCapabilityStringFromIeWithoutOweSupported(ie, "[WPA-?-CCMP+TKIP]");
+ verifyCapabilityStringFromIeWithoutOweSupported(ie, "[WPA-?-CCMP-128+TKIP]");
}
/**
@@ -805,7 +805,7 @@ public class InformationElementUtilTest extends WifiBaseTest {
0x1 << 4,
false,
false,
- "[WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][RSN-PSK-CCMP+TKIP]",
+ "[WPA-PSK-CCMP-128+TKIP][WPA2-PSK-CCMP-128+TKIP][RSN-PSK-CCMP-128+TKIP]",
null);
}
@@ -835,7 +835,7 @@ public class InformationElementUtilTest extends WifiBaseTest {
// Padding
(byte) 0x00, (byte) 0x00 };
verifyCapabilityStringFromIeWithOweSupported(
- ieRsn, "[WPA2-PSK-CCMP][RSN-PSK+SAE-CCMP]", null);
+ ieRsn, "[WPA2-PSK-CCMP-128][RSN-PSK+SAE-CCMP-128]", null);
}
/**
@@ -863,7 +863,7 @@ public class InformationElementUtilTest extends WifiBaseTest {
(byte) 0x00, (byte) 0x0F, (byte) 0xAC, (byte) 0x09,
// Padding
(byte) 0x00, (byte) 0x00 };
- verifyCapabilityStringFromIeWithOweSupported(ieRsn, "[RSN-SAE+FT/SAE-CCMP]", null);
+ verifyCapabilityStringFromIeWithOweSupported(ieRsn, "[RSN-SAE+FT/SAE-CCMP-128]", null);
}
/**
@@ -891,7 +891,7 @@ public class InformationElementUtilTest extends WifiBaseTest {
(byte) 0x00, (byte) 0x0F, (byte) 0xAC, (byte) 0x18,
// Padding
(byte) 0x00, (byte) 0x00 };
- verifyCapabilityStringFromIeWithOweSupported(ieRsn, "[RSN-SAE+SAE_EXT_KEY-CCMP]", null);
+ verifyCapabilityStringFromIeWithOweSupported(ieRsn, "[RSN-SAE+SAE_EXT_KEY-CCMP-128]", null);
}
/**
@@ -921,7 +921,7 @@ public class InformationElementUtilTest extends WifiBaseTest {
// Padding
(byte) 0x00, (byte) 0x00 };
verifyCapabilityStringFromIeWithOweSupported(
- ieRsn, "[RSN-SAE_EXT_KEY+FT/SAE_EXT_KEY-CCMP]", null);
+ ieRsn, "[RSN-SAE_EXT_KEY+FT/SAE_EXT_KEY-CCMP-128]", null);
}
/**
@@ -947,7 +947,7 @@ public class InformationElementUtilTest extends WifiBaseTest {
(byte) 0x00, (byte) 0x0F, (byte) 0xAC, (byte) 0x12,
// Padding
(byte) 0x00, (byte) 0x00 };
- verifyCapabilityStringFromIeWithOweSupported(ieRsn, "[RSN-OWE-CCMP]", null);
+ verifyCapabilityStringFromIeWithOweSupported(ieRsn, "[RSN-OWE-CCMP-128]", null);
}
/**
@@ -963,7 +963,8 @@ public class InformationElementUtilTest extends WifiBaseTest {
(byte) 0x50, (byte) 0x6F, (byte) 0x9A, (byte) 0x1C,
// OWE IE contains BSSID, SSID and channel of other BSS, but we don't parse it.
(byte) 0x00, (byte) 0x000, (byte) 0x00, (byte) 0x00 };
- verifyCapabilityStringFromIe(ieOwe, 0x1 << 0, true, "[RSN-OWE_TRANSITION-CCMP][ESS]", null);
+ verifyCapabilityStringFromIe(ieOwe, 0x1 << 0, true, "[RSN-OWE_TRANSITION-CCMP-128][ESS]",
+ null);
}
/**
@@ -1015,6 +1016,38 @@ public class InformationElementUtilTest extends WifiBaseTest {
}
/**
+ * Test Capabilities.generateCapabilitiesString() with RSN IE, GCMP-128 and SUITE_B_192.
+ * Expect the function to return a string with the proper security information.
+ */
+ @Test
+ public void buildCapabilities_rsnSuiteB192ElementWithGcmp128() {
+ InformationElement ieRsn = new InformationElement();
+ ieRsn.id = InformationElement.EID_RSN;
+ ieRsn.bytes = new byte[] {
+ // RSNE Version (0x0001)
+ (byte) 0x01, (byte) 0x00,
+ // Group cipher suite: GCMP-128
+ (byte) 0x00, (byte) 0x0F, (byte) 0xAC, (byte) 0x09,
+ // Number of cipher suites (1)
+ (byte) 0x01, (byte) 0x00,
+ // Cipher suite: GCMP-256
+ (byte) 0x00, (byte) 0x0F, (byte) 0xAC, (byte) 0x08,
+ // Number of AKMs (1)
+ (byte) 0x01, (byte) 0x00,
+ // SUITE_B_192 AKM
+ (byte) 0x00, (byte) 0x0F, (byte) 0xAC, (byte) 0x0C,
+ // RSN capabilities
+ (byte) 0x40, (byte) 0x00,
+ // PMKID count
+ (byte) 0x00, (byte) 0x00,
+ // Group mgmt cipher suite: BIP_GMAC_256
+ (byte) 0x00, (byte) 0x0F, (byte) 0xAC, (byte) 0x0c,
+ };
+ verifyCapabilityStringFromIeWithoutOweSupported(ieRsn,
+ "[RSN-EAP_SUITE_B_192-GCMP-128][MFPR]");
+ }
+
+ /**
* Test Capabilities.generateCapabilitiesString() with RSN IE,
* CCMP and FILS SHA256. Expect the function to return a string
* with the proper security information.
@@ -1044,8 +1077,8 @@ public class InformationElementUtilTest extends WifiBaseTest {
(byte) 0x00, (byte) 0x00 };
verifyCapabilityStringFromIeWithOweSupported(
ieRsn,
- "[WPA2-EAP/SHA1+EAP/SHA256+EAP-FILS-SHA256-CCMP]"
- + "[RSN-EAP/SHA1+EAP/SHA256+EAP-FILS-SHA256-CCMP]",
+ "[WPA2-EAP/SHA1+EAP/SHA256+EAP-FILS-SHA256-CCMP-128]"
+ + "[RSN-EAP/SHA1+EAP/SHA256+EAP-FILS-SHA256-CCMP-128]",
null);
}
@@ -1079,8 +1112,8 @@ public class InformationElementUtilTest extends WifiBaseTest {
(byte) 0x00, (byte) 0x00 };
verifyCapabilityStringFromIeWithOweSupported(
ieRsn,
- "[WPA2-EAP/SHA1+EAP/SHA256+EAP-FILS-SHA384-CCMP]"
- + "[RSN-EAP/SHA1+EAP/SHA256+EAP-FILS-SHA384-CCMP]",
+ "[WPA2-EAP/SHA1+EAP/SHA256+EAP-FILS-SHA384-CCMP-128]"
+ + "[RSN-EAP/SHA1+EAP/SHA256+EAP-FILS-SHA384-CCMP-128]",
null);
}
@@ -1130,7 +1163,7 @@ public class InformationElementUtilTest extends WifiBaseTest {
(byte) 0x00
};
verifyCapabilityStringFromIeWithOweSupported(
- ieRsn, "[RSN-SAE_EXT_KEY-CCMP]", unknownAkmMap);
+ ieRsn, "[RSN-SAE_EXT_KEY-CCMP-128]", unknownAkmMap);
}
/**
@@ -1212,7 +1245,8 @@ public class InformationElementUtilTest extends WifiBaseTest {
0x1 << 4,
true,
true,
- "[WPA2-PSK-CCMP][RSN-PSK-CCMP][RSN-SAE-CCMP][RSN-SAE_EXT_KEY-GCMP-256][MFPC][RSNO]",
+ "[WPA2-PSK-CCMP-128][RSN-PSK-CCMP-128][RSN-SAE-CCMP-128][RSN-SAE_EXT_KEY-GCMP-256"
+ + "][MFPC][RSNO]",
null);
}
@@ -1274,7 +1308,7 @@ public class InformationElementUtilTest extends WifiBaseTest {
0x1 << 4,
true,
true,
- "[RSN-SAE-CCMP][RSN-SAE_EXT_KEY-GCMP-256][MFPR][MFPC][RSNO]",
+ "[RSN-SAE-CCMP-128][RSN-SAE_EXT_KEY-GCMP-256][MFPR][MFPC][RSNO]",
null);
}
@@ -1333,7 +1367,7 @@ public class InformationElementUtilTest extends WifiBaseTest {
0x1 << 4,
true,
false,
- "[WPA2-PSK-CCMP][RSN-PSK-CCMP]",
+ "[WPA2-PSK-CCMP-128][RSN-PSK-CCMP-128]",
null);
}
@@ -1380,7 +1414,7 @@ public class InformationElementUtilTest extends WifiBaseTest {
ieWps.bytes = new byte[] { (byte) 0x00, (byte) 0x50, (byte) 0xF2, (byte) 0x04 };
InformationElement[] ies = new InformationElement[] { ieWpa, ieWps };
- verifyCapabilityStringFromIes(ies, 0x1 << 4, false, false, "[WPA-PSK-CCMP+TKIP][WPS]",
+ verifyCapabilityStringFromIes(ies, 0x1 << 4, false, false, "[WPA-PSK-CCMP-128+TKIP][WPS]",
null);
}
@@ -2861,7 +2895,37 @@ public class InformationElementUtilTest extends WifiBaseTest {
(byte) 0x40, (byte) 0x00,
};
verifyCapabilityStringFromIeWithoutOweSupported(ie,
- "[RSN-PASN+SAE-CCMP+GCMP-256][MFPR]");
+ "[RSN-PASN+SAE-CCMP-128+GCMP-256][MFPR]");
+ }
+
+ /**
+ * Test Capabilities.generateCapabilitiesString() with a RSN IE.
+ * Expect the function to return a string with the proper security information.
+ */
+ @Test
+ public void buildCapabilities_rsnElementWithPasnSaeAndCcmp256() {
+ InformationElement ie = new InformationElement();
+ ie.id = InformationElement.EID_RSN;
+ ie.bytes = new byte[] {
+ // Version
+ (byte) 0x01, (byte) 0x00,
+ // Group cipher suite: TKIP
+ (byte) 0x00, (byte) 0x0F, (byte) 0xAC, (byte) 0x02,
+ // Pairwise cipher count
+ (byte) 0x01, (byte) 0x00,
+ // Pairwise cipher suite: CCMP-256
+ (byte) 0x00, (byte) 0x0F, (byte) 0xAC, (byte) 0x0A,
+ // AKM count
+ (byte) 0x02, (byte) 0x00,
+ // AMK suite: PASN
+ (byte) 0x00, (byte) 0x0F, (byte) 0xAC, (byte) 0x15,
+ // AKM suite: SAE
+ (byte) 0x00, (byte) 0x0F, (byte) 0xAC, (byte) 0x08,
+ // RSN capabilities
+ (byte) 0x40, (byte) 0x00,
+ };
+ verifyCapabilityStringFromIeWithoutOweSupported(ie,
+ "[RSN-PASN+SAE-CCMP-256][MFPR]");
}
/**
diff --git a/tests/hostsidetests/multidevices/test/Android.bp b/tests/hostsidetests/multidevices/test/Android.bp
index 2adbfb5739..3d3ef73ee5 100644
--- a/tests/hostsidetests/multidevices/test/Android.bp
+++ b/tests/hostsidetests/multidevices/test/Android.bp
@@ -118,14 +118,14 @@ python_test_host {
}
python_test_host {
- name: "CtsWifiDirectTests",
- main: "direct/cts_wifi_direct_test_suite.py",
+ name: "WifiDirectTests",
+ main: "direct/wifi_direct_test_suite.py",
srcs: [
"direct/group_owner_negotiation_test.py",
"direct/group_owner_test.py",
"direct/group_owner_with_config_test.py",
"direct/service_discovery_test.py",
- "direct/cts_wifi_direct_test_suite.py",
+ "direct/wifi_direct_test_suite.py",
],
test_config: "direct/AndroidTest.xml",
libs: [
@@ -142,7 +142,6 @@ python_test_host {
},
test_suites: [
"general-tests",
- "cts-v-host",
],
}
diff --git a/tests/hostsidetests/multidevices/test/aware/AndroidTestNew.xml b/tests/hostsidetests/multidevices/test/aware/AndroidTestNew.xml
index 244257efec..69de107885 100644
--- a/tests/hostsidetests/multidevices/test/aware/AndroidTestNew.xml
+++ b/tests/hostsidetests/multidevices/test/aware/AndroidTestNew.xml
@@ -21,18 +21,12 @@
<target_preparer class="AndroidDeviceFeaturesCheckDecorator">
<option name="required_feature" value="android.hardware.wifi.aware" />
</target_preparer>
- <target_preparer class="AndroidMainlineModulesCheckDecorator">
- <option name="mainline_module_package_name" value="com.google.android.wifi" />
- </target_preparer>
<target_preparer class="AndroidInstallAppsDecorator" />
</device>
<device name="AndroidDevice">
<target_preparer class="AndroidDeviceFeaturesCheckDecorator">
<option name="required_feature" value="android.hardware.wifi.aware" />
</target_preparer>
- <target_preparer class="AndroidMainlineModulesCheckDecorator">
- <option name="mainline_module_package_name" value="com.google.android.wifi" />
- </target_preparer>
<target_preparer class="AndroidInstallAppsDecorator" />
</device>
diff --git a/tests/hostsidetests/multidevices/test/aware/wifi_aware_discovery_ranging_test.py b/tests/hostsidetests/multidevices/test/aware/wifi_aware_discovery_ranging_test.py
index 6e9a7b77d5..6951f36e5b 100644
--- a/tests/hostsidetests/multidevices/test/aware/wifi_aware_discovery_ranging_test.py
+++ b/tests/hostsidetests/multidevices/test/aware/wifi_aware_discovery_ranging_test.py
@@ -92,12 +92,16 @@ class WifiAwareDiscoveryRangingTest(base_test.BaseTestClass):
self.publisher = self.ads[0]
self.subscriber = self.ads[1]
- def setup_device(device: android_device.AndroidDevice):
- device.load_snippet('wifi', _SNIPPET_PACKAGE_NAME)
- device.wifi.wifiEnable()
- wifi_test_utils.set_screen_on_and_unlock(device)
- wifi_test_utils.enable_wifi_verbose_logging(device)
- # Device capability check
+ # Device setup
+ utils.concurrent_exec(
+ self._setup_device,
+ ((self.publisher,), (self.subscriber,)),
+ max_workers=2,
+ raise_on_exception=True,
+ )
+
+ # Device capability check
+ for device in [self.publisher, self.subscriber]:
asserts.abort_class_if(
not device.wifi.wifiAwareIsSupported(),
f'{device} does not support Wi-Fi Aware.',
@@ -111,12 +115,11 @@ class WifiAwareDiscoveryRangingTest(base_test.BaseTestClass):
f'{device} does not support Wi-Fi RTT.',
)
- utils.concurrent_exec(
- setup_device,
- ((self.publisher,), (self.subscriber,)),
- max_workers=2,
- raise_on_exception=True,
- )
+ def _setup_device(self, device: android_device.AndroidDevice):
+ device.load_snippet('wifi', _SNIPPET_PACKAGE_NAME)
+ device.wifi.wifiEnable()
+ wifi_test_utils.set_screen_on_and_unlock(device)
+ wifi_test_utils.enable_wifi_verbose_logging(device)
def test_discovery_ranging_to_peer_handle(self) -> None:
"""Test ranging to a Wi-Fi Aware peer handle.
diff --git a/tests/hostsidetests/multidevices/test/aware/wifi_aware_network_test.py b/tests/hostsidetests/multidevices/test/aware/wifi_aware_network_test.py
index f711b6dccc..c0d406603e 100644
--- a/tests/hostsidetests/multidevices/test/aware/wifi_aware_network_test.py
+++ b/tests/hostsidetests/multidevices/test/aware/wifi_aware_network_test.py
@@ -81,27 +81,30 @@ class WifiAwareNetworkTest(base_test.BaseTestClass):
self.publisher = self.ads[0]
self.subscriber = self.ads[1]
- def setup_device(device: android_device.AndroidDevice):
- device.load_snippet('wifi', _SNIPPET_PACKAGE_NAME)
- device.wifi.wifiEnable()
- wifi_test_utils.set_screen_on_and_unlock(device)
- wifi_test_utils.enable_wifi_verbose_logging(device)
- # Device capability check
+ # Device setup
+ utils.concurrent_exec(
+ self._setup_device,
+ ((self.publisher,), (self.subscriber,)),
+ max_workers=2,
+ raise_on_exception=True,
+ )
+
+ # Device capability check
+ for device in [self.publisher, self.subscriber]:
asserts.abort_class_if(
not device.wifi.wifiAwareIsSupported(),
f'{device} does not support Wi-Fi Aware.',
)
asserts.abort_class_if(
not device.wifi.wifiAwareIsAvailable(),
- f'{device} Wi-Fi Aware is not available.',
+ f'Wi-Fi Aware is not available on {device}.',
)
- utils.concurrent_exec(
- setup_device,
- ((self.publisher,), (self.subscriber,)),
- max_workers=2,
- raise_on_exception=True,
- )
+ def _setup_device(self, device: android_device.AndroidDevice):
+ device.load_snippet('wifi', _SNIPPET_PACKAGE_NAME)
+ device.wifi.wifiEnable()
+ wifi_test_utils.set_screen_on_and_unlock(device)
+ wifi_test_utils.enable_wifi_verbose_logging(device)
@ApiTest(
apis=[
diff --git a/tests/hostsidetests/multidevices/test/direct/AndroidTest.xml b/tests/hostsidetests/multidevices/test/direct/AndroidTest.xml
index 63f3af4ada..6da3197442 100644
--- a/tests/hostsidetests/multidevices/test/direct/AndroidTest.xml
+++ b/tests/hostsidetests/multidevices/test/direct/AndroidTest.xml
@@ -10,7 +10,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<configuration description="Test config for Wi-Fi Direct multi-device CTS tests">
+<configuration description="Test config for Wi-Fi Direct multi-device tests">
<option name="test-suite-tag" value="cts-v-host" />
<option name="config-descriptor:metadata" key="component" value="wifi" />
<option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
@@ -21,23 +21,17 @@
<target_preparer class="AndroidDeviceFeaturesCheckDecorator">
<option name="required_feature" value="android.hardware.wifi.direct" />
</target_preparer>
- <target_preparer class="AndroidMainlineModulesCheckDecorator">
- <option name="mainline_module_package_name" value="com.google.android.wifi" />
- </target_preparer>
<target_preparer class="AndroidInstallAppsDecorator" />
</device>
<device name="AndroidDevice">
<target_preparer class="AndroidDeviceFeaturesCheckDecorator">
<option name="required_feature" value="android.hardware.wifi.direct" />
</target_preparer>
- <target_preparer class="AndroidMainlineModulesCheckDecorator">
- <option name="mainline_module_package_name" value="com.google.android.wifi" />
- </target_preparer>
<target_preparer class="AndroidInstallAppsDecorator" />
</device>
<test class="MoblyAospPackageTest" />
- <option name="mobly_pkg" key="file" value="CtsWifiDirectTests" />
+ <option name="mobly_pkg" key="file" value="WifiDirectTests" />
<option name="build_apk" key="file" value="wifi_mobly_snippet.apk" />
</configuration> \ No newline at end of file
diff --git a/tests/hostsidetests/multidevices/test/direct/cts_wifi_direct_test_suite.py b/tests/hostsidetests/multidevices/test/direct/wifi_direct_test_suite.py
index 80d12abe05..6598e39648 100644
--- a/tests/hostsidetests/multidevices/test/direct/cts_wifi_direct_test_suite.py
+++ b/tests/hostsidetests/multidevices/test/direct/wifi_direct_test_suite.py
@@ -13,7 +13,7 @@
# limitations under the License.
# Lint as: python3
-"""CTS Wi-Fi Direct test suite."""
+"""Wi-Fi Direct test suite."""
from mobly import base_suite
from mobly import suite_runner
@@ -24,8 +24,8 @@ from direct import group_owner_with_config_test
from direct import service_discovery_test
-class CtsWifiDirectTestSuite(base_suite.BaseSuite):
- """CTS Wi-Fi Direct test suite."""
+class WifiDirectTestSuite(base_suite.BaseSuite):
+ """Wi-Fi Direct test suite."""
def setup_suite(self, config):
del config # unused
diff --git a/tests/hostsidetests/multidevices/test/softap/AndroidTest.xml b/tests/hostsidetests/multidevices/test/softap/AndroidTest.xml
index 19da4cca39..26ddcdd877 100644
--- a/tests/hostsidetests/multidevices/test/softap/AndroidTest.xml
+++ b/tests/hostsidetests/multidevices/test/softap/AndroidTest.xml
@@ -21,18 +21,12 @@
<target_preparer class="AndroidDeviceFeaturesCheckDecorator">
<option name="required_feature" value="android.hardware.wifi" />
</target_preparer>
- <target_preparer class="AndroidMainlineModulesCheckDecorator">
- <option name="mainline_module_package_name" value="com.google.android.wifi" />
- </target_preparer>
<target_preparer class="AndroidInstallAppsDecorator" />
</device>
<device name="AndroidDevice">
<target_preparer class="AndroidDeviceFeaturesCheckDecorator">
<option name="required_feature" value="android.hardware.wifi" />
</target_preparer>
- <target_preparer class="AndroidMainlineModulesCheckDecorator">
- <option name="mainline_module_package_name" value="com.google.android.wifi" />
- </target_preparer>
<target_preparer class="AndroidInstallAppsDecorator" />
</device>