summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Les Lee <lesl@google.com> 2022-01-11 12:07:57 +0800
committer Les Lee <lesl@google.com> 2022-01-24 10:16:00 +0800
commit1a8877f52f2d5511c3fef8ad0f916cb4299c386c (patch)
tree8952c0d299d10effd466f33b12d21cbeeaf95944
parent8d6f835e75e88218a6cf71e8bbb62210ef56e3d3 (diff)
wifi: Add new API to notify wificond of CC have changed
When device doesn't support NL80211_CMD_REG_CHANGED, the wificond has no way to know the CC(country code) have changed. Add a new API to allow the wifi frameworks notify wificond daemon of country code have changed. Bug: 211573255 Bug: 212554181 Bug: 207426796 Test: atest WifiNl80211ManagerTest Test: Maunal Test with log check. Change-Id: I1e2c980062e66e6dcf007c0e2a4f1e9b203536ac
-rw-r--r--core/api/system-current.txt1
-rw-r--r--wifi/java/src/android/net/wifi/nl80211/WifiNl80211Manager.java20
-rw-r--r--wifi/tests/src/android/net/wifi/nl80211/WifiNl80211ManagerTest.java20
3 files changed, 41 insertions, 0 deletions
diff --git a/core/api/system-current.txt b/core/api/system-current.txt
index ab2d3d50c2a8..69428af3eb52 100644
--- a/core/api/system-current.txt
+++ b/core/api/system-current.txt
@@ -8819,6 +8819,7 @@ package android.net.wifi.nl80211 {
method @Nullable public android.net.wifi.nl80211.DeviceWiphyCapabilities getDeviceWiphyCapabilities(@NonNull String);
method @NonNull public java.util.List<android.net.wifi.nl80211.NativeScanResult> getScanResults(@NonNull String, int);
method @Nullable public android.net.wifi.nl80211.WifiNl80211Manager.TxPacketCounters getTxPacketCounters(@NonNull String);
+ method public boolean notifyCountryCodeChanged();
method @Nullable public static android.net.wifi.nl80211.WifiNl80211Manager.OemSecurityType parseOemSecurityTypeElement(int, int, @NonNull byte[]);
method @Deprecated public boolean registerApCallback(@NonNull String, @NonNull java.util.concurrent.Executor, @NonNull android.net.wifi.nl80211.WifiNl80211Manager.SoftApCallback);
method public boolean registerCountryCodeChangedListener(@NonNull java.util.concurrent.Executor, @NonNull android.net.wifi.nl80211.WifiNl80211Manager.CountryCodeChangedListener);
diff --git a/wifi/java/src/android/net/wifi/nl80211/WifiNl80211Manager.java b/wifi/java/src/android/net/wifi/nl80211/WifiNl80211Manager.java
index 3b7566051fae..459696e81ee4 100644
--- a/wifi/java/src/android/net/wifi/nl80211/WifiNl80211Manager.java
+++ b/wifi/java/src/android/net/wifi/nl80211/WifiNl80211Manager.java
@@ -1262,6 +1262,26 @@ public class WifiNl80211Manager {
}
/**
+ * Notifies the wificond daemon that the WiFi framework has successfully updated the Country
+ * Code of the driver. The wificond daemon needs this notification if the device does not
+ * support the NL80211_CMD_REG_CHANGED (otherwise it will find out on its own). The wificond
+ * updates in internal state in response to this Country Code update.
+ *
+ * @return true on success, false otherwise.
+ */
+ public boolean notifyCountryCodeChanged() {
+ try {
+ if (mWificond != null) {
+ mWificond.notifyCountryCodeChanged();
+ return true;
+ }
+ } catch (RemoteException e1) {
+ Log.e(TAG, "Failed to notify country code changed due to remote exception");
+ }
+ return false;
+ }
+
+ /**
* Register the provided callback handler for SoftAp events. The interface must first be created
* using {@link #setupInterfaceForSoftApMode(String)}. The callback registration is valid until
* the interface is deleted using {@link #tearDownSoftApInterface(String)} (no deregistration
diff --git a/wifi/tests/src/android/net/wifi/nl80211/WifiNl80211ManagerTest.java b/wifi/tests/src/android/net/wifi/nl80211/WifiNl80211ManagerTest.java
index 3fb23013bdec..4032a7b0c75c 100644
--- a/wifi/tests/src/android/net/wifi/nl80211/WifiNl80211ManagerTest.java
+++ b/wifi/tests/src/android/net/wifi/nl80211/WifiNl80211ManagerTest.java
@@ -1137,6 +1137,26 @@ public class WifiNl80211ManagerTest {
assertEquals(capaExpected, capaActual);
}
+ /**
+ * Tests notifyCountryCodeChanged
+ */
+ @Test
+ public void testNotifyCountryCodeChanged() throws Exception {
+ doNothing().when(mWificond).notifyCountryCodeChanged();
+ assertTrue(mWificondControl.notifyCountryCodeChanged());
+ verify(mWificond).notifyCountryCodeChanged();
+ }
+
+ /**
+ * Tests notifyCountryCodeChanged with RemoteException
+ */
+ @Test
+ public void testNotifyCountryCodeChangedRemoteException() throws Exception {
+ doThrow(new RemoteException()).when(mWificond).notifyCountryCodeChanged();
+ assertFalse(mWificondControl.notifyCountryCodeChanged());
+ verify(mWificond).notifyCountryCodeChanged();
+ }
+
// Create a ArgumentMatcher which captures a SingleScanSettings parameter and checks if it
// matches the provided frequency set and ssid set.
private class ScanMatcher implements ArgumentMatcher<SingleScanSettings> {