summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--service/java/com/android/server/wifi/ClientModeImpl.java19
-rw-r--r--service/res/values/config.xml3
-rw-r--r--service/res/values/overlayable.xml1
-rw-r--r--tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java13
4 files changed, 29 insertions, 7 deletions
diff --git a/service/java/com/android/server/wifi/ClientModeImpl.java b/service/java/com/android/server/wifi/ClientModeImpl.java
index d8a9aa178..fed81fe44 100644
--- a/service/java/com/android/server/wifi/ClientModeImpl.java
+++ b/service/java/com/android/server/wifi/ClientModeImpl.java
@@ -268,7 +268,7 @@ public class ClientModeImpl extends StateMachine {
private boolean mEnableRssiPolling = false;
// Accessed via Binder thread ({get,set}PollRssiIntervalMsecs), and the main Wifi thread.
- private volatile int mPollRssiIntervalMsecs = DEFAULT_POLL_RSSI_INTERVAL_MSECS;
+ private volatile int mPollRssiIntervalMsecs = -1;
private int mRssiPollToken = 0;
/* 3 operational states for STA operation: CONNECT_MODE, SCAN_ONLY_MODE, SCAN_ONLY_WIFI_OFF_MODE
* In CONNECT_MODE, the STA can scan and connect to an access point
@@ -287,11 +287,11 @@ public class ClientModeImpl extends StateMachine {
private PowerManager.WakeLock mSuspendWakeLock;
/**
- * Interval in milliseconds between polling for RSSI and linkspeed information.
- * This is also used as the polling interval for WifiTrafficPoller, which updates
+ * Maximum allowable interval in milliseconds between polling for RSSI and linkspeed
+ * information. This is also used as the polling interval for WifiTrafficPoller, which updates
* its data activity on every CMD_RSSI_POLL.
*/
- private static final int DEFAULT_POLL_RSSI_INTERVAL_MSECS = 3000;
+ private static final int MAXIMUM_POLL_RSSI_INTERVAL_MSECS = 6000;
/**
* Interval in milliseconds between receiving a disconnect event
@@ -353,7 +353,12 @@ public class ClientModeImpl extends StateMachine {
private WifiConfiguration mTargetWifiConfiguration = null;
int getPollRssiIntervalMsecs() {
- return mPollRssiIntervalMsecs;
+ if (mPollRssiIntervalMsecs > 0) {
+ return mPollRssiIntervalMsecs;
+ }
+ return Math.min(mContext.getResources().getInteger(
+ R.integer.config_wifiPollRssiIntervalMilliseconds),
+ MAXIMUM_POLL_RSSI_INTERVAL_MSECS);
}
void setPollRssiIntervalMsecs(int newPollIntervalMsecs) {
@@ -4518,7 +4523,7 @@ public class ClientModeImpl extends StateMachine {
mLinkProbeManager.updateConnectionStats(
mWifiInfo, mInterfaceName);
sendMessageDelayed(obtainMessage(CMD_RSSI_POLL, mRssiPollToken, 0),
- mPollRssiIntervalMsecs);
+ getPollRssiIntervalMsecs());
if (mVerboseLoggingEnabled) sendRssiChangeBroadcast(mWifiInfo.getRssi());
mWifiTrafficPoller.notifyOnDataActivity(mWifiInfo.txSuccess,
mWifiInfo.rxSuccess);
@@ -4536,7 +4541,7 @@ public class ClientModeImpl extends StateMachine {
mLinkProbeManager.resetOnScreenTurnedOn();
fetchRssiLinkSpeedAndFrequencyNative();
sendMessageDelayed(obtainMessage(CMD_RSSI_POLL, mRssiPollToken, 0),
- mPollRssiIntervalMsecs);
+ getPollRssiIntervalMsecs());
}
break;
case CMD_PKT_CNT_FETCH:
diff --git a/service/res/values/config.xml b/service/res/values/config.xml
index fd24fa66d..f70b2bdd2 100644
--- a/service/res/values/config.xml
+++ b/service/res/values/config.xml
@@ -324,4 +324,7 @@
<!-- The interval in milliseconds at which wifi rtt ranging requests will be throttled when
they are coming from the background apps (default = 30 mins). -->
<integer translatable="false" name="config_wifiRttBackgroundExecGapMs">1800000</integer>
+
+ <!-- Integer indicating the RSSI and link layer stats polling interval in milliseconds when device is connected and screen is on -->
+ <integer translatable="false" name="config_wifiPollRssiIntervalMilliseconds">3000</integer>
</resources>
diff --git a/service/res/values/overlayable.xml b/service/res/values/overlayable.xml
index 3489a33d4..72bb4c3d5 100644
--- a/service/res/values/overlayable.xml
+++ b/service/res/values/overlayable.xml
@@ -104,6 +104,7 @@
<item type="bool" name="config_wifiPnoRecencySortingEnabled" />
<item type="bool" name="config_wifiSuspendOptimizationsEnabled" />
<item type="integer" name="config_wifiRttBackgroundExecGapMs" />
+ <item type="integer" name="config_wifiPollRssiIntervalMilliseconds" />
<!-- Params from config.xml that can be overlayed -->
<!-- Params from strings.xml that can be overlayed -->
diff --git a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
index aefd567bd..351158aaa 100644
--- a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
@@ -474,6 +474,7 @@ public class ClientModeImplTest extends WifiBaseTest {
mResources.setBoolean(R.bool.config_wifi_connected_mac_randomization_supported, true);
mResources.setIntArray(R.array.config_wifiRssiLevelThresholds,
RssiUtilTest.RSSI_THRESHOLDS);
+ mResources.setInteger(R.integer.config_wifiPollRssiIntervalMilliseconds, 3000);
when(mContext.getResources()).thenReturn(mResources);
when(mFrameworkFacade.getIntegerSetting(mContext,
@@ -4133,4 +4134,16 @@ public class ClientModeImplTest extends WifiBaseTest {
verify(mWifiConnectivityManager, never())
.forceConnectivityScan(ClientModeImpl.WIFI_WORK_SOURCE);
}
+
+ /**
+ * Test that the interval for poll RSSI is read from config overlay correctly.
+ */
+ @Test
+ public void testPollRssiIntervalIsSetCorrectly() throws Exception {
+ assertEquals(3000, mCmi.getPollRssiIntervalMsecs());
+ mResources.setInteger(R.integer.config_wifiPollRssiIntervalMilliseconds, 6000);
+ assertEquals(6000, mCmi.getPollRssiIntervalMsecs());
+ mResources.setInteger(R.integer.config_wifiPollRssiIntervalMilliseconds, 7000);
+ assertEquals(6000, mCmi.getPollRssiIntervalMsecs());
+ }
}