diff options
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/WifiInjector.java | 1 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/WifiMetrics.java | 16 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/WifiScoreCard.java | 25 | ||||
-rw-r--r-- | service/proto/src/metrics.proto | 9 |
4 files changed, 41 insertions, 10 deletions
diff --git a/service/java/com/android/server/wifi/WifiInjector.java b/service/java/com/android/server/wifi/WifiInjector.java index 6daca9066..85ccfd11f 100644 --- a/service/java/com/android/server/wifi/WifiInjector.java +++ b/service/java/com/android/server/wifi/WifiInjector.java @@ -264,6 +264,7 @@ public class WifiInjector { mFrameworkFacade, mContext, wifiHandler); String l2KeySeed = Secure.getString(mContext.getContentResolver(), Secure.ANDROID_ID); mWifiScoreCard = new WifiScoreCard(mClock, l2KeySeed, mDeviceConfigFacade); + mWifiMetrics.setWifiScoreCard(mWifiScoreCard); mLruConnectionTracker = new LruConnectionTracker(MAX_RECENTLY_CONNECTED_NETWORK, mContext); // Config Manager diff --git a/service/java/com/android/server/wifi/WifiMetrics.java b/service/java/com/android/server/wifi/WifiMetrics.java index ad5af9451..9a75a5f45 100644 --- a/service/java/com/android/server/wifi/WifiMetrics.java +++ b/service/java/com/android/server/wifi/WifiMetrics.java @@ -204,6 +204,7 @@ public class WifiMetrics { private WifiDataStall mWifiDataStall; private WifiLinkLayerStats mLastLinkLayerStats; private WifiHealthMonitor mWifiHealthMonitor; + private WifiScoreCard mWifiScoreCard; private String mLastBssid; private int mLastFrequency = -1; private int mSeqNumInsideFramework = 0; @@ -979,6 +980,8 @@ public class WifiMetrics { sb.append("CREATOR_CARRIER"); break; } + sb.append(", numConsecutiveConnectionFailure=" + + mConnectionEvent.numConsecutiveConnectionFailure); } return sb.toString(); } @@ -1134,6 +1137,11 @@ public class WifiMetrics { mWifiHealthMonitor = wifiHealthMonitor; } + /** Sets internal WifiScoreCard member */ + public void setWifiScoreCard(WifiScoreCard wifiScoreCard) { + mWifiScoreCard = wifiScoreCard; + } + /** * Increment cumulative counters for link layer stats. * @param newStats @@ -1393,6 +1401,14 @@ public class WifiMetrics { mCurrentConnectionEvent.mConnectionEvent.networkCreator = WifiMetricsProto.ConnectionEvent.CREATOR_UNKNOWN; } + + mCurrentConnectionEvent.mConnectionEvent.screenOn = mScreenOn; + if (mCurrentConnectionEvent.mConfigSsid != null) { + WifiScoreCard.NetworkConnectionStats recentStats = mWifiScoreCard.lookupNetwork( + mCurrentConnectionEvent.mConfigSsid).getRecentStats(); + mCurrentConnectionEvent.mConnectionEvent.numConsecutiveConnectionFailure = + recentStats.getCount(WifiScoreCard.CNT_CONSECUTIVE_CONNECTION_FAILURE); + } } } } diff --git a/service/java/com/android/server/wifi/WifiScoreCard.java b/service/java/com/android/server/wifi/WifiScoreCard.java index 61a8435ed..4f12470e0 100644 --- a/service/java/com/android/server/wifi/WifiScoreCard.java +++ b/service/java/com/android/server/wifi/WifiScoreCard.java @@ -838,6 +838,7 @@ public class WifiScoreCard { if (rssi >= mDeviceConfigFacade.getHealthMonitorMinRssiThrDbm()) { if (failureReason != BssidBlocklistMonitor.REASON_WRONG_PASSWORD) { mRecentStats.incrementCount(CNT_CONNECTION_FAILURE); + mRecentStats.incrementCount(CNT_CONSECUTIVE_CONNECTION_FAILURE); } switch (failureReason) { case BssidBlocklistMonitor.REASON_AP_UNABLE_TO_HANDLE_NEW_STA: @@ -904,6 +905,9 @@ public class WifiScoreCard { } } } + // Reset CNT_CONSECUTIVE_CONNECTION_FAILURE here so that it can report the correct + // failure count after a connection success + mRecentStats.clearCount(CNT_CONSECUTIVE_CONNECTION_FAILURE); mConnectionSessionStartTimeMs = TS_NONE; mLastRssiPollTimeMs = TS_NONE; } @@ -1225,8 +1229,9 @@ public class WifiScoreCard { public static final int CNT_SHORT_CONNECTION_NONLOCAL = 6; public static final int CNT_DISCONNECTION_NONLOCAL = 7; public static final int CNT_DISCONNECTION = 8; + public static final int CNT_CONSECUTIVE_CONNECTION_FAILURE = 9; // Constant being used to keep track of how many counter there are. - public static final int NUMBER_CONNECTION_CNT_CODE = 9; + public static final int NUMBER_CONNECTION_CNT_CODE = 10; private static final String[] CONNECTION_CNT_NAME = { " ConnectAttempt: ", " ConnectFailure: ", @@ -1236,7 +1241,8 @@ public class WifiScoreCard { " AuthFailure: ", " ShortDiscNonlocal: ", " DisconnectNonlocal: ", - " Disconnect: " + " Disconnect: ", + " ConsecutiveConnectFailure: " }; @IntDef(prefix = { "CNT_" }, value = { @@ -1248,7 +1254,8 @@ public class WifiScoreCard { CNT_AUTHENTICATION_FAILURE, CNT_SHORT_CONNECTION_NONLOCAL, CNT_DISCONNECTION_NONLOCAL, - CNT_DISCONNECTION + CNT_DISCONNECTION, + CNT_CONSECUTIVE_CONNECTION_FAILURE }) @Retention(RetentionPolicy.SOURCE) public @interface ConnectionCountCode {} @@ -1290,13 +1297,11 @@ public class WifiScoreCard { } /** - * Set counter value - * @param countCode is the selected counter - * @param cnt is the value set to the selected counter + * Clear counter value + * @param countCode is the selected counter to be cleared */ - public void setCount(@ConnectionCountCode int countCode, int cnt) { - mCount[countCode] = cnt; - mRecentCountCode = countCode; + public void clearCount(@ConnectionCountCode int countCode) { + mCount[countCode] = 0; } /** @@ -1309,7 +1314,7 @@ public class WifiScoreCard { } /** - * Got the recent count code + * Got the recent incremented count code */ public int getRecentCountCode() { return mRecentCountCode; diff --git a/service/proto/src/metrics.proto b/service/proto/src/metrics.proto index 12fc7bcc0..1c9ea37d8 100644 --- a/service/proto/src/metrics.proto +++ b/service/proto/src/metrics.proto @@ -1016,6 +1016,15 @@ message ConnectionEvent { // UID of the app that created this network. optional NetworkCreator network_creator = 17; + + // Whether the screen is on when the connection event starts + optional bool screen_on = 18; + + // Number of consecutive connection failures with the same SSID at high RSSI + // before current connection event. Any connection failure at low RSSI in the + // middle won't break the streak count. The count is cleared after + // a network disconnection event. + optional int32 num_consecutive_connection_failure = 19 [default = -1]; } // Number of occurrences of a specific RSSI poll rssi value |