summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--service/java/com/android/server/wifi/ClientModeImpl.java14
-rw-r--r--service/java/com/android/server/wifi/WifiMetrics.java68
-rw-r--r--service/proto/src/metrics.proto11
-rw-r--r--tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java9
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java17
5 files changed, 118 insertions, 1 deletions
diff --git a/service/java/com/android/server/wifi/ClientModeImpl.java b/service/java/com/android/server/wifi/ClientModeImpl.java
index 727676880..ac1c8d0b4 100644
--- a/service/java/com/android/server/wifi/ClientModeImpl.java
+++ b/service/java/com/android/server/wifi/ClientModeImpl.java
@@ -2965,6 +2965,20 @@ public class ClientModeImpl extends StateMachine {
}
}
+ if (configuration != null
+ && configuration.carrierId != TelephonyManager.UNKNOWN_CARRIER_ID) {
+ if (level2FailureCode == WifiMetrics.ConnectionEvent.FAILURE_NONE) {
+ mWifiMetrics.incrementNumOfCarrierWifiConnectionSuccess();
+ } else if (level2FailureCode
+ == WifiMetrics.ConnectionEvent.FAILURE_AUTHENTICATION_FAILURE
+ && level2FailureReason
+ != WifiMetricsProto.ConnectionEvent.AUTH_FAILURE_NONE) {
+ mWifiMetrics.incrementNumOfCarrierWifiConnectionAuthFailure();
+ } else {
+ mWifiMetrics.incrementNumOfCarrierWifiConnectionNonAuthFailure();
+ }
+ }
+
boolean isAssociationRejection = level2FailureCode
== WifiMetrics.ConnectionEvent.FAILURE_ASSOCIATION_REJECTION;
boolean isAuthenticationFailure = level2FailureCode
diff --git a/service/java/com/android/server/wifi/WifiMetrics.java b/service/java/com/android/server/wifi/WifiMetrics.java
index 0559326b1..dbd532541 100644
--- a/service/java/com/android/server/wifi/WifiMetrics.java
+++ b/service/java/com/android/server/wifi/WifiMetrics.java
@@ -62,6 +62,7 @@ import com.android.server.wifi.hotspot2.Utils;
import com.android.server.wifi.p2p.WifiP2pMetrics;
import com.android.server.wifi.proto.WifiStatsLog;
import com.android.server.wifi.proto.nano.WifiMetricsProto;
+import com.android.server.wifi.proto.nano.WifiMetricsProto.CarrierWifiMetrics;
import com.android.server.wifi.proto.nano.WifiMetricsProto.ConnectToNetworkNotificationAndActionCount;
import com.android.server.wifi.proto.nano.WifiMetricsProto.DeviceMobilityStatePnoScanStats;
import com.android.server.wifi.proto.nano.WifiMetricsProto.ExperimentValues;
@@ -500,6 +501,9 @@ public class WifiMetrics {
private final SoftApConfigLimitationMetrics mSoftApConfigLimitationMetrics =
new SoftApConfigLimitationMetrics();
+ private final CarrierWifiMetrics mCarrierWifiMetrics =
+ new CarrierWifiMetrics();
+
@VisibleForTesting
static class NetworkSelectionExperimentResults {
public static final int MAX_CHOICES = 10;
@@ -1185,6 +1189,38 @@ public class WifiMetrics {
}
}
+ class CarrierWifiMetrics {
+ public int numConnectionSuccess = 0;
+ public int numConnectionAuthFailure = 0;
+ public int numConnectionNonAuthFailure = 0;
+
+ public WifiMetricsProto.CarrierWifiMetrics toProto() {
+ WifiMetricsProto.CarrierWifiMetrics proto =
+ new WifiMetricsProto.CarrierWifiMetrics();
+ proto.numConnectionSuccess = numConnectionSuccess;
+ proto.numConnectionAuthFailure = numConnectionAuthFailure;
+ proto.numConnectionNonAuthFailure = numConnectionNonAuthFailure;
+ return proto;
+ }
+
+ public void clear() {
+ numConnectionSuccess = 0;
+ numConnectionAuthFailure = 0;
+ numConnectionNonAuthFailure = 0;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("numConnectionSuccess=")
+ .append(numConnectionSuccess)
+ .append(", numConnectionAuthFailure=")
+ .append(numConnectionAuthFailure)
+ .append(", numConnectionNonAuthFailure")
+ .append(numConnectionNonAuthFailure);
+ return sb.toString();
+ }
+ }
public WifiMetrics(Context context, FrameworkFacade facade, Clock clock, Looper looper,
WifiAwareMetrics awareMetrics, RttMetrics rttMetrics,
@@ -3646,6 +3682,8 @@ public class WifiMetrics {
+ mTxThroughputMbpsHistogramAbove2G);
pw.println("mRxThroughputMbpsHistogramAbove2G:\n"
+ mRxThroughputMbpsHistogramAbove2G);
+ pw.println("mCarrierWifiMetrics:\n"
+ + mCarrierWifiMetrics);
dumpInitPartialScanMetrics(pw);
}
@@ -4321,6 +4359,8 @@ public class WifiMetrics {
initialPartialScanStats.failedScanChannelCountHistogram =
mInitPartialScanFailureHistogram.toProto();
mWifiLogProto.initPartialScanStats = initialPartialScanStats;
+
+ mWifiLogProto.carrierWifiMetrics = mCarrierWifiMetrics.toProto();
}
}
@@ -4538,6 +4578,7 @@ public class WifiMetrics {
mInitPartialScanFailureCount = 0;
mInitPartialScanSuccessHistogram.clear();
mInitPartialScanFailureHistogram.clear();
+ mCarrierWifiMetrics.clear();
}
}
@@ -6461,4 +6502,31 @@ public class WifiMetrics {
mWifiLogProto.numBssidDifferentSelectionBetweenFrameworkAndFirmware++;
}
}
+
+ /**
+ * Note the carrier wifi network connected successfully.
+ */
+ public void incrementNumOfCarrierWifiConnectionSuccess() {
+ synchronized (mLock) {
+ mCarrierWifiMetrics.numConnectionSuccess++;
+ }
+ }
+
+ /**
+ * Note the carrier wifi network connection authentication failure.
+ */
+ public void incrementNumOfCarrierWifiConnectionAuthFailure() {
+ synchronized (mLock) {
+ mCarrierWifiMetrics.numConnectionAuthFailure++;
+ }
+ }
+
+ /**
+ * Note the carrier wifi network connection non-authentication failure.
+ */
+ public void incrementNumOfCarrierWifiConnectionNonAuthFailure() {
+ synchronized (mLock) {
+ mCarrierWifiMetrics.numConnectionNonAuthFailure++;
+ }
+ }
}
diff --git a/service/proto/src/metrics.proto b/service/proto/src/metrics.proto
index 8755271f7..eaea7342b 100644
--- a/service/proto/src/metrics.proto
+++ b/service/proto/src/metrics.proto
@@ -709,6 +709,9 @@ message WifiLog {
// Number of connection with different BSSID between framework and firmware selection.
optional int32 num_bssid_different_selection_between_framework_and_firmware = 199;
+
+ // Metrics about carrier wifi network.
+ optional CarrierWifiMetrics carrier_wifi_metrics = 200;
}
// Information that gets logged for every WiFi connection.
@@ -3295,3 +3298,11 @@ message UserReactionToApprovalUiEvent {
// Event of user reaction to the carrier approval UI.
repeated UserReaction user_approval_carrier_ui_reaction = 2;
}
+
+message CarrierWifiMetrics {
+ // Number of successful network connection using Carrier ID
+ optional int32 num_connection_success = 1;
+ // Number of failed authentication from network connection using Carrier ID
+ optional int32 num_connection_auth_failure = 2;
+ optional int32 num_connection_non_auth_failure = 3;
+}
diff --git a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
index c3829be46..bb9db6d51 100644
--- a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
@@ -997,6 +997,8 @@ public class ClientModeImplTest extends WifiBaseTest {
@Test
public void connect() throws Exception {
triggerConnect();
+ WifiConfiguration config = mWifiConfigManager.getConfiguredNetwork(FRAMEWORK_NETWORK_ID);
+ config.carrierId = CARRIER_ID_1;
when(mWifiConfigManager.getScanDetailCacheForNetwork(FRAMEWORK_NETWORK_ID))
.thenReturn(mScanDetailCache);
@@ -1045,6 +1047,7 @@ public class ClientModeImplTest extends WifiBaseTest {
assertEquals("", mConnectedNetwork.enterpriseConfig.getAnonymousIdentity());
verify(mWifiStateTracker).updateState(eq(WifiStateTracker.CONNECTED));
assertEquals("ConnectedState", getCurrentState().getName());
+ verify(mWifiMetrics).incrementNumOfCarrierWifiConnectionSuccess();
verify(mWifiLockManager).updateWifiClientConnected(true);
verify(mWifiNative).getConnectionCapabilities(any());
verify(mThroughputPredictor).predictMaxTxThroughput(any());
@@ -1703,6 +1706,7 @@ public class ClientModeImplTest extends WifiBaseTest {
WifiConfiguration config = new WifiConfiguration();
config.SSID = sSSID;
config.getNetworkSelectionStatus().setHasEverConnected(false);
+ config.carrierId = CARRIER_ID_1;
when(mWifiConfigManager.getConfiguredNetwork(anyInt())).thenReturn(config);
mCmi.sendMessage(WifiMonitor.AUTHENTICATION_FAILURE_EVENT,
@@ -1712,7 +1716,7 @@ public class ClientModeImplTest extends WifiBaseTest {
verify(mWrongPasswordNotifier).onWrongPasswordError(eq(sSSID));
verify(mWifiConfigManager).updateNetworkSelectionStatus(anyInt(),
eq(WifiConfiguration.NetworkSelectionStatus.DISABLED_BY_WRONG_PASSWORD));
-
+ verify(mWifiMetrics).incrementNumOfCarrierWifiConnectionAuthFailure();
assertEquals("DisconnectedState", getCurrentState().getName());
}
@@ -3077,6 +3081,8 @@ public class ClientModeImplTest extends WifiBaseTest {
@Test
public void testAssociationRejectionUpdatesWatchdog() throws Exception {
initializeAndAddNetworkAndVerifySuccess();
+ WifiConfiguration config = mWifiConfigManager.getConfiguredNetwork(FRAMEWORK_NETWORK_ID);
+ config.carrierId = CARRIER_ID_1;
mCmi.sendMessage(ClientModeImpl.CMD_START_CONNECT, 0, 0, sBSSID);
mCmi.sendMessage(WifiMonitor.ASSOCIATION_REJECTION_EVENT, 0, 0, sBSSID);
mLooper.dispatchAll();
@@ -3084,6 +3090,7 @@ public class ClientModeImplTest extends WifiBaseTest {
anyString(), anyString(), anyInt());
verify(mBssidBlocklistMonitor).handleBssidConnectionFailure(sBSSID, sSSID,
BssidBlocklistMonitor.REASON_ASSOCIATION_REJECTION, false);
+ verify(mWifiMetrics).incrementNumOfCarrierWifiConnectionNonAuthFailure();
}
/**
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
index 67d0c82a7..fcaee0550 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
@@ -4975,4 +4975,21 @@ public class WifiMetricsTest extends WifiBaseTest {
assertEquals(0, mWifiMetrics.startConnectionEvent(mTestWifiConfig, "TestNetwork",
WifiMetricsProto.ConnectionEvent.ROAM_ENTERPRISE));
}
+
+ @Test
+ public void testCarrierWifiConnectionEvent() throws Exception {
+ mWifiMetrics.incrementNumOfCarrierWifiConnectionSuccess();
+ for (int i = 0; i < 2; i++) {
+ mWifiMetrics.incrementNumOfCarrierWifiConnectionAuthFailure();
+ }
+ for (int i = 0; i < 3; i++) {
+ mWifiMetrics.incrementNumOfCarrierWifiConnectionNonAuthFailure();
+ }
+
+ dumpProtoAndDeserialize();
+
+ assertEquals(1, mDecodedProto.carrierWifiMetrics.numConnectionSuccess);
+ assertEquals(2, mDecodedProto.carrierWifiMetrics.numConnectionAuthFailure);
+ assertEquals(3, mDecodedProto.carrierWifiMetrics.numConnectionNonAuthFailure);
+ }
}