summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorxshu <xshu@google.com>2020-08-17 19:31:28 -0700
committerxshu <xshu@google.com>2020-09-02 16:31:02 -0700
commit6aa15665ac75806ff5c688cff47e8dd671130b1f (patch)
treea32a3d18ed81128c372e4776e072e0f1575e986b /service
parent4036c533b3da963ef103a923037ca944e3c283ea (diff)
Add WifiStatus to UserAction metrics
(cherry-picked from c53ba0980a30bf07a73dc56743183315c0b70041) Include a snapshot of latest wifi status in the UserActionEvent. Updated-PDD: true Bug: 165118962 Test: atest com.android.server.wifi Change-Id: I21b617a520c11babfc39fa8d0103900fd78ea270 Merged-In: I21b617a520c11babfc39fa8d0103900fd78ea270
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiMetrics.java82
-rw-r--r--service/proto/src/metrics.proto23
2 files changed, 101 insertions, 4 deletions
diff --git a/service/java/com/android/server/wifi/WifiMetrics.java b/service/java/com/android/server/wifi/WifiMetrics.java
index cfc06b5b5..a5771f7e3 100644
--- a/service/java/com/android/server/wifi/WifiMetrics.java
+++ b/service/java/com/android/server/wifi/WifiMetrics.java
@@ -92,6 +92,7 @@ import com.android.server.wifi.proto.nano.WifiMetricsProto.WifiLockStats;
import com.android.server.wifi.proto.nano.WifiMetricsProto.WifiNetworkRequestApiLog;
import com.android.server.wifi.proto.nano.WifiMetricsProto.WifiNetworkSuggestionApiLog;
import com.android.server.wifi.proto.nano.WifiMetricsProto.WifiNetworkSuggestionApiLog.SuggestionAppCount;
+import com.android.server.wifi.proto.nano.WifiMetricsProto.WifiStatus;
import com.android.server.wifi.proto.nano.WifiMetricsProto.WifiToggleStats;
import com.android.server.wifi.proto.nano.WifiMetricsProto.WifiUsabilityStats;
import com.android.server.wifi.proto.nano.WifiMetricsProto.WifiUsabilityStatsEntry;
@@ -232,6 +233,7 @@ public class WifiMetrics {
@VisibleForTesting static final int MAX_USER_ACTION_EVENTS = 200;
private LinkedList<StaEventWithTime> mStaEventList = new LinkedList<>();
private LinkedList<UserActionEventWithTime> mUserActionEventList = new LinkedList<>();
+ private WifiStatusBuilder mWifiStatusBuilder = new WifiStatusBuilder();
private int mLastPollRssi = -127;
private int mLastPollLinkSpeed = -1;
private int mLastPollRxLinkSpeed = -1;
@@ -753,6 +755,59 @@ public class WifiMetrics {
}
}
+ class WifiStatusBuilder {
+ private int mNetworkId = WifiConfiguration.INVALID_NETWORK_ID;
+ private boolean mConnected;
+ private boolean mValidated;
+ private int mRssi;
+ private int mEstimatedTxKbps;
+ private int mEstimatedRxKbps;
+ private boolean mIsStuckDueToUserChoice;
+
+ public void setNetworkId(int networkId) {
+ mNetworkId = networkId;
+ }
+
+ public int getNetworkId() {
+ return mNetworkId;
+ }
+
+ public void setConnected(boolean connected) {
+ mConnected = connected;
+ }
+
+ public void setValidated(boolean validated) {
+ mValidated = validated;
+ }
+
+ public void setRssi(int rssi) {
+ mRssi = rssi;
+ }
+
+ public void setEstimatedTxKbps(int estimatedTxKbps) {
+ mEstimatedTxKbps = estimatedTxKbps;
+ }
+
+ public void setEstimatedRxKbps(int estimatedRxKbps) {
+ mEstimatedRxKbps = estimatedRxKbps;
+ }
+
+ public void setUserChoice(boolean userChoice) {
+ mIsStuckDueToUserChoice = userChoice;
+ }
+
+ public WifiStatus toProto() {
+ WifiStatus result = new WifiStatus();
+ result.isConnected = mConnected;
+ result.isValidated = mValidated;
+ result.lastRssi = mRssi;
+ result.estimatedTxKbps = mEstimatedTxKbps;
+ result.estimatedRxKbps = mEstimatedRxKbps;
+ result.isStuckDueToUserConnectChoice = mIsStuckDueToUserChoice;
+ return result;
+ }
+ }
+
class UserActionEventWithTime {
private UserActionEvent mUserActionEvent;
private long mWallClockTimeMs = 0; // wall clock time for debugging only
@@ -763,13 +818,11 @@ public class WifiMetrics {
mUserActionEvent.startTimeMillis = mClock.getElapsedSinceBootMillis();
mWallClockTimeMs = mClock.getWallClockMillis();
mUserActionEvent.targetNetworkInfo = targetNetworkInfo;
+ mUserActionEvent.wifiStatus = mWifiStatusBuilder.toProto();
}
UserActionEventWithTime(int eventType, int targetNetId) {
- mUserActionEvent = new UserActionEvent();
- mUserActionEvent.eventType = eventType;
- mUserActionEvent.startTimeMillis = mClock.getElapsedSinceBootMillis();
- mWallClockTimeMs = mClock.getWallClockMillis();
+ this(eventType, null);
if (targetNetId >= 0) {
WifiConfiguration config = mWifiConfigManager.getConfiguredNetwork(targetNetId);
if (config != null) {
@@ -835,6 +888,10 @@ public class WifiMetrics {
sb.append(" isEphemeral=").append(networkInfo.isEphemeral);
sb.append(" isPasspoint=").append(networkInfo.isPasspoint);
}
+ WifiStatus wifiStatus = mUserActionEvent.wifiStatus;
+ if (wifiStatus != null) {
+ sb.append("\nWifiStatus=" + wifiStatus.toString());
+ }
return sb.toString();
}
@@ -1610,6 +1667,7 @@ public class WifiMetrics {
if (!result) {
mScanResultRssiTimestampMillis = -1;
}
+ mWifiStatusBuilder.setConnected(result);
}
}
}
@@ -2087,6 +2145,8 @@ public class WifiMetrics {
mLastPollRxLinkSpeed = wifiInfo.getRxLinkSpeedMbps();
incrementTxLinkSpeedBandCount(mLastPollLinkSpeed, mLastPollFreq);
incrementRxLinkSpeedBandCount(mLastPollRxLinkSpeed, mLastPollFreq);
+ mWifiStatusBuilder.setRssi(mLastPollRssi);
+ mWifiStatusBuilder.setNetworkId(wifiInfo.getNetworkId());
}
/**
@@ -2262,6 +2322,8 @@ public class WifiMetrics {
mRxThroughputMbpsHistogramAbove2G.increment(rxThroughputKbps / 1000);
}
}
+ mWifiStatusBuilder.setEstimatedTxKbps(txThroughputKbps);
+ mWifiStatusBuilder.setEstimatedRxKbps(rxThroughputKbps);
}
}
@@ -4649,6 +4711,10 @@ public class WifiMetrics {
mWifiState = wifiState;
mWifiWins = (wifiState == WifiMetricsProto.WifiLog.WIFI_ASSOCIATED);
mWifiWinsUsabilityScore = (wifiState == WifiMetricsProto.WifiLog.WIFI_ASSOCIATED);
+ if (wifiState == WifiMetricsProto.WifiLog.WIFI_DISCONNECTED
+ || wifiState == WifiMetricsProto.WifiLog.WIFI_DISABLED) {
+ mWifiStatusBuilder = new WifiStatusBuilder();
+ }
}
}
@@ -4753,6 +4819,7 @@ public class WifiMetrics {
case StaEvent.TYPE_CMD_START_ROAM:
case StaEvent.TYPE_CONNECT_NETWORK:
case StaEvent.TYPE_NETWORK_AGENT_VALID_NETWORK:
+ mWifiStatusBuilder.setValidated(true);
case StaEvent.TYPE_FRAMEWORK_DISCONNECT:
case StaEvent.TYPE_SCORE_BREACH:
case StaEvent.TYPE_MAC_CHANGE:
@@ -6158,6 +6225,13 @@ public class WifiMetrics {
synchronized (mLock) {
if (networkId == WifiConfiguration.INVALID_NETWORK_ID) return;
mNetworkIdToNominatorId.put(networkId, nominatorId);
+
+ // user connect choice is preventing switcing off from the connected network
+ if (nominatorId
+ == WifiMetricsProto.ConnectionEvent.NOMINATOR_SAVED_USER_CONNECT_CHOICE
+ && mWifiStatusBuilder.getNetworkId() == networkId) {
+ mWifiStatusBuilder.setUserChoice(true);
+ }
}
}
diff --git a/service/proto/src/metrics.proto b/service/proto/src/metrics.proto
index c16ecfbba..a9c759e7e 100644
--- a/service/proto/src/metrics.proto
+++ b/service/proto/src/metrics.proto
@@ -3169,6 +3169,29 @@ message UserActionEvent {
// Additional information on the target network for the action. This is not applicable and will
// be null for some actions such as EVENT_TOGGLE_WIFI_ON.
optional TargetNetworkInfo target_network_info = 3;
+
+ // Information about the currently connected network.
+ optional WifiStatus wifi_status = 4;
+}
+
+message WifiStatus {
+ // Wifi is connected.
+ optional bool is_connected = 1;
+
+ // Wifi is validated
+ optional bool is_validated = 2;
+
+ // The last observed RSSI
+ optional sint32 last_rssi = 3;
+
+ // Estimated TX
+ optional int32 estimated_tx_kbps = 4;
+
+ // Estimated RX
+ optional int32 estimated_rx_kbps = 5;
+
+ // There is another candidate with better score, but user connect choice is preventing the switch.
+ optional bool is_stuck_due_to_user_connect_choice = 6;
}
// Additional information on a network