summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--service/java/com/android/server/wifi/WifiMetrics.java62
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java64
2 files changed, 74 insertions, 52 deletions
diff --git a/service/java/com/android/server/wifi/WifiMetrics.java b/service/java/com/android/server/wifi/WifiMetrics.java
index 125cd0987..ffe76afe9 100644
--- a/service/java/com/android/server/wifi/WifiMetrics.java
+++ b/service/java/com/android/server/wifi/WifiMetrics.java
@@ -63,6 +63,7 @@ import com.android.server.wifi.nano.WifiMetricsProto.LinkProbeStats;
import com.android.server.wifi.nano.WifiMetricsProto.LinkProbeStats.LinkProbeFailureReasonCount;
import com.android.server.wifi.nano.WifiMetricsProto.LinkSpeedCount;
import com.android.server.wifi.nano.WifiMetricsProto.NetworkSelectionExperimentDecisions;
+import com.android.server.wifi.nano.WifiMetricsProto.PasspointProfileTypeCount;
import com.android.server.wifi.nano.WifiMetricsProto.PasspointProvisionStats;
import com.android.server.wifi.nano.WifiMetricsProto.PasspointProvisionStats.ProvisionFailureCount;
import com.android.server.wifi.nano.WifiMetricsProto.PnoScanMetrics;
@@ -276,7 +277,8 @@ public class WifiMetrics {
private final SparseIntArray mAvailableSavedPasspointProviderBssidsInScanHistogram =
new SparseIntArray();
- private final SparseIntArray mInstalledPasspointProfileType = new SparseIntArray();
+ private final IntCounter mInstalledPasspointProfileTypeForR1 = new IntCounter();
+ private final IntCounter mInstalledPasspointProfileTypeForR2 = new IntCounter();
/** Mapping of "Connect to Network" notifications to counts. */
private final SparseIntArray mConnectToNetworkNotificationCount = new SparseIntArray();
@@ -2535,12 +2537,10 @@ public class WifiMetrics {
pw.println("mWifiLogProto.numPasspointProvidersSuccessfullyConnected="
+ mWifiLogProto.numPasspointProvidersSuccessfullyConnected);
- pw.println("mWifiLogProto.installedPasspointProfileType: ");
- for (int i = 0; i < mInstalledPasspointProfileType.size(); i++) {
- int eapType = mInstalledPasspointProfileType.keyAt(i);
- pw.println("EAP_METHOD (" + eapType + "): "
- + mInstalledPasspointProfileType.valueAt(i));
- }
+ pw.println("mWifiLogProto.installedPasspointProfileTypeForR1:"
+ + mInstalledPasspointProfileTypeForR1);
+ pw.println("mWifiLogProto.installedPasspointProfileTypeForR2:"
+ + mInstalledPasspointProfileTypeForR2);
pw.println("mWifiLogProto.passpointProvisionStats.numProvisionSuccess="
+ mNumProvisionSuccess);
@@ -2907,7 +2907,8 @@ public class WifiMetrics {
int eapType;
PasspointConfiguration config;
synchronized (mLock) {
- mInstalledPasspointProfileType.clear();
+ mInstalledPasspointProfileTypeForR1.clear();
+ mInstalledPasspointProfileTypeForR2.clear();
for (Map.Entry<String, PasspointProvider> entry : providers.entrySet()) {
config = entry.getValue().getConfig();
if (config.getCredential().getUserCredential() != null) {
@@ -2940,8 +2941,11 @@ public class WifiMetrics {
passpointType = WifiMetricsProto.PasspointProfileTypeCount.TYPE_UNKNOWN;
}
- int count = mInstalledPasspointProfileType.get(passpointType);
- mInstalledPasspointProfileType.put(passpointType, count + 1);
+ if (config.validateForR2()) {
+ mInstalledPasspointProfileTypeForR2.increment(passpointType);
+ } else {
+ mInstalledPasspointProfileTypeForR1.increment(passpointType);
+ }
}
}
}
@@ -3157,21 +3161,10 @@ public class WifiMetrics {
notificationActionCountArray[i] = keyVal;
}
- /**
- * Convert the SparseIntArray of saved Passpoint profile types and counts to proto's
- * repeated IntKeyVal array.
- */
- int counts = mInstalledPasspointProfileType.size();
- mWifiLogProto.installedPasspointProfileType =
- new WifiMetricsProto.PasspointProfileTypeCount[counts];
- for (int i = 0; i < counts; i++) {
- mWifiLogProto.installedPasspointProfileType[i] =
- new WifiMetricsProto.PasspointProfileTypeCount();
- mWifiLogProto.installedPasspointProfileType[i].eapMethodType =
- mInstalledPasspointProfileType.keyAt(i);
- mWifiLogProto.installedPasspointProfileType[i].count =
- mInstalledPasspointProfileType.valueAt(i);
- }
+ mWifiLogProto.installedPasspointProfileTypeForR1 =
+ convertPasspointProfilesToProto(mInstalledPasspointProfileTypeForR1);
+ mWifiLogProto.installedPasspointProfileTypeForR2 =
+ convertPasspointProfilesToProto(mInstalledPasspointProfileTypeForR2);
mWifiLogProto.connectToNetworkNotificationActionCount = notificationActionCountArray;
@@ -3458,7 +3451,8 @@ public class WifiMetrics {
mWifiWakeMetrics.clear();
mObserved80211mcApInScanHistogram.clear();
mWifiIsUnusableList.clear();
- mInstalledPasspointProfileType.clear();
+ mInstalledPasspointProfileTypeForR1.clear();
+ mInstalledPasspointProfileTypeForR2.clear();
mWifiUsabilityStatsListGood.clear();
mWifiUsabilityStatsListBad.clear();
mWifiUsabilityStatsEntriesList.clear();
@@ -4531,6 +4525,22 @@ public class WifiMetrics {
}
/**
+ * Convert the IntCounter of passpoint profile types and counts to proto's
+ * repeated IntKeyVal array.
+ *
+ * @param passpointProfileTypes passpoint profile types and counts.
+ */
+ private PasspointProfileTypeCount[] convertPasspointProfilesToProto(
+ IntCounter passpointProfileTypes) {
+ return passpointProfileTypes.toProto(PasspointProfileTypeCount.class, (key, count) -> {
+ PasspointProfileTypeCount entry = new PasspointProfileTypeCount();
+ entry.eapMethodType = key;
+ entry.count = count;
+ return entry;
+ });
+ }
+
+ /**
* Reports that the device entered a new mobility state.
*
* @param newState the new device mobility state.
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
index 9b9f032ce..303f5b36e 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
@@ -530,12 +530,11 @@ public class WifiMetricsTest {
return testSavedNetworks;
}
- private PasspointProvider createMockProvider(int eapType) {
+ private PasspointProvider createMockProvider(int eapType, boolean validateForR2) {
PasspointProvider provider = mock(PasspointProvider.class);
- PasspointConfiguration config = new PasspointConfiguration();
+ PasspointConfiguration config = mock(PasspointConfiguration.class);
Credential credential = new Credential();
- config.setCredential(credential);
switch (eapType) {
case EAPConstants.EAP_TLS:
credential.setCertCredential(new Credential.CertificateCredential());
@@ -552,6 +551,8 @@ public class WifiMetricsTest {
break;
}
when(provider.getConfig()).thenReturn(config);
+ when(config.getCredential()).thenReturn(credential);
+ when(config.validateForR2()).thenReturn(validateForR2);
return provider;
}
@@ -567,7 +568,10 @@ public class WifiMetricsTest {
int eapType = SAVED_PASSPOINT_PROVIDERS_TYPE.keyAt(i);
int count = SAVED_PASSPOINT_PROVIDERS_TYPE.valueAt(i);
for (int j = 0; j < count; j++) {
- providers.put(Integer.toString(eapType) + j, createMockProvider(eapType));
+ providers.put(Integer.toString(eapType) + j, createMockProvider(eapType, false));
+ }
+ for (int j = count; j < count * 2; j++) {
+ providers.put(Integer.toString(eapType) + j, createMockProvider(eapType, true));
}
}
mWifiMetrics.updateSavedPasspointProfilesInfo(providers);
@@ -1124,28 +1128,8 @@ public class WifiMetricsTest {
assertEquals(NUM_CLIENT_INTERFACE_DOWN, mDecodedProto.numClientInterfaceDown);
assertEquals(NUM_SOFTAP_INTERFACE_DOWN, mDecodedProto.numSoftApInterfaceDown);
assertEquals(NUM_PASSPOINT_PROVIDERS, mDecodedProto.numPasspointProviders);
- for (PasspointProfileTypeCount passpointProfileType : mDecodedProto
- .installedPasspointProfileType) {
- switch(passpointProfileType.eapMethodType) {
- case PasspointProfileTypeCount.TYPE_EAP_AKA:
- assertEquals(NUM_EAP_AKA_TYPE, passpointProfileType.count);
- break;
- case PasspointProfileTypeCount.TYPE_EAP_AKA_PRIME:
- assertEquals(NUM_EAP_AKA_PRIME_TYPE, passpointProfileType.count);
- break;
- case PasspointProfileTypeCount.TYPE_EAP_SIM:
- assertEquals(NUM_EAP_SIM_TYPE, passpointProfileType.count);
- break;
- case PasspointProfileTypeCount.TYPE_EAP_TLS:
- assertEquals(NUM_EAP_TLS_TYPE, passpointProfileType.count);
- break;
- case PasspointProfileTypeCount.TYPE_EAP_TTLS:
- assertEquals(NUM_EAP_TTLS_TYPE, passpointProfileType.count);
- break;
- default:
- fail("unknown type counted");
- }
- }
+ assertPasspointProfileTypeCount(mDecodedProto.installedPasspointProfileTypeForR1);
+ assertPasspointProfileTypeCount(mDecodedProto.installedPasspointProfileTypeForR2);
assertEquals(NUM_PASSPOINT_PROVIDER_INSTALLATION,
mDecodedProto.numPasspointProviderInstallation);
assertEquals(NUM_PASSPOINT_PROVIDER_INSTALL_SUCCESS,
@@ -3929,4 +3913,32 @@ public class WifiMetricsTest {
stats2 = nextRandomStats(stats2);
return stats2;
}
+
+ /**
+ * Verify the counts of passpoint profile type are correct.
+ * @param profileTypes type and count of installed passpoint profiles
+ */
+ private void assertPasspointProfileTypeCount(PasspointProfileTypeCount[] profileTypes) {
+ for (PasspointProfileTypeCount passpointProfileType : profileTypes) {
+ switch(passpointProfileType.eapMethodType) {
+ case PasspointProfileTypeCount.TYPE_EAP_AKA:
+ assertEquals(NUM_EAP_AKA_TYPE, passpointProfileType.count);
+ break;
+ case PasspointProfileTypeCount.TYPE_EAP_AKA_PRIME:
+ assertEquals(NUM_EAP_AKA_PRIME_TYPE, passpointProfileType.count);
+ break;
+ case PasspointProfileTypeCount.TYPE_EAP_SIM:
+ assertEquals(NUM_EAP_SIM_TYPE, passpointProfileType.count);
+ break;
+ case PasspointProfileTypeCount.TYPE_EAP_TLS:
+ assertEquals(NUM_EAP_TLS_TYPE, passpointProfileType.count);
+ break;
+ case PasspointProfileTypeCount.TYPE_EAP_TTLS:
+ assertEquals(NUM_EAP_TTLS_TYPE, passpointProfileType.count);
+ break;
+ default:
+ fail("unknown type counted");
+ }
+ }
+ }
}