summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorDavid Su <dysu@google.com>2020-05-26 22:26:05 -0700
committerDavid Su <dysu@google.com>2020-05-27 22:05:13 +0000
commit41769d6bebe1cda033204823aee61c8f205fdeff (patch)
treefb5e407647703389238b13519617a00dbd92a907 /service
parent8dddd90021f0d9419a3caf4cd07ba4c5af8746c7 (diff)
Add overlays for stationary/moving PNO scan interval
Allow customization of the stationary/moving PNO scan interval using overlays. Bug: 157172802 Test: atest WifiConnectivityManagerTest Change-Id: I31a976ae38fa3e5ba25210bcf608afc14f61e672 Merged-In: I31a976ae38fa3e5ba25210bcf608afc14f61e672
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiConnectivityManager.java33
-rw-r--r--service/res/values/config.xml13
-rw-r--r--service/res/values/overlayable.xml2
3 files changed, 27 insertions, 21 deletions
diff --git a/service/java/com/android/server/wifi/WifiConnectivityManager.java b/service/java/com/android/server/wifi/WifiConnectivityManager.java
index 8470d0c7d..b6f4baff5 100644
--- a/service/java/com/android/server/wifi/WifiConnectivityManager.java
+++ b/service/java/com/android/server/wifi/WifiConnectivityManager.java
@@ -85,16 +85,6 @@ public class WifiConnectivityManager {
// it should comply to the minimum scan interval rule.
private static final boolean SCAN_IMMEDIATELY = true;
private static final boolean SCAN_ON_SCHEDULE = false;
- // Initial PNO scan interval in milliseconds when the device is moving. The scan interval backs
- // off from this initial interval on subsequent scans. This scan is performed when screen is
- // off and disconnected.
- @VisibleForTesting
- static final int MOVING_PNO_SCAN_INTERVAL_MS = 20 * 1000; // 20 seconds
- // Initial PNO scan interval in milliseconds when the device is stationary. The scan interval
- // backs off from this initial interval on subsequent scans. This scan is performed when screen
- // is off and disconnected.
- @VisibleForTesting
- static final int STATIONARY_PNO_SCAN_INTERVAL_MS = 60 * 1000; // 1 minute
// PNO scan interval in milli-seconds. This is the scan
// performed when screen is off and connected.
@@ -208,7 +198,6 @@ public class WifiConnectivityManager {
private int[] mCurrentSingleScanScheduleSec;
private int mCurrentSingleScanScheduleIndex;
- private int mPnoScanIntervalMs;
private WifiChannelUtilization mWifiChannelUtilization;
// Cached WifiCandidates used in high mobility state to avoid connecting to APs that are
// moving relative to the user.
@@ -792,7 +781,6 @@ public class WifiConnectivityManager {
mClock = clock;
mScoringParams = scoringParams;
mConnectionAttemptTimeStamps = new LinkedList<>();
- mPnoScanIntervalMs = MOVING_PNO_SCAN_INTERVAL_MS;
// Listen to WifiConfigManager network update events
mConfigManager.addOnNetworkUpdateListener(new OnNetworkUpdateListener());
@@ -1321,14 +1309,16 @@ public class WifiConnectivityManager {
startPeriodicSingleScan();
}
- private static int deviceMobilityStateToPnoScanIntervalMs(@DeviceMobilityState int state) {
+ private int deviceMobilityStateToPnoScanIntervalMs(@DeviceMobilityState int state) {
switch (state) {
case WifiManager.DEVICE_MOBILITY_STATE_UNKNOWN:
case WifiManager.DEVICE_MOBILITY_STATE_LOW_MVMT:
case WifiManager.DEVICE_MOBILITY_STATE_HIGH_MVMT:
- return MOVING_PNO_SCAN_INTERVAL_MS;
+ return mContext.getResources()
+ .getInteger(R.integer.config_wifiMovingPnoScanIntervalMillis);
case WifiManager.DEVICE_MOBILITY_STATE_STATIONARY:
- return STATIONARY_PNO_SCAN_INTERVAL_MS;
+ return mContext.getResources()
+ .getInteger(R.integer.config_wifiStationaryPnoScanIntervalMillis);
default:
return -1;
}
@@ -1343,16 +1333,18 @@ public class WifiConnectivityManager {
* @param newState the new device mobility state
*/
public void setDeviceMobilityState(@DeviceMobilityState int newState) {
- mDeviceMobilityState = newState;
+ int oldDeviceMobilityState = mDeviceMobilityState;
localLog("Device mobility state changed. state=" + newState);
- mWifiChannelUtilization.setDeviceMobilityState(newState);
int newPnoScanIntervalMs = deviceMobilityStateToPnoScanIntervalMs(newState);
if (newPnoScanIntervalMs < 0) {
Log.e(TAG, "Invalid device mobility state: " + newState);
return;
}
+ mDeviceMobilityState = newState;
+ mWifiChannelUtilization.setDeviceMobilityState(newState);
- if (newPnoScanIntervalMs == mPnoScanIntervalMs) {
+ int oldPnoScanIntervalMs = deviceMobilityStateToPnoScanIntervalMs(oldDeviceMobilityState);
+ if (newPnoScanIntervalMs == oldPnoScanIntervalMs) {
if (mPnoScanStarted) {
mWifiMetrics.logPnoScanStop();
mWifiMetrics.enterDeviceMobilityState(newState);
@@ -1361,8 +1353,7 @@ public class WifiConnectivityManager {
mWifiMetrics.enterDeviceMobilityState(newState);
}
} else {
- mPnoScanIntervalMs = newPnoScanIntervalMs;
- Log.d(TAG, "PNO Scan Interval changed to " + mPnoScanIntervalMs + " ms.");
+ Log.d(TAG, "PNO Scan Interval changed to " + newPnoScanIntervalMs + " ms.");
if (mPnoScanStarted) {
Log.d(TAG, "Restarting PNO Scan with new scan interval");
@@ -1400,7 +1391,7 @@ public class WifiConnectivityManager {
scanSettings.band = getScanBand();
scanSettings.reportEvents = WifiScanner.REPORT_EVENT_NO_BATCH;
scanSettings.numBssidsPerScan = 0;
- scanSettings.periodInMs = mPnoScanIntervalMs;
+ scanSettings.periodInMs = deviceMobilityStateToPnoScanIntervalMs(mDeviceMobilityState);
mPnoScanListener.clearScanDetails();
diff --git a/service/res/values/config.xml b/service/res/values/config.xml
index dc2538cbc..4451f7c12 100644
--- a/service/res/values/config.xml
+++ b/service/res/values/config.xml
@@ -417,4 +417,17 @@
<!-- Wifi driver Automatic channel selection (ACS) for softap to include DFS channels -->
<bool translatable="false" name="config_wifiSoftapAcsIncludeDfs">false</bool>
+
+ <!-- Initial PNO scan interval, in milliseconds, when the device is moving (i.e.
+ WifiManager.DEVICE_MOBILITY_STATE_UNKNOWN, WifiManager.DEVICE_MOBILITY_STATE_HIGH_MVMT, or
+ WifiManager.DEVICE_MOBILITY_STATE_LOW_MVMT).
+ The scan interval backs off from this initial interval on subsequent scans.
+ This scan is performed when screen is off and disconnected. -->
+ <integer translatable="false" name="config_wifiMovingPnoScanIntervalMillis">20000</integer>
+
+ <!-- Initial PNO scan interval, in milliseconds, when the device is stationary (i.e.
+ WifiManager.DEVICE_MOBILITY_STATE_STATIONARY).
+ The scan interval backs off from this initial interval on subsequent scans.
+ This scan is performed when screen is off and disconnected. -->
+ <integer translatable="false" name="config_wifiStationaryPnoScanIntervalMillis">60000</integer>
</resources>
diff --git a/service/res/values/overlayable.xml b/service/res/values/overlayable.xml
index 52ef09e4f..9e0a18d7d 100644
--- a/service/res/values/overlayable.xml
+++ b/service/res/values/overlayable.xml
@@ -131,6 +131,8 @@
<item type="integer" name="config_wifiMaxNativeFailureSelfRecoveryPerHour" />
<item type="bool" name="config_wifiIgnoreOpenSavedNetworkWhenSecureSuggestionAvailable" />
<item type="bool" name="config_wifiSoftapAcsIncludeDfs" />
+ <item type="integer" name="config_wifiMovingPnoScanIntervalMillis" />
+ <item type="integer" name="config_wifiStationaryPnoScanIntervalMillis" />
<!-- Params from config.xml that can be overlayed -->
<!-- Params from strings.xml that can be overlayed -->