From 00355555f01550d6564908b503bc45daab3b47cb Mon Sep 17 00:00:00 2001 From: xshu Date: Thu, 23 Apr 2020 02:31:03 -0700 Subject: Settings toggle value metrics Collects metrics on status of the following toggles: - wifi verbose logging (developer option) - wifi scanning - enhanced MAC randomization (developer option) Bug: 153925826 Test: atest com.android.server.wifi Change-Id: I4538f4c4535b0c68a2234f60ecb5a4d9a860f9d4 --- .../java/com/android/server/wifi/WifiMetrics.java | 22 +++++++++++++++++ .../com/android/server/wifi/WifiServiceImpl.java | 28 ++++++++++++++-------- service/proto/src/metrics.proto | 6 +++++ 3 files changed, 46 insertions(+), 10 deletions(-) (limited to 'service') diff --git a/service/java/com/android/server/wifi/WifiMetrics.java b/service/java/com/android/server/wifi/WifiMetrics.java index f11a7f139..883203d2c 100644 --- a/service/java/com/android/server/wifi/WifiMetrics.java +++ b/service/java/com/android/server/wifi/WifiMetrics.java @@ -1743,6 +1743,24 @@ public class WifiMetrics { } } + /** + * Developer options toggle value for verbose logging. + */ + public void setVerboseLoggingEnabled(boolean enabled) { + synchronized (mLock) { + mWifiLogProto.isVerboseLoggingEnabled = enabled; + } + } + + /** + * Developer options toggle value for enhanced MAC randomization. + */ + public void setEnhancedMacRandomizationForceEnabled(boolean enabled) { + synchronized (mLock) { + mWifiLogProto.isEnhancedMacRandomizationForceEnabled = enabled; + } + } + /** * Increment Non Empty Scan Results count */ @@ -3107,6 +3125,10 @@ public class WifiMetrics { pw.println("mWifiLogProto.isLocationEnabled=" + mWifiLogProto.isLocationEnabled); pw.println("mWifiLogProto.isScanningAlwaysEnabled=" + mWifiLogProto.isScanningAlwaysEnabled); + pw.println("mWifiLogProto.isVerboseLoggingEnabled=" + + mWifiLogProto.isVerboseLoggingEnabled); + pw.println("mWifiLogProto.isEnhancedMacRandomizationForceEnabled=" + + mWifiLogProto.isEnhancedMacRandomizationForceEnabled); pw.println("mWifiLogProto.numNetworksAddedByUser=" + mWifiLogProto.numNetworksAddedByUser); pw.println("mWifiLogProto.numNetworksAddedByApps=" diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java index e6e5f2b36..38f626445 100644 --- a/service/java/com/android/server/wifi/WifiServiceImpl.java +++ b/service/java/com/android/server/wifi/WifiServiceImpl.java @@ -3182,6 +3182,20 @@ public class WifiServiceImpl extends BaseWifiService { args); } + private void updateWifiMetrics() { + mWifiThreadRunner.run(() -> { + mWifiMetrics.updateSavedNetworks( + mWifiConfigManager.getSavedNetworks(Process.WIFI_UID)); + mPasspointManager.updateMetrics(); + }); + boolean isEnhancedMacRandEnabled = mFrameworkFacade.getIntegerSetting(mContext, + WifiConfigManager.ENHANCED_MAC_RANDOMIZATION_FEATURE_FORCE_ENABLE_FLAG, 0) == 1 + ? true : false; + mWifiMetrics.setEnhancedMacRandomizationForceEnabled(isEnhancedMacRandEnabled); + mWifiMetrics.setIsScanningAlwaysEnabled(isScanAlwaysAvailable()); + mWifiMetrics.setVerboseLoggingEnabled(mVerboseLoggingEnabled); + } + @Override protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP) @@ -3193,11 +3207,7 @@ public class WifiServiceImpl extends BaseWifiService { } if (args != null && args.length > 0 && WifiMetrics.PROTO_DUMP_ARG.equals(args[0])) { // WifiMetrics proto bytes were requested. Dump only these. - mWifiThreadRunner.run(() -> { - mWifiMetrics.updateSavedNetworks( - mWifiConfigManager.getSavedNetworks(Process.WIFI_UID)); - mPasspointManager.updateMetrics(); - }); + updateWifiMetrics(); mWifiMetrics.dump(fd, pw, args); } else if (args != null && args.length > 0 && IpClientUtil.DUMP_ARG.equals(args[0])) { // IpClient dump was requested. Pass it along and take no further action. @@ -3240,12 +3250,10 @@ public class WifiServiceImpl extends BaseWifiService { wifiScoreCard.getNetworkListBase64(true), ""); pw.println("WifiScoreCard:"); pw.println(networkListBase64); - mWifiThreadRunner.run(() -> { - mWifiMetrics.updateSavedNetworks( - mWifiConfigManager.getSavedNetworks(Process.WIFI_UID)); - mPasspointManager.updateMetrics(); - }); + + updateWifiMetrics(); mWifiMetrics.dump(fd, pw, args); + pw.println(); mWifiThreadRunner.run(() -> mWifiNetworkSuggestionsManager.dump(fd, pw, args)); pw.println(); diff --git a/service/proto/src/metrics.proto b/service/proto/src/metrics.proto index 669dd2e32..2a8455235 100644 --- a/service/proto/src/metrics.proto +++ b/service/proto/src/metrics.proto @@ -687,6 +687,12 @@ message WifiLog { // List of user initiated actions repeated UserActionEvent user_action_events = 192; + + // Does the user have wifi verbose logging enabled. + optional bool is_verbose_logging_enabled = 193; + + // Does the user have enhanced MAC randomization forced to on. + optional bool is_enhanced_mac_randomization_force_enabled = 194; } // Information that gets logged for every WiFi connection. -- cgit v1.2.3