summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorNingyuan Wang <nywang@google.com>2017-03-23 18:09:18 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2017-03-23 18:09:19 +0000
commit7a74c36073dfe94717b24741538502f9781140cb (patch)
tree13d8e30e25d94f19082dad565f41b7cd2d38431b /service
parente5909d266e65deae7612486cf2cc7570449b8514 (diff)
parent51493e199ebf1e1191ccf652f0081d229018a11f (diff)
Merge "Separate single scan and sched scan result handling"
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiMonitor.java11
-rw-r--r--service/java/com/android/server/wifi/WificondControl.java2
-rw-r--r--service/java/com/android/server/wifi/scanner/WificondScannerImpl.java62
3 files changed, 61 insertions, 14 deletions
diff --git a/service/java/com/android/server/wifi/WifiMonitor.java b/service/java/com/android/server/wifi/WifiMonitor.java
index 15ec8fd77..c4f0bdedb 100644
--- a/service/java/com/android/server/wifi/WifiMonitor.java
+++ b/service/java/com/android/server/wifi/WifiMonitor.java
@@ -87,6 +87,9 @@ public class WifiMonitor {
public static final int SUP_REQUEST_SIM_AUTH = BASE + 16;
public static final int SCAN_FAILED_EVENT = BASE + 17;
+ /* Pno scan results are available */
+ public static final int PNO_SCAN_RESULTS_EVENT = BASE + 18;
+
/* Indicates assoc reject event */
public static final int ASSOCIATION_REJECTION_EVENT = BASE + 43;
@@ -464,6 +467,14 @@ public class WifiMonitor {
}
/**
+ * Broadcast pno scan result event to all the handlers registered for this event.
+ * @param iface Name of iface on which this occurred.
+ */
+ public void broadcastPnoScanResultEvent(String iface) {
+ sendMessage(iface, PNO_SCAN_RESULTS_EVENT);
+ }
+
+ /**
* Broadcast scan failed event to all the handlers registered for this event.
* @param iface Name of iface on which this occurred.
*/
diff --git a/service/java/com/android/server/wifi/WificondControl.java b/service/java/com/android/server/wifi/WificondControl.java
index e2a08a853..c88a80426 100644
--- a/service/java/com/android/server/wifi/WificondControl.java
+++ b/service/java/com/android/server/wifi/WificondControl.java
@@ -87,7 +87,7 @@ public class WificondControl {
@Override
public void OnPnoNetworkFound() {
Log.d(TAG, "Pno scan result event");
- mWifiMonitor.broadcastScanResultEvent(mClientInterfaceName);
+ mWifiMonitor.broadcastPnoScanResultEvent(mClientInterfaceName);
}
@Override
diff --git a/service/java/com/android/server/wifi/scanner/WificondScannerImpl.java b/service/java/com/android/server/wifi/scanner/WificondScannerImpl.java
index e3058b6c4..9f73a246c 100644
--- a/service/java/com/android/server/wifi/scanner/WificondScannerImpl.java
+++ b/service/java/com/android/server/wifi/scanner/WificondScannerImpl.java
@@ -145,6 +145,8 @@ public class WificondScannerImpl extends WifiScannerImpl implements Handler.Call
wifiMonitor.registerHandler(mWifiNative.getInterfaceName(),
WifiMonitor.SCAN_FAILED_EVENT, mEventHandler);
wifiMonitor.registerHandler(mWifiNative.getInterfaceName(),
+ WifiMonitor.PNO_SCAN_RESULTS_EVENT, mEventHandler);
+ wifiMonitor.registerHandler(mWifiNative.getInterfaceName(),
WifiMonitor.SCAN_RESULTS_EVENT, mEventHandler);
}
@@ -502,6 +504,13 @@ public class WificondScannerImpl extends WifiScannerImpl implements Handler.Call
reportScanFailure();
processPendingScans();
break;
+ case WifiMonitor.PNO_SCAN_RESULTS_EVENT:
+ mAlarmManager.cancel(mScanTimeoutListener);
+ pollLatestScanDataForPno();
+ // TODO(b/36276738): Remove this after we fix b/36231150.
+ Log.d(TAG, "processPendingScans in request of SCHED_SCAN_RESULTS_EVENT");
+ processPendingScans();
+ break;
case WifiMonitor.SCAN_RESULTS_EVENT:
mAlarmManager.cancel(mScanTimeoutListener);
pollLatestScanData();
@@ -542,6 +551,46 @@ public class WificondScannerImpl extends WifiScannerImpl implements Handler.Call
}
}
+ private void pollLatestScanDataForPno() {
+ synchronized (mSettingsLock) {
+ if (mLastScanSettings == null) {
+ // got a scan before we started scanning or after scan was canceled
+ return;
+ }
+ ArrayList<ScanDetail> nativeResults = mWifiNative.getScanResults();
+ List<ScanResult> hwPnoScanResults = new ArrayList<>();
+ int numFilteredScanResults = 0;
+ for (int i = 0; i < nativeResults.size(); ++i) {
+ ScanResult result = nativeResults.get(i).getScanResult();
+ long timestamp_ms = result.timestamp / 1000; // convert us -> ms
+ if (timestamp_ms > mLastScanSettings.startTime) {
+ if (mLastScanSettings.hwPnoScanActive) {
+ hwPnoScanResults.add(result);
+ }
+ } else {
+ numFilteredScanResults++;
+ }
+ }
+
+ if (numFilteredScanResults != 0) {
+ Log.d(TAG, "Filtering out " + numFilteredScanResults + " pno scan results.");
+ }
+
+ if (mLastScanSettings.hwPnoScanActive
+ && mLastScanSettings.pnoScanEventHandler != null) {
+ ScanResult[] pnoScanResultsArray = new ScanResult[hwPnoScanResults.size()];
+ for (int i = 0; i < pnoScanResultsArray.length; ++i) {
+ ScanResult result = nativeResults.get(i).getScanResult();
+ pnoScanResultsArray[i] = hwPnoScanResults.get(i);
+ }
+ mLastScanSettings.pnoScanEventHandler.onPnoNetworkFound(pnoScanResultsArray);
+ }
+ // mLastScanSettings is for either single/batched scan or pno scan.
+ // We can safely set it to null when pno scan finishes.
+ mLastScanSettings = null;
+ }
+ }
+
private void pollLatestScanData() {
synchronized (mSettingsLock) {
if (mLastScanSettings == null) {
@@ -553,7 +602,6 @@ public class WificondScannerImpl extends WifiScannerImpl implements Handler.Call
ArrayList<ScanDetail> nativeResults = mWifiNative.getScanResults();
List<ScanResult> singleScanResults = new ArrayList<>();
List<ScanResult> backgroundScanResults = new ArrayList<>();
- List<ScanResult> hwPnoScanResults = new ArrayList<>();
int numFilteredScanResults = 0;
for (int i = 0; i < nativeResults.size(); ++i) {
ScanResult result = nativeResults.get(i).getScanResult();
@@ -567,9 +615,6 @@ public class WificondScannerImpl extends WifiScannerImpl implements Handler.Call
result.frequency)) {
singleScanResults.add(result);
}
- if (mLastScanSettings.hwPnoScanActive) {
- hwPnoScanResults.add(result);
- }
} else {
numFilteredScanResults++;
}
@@ -650,15 +695,6 @@ public class WificondScannerImpl extends WifiScannerImpl implements Handler.Call
.onScanStatus(WifiNative.WIFI_SCAN_RESULTS_AVAILABLE);
}
- if (mLastScanSettings.hwPnoScanActive
- && mLastScanSettings.pnoScanEventHandler != null) {
- ScanResult[] pnoScanResultsArray = new ScanResult[hwPnoScanResults.size()];
- for (int i = 0; i < pnoScanResultsArray.length; ++i) {
- pnoScanResultsArray[i] = hwPnoScanResults.get(i);
- }
- mLastScanSettings.pnoScanEventHandler.onPnoNetworkFound(pnoScanResultsArray);
- }
-
mLastScanSettings = null;
}
}