Add support for background scanning
Background scanning (preferred network offload) allows us the
host to sleep while the dongle monitors the presence of any
preferred networks. This allows us for significant power savings
since the system does not have to wake up often to initiate
a scan
Bug: 3453021
Change-Id: I7c1dbfd0c3f717df81e4da6091c4c5657c9ec9ca
diff --git a/services/java/com/android/server/WifiService.java b/services/java/com/android/server/WifiService.java
index cc25e8d..f9b94a3 100644
--- a/services/java/com/android/server/WifiService.java
+++ b/services/java/com/android/server/WifiService.java
@@ -96,6 +96,9 @@
private boolean mDeviceIdle;
private int mPluggedType;
+ /* Chipset supports background scan */
+ private final boolean mBackgroundScanSupported;
+
// true if the user enabled Wifi while in airplane mode
private AtomicBoolean mAirplaneModeOverwridden = new AtomicBoolean(false);
@@ -369,6 +372,9 @@
Settings.Secure.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY, 900) * 1000l;
mNotificationEnabledSettingObserver = new NotificationEnabledSettingObserver(new Handler());
mNotificationEnabledSettingObserver.register();
+
+ mBackgroundScanSupported = mContext.getResources().getBoolean(
+ com.android.internal.R.bool.config_wifi_background_scan_support);
}
/**
@@ -900,6 +906,9 @@
reportStartWorkSource();
evaluateTrafficStatsPolling();
mWifiStateMachine.enableRssiPolling(true);
+ if (mBackgroundScanSupported) {
+ mWifiStateMachine.enableBackgroundScan(false);
+ }
mWifiStateMachine.enableAllNetworks();
updateWifiState();
} else if (action.equals(Intent.ACTION_SCREEN_OFF)) {
@@ -909,6 +918,9 @@
mScreenOff = true;
evaluateTrafficStatsPolling();
mWifiStateMachine.enableRssiPolling(false);
+ if (mBackgroundScanSupported) {
+ mWifiStateMachine.enableBackgroundScan(true);
+ }
/*
* Set a timer to put Wi-Fi to sleep, but only if the screen is off
* AND the "stay on while plugged in" setting doesn't match the