summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiConfigManager.java24
-rw-r--r--service/java/com/android/server/wifi/WifiMetrics.java56
-rw-r--r--service/java/com/android/server/wifi/hotspot2/PasspointManager.java12
-rw-r--r--service/java/com/android/server/wifi/hotspot2/PasspointProvider.java6
-rw-r--r--service/proto/src/metrics.proto2
5 files changed, 95 insertions, 5 deletions
diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java
index 90c7f42c2..0fb7745f2 100644
--- a/service/java/com/android/server/wifi/WifiConfigManager.java
+++ b/service/java/com/android/server/wifi/WifiConfigManager.java
@@ -52,6 +52,7 @@ import android.util.Pair;
import com.android.internal.annotations.VisibleForTesting;
import com.android.server.wifi.hotspot2.PasspointManager;
+import com.android.server.wifi.proto.nano.WifiMetricsProto.UserActionEvent;
import com.android.server.wifi.util.LruConnectionTracker;
import com.android.server.wifi.util.MissingCounterTimerLockList;
import com.android.server.wifi.util.WifiPermissionsUtil;
@@ -1183,6 +1184,25 @@ public class WifiConfigManager {
return newInternalConfig;
}
+ private void logUserActionEvents(WifiConfiguration before, WifiConfiguration after) {
+ // Logs changes in meteredOverride.
+ if (before.meteredOverride != after.meteredOverride) {
+ mWifiInjector.getWifiMetrics().logUserActionEvent(
+ WifiMetrics.convertMeteredOverrideEnumToUserActionEventType(
+ after.meteredOverride),
+ after.networkId);
+ }
+
+ // Logs changes in macRandomizationSetting.
+ if (before.macRandomizationSetting != after.macRandomizationSetting) {
+ mWifiInjector.getWifiMetrics().logUserActionEvent(
+ after.macRandomizationSetting == WifiConfiguration.RANDOMIZATION_NONE
+ ? UserActionEvent.EVENT_CONFIGURE_MAC_RANDOMIZATION_OFF
+ : UserActionEvent.EVENT_CONFIGURE_MAC_RANDOMIZATION_ON,
+ after.networkId);
+ }
+ }
+
/**
* Add a network or update a network configuration to our database.
* If the supplied networkId is INVALID_NETWORK_ID, we create a new empty
@@ -1228,6 +1248,10 @@ public class WifiConfigManager {
+ config.getKey());
return new NetworkUpdateResult(WifiConfiguration.INVALID_NETWORK_ID);
}
+ if (mWifiPermissionsUtil.checkNetworkSettingsPermission(uid)
+ && !config.isPasspoint()) {
+ logUserActionEvents(existingInternalConfig, config);
+ }
newInternalConfig =
updateExistingInternalWifiConfigurationFromExternal(
existingInternalConfig, config, uid, packageName);
diff --git a/service/java/com/android/server/wifi/WifiMetrics.java b/service/java/com/android/server/wifi/WifiMetrics.java
index 7257bc224..f11a7f139 100644
--- a/service/java/com/android/server/wifi/WifiMetrics.java
+++ b/service/java/com/android/server/wifi/WifiMetrics.java
@@ -16,6 +16,8 @@
package com.android.server.wifi;
+import static android.net.wifi.WifiConfiguration.MeteredOverride;
+
import static java.lang.StrictMath.toIntExact;
import android.content.Context;
@@ -77,6 +79,7 @@ import com.android.server.wifi.proto.nano.WifiMetricsProto.PnoScanMetrics;
import com.android.server.wifi.proto.nano.WifiMetricsProto.SoftApConnectedClientsEvent;
import com.android.server.wifi.proto.nano.WifiMetricsProto.StaEvent;
import com.android.server.wifi.proto.nano.WifiMetricsProto.StaEvent.ConfigInfo;
+import com.android.server.wifi.proto.nano.WifiMetricsProto.TargetNetworkInfo;
import com.android.server.wifi.proto.nano.WifiMetricsProto.UserActionEvent;
import com.android.server.wifi.proto.nano.WifiMetricsProto.WifiIsUnusableEvent;
import com.android.server.wifi.proto.nano.WifiMetricsProto.WifiLinkLayerUsageStats;
@@ -734,6 +737,14 @@ public class WifiMetrics {
private UserActionEvent mUserActionEvent;
private long mWallClockTimeMs = 0; // wall clock time for debugging only
+ UserActionEventWithTime(int eventType, TargetNetworkInfo targetNetworkInfo) {
+ mUserActionEvent = new UserActionEvent();
+ mUserActionEvent.eventType = eventType;
+ mUserActionEvent.startTimeMillis = mClock.getElapsedSinceBootMillis();
+ mWallClockTimeMs = mClock.getWallClockMillis();
+ mUserActionEvent.targetNetworkInfo = targetNetworkInfo;
+ }
+
UserActionEventWithTime(int eventType, int targetNetId) {
mUserActionEvent = new UserActionEvent();
mUserActionEvent.eventType = eventType;
@@ -742,8 +753,7 @@ public class WifiMetrics {
if (targetNetId >= 0) {
WifiConfiguration config = mWifiConfigManager.getConfiguredNetwork(targetNetId);
if (config != null) {
- WifiMetricsProto.TargetNetworkInfo networkInfo =
- new WifiMetricsProto.TargetNetworkInfo();
+ TargetNetworkInfo networkInfo = new TargetNetworkInfo();
networkInfo.isEphemeral = config.isEphemeral();
networkInfo.isPasspoint = config.isPasspoint();
mUserActionEvent.targetNetworkInfo = networkInfo;
@@ -770,6 +780,9 @@ public class WifiMetrics {
case UserActionEvent.EVENT_CONFIGURE_METERED_STATUS_UNMETERED:
eventType = "EVENT_CONFIGURE_METERED_STATUS_UNMETERED";
break;
+ case UserActionEvent.EVENT_CONFIGURE_METERED_STATUS_AUTO:
+ eventType = "EVENT_CONFIGURE_METERED_STATUS_AUTO";
+ break;
case UserActionEvent.EVENT_CONFIGURE_MAC_RANDOMIZATION_ON:
eventType = "EVENT_CONFIGURE_MAC_RANDOMIZATION_ON";
break;
@@ -794,7 +807,7 @@ public class WifiMetrics {
}
sb.append(" eventType=").append(eventType);
sb.append(" startTimeMillis=").append(mUserActionEvent.startTimeMillis);
- WifiMetricsProto.TargetNetworkInfo networkInfo = mUserActionEvent.targetNetworkInfo;
+ TargetNetworkInfo networkInfo = mUserActionEvent.targetNetworkInfo;
if (networkInfo != null) {
sb.append(" isEphemeral=").append(networkInfo.isEphemeral);
sb.append(" isPasspoint=").append(networkInfo.isPasspoint);
@@ -5118,6 +5131,25 @@ public class WifiMetrics {
}
/**
+ * Converts MeteredOverride enum to UserActionEvent type.
+ * @param value
+ */
+ public static int convertMeteredOverrideEnumToUserActionEventType(@MeteredOverride int value) {
+ int result = UserActionEvent.EVENT_UNKNOWN;
+ switch(value) {
+ case WifiConfiguration.METERED_OVERRIDE_NONE:
+ result = UserActionEvent.EVENT_CONFIGURE_METERED_STATUS_AUTO;
+ break;
+ case WifiConfiguration.METERED_OVERRIDE_METERED:
+ result = UserActionEvent.EVENT_CONFIGURE_METERED_STATUS_METERED;
+ break;
+ case WifiConfiguration.METERED_OVERRIDE_NOT_METERED:
+ result = UserActionEvent.EVENT_CONFIGURE_METERED_STATUS_UNMETERED;
+ break;
+ }
+ return result;
+ }
+ /**
* Logs a UserActionEvent without a target network.
* @param eventType the type of user action (one of WifiMetricsProto.UserActionEvent.EventType)
*/
@@ -5140,6 +5172,24 @@ public class WifiMetrics {
}
/**
+ * Logs a UserActionEvent, directly specifying the target network's properties.
+ * @param eventType the type of user action (one of WifiMetricsProto.UserActionEvent.EventType)
+ * @param isEphemeral true if the target network is ephemeral.
+ * @param isPasspoint true if the target network is passpoint.
+ */
+ public void logUserActionEvent(int eventType, boolean isEphemeral, boolean isPasspoint) {
+ synchronized (mLock) {
+ TargetNetworkInfo networkInfo = new TargetNetworkInfo();
+ networkInfo.isEphemeral = isEphemeral;
+ networkInfo.isPasspoint = isPasspoint;
+ mUserActionEventList.add(new UserActionEventWithTime(eventType, networkInfo));
+ if (mUserActionEventList.size() > MAX_USER_ACTION_EVENTS) {
+ mUserActionEventList.remove();
+ }
+ }
+ }
+
+ /**
* Update the difference between the last two WifiLinkLayerStats for WifiIsUnusableEvent
*/
public void updateWifiIsUnusableLinkLayerStats(long txSuccessDelta, long txRetriesDelta,
diff --git a/service/java/com/android/server/wifi/hotspot2/PasspointManager.java b/service/java/com/android/server/wifi/hotspot2/PasspointManager.java
index b60ef3f63..ba89bce2c 100644
--- a/service/java/com/android/server/wifi/hotspot2/PasspointManager.java
+++ b/service/java/com/android/server/wifi/hotspot2/PasspointManager.java
@@ -65,6 +65,7 @@ import com.android.server.wifi.hotspot2.anqp.ANQPElement;
import com.android.server.wifi.hotspot2.anqp.Constants;
import com.android.server.wifi.hotspot2.anqp.HSOsuProvidersElement;
import com.android.server.wifi.hotspot2.anqp.OsuProviderInfo;
+import com.android.server.wifi.proto.nano.WifiMetricsProto.UserActionEvent;
import com.android.server.wifi.util.InformationElementUtil;
import java.io.IOException;
@@ -664,6 +665,10 @@ public class PasspointManager {
if (TextUtils.equals(provider.getConfig().getHomeSp().getFqdn(), fqdn)) {
boolean settingChanged = provider.setMacRandomizationEnabled(enable);
if (settingChanged) {
+ mWifiMetrics.logUserActionEvent(enable
+ ? UserActionEvent.EVENT_CONFIGURE_MAC_RANDOMIZATION_ON
+ : UserActionEvent.EVENT_CONFIGURE_MAC_RANDOMIZATION_OFF,
+ provider.isFromSuggestion(), true);
mWifiConfigManager.removePasspointConfiguredNetwork(
provider.getWifiConfig().getKey());
}
@@ -689,7 +694,12 @@ public class PasspointManager {
// Loop through all profiles with matching FQDN
for (PasspointProvider provider : passpointProviders) {
if (TextUtils.equals(provider.getConfig().getHomeSp().getFqdn(), fqdn)) {
- provider.setMeteredOverride(meteredOverride);
+ if (provider.setMeteredOverride(meteredOverride)) {
+ mWifiMetrics.logUserActionEvent(
+ WifiMetrics.convertMeteredOverrideEnumToUserActionEventType(
+ meteredOverride),
+ provider.isFromSuggestion(), true);
+ }
found = true;
}
}
diff --git a/service/java/com/android/server/wifi/hotspot2/PasspointProvider.java b/service/java/com/android/server/wifi/hotspot2/PasspointProvider.java
index 006b8eaef..45fa39502 100644
--- a/service/java/com/android/server/wifi/hotspot2/PasspointProvider.java
+++ b/service/java/com/android/server/wifi/hotspot2/PasspointProvider.java
@@ -241,9 +241,13 @@ public class PasspointProvider {
/**
* Get the metered override for this passpoint profile.
+ *
+ * @return true if the setting has changed
*/
- public void setMeteredOverride(@MeteredOverride int meteredOverride) {
+ public boolean setMeteredOverride(@MeteredOverride int meteredOverride) {
+ boolean changed = mConfig.getMeteredOverride() != meteredOverride;
mConfig.setMeteredOverride(meteredOverride);
+ return changed;
}
/**
diff --git a/service/proto/src/metrics.proto b/service/proto/src/metrics.proto
index 627c24529..669dd2e32 100644
--- a/service/proto/src/metrics.proto
+++ b/service/proto/src/metrics.proto
@@ -3103,6 +3103,8 @@ message UserActionEvent {
EVENT_TOGGLE_WIFI_OFF = 10;
// User manually connects to a network
EVENT_MANUAL_CONNECT = 11;
+ // User changes the metered setting to "detect automatically"
+ EVENT_CONFIGURE_METERED_STATUS_AUTO = 12;
}
// The type of user action