summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorxshu <xshu@google.com>2019-04-04 17:35:50 -0700
committerxshu <xshu@google.com>2019-04-04 17:39:07 -0700
commitebdd2647be2f797295278ea2a6b7209bb4b65f45 (patch)
tree6829cf1365453801884ec81a11d5883c52c889e8 /service
parent89bce6ef926ea42e0b77b9098e8bb41b6568c4da (diff)
metrics for setWifiEnabled & legacy connection APIs
Goal is to caputure usage stats of these APIs to help track migration progress to new APIs. Bug: 129884654 Test: unit tests Test: manaually verify logs with "adb shell dumpsys wifi | grep -A 20 mWifiToggleStats" Change-Id: Ia329a54ec93ca1663dcd689adfee10c76a906aeb
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiMetrics.java38
-rw-r--r--service/java/com/android/server/wifi/WifiServiceImpl.java37
2 files changed, 58 insertions, 17 deletions
diff --git a/service/java/com/android/server/wifi/WifiMetrics.java b/service/java/com/android/server/wifi/WifiMetrics.java
index 5220cb201..9e5d4a2af 100644
--- a/service/java/com/android/server/wifi/WifiMetrics.java
+++ b/service/java/com/android/server/wifi/WifiMetrics.java
@@ -71,6 +71,7 @@ import com.android.server.wifi.nano.WifiMetricsProto.WifiLinkLayerUsageStats;
import com.android.server.wifi.nano.WifiMetricsProto.WifiLockStats;
import com.android.server.wifi.nano.WifiMetricsProto.WifiNetworkRequestApiLog;
import com.android.server.wifi.nano.WifiMetricsProto.WifiNetworkSuggestionApiLog;
+import com.android.server.wifi.nano.WifiMetricsProto.WifiToggleStats;
import com.android.server.wifi.nano.WifiMetricsProto.WifiUsabilityStats;
import com.android.server.wifi.nano.WifiMetricsProto.WifiUsabilityStatsEntry;
import com.android.server.wifi.nano.WifiMetricsProto.WpsMetrics;
@@ -372,6 +373,7 @@ public class WifiMetrics {
private final WifiLockStats mWifiLockStats = new WifiLockStats();
private static final int[] WIFI_LOCK_SESSION_DURATION_HISTOGRAM_BUCKETS =
{1, 10, 60, 600, 3600};
+ private final WifiToggleStats mWifiToggleStats = new WifiToggleStats();
private final IntHistogram mWifiLockHighPerfAcqDurationSecHistogram =
new IntHistogram(WIFI_LOCK_SESSION_DURATION_HISTOGRAM_BUCKETS);
@@ -2753,6 +2755,11 @@ public class WifiMetrics {
+ mWifiLockHighPerfActiveSessionDurationSecHistogram);
pw.println("mWifiLockLowLatencyActiveSessionDurationSecHistogram:\n"
+ mWifiLockLowLatencyActiveSessionDurationSecHistogram);
+ pw.println("mWifiToggleStats:\n" + mWifiToggleStats);
+ pw.println("mWifiLogProto.numAddOrUpdateNetworkCalls="
+ + mWifiLogProto.numAddOrUpdateNetworkCalls);
+ pw.println("mWifiLogProto.numEnableNetworkCalls="
+ + mWifiLogProto.numEnableNetworkCalls);
}
}
@@ -3281,6 +3288,7 @@ public class WifiMetrics {
mWifiLockLowLatencyActiveSessionDurationSecHistogram.toProto();
mWifiLogProto.wifiLockStats = mWifiLockStats;
+ mWifiLogProto.wifiToggleStats = mWifiToggleStats;
}
}
@@ -3462,6 +3470,7 @@ public class WifiMetrics {
mWifiLockHighPerfActiveSessionDurationSecHistogram.clear();
mWifiLockLowLatencyActiveSessionDurationSecHistogram.clear();
mWifiLockStats.clear();
+ mWifiToggleStats.clear();
}
}
@@ -4849,4 +4858,33 @@ public class WifiMetrics {
break;
}
}
+
+ /** Increments metrics counting number of addOrUpdateNetwork calls. **/
+ public void incrementNumAddOrUpdateNetworkCalls() {
+ synchronized (mLock) {
+ mWifiLogProto.numAddOrUpdateNetworkCalls++;
+ }
+ }
+
+ /** Increments metrics counting number of enableNetwork calls. **/
+ public void incrementNumEnableNetworkCalls() {
+ synchronized (mLock) {
+ mWifiLogProto.numEnableNetworkCalls++;
+ }
+ }
+
+ /** Add to WifiToggleStats **/
+ public void incrementNumWifiToggles(boolean isPrivileged, boolean enable) {
+ synchronized (mLock) {
+ if (isPrivileged && enable) {
+ mWifiToggleStats.numToggleOnPrivileged++;
+ } else if (isPrivileged && !enable) {
+ mWifiToggleStats.numToggleOffPrivileged++;
+ } else if (!isPrivileged && enable) {
+ mWifiToggleStats.numToggleOnNormal++;
+ } else {
+ mWifiToggleStats.numToggleOffNormal++;
+ }
+ }
+ }
}
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index 5a5bc1824..7a9f72440 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -908,6 +908,7 @@ public class WifiServiceImpl extends BaseWifiService {
} finally {
Binder.restoreCallingIdentity(ident);
}
+ mWifiMetrics.incrementNumWifiToggles(isPrivileged, enable);
mWifiController.sendMessage(CMD_WIFI_TOGGLED);
return true;
}
@@ -2039,6 +2040,12 @@ public class WifiServiceImpl extends BaseWifiService {
}
mLog.info("addOrUpdateNetwork uid=%").c(Binder.getCallingUid()).flush();
+ if (config == null) {
+ Slog.e(TAG, "bad network configuration");
+ return -1;
+ }
+ mWifiMetrics.incrementNumAddOrUpdateNetworkCalls();
+
// Previously, this API is overloaded for installing Passpoint profiles. Now
// that we have a dedicated API for doing it, redirect the call to the dedicated API.
if (config.isPasspoint()) {
@@ -2068,24 +2075,19 @@ public class WifiServiceImpl extends BaseWifiService {
return 0;
}
- if (config != null) {
- //TODO: pass the Uid the ClientModeImpl as a message parameter
- Slog.i("addOrUpdateNetwork", " uid = " + Integer.toString(Binder.getCallingUid())
- + " SSID " + config.SSID
- + " nid=" + Integer.toString(config.networkId));
- if (config.networkId == WifiConfiguration.INVALID_NETWORK_ID) {
- config.creatorUid = Binder.getCallingUid();
- } else {
- config.lastUpdateUid = Binder.getCallingUid();
- }
- if (mClientModeImplChannel != null) {
- return mClientModeImpl.syncAddOrUpdateNetwork(mClientModeImplChannel, config);
- } else {
- Slog.e(TAG, "mClientModeImplChannel is not initialized");
- return -1;
- }
+ //TODO: pass the Uid the ClientModeImpl as a message parameter
+ Slog.i("addOrUpdateNetwork", " uid = " + Integer.toString(Binder.getCallingUid())
+ + " SSID " + config.SSID
+ + " nid=" + Integer.toString(config.networkId));
+ if (config.networkId == WifiConfiguration.INVALID_NETWORK_ID) {
+ config.creatorUid = Binder.getCallingUid();
} else {
- Slog.e(TAG, "bad network configuration");
+ config.lastUpdateUid = Binder.getCallingUid();
+ }
+ if (mClientModeImplChannel != null) {
+ return mClientModeImpl.syncAddOrUpdateNetwork(mClientModeImplChannel, config);
+ } else {
+ Slog.e(TAG, "mClientModeImplChannel is not initialized");
return -1;
}
}
@@ -2154,6 +2156,7 @@ public class WifiServiceImpl extends BaseWifiService {
.c(Binder.getCallingUid())
.c(disableOthers).flush();
+ mWifiMetrics.incrementNumEnableNetworkCalls();
if (mClientModeImplChannel != null) {
return mClientModeImpl.syncEnableNetwork(mClientModeImplChannel, netId,
disableOthers);