summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authormukesh agrawal <quiche@google.com>2017-06-06 16:12:30 -0700
committerMukesh Agrawal <quiche@google.com>2017-06-08 18:13:18 +0000
commit6fe5d5a2c296ba5f3b7b0492d5c8c1a0dccf5216 (patch)
tree556834e5a31555bd04cb95b1d5fed0cd4df8ab91 /service
parent12f18f1708c4d27388478230c03fd51a59e22f98 (diff)
add adb hooks for tweaking RSSI poll frequency
One of the significant power draws, when the screen is on, is the periodic RSSI poll (and, presumably, the associated link-layer stats fetch). Given this, we want to experiment with different RSSI poll intervals, to balance power vs. whatever benefit the RSSI / link-layer stats provide. So add adb commands which let a user get and set the RSSI poll frequency. Bug: 38342148 Test: tests/wifitests/runtest.sh (on bullhead) Test: manual (see below) 1. adb root 2. adb shell cmd wifi get-poll-rssi-interval-msecs WifiStateMachine.mPollRssiIntervalMsecs = 3000 3. turn on screen, wait 15 seconds 4. adb shell dumpsys wifi | grep CMD_RSSI_POLL -> expect one line like the following, every 3 seconds rec[80]: time=06-06 23:36:18.201 processed=L2ConnectedState org=ConnectedState dest=<null> what=131155(0x20053) !CMD_RSSI_POLL rt=618277/618277 4 0 "GoogleGuest" 9c:1c:12:e8:70:f2 rssi=-59 f=5500 sc=56 link=300 tx=0.0, 0.0, 0.0 rx=0.0 bcn=4463 [on:3085 tx:0 rx:3 period:111] from screen [on:25363 period:27771] score=56 5. adb shell cmd wifi set-poll-rssi-interval-msecs 10000 6. turn on screen, wait 30 secods 7. adb shell dumpsys wifi | grep CMD_RSSI_POLL -> expect one line like the following, every 10 seconds rec[104]: time=06-06 23:37:40.921 processed=L2ConnectedState org=ConnectedState dest=<null> what=131155(0x20053) CMD_RSSI_POLL rt=700997/700997 6 0 "GoogleGuest" 9c:1c:12:e8:70:f2 rssi=-62 f=5500 sc=56 link=270 tx=0.0, 0.0, 0.0 rx=0.0 bcn=4665 [on:0 tx:0 rx:0 period:1] from screen [on:0 period:3162] 8. adb shell cmd wifi set-poll-rssi-interval-msecs 0 -> Invalid argument to 'set-poll-rssi-interval-msecs' - must be a positive integer 9. adb shell cmd wifi set-poll-rssi-interval-msecs not-a-number -> Invalid argument to 'set-poll-rssi-interval-msecs' - must be a positive integer Change-Id: Ibb2268cef81ef986fd71f848e889a4d7a94b901d
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiShellCommand.java28
-rw-r--r--service/java/com/android/server/wifi/WifiStateMachine.java20
2 files changed, 43 insertions, 5 deletions
diff --git a/service/java/com/android/server/wifi/WifiShellCommand.java b/service/java/com/android/server/wifi/WifiShellCommand.java
index fc153d1fe..f4db178a8 100644
--- a/service/java/com/android/server/wifi/WifiShellCommand.java
+++ b/service/java/com/android/server/wifi/WifiShellCommand.java
@@ -75,6 +75,30 @@ public class WifiShellCommand extends ShellCommand {
pw.println("IPREACH_DISCONNECT state is "
+ mStateMachine.getIpReachabilityDisconnectEnabled());
return 0;
+ case "set-poll-rssi-interval-msecs":
+ int newPollIntervalMsecs;
+ try {
+ newPollIntervalMsecs = Integer.parseInt(getNextArgRequired());
+ } catch (NumberFormatException e) {
+ pw.println(
+ "Invalid argument to 'set-poll-rssi-interval-msecs' "
+ + "- must be a positive integer");
+ return -1;
+ }
+
+ if (newPollIntervalMsecs < 1) {
+ pw.println(
+ "Invalid argument to 'set-poll-rssi-interval-msecs' "
+ + "- must be a positive integer");
+ return -1;
+ }
+
+ mStateMachine.setPollRssiIntervalMsecs(newPollIntervalMsecs);
+ return 0;
+ case "get-poll-rssi-interval-msecs":
+ pw.println("WifiStateMachine.mPollRssiIntervalMsecs = "
+ + mStateMachine.getPollRssiIntervalMsecs());
+ return 0;
default:
return handleDefaultCommands(cmd);
}
@@ -104,6 +128,10 @@ public class WifiShellCommand extends ShellCommand {
pw.println(" Sets whether CMD_IP_REACHABILITY_LOST events should trigger disconnects.");
pw.println(" get-ipreach-disconnect");
pw.println(" Gets setting of CMD_IP_REACHABILITY_LOST events triggering disconnects.");
+ pw.println(" set-poll-rssi-interval-msecs <int>");
+ pw.println(" Sets the interval between RSSI polls to <int> milliseconds.");
+ pw.println(" get-poll-rssi-interval-msecs");
+ pw.println(" Gets current interval between RSSI polls, in milliseconds.");
pw.println();
}
}
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java
index 06da92545..89675b62d 100644
--- a/service/java/com/android/server/wifi/WifiStateMachine.java
+++ b/service/java/com/android/server/wifi/WifiStateMachine.java
@@ -284,6 +284,8 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
private boolean testNetworkDisconnect = false;
private boolean mEnableRssiPolling = false;
+ // Accessed via Binder thread ({get,set}PollRssiIntervalMsecs), and WifiStateMachine thread.
+ private volatile int mPollRssiIntervalMsecs = DEFAULT_POLL_RSSI_INTERVAL_MSECS;
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
@@ -311,7 +313,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
* Interval in milliseconds between polling for RSSI
* and linkspeed information
*/
- private static final int POLL_RSSI_INTERVAL_MSECS = 3000;
+ private static final int DEFAULT_POLL_RSSI_INTERVAL_MSECS = 3000;
/**
* Interval in milliseconds between receiving a disconnect event
@@ -379,6 +381,14 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
private long mLastDriverRoamAttempt = 0;
private WifiConfiguration targetWificonfiguration = null;
+ int getPollRssiIntervalMsecs() {
+ return mPollRssiIntervalMsecs;
+ }
+
+ void setPollRssiIntervalMsecs(int newPollIntervalMsecs) {
+ mPollRssiIntervalMsecs = newPollIntervalMsecs;
+ }
+
/**
* Method to clear {@link #mTargetRoamBSSID} and reset the the current connected network's
* bssid in wpa_supplicant after a roam/connect attempt.
@@ -5709,8 +5719,8 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
mWifiInfo, mNetworkAgent, mAggressiveHandover,
mWifiMetrics);
}
- sendMessageDelayed(obtainMessage(CMD_RSSI_POLL,
- mRssiPollToken, 0), POLL_RSSI_INTERVAL_MSECS);
+ sendMessageDelayed(obtainMessage(CMD_RSSI_POLL, mRssiPollToken, 0),
+ mPollRssiIntervalMsecs);
if (mVerboseLoggingEnabled) sendRssiChangeBroadcast(mWifiInfo.getRssi());
} else {
// Polling has completed
@@ -5727,8 +5737,8 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
if (mEnableRssiPolling) {
// First poll
fetchRssiLinkSpeedAndFrequencyNative();
- sendMessageDelayed(obtainMessage(CMD_RSSI_POLL,
- mRssiPollToken, 0), POLL_RSSI_INTERVAL_MSECS);
+ sendMessageDelayed(obtainMessage(CMD_RSSI_POLL, mRssiPollToken, 0),
+ mPollRssiIntervalMsecs);
}
break;
case WifiManager.RSSI_PKTCNT_FETCH: