diff options
author | Robert Greenwalt <rgreenwalt@google.com> | 2013-09-22 15:59:00 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-09-22 15:59:01 +0000 |
commit | 0983eadff23bfc3ab7812be455d4a66edc3dcc7b (patch) | |
tree | 43deae857670f87fa4b678df261cc19e9a9f8652 | |
parent | ca833c389b3cc2f95f27fe7782d0bebb8b36d660 (diff) | |
parent | 13820af302ead6b6a17b5f1b3991fcf8af252f93 (diff) | |
download | frameworks_base-0983eadff23bfc3ab7812be455d4a66edc3dcc7b.zip frameworks_base-0983eadff23bfc3ab7812be455d4a66edc3dcc7b.tar.gz frameworks_base-0983eadff23bfc3ab7812be455d4a66edc3dcc7b.tar.bz2 |
Merge "Fix BatchScan request coalesing" into klp-dev
-rw-r--r-- | services/java/com/android/server/wifi/WifiService.java | 38 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/BatchedScanSettings.java | 36 |
2 files changed, 51 insertions, 23 deletions
diff --git a/services/java/com/android/server/wifi/WifiService.java b/services/java/com/android/server/wifi/WifiService.java index a604d3f..f93a45b 100644 --- a/services/java/com/android/server/wifi/WifiService.java +++ b/services/java/com/android/server/wifi/WifiService.java @@ -455,9 +455,7 @@ public final class WifiService extends IWifiManager.Stub { private void resolveBatchedScannersLocked() { BatchedScanSettings setting = new BatchedScanSettings(); - setting.scanIntervalSec = BatchedScanSettings.DEFAULT_INTERVAL_SEC; int responsibleUid = 0; - setting.channelSet = new ArrayList<String>(); if (mBatchedScanners.size() == 0) { mWifiStateMachine.setBatchedScanSettings(null, 0); @@ -472,7 +470,7 @@ public final class WifiService extends IWifiManager.Stub { } if (s.maxApPerScan != BatchedScanSettings.UNSPECIFIED && (setting.maxApPerScan == BatchedScanSettings.UNSPECIFIED || - s.maxApPerScan > setting.maxApPerScan)) { + s.maxApPerScan > setting.maxApPerScan)) { setting.maxApPerScan = s.maxApPerScan; } if (s.scanIntervalSec != BatchedScanSettings.UNSPECIFIED && @@ -481,31 +479,25 @@ public final class WifiService extends IWifiManager.Stub { responsibleUid = r.uid; } if (s.maxApForDistance != BatchedScanSettings.UNSPECIFIED && - s.maxApForDistance > setting.maxApForDistance) { + (setting.maxApForDistance == BatchedScanSettings.UNSPECIFIED || + s.maxApForDistance > setting.maxApForDistance)) { setting.maxApForDistance = s.maxApForDistance; } - if (s.channelSet != null) { - for (String i : s.channelSet) { - if (setting.channelSet.contains(i) == false) setting.channelSet.add(i); + if (s.channelSet != null && s.channelSet.size() != 0) { + if (setting.channelSet == null || setting.channelSet.size() != 0) { + if (setting.channelSet == null) setting.channelSet = new ArrayList<String>(); + for (String i : s.channelSet) { + if (setting.channelSet.contains(i) == false) setting.channelSet.add(i); + } + } // else, ignore the constraint - we already use all channels + } else { + if (setting.channelSet == null || setting.channelSet.size() != 0) { + setting.channelSet = new ArrayList<String>(); } } } - if (setting.channelSet.size() == 0) setting.channelSet = null; - if (setting.scanIntervalSec < BatchedScanSettings.MIN_INTERVAL_SEC) { - setting.scanIntervalSec = BatchedScanSettings.MIN_INTERVAL_SEC; - } - if (setting.maxScansPerBatch == BatchedScanSettings.UNSPECIFIED) { - setting.maxScansPerBatch = BatchedScanSettings.DEFAULT_SCANS_PER_BATCH; - } - if (setting.maxApPerScan == BatchedScanSettings.UNSPECIFIED) { - setting.maxApPerScan = BatchedScanSettings.DEFAULT_AP_PER_SCAN; - } - if (setting.scanIntervalSec == BatchedScanSettings.UNSPECIFIED) { - setting.scanIntervalSec = BatchedScanSettings.DEFAULT_INTERVAL_SEC; - } - if (setting.maxApForDistance == BatchedScanSettings.UNSPECIFIED) { - setting.maxApForDistance = BatchedScanSettings.DEFAULT_AP_FOR_DISTANCE; - } + + setting.constrain(); mWifiStateMachine.setBatchedScanSettings(setting, responsibleUid); } diff --git a/wifi/java/android/net/wifi/BatchedScanSettings.java b/wifi/java/android/net/wifi/BatchedScanSettings.java index 44a2ab4..f7ebc17 100644 --- a/wifi/java/android/net/wifi/BatchedScanSettings.java +++ b/wifi/java/android/net/wifi/BatchedScanSettings.java @@ -135,6 +135,42 @@ public class BatchedScanSettings implements Parcelable { return false; } + /** @hide */ + public void constrain() { + if (scanIntervalSec == UNSPECIFIED) { + scanIntervalSec = DEFAULT_INTERVAL_SEC; + } else if (scanIntervalSec < MIN_INTERVAL_SEC) { + scanIntervalSec = MIN_INTERVAL_SEC; + } else if (scanIntervalSec > MAX_INTERVAL_SEC) { + scanIntervalSec = MAX_INTERVAL_SEC; + } + + if (maxScansPerBatch == UNSPECIFIED) { + maxScansPerBatch = DEFAULT_SCANS_PER_BATCH; + } else if (maxScansPerBatch < MIN_SCANS_PER_BATCH) { + maxScansPerBatch = MIN_SCANS_PER_BATCH; + } else if (maxScansPerBatch > MAX_SCANS_PER_BATCH) { + maxScansPerBatch = MAX_SCANS_PER_BATCH; + } + + if (maxApPerScan == UNSPECIFIED) { + maxApPerScan = DEFAULT_AP_PER_SCAN; + } else if (maxApPerScan < MIN_AP_PER_SCAN) { + maxApPerScan = MIN_AP_PER_SCAN; + } else if (maxApPerScan > MAX_AP_PER_SCAN) { + maxApPerScan = MAX_AP_PER_SCAN; + } + + if (maxApForDistance == UNSPECIFIED) { + maxApForDistance = DEFAULT_AP_FOR_DISTANCE; + } else if (maxApForDistance < MIN_AP_FOR_DISTANCE) { + maxApForDistance = MIN_AP_FOR_DISTANCE; + } else if (maxApForDistance > MAX_AP_FOR_DISTANCE) { + maxApForDistance = MAX_AP_FOR_DISTANCE; + } + } + + @Override public boolean equals(Object obj) { if (obj instanceof BatchedScanSettings == false) return false; |