diff options
author | Mitchell Wills <mwills@google.com> | 2016-03-30 21:58:42 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2016-03-30 21:58:44 +0000 |
commit | 0e776ddb6de62e76c54ff32148d9d170172be308 (patch) | |
tree | f3e3f5d2ac13bf1132f5be234cc330af556d3a62 /service | |
parent | c71fb2904e5588444ff2cbab6273661921675339 (diff) | |
parent | 0ea5062316013cd4173faf16c2a0f3ecd1b9ed43 (diff) |
Merge "Add handling of incoming WorkSource for scans" into nyc-dev
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/WifiScanningServiceImpl.java | 32 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/WifiStateMachine.java | 9 |
2 files changed, 29 insertions, 12 deletions
diff --git a/service/java/com/android/server/wifi/WifiScanningServiceImpl.java b/service/java/com/android/server/wifi/WifiScanningServiceImpl.java index 6f488886c..015730569 100644 --- a/service/java/com/android/server/wifi/WifiScanningServiceImpl.java +++ b/service/java/com/android/server/wifi/WifiScanningServiceImpl.java @@ -465,7 +465,13 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub { // Determine the system state (Wifi enabled/disabled/associated...etc) and // screenOn/Off, use it to increment the Metrics SystemScanState count // mWifiMetrics.incrementWifiSystemScanStateCount(???, ???); - if (validateAndAddToScanQueue(ci, msg.arg2, (ScanSettings) msg.obj)) { + + Bundle scanParams = (Bundle) msg.obj; + ScanSettings scanSettings = + scanParams.getParcelable(WifiScanner.SCAN_PARAMS_SCAN_SETTINGS_KEY); + WorkSource workSource = + scanParams.getParcelable(WifiScanner.SCAN_PARAMS_WORK_SOURCE_KEY); + if (validateAndAddToScanQueue(ci, msg.arg2, scanSettings, workSource)) { replySucceeded(msg); // If were not currently scanning then try to start a scan. Otherwise // this scan will be scheduled when transitioning back to IdleState @@ -539,7 +545,8 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub { } } - boolean validateAndAddToScanQueue(ClientInfo ci, int handler, ScanSettings settings) { + boolean validateAndAddToScanQueue(ClientInfo ci, int handler, ScanSettings settings, + WorkSource workSource) { if (ci == null) { Log.d(TAG, "Failing single scan request ClientInfo not found " + handler); return false; @@ -551,6 +558,7 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub { } } logScanRequest("addSingleScanRequest", ci, handler, settings, null); + // TODO(b/27903217): Blame scan on provided work source mPendingScans.put(ci, handler, settings); return true; } @@ -893,18 +901,24 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub { return NOT_HANDLED; case CMD_DRIVER_UNLOADED: return NOT_HANDLED; - case WifiScanner.CMD_START_BACKGROUND_SCAN: + case WifiScanner.CMD_START_BACKGROUND_SCAN: { mWifiMetrics.incrementBackgroundScanCount(); - if (addBackgroundScanRequest(ci, msg.arg2, (ScanSettings) msg.obj)) { + Bundle scanParams = (Bundle) msg.obj; + ScanSettings scanSettings = + scanParams.getParcelable(WifiScanner.SCAN_PARAMS_SCAN_SETTINGS_KEY); + WorkSource workSource = + scanParams.getParcelable(WifiScanner.SCAN_PARAMS_WORK_SOURCE_KEY); + if (addBackgroundScanRequest(ci, msg.arg2, scanSettings, workSource)) { replySucceeded(msg); } else { replyFailed(msg, WifiScanner.REASON_INVALID_REQUEST, "bad request"); } break; + } case WifiScanner.CMD_STOP_BACKGROUND_SCAN: removeBackgroundScanRequest(ci, msg.arg2); break; - case WifiScanner.CMD_START_PNO_SCAN: + case WifiScanner.CMD_START_PNO_SCAN: { mWifiMetrics.incrementBackgroundScanCount(); Bundle pnoParams = (Bundle) msg.obj; PnoSettings pnoSettings = @@ -917,6 +931,7 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub { replyFailed(msg, WifiScanner.REASON_INVALID_REQUEST, "bad request"); } break; + } case WifiScanner.CMD_STOP_PNO_SCAN: removeScanRequestForPno(ci, msg.arg2); break; @@ -1022,7 +1037,7 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub { } private boolean addBackgroundScanRequest(ClientInfo ci, int handler, - ScanSettings settings) { + ScanSettings settings, WorkSource workSource) { // sanity check the input if (ci == null) { Log.d(TAG, "Failing scan request ClientInfo not found " + handler); @@ -1073,6 +1088,7 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub { } logScanRequest("addBackgroundScanRequest", ci, handler, settings, null); + // TODO(b/27903217): Blame scan on provided work source mActiveBackgroundScans.put(ci, handler, settings); if (updateSchedule()) { @@ -1203,7 +1219,7 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub { // We need to schedule a background scan either because HW PNO requires background // scan or if there is no HW PNO scan support. if (shouldScheduleBackgroundScan) { - if(!addBackgroundScanRequest(ci, handler, scanSettings)) { + if (!addBackgroundScanRequest(ci, handler, scanSettings, null)) { loge("Background scan request for PNO failed."); return false; } @@ -2010,7 +2026,7 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub { Message msg = Message.obtain(); msg.what = WifiScanner.CMD_START_BACKGROUND_SCAN; msg.arg2 = SCAN_COMMAND_ID; - msg.obj = settings; + msg.getData().putParcelable(WifiScanner.SCAN_PARAMS_SCAN_SETTINGS_KEY, settings); mClientHandler.sendMessage(msg); } diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index 6a1217e7d..5b579d5ae 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -2003,7 +2003,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.PnoEven Set<Integer> hiddenNetworkIds = mWifiConfigManager.getHiddenConfiguredNetworkIds(); // call wifi native to start the scan - if (startScanNative(freqs, hiddenNetworkIds)) { + if (startScanNative(freqs, hiddenNetworkIds, workSource)) { // only count battery consumption if scan request is accepted noteScanStart(message.arg1, workSource); // a full scan covers everything, clearing scan request buffer @@ -2059,7 +2059,8 @@ public class WifiStateMachine extends StateMachine implements WifiNative.PnoEven /** * return true iff scan request is accepted */ - private boolean startScanNative(final Set<Integer> freqs, Set<Integer> hiddenNetworkIds) { + private boolean startScanNative(final Set<Integer> freqs, Set<Integer> hiddenNetworkIds, + WorkSource workSource) { WifiScanner.ScanSettings settings = new WifiScanner.ScanSettings(); if (freqs == null) { settings.band = WifiScanner.WIFI_BAND_BOTH_WITH_DFS; @@ -2095,7 +2096,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.PnoEven public void onPeriodChanged(int periodInMs) { } }; - mWifiScanner.startScan(settings, nativeScanListener); + mWifiScanner.startScan(settings, nativeScanListener, workSource); mIsScanOngoing = true; mIsFullScanOngoing = (freqs == null); lastScanFreqs = freqs; @@ -7236,7 +7237,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.PnoEven hiddenNetworkIds.add(config.networkId); } // Call wifi native to start the scan - if (startScanNative(freqs, hiddenNetworkIds)) { + if (startScanNative(freqs, hiddenNetworkIds, null)) { // Only count battery consumption if scan request is accepted noteScanStart(SCAN_ALARM_SOURCE, null); messageHandlingStatus = MESSAGE_HANDLING_STATUS_OK; |