diff options
author | Etan Cohen <etancohen@google.com> | 2019-11-30 18:22:22 -0800 |
---|---|---|
committer | Etan Cohen <etancohen@google.com> | 2019-12-09 14:44:53 -0800 |
commit | 621745b542350fc6435bdc6d6741cbce9d1382fa (patch) | |
tree | 04467feb30ce853454d6d2da141d9b465b9dfb20 | |
parent | cdaf27dae9b472d3e01f7268c8ef398746e99bd4 (diff) |
[WIFI][MAINLINE] Transition WificondControl interfaces: PnoSettings
Transition WificondControl public interfaces to that class itself.
Preparation for the class being extracted to an official API.
Classes shifted: API shifted to use native (wificond) PnoSettings
Bug: 140062898
Test: atest android.net.wifi
Test: atest com.android.server.wifi
Change-Id: I8a3ddf1ebce11239e1d22e20641166cb9e8296f6
4 files changed, 46 insertions, 30 deletions
diff --git a/service/java/com/android/server/wifi/WifiNative.java b/service/java/com/android/server/wifi/WifiNative.java index f5a52a6ae..341a26880 100644 --- a/service/java/com/android/server/wifi/WifiNative.java +++ b/service/java/com/android/server/wifi/WifiNative.java @@ -1408,7 +1408,7 @@ public class WifiNative { * @return true on success. */ public boolean startPnoScan(@NonNull String ifaceName, PnoSettings pnoSettings) { - return mWificondControl.startPnoScan(ifaceName, pnoSettings); + return mWificondControl.startPnoScan(ifaceName, pnoSettings.toNativePnoSettings()); } /** @@ -2480,6 +2480,22 @@ public class WifiNative { public int hashCode() { return Objects.hash(ssid, flags, auth_bit_field, frequencies); } + + com.android.server.wifi.wificond.PnoNetwork toNativePnoNetwork() { + com.android.server.wifi.wificond.PnoNetwork nativePnoNetwork = + new com.android.server.wifi.wificond.PnoNetwork(); + nativePnoNetwork.isHidden = + (flags & WifiScanner.PnoSettings.PnoNetwork.FLAG_DIRECTED_SCAN) != 0; + try { + nativePnoNetwork.ssid = + NativeUtil.byteArrayFromArrayList(NativeUtil.decodeSsid(ssid)); + } catch (IllegalArgumentException e) { + Log.e(TAG, "Illegal argument " + ssid, e); + return null; + } + nativePnoNetwork.frequencies = frequencies; + return nativePnoNetwork; + } } /** @@ -2499,6 +2515,27 @@ public class WifiNative { public int periodInMs; public boolean isConnected; public PnoNetwork[] networkList; + + com.android.server.wifi.wificond.PnoSettings toNativePnoSettings() { + com.android.server.wifi.wificond.PnoSettings nativePnoSettings = + new com.android.server.wifi.wificond.PnoSettings(); + nativePnoSettings.intervalMs = periodInMs; + nativePnoSettings.min2gRssi = min24GHzRssi; + nativePnoSettings.min5gRssi = min5GHzRssi; + nativePnoSettings.min6gRssi = min6GHzRssi; + + nativePnoSettings.pnoNetworks = new ArrayList<>(); + if (networkList != null) { + for (PnoNetwork network : networkList) { + com.android.server.wifi.wificond.PnoNetwork nativeNetwork = + network.toNativePnoNetwork(); + if (nativeNetwork != null) { + nativePnoSettings.pnoNetworks.add(nativeNetwork); + } + } + } + return nativePnoSettings; + } } public static interface ScanEventHandler { diff --git a/service/java/com/android/server/wifi/WificondControl.java b/service/java/com/android/server/wifi/WificondControl.java index 487a53723..4a7451921 100644 --- a/service/java/com/android/server/wifi/WificondControl.java +++ b/service/java/com/android/server/wifi/WificondControl.java @@ -46,7 +46,6 @@ import com.android.server.wifi.wificond.ChannelSettings; import com.android.server.wifi.wificond.HiddenNetwork; import com.android.server.wifi.wificond.NativeScanResult; import com.android.server.wifi.wificond.NativeWifiClient; -import com.android.server.wifi.wificond.PnoNetwork; import com.android.server.wifi.wificond.PnoSettings; import com.android.server.wifi.wificond.RadioChainInfo; import com.android.server.wifi.wificond.SingleScanSettings; @@ -845,37 +844,15 @@ public class WificondControl implements IBinder.DeathRecipient { * @param pnoSettings Pno scan configuration. * @return true on success. */ - public boolean startPnoScan(@NonNull String ifaceName, WifiNative.PnoSettings pnoSettings) { + public boolean startPnoScan(@NonNull String ifaceName, PnoSettings pnoSettings) { IWifiScannerImpl scannerImpl = getScannerImpl(ifaceName); if (scannerImpl == null) { Log.e(TAG, "No valid wificond scanner interface handler"); return false; } - PnoSettings settings = new PnoSettings(); - settings.pnoNetworks = new ArrayList<>(); - settings.intervalMs = pnoSettings.periodInMs; - settings.min2gRssi = pnoSettings.min24GHzRssi; - settings.min5gRssi = pnoSettings.min5GHzRssi; - settings.min6gRssi = pnoSettings.min6GHzRssi; - if (pnoSettings.networkList != null) { - for (WifiNative.PnoNetwork network : pnoSettings.networkList) { - PnoNetwork condNetwork = new PnoNetwork(); - condNetwork.isHidden = (network.flags - & WifiScanner.PnoSettings.PnoNetwork.FLAG_DIRECTED_SCAN) != 0; - try { - condNetwork.ssid = - NativeUtil.byteArrayFromArrayList(NativeUtil.decodeSsid(network.ssid)); - } catch (IllegalArgumentException e) { - Log.e(TAG, "Illegal argument " + network.ssid, e); - continue; - } - condNetwork.frequencies = network.frequencies; - settings.pnoNetworks.add(condNetwork); - } - } try { - boolean success = scannerImpl.startPnoScan(settings); + boolean success = scannerImpl.startPnoScan(pnoSettings); mWifiInjector.getWifiMetrics().incrementPnoScanStartAttempCount(); if (!success) { mWifiInjector.getWifiMetrics().incrementPnoScanFailedCount(); @@ -928,7 +905,7 @@ public class WificondControl implements IBinder.DeathRecipient { * The result depends on the on the country code that has been set. * * @param band as specified by one of the WifiScanner.WIFI_BAND_* constants. - * The following bands are supported {@link WifiBandBasic}: + * The following bands are supported {@link @WifiScanner.WifiBandBasic}: * WifiScanner.WIFI_BAND_24_GHZ * WifiScanner.WIFI_BAND_5_GHZ * WifiScanner.WIFI_BAND_5_GHZ_DFS_ONLY diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java index c13a5fc90..73969d7a6 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java @@ -558,7 +558,7 @@ public class WifiNativeTest extends WifiBaseTest { public void testStartPnoScan() throws Exception { mWifiNative.startPnoScan(WIFI_IFACE_NAME, TEST_PNO_SETTINGS); verify(mWificondControl).startPnoScan( - WIFI_IFACE_NAME, TEST_PNO_SETTINGS); + WIFI_IFACE_NAME, TEST_PNO_SETTINGS.toNativePnoSettings()); } /** diff --git a/tests/wifitests/src/com/android/server/wifi/WificondControlTest.java b/tests/wifitests/src/com/android/server/wifi/WificondControlTest.java index 5a0d91488..74b51add5 100644 --- a/tests/wifitests/src/com/android/server/wifi/WificondControlTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WificondControlTest.java @@ -796,7 +796,8 @@ public class WificondControlTest extends WifiBaseTest { @Test public void testStartPnoScan() throws Exception { when(mWifiScannerImpl.startPnoScan(any(PnoSettings.class))).thenReturn(true); - assertTrue(mWificondControl.startPnoScan(TEST_INTERFACE_NAME, TEST_PNO_SETTINGS)); + assertTrue(mWificondControl.startPnoScan(TEST_INTERFACE_NAME, + TEST_PNO_SETTINGS.toNativePnoSettings())); verify(mWifiScannerImpl).startPnoScan(argThat(new PnoScanMatcher(TEST_PNO_SETTINGS))); } @@ -889,7 +890,8 @@ public class WificondControlTest extends WifiBaseTest { @Test public void testStartPnoScanForMetrics() throws Exception { when(mWifiScannerImpl.startPnoScan(any(PnoSettings.class))).thenReturn(false); - assertFalse(mWificondControl.startPnoScan(TEST_INTERFACE_NAME, TEST_PNO_SETTINGS)); + assertFalse(mWificondControl.startPnoScan(TEST_INTERFACE_NAME, + TEST_PNO_SETTINGS.toNativePnoSettings())); verify(mWifiMetrics).incrementPnoScanStartAttempCount(); verify(mWifiMetrics).incrementPnoScanFailedCount(); } |