diff options
author | Etan Cohen <etancohen@google.com> | 2019-11-23 16:45:39 -0800 |
---|---|---|
committer | Etan Cohen <etancohen@google.com> | 2019-12-09 10:49:59 -0800 |
commit | 2d3b38274c113659314e233bf203dafc659b4507 (patch) | |
tree | a1c5cc8a90cf2f7530266a7f26f6af6c7d8a609e /service | |
parent | 7563bf5a395006fedea65d4c648a8bda9997148a (diff) |
[WIFI][MAINLINE] Convert ScanType usage to a single WifiScanner API
Remove internal representation of the Wi-Fi Scan requets type.
Bug: 140062898
Test: atest android.net.wifi
Test: atest com.android.server.wifi
Change-Id: I96734149e95bb2fce543a4051b250235c1df929b
Diffstat (limited to 'service')
3 files changed, 24 insertions, 46 deletions
diff --git a/service/java/com/android/server/wifi/WifiNative.java b/service/java/com/android/server/wifi/WifiNative.java index 3dfd63bf9..7729d6157 100644 --- a/service/java/com/android/server/wifi/WifiNative.java +++ b/service/java/com/android/server/wifi/WifiNative.java @@ -1385,14 +1385,14 @@ public class WifiNative { /** * Start a scan using wificond for the given parameters. * @param ifaceName Name of the interface. - * @param scanType Type of scan to perform. One of {@link ScanSettings#SCAN_TYPE_LOW_LATENCY}, - * {@link ScanSettings#SCAN_TYPE_LOW_POWER} or {@link ScanSettings#SCAN_TYPE_HIGH_ACCURACY}. + * @param scanType Type of scan to perform. One of {@link WifiScanner#SCAN_TYPE_LOW_LATENCY}, + * {@link WifiScanner#SCAN_TYPE_LOW_POWER} or {@link WifiScanner#SCAN_TYPE_HIGH_ACCURACY}. * @param freqs list of frequencies to scan for, if null scan all supported channels. * @param hiddenNetworkSSIDs List of hidden networks to be scanned for. * @return Returns true on success. */ public boolean scan( - @NonNull String ifaceName, int scanType, Set<Integer> freqs, + @NonNull String ifaceName, @WifiScanner.ScanType int scanType, Set<Integer> freqs, List<String> hiddenNetworkSSIDs) { return mWificondControl.scan(ifaceName, scanType, freqs, hiddenNetworkSSIDs); } @@ -2542,16 +2542,12 @@ public class WifiNative { } } - public static final int SCAN_TYPE_LOW_LATENCY = 0; - public static final int SCAN_TYPE_LOW_POWER = 1; - public static final int SCAN_TYPE_HIGH_ACCURACY = 2; - public static class ScanSettings { /** - * Type of scan to perform. One of {@link ScanSettings#SCAN_TYPE_LOW_LATENCY}, - * {@link ScanSettings#SCAN_TYPE_LOW_POWER} or {@link ScanSettings#SCAN_TYPE_HIGH_ACCURACY}. + * Type of scan to perform. One of {@link WifiScanner#SCAN_TYPE_LOW_LATENCY}, + * {@link WifiScanner#SCAN_TYPE_LOW_POWER} or {@link WifiScanner#SCAN_TYPE_HIGH_ACCURACY}. */ - public int scanType; + public @WifiScanner.ScanType int scanType; public int base_period_ms; public int max_ap_per_scan; public int report_threshold_percent; diff --git a/service/java/com/android/server/wifi/WificondControl.java b/service/java/com/android/server/wifi/WificondControl.java index 7a4e9e698..6141b7b13 100644 --- a/service/java/com/android/server/wifi/WificondControl.java +++ b/service/java/com/android/server/wifi/WificondControl.java @@ -656,13 +656,13 @@ public class WificondControl implements IBinder.DeathRecipient { /** * Return scan type for the parcelable {@link SingleScanSettings} */ - private static int getScanType(int scanType) { + private static int getScanType(@WifiScanner.ScanType int scanType) { switch (scanType) { - case WifiNative.SCAN_TYPE_LOW_LATENCY: + case WifiScanner.SCAN_TYPE_LOW_LATENCY: return IWifiScannerImpl.SCAN_TYPE_LOW_SPAN; - case WifiNative.SCAN_TYPE_LOW_POWER: + case WifiScanner.SCAN_TYPE_LOW_POWER: return IWifiScannerImpl.SCAN_TYPE_LOW_POWER; - case WifiNative.SCAN_TYPE_HIGH_ACCURACY: + case WifiScanner.SCAN_TYPE_HIGH_ACCURACY: return IWifiScannerImpl.SCAN_TYPE_HIGH_ACCURACY; default: throw new IllegalArgumentException("Invalid scan type " + scanType); @@ -677,10 +677,8 @@ public class WificondControl implements IBinder.DeathRecipient { * @param hiddenNetworkSSIDs List of hidden networks to be scanned for. * @return Returns true on success. */ - public boolean scan(@NonNull String ifaceName, - int scanType, - Set<Integer> freqs, - List<String> hiddenNetworkSSIDs) { + public boolean scan(@NonNull String ifaceName, @WifiScanner.ScanType int scanType, + Set<Integer> freqs, List<String> hiddenNetworkSSIDs) { IWifiScannerImpl scannerImpl = getScannerImpl(ifaceName); if (scannerImpl == null) { Log.e(TAG, "No valid wificond scanner interface handler"); diff --git a/service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java b/service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java index 6dd2021d7..2388ffdfa 100644 --- a/service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java +++ b/service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java @@ -1012,10 +1012,10 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub { } } - boolean validateScanType(int type) { - return type == WifiScanner.SCAN_TYPE_LOW_LATENCY + boolean validateScanType(@WifiScanner.ScanType int type) { + return (type == WifiScanner.SCAN_TYPE_LOW_LATENCY || type == WifiScanner.SCAN_TYPE_LOW_POWER - || type == WifiScanner.SCAN_TYPE_HIGH_ACCURACY; + || type == WifiScanner.SCAN_TYPE_HIGH_ACCURACY); } boolean validateScanRequest(ClientInfo ci, int handler, ScanSettings settings) { @@ -1050,30 +1050,15 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub { return true; } - int getNativeScanType(int type) { - switch(type) { - case WifiScanner.SCAN_TYPE_LOW_LATENCY: - return WifiNative.SCAN_TYPE_LOW_LATENCY; - case WifiScanner.SCAN_TYPE_LOW_POWER: - return WifiNative.SCAN_TYPE_LOW_POWER; - case WifiScanner.SCAN_TYPE_HIGH_ACCURACY: - return WifiNative.SCAN_TYPE_HIGH_ACCURACY; - default: - // This should never happen becuase we've validated the incoming type in - // |validateScanType|. - throw new IllegalArgumentException("Invalid scan type " + type); - } - } - // We can coalesce a LOW_POWER/LOW_LATENCY scan request into an ongoing HIGH_ACCURACY // scan request. But, we can't coalesce a HIGH_ACCURACY scan request into an ongoing // LOW_POWER/LOW_LATENCY scan request. boolean activeScanTypeSatisfies(int requestScanType) { switch(mActiveScanSettings.scanType) { - case WifiNative.SCAN_TYPE_LOW_LATENCY: - case WifiNative.SCAN_TYPE_LOW_POWER: - return requestScanType != WifiNative.SCAN_TYPE_HIGH_ACCURACY; - case WifiNative.SCAN_TYPE_HIGH_ACCURACY: + case WifiScanner.SCAN_TYPE_LOW_LATENCY: + case WifiScanner.SCAN_TYPE_LOW_POWER: + return requestScanType != WifiScanner.SCAN_TYPE_HIGH_ACCURACY; + case WifiScanner.SCAN_TYPE_HIGH_ACCURACY: return true; default: // This should never happen becuase we've validated the incoming type in @@ -1087,10 +1072,10 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub { // scan type should be HIGH_ACCURACY. int mergeScanTypes(int existingScanType, int newScanType) { switch(existingScanType) { - case WifiNative.SCAN_TYPE_LOW_LATENCY: - case WifiNative.SCAN_TYPE_LOW_POWER: + case WifiScanner.SCAN_TYPE_LOW_LATENCY: + case WifiScanner.SCAN_TYPE_LOW_POWER: return newScanType; - case WifiNative.SCAN_TYPE_HIGH_ACCURACY: + case WifiScanner.SCAN_TYPE_HIGH_ACCURACY: return existingScanType; default: // This should never happen becuase we've validated the incoming type in @@ -1104,7 +1089,7 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub { return false; } - if (!activeScanTypeSatisfies(getNativeScanType(settings.type))) { + if (!activeScanTypeSatisfies(settings.type)) { return false; } @@ -1177,8 +1162,7 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub { ChannelCollection channels = mChannelHelper.createChannelCollection(); List<WifiNative.HiddenNetwork> hiddenNetworkList = new ArrayList<>(); for (RequestInfo<ScanSettings> entry : mPendingScans) { - settings.scanType = - mergeScanTypes(settings.scanType, getNativeScanType(entry.settings.type)); + settings.scanType = mergeScanTypes(settings.scanType, entry.settings.type); channels.addChannels(entry.settings); for (ScanSettings.HiddenNetwork srcNetwork : entry.settings.hiddenNetworks) { WifiNative.HiddenNetwork hiddenNetwork = new WifiNative.HiddenNetwork(); |