diff options
5 files changed, 57 insertions, 10 deletions
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 @@ -1744,6 +1744,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 */ public void incrementNonEmptyScanResultCount() { @@ -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 37f34639e..ac6f7fb63 100644 --- a/service/java/com/android/server/wifi/WifiServiceImpl.java +++ b/service/java/com/android/server/wifi/WifiServiceImpl.java @@ -3180,6 +3180,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) @@ -3191,11 +3205,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. @@ -3238,12 +3248,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. diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java index 191f81cee..0b9885c93 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java @@ -317,6 +317,8 @@ public class WifiMetricsTest extends WifiBaseTest { - NUM_NETWORKS_ADDED_BY_USER; private static final boolean TEST_VAL_IS_LOCATION_ENABLED = true; private static final boolean IS_SCANNING_ALWAYS_ENABLED = true; + private static final boolean IS_VERBOSE_LOGGING_ENABLED = true; + private static final boolean IS_ENHANCED_MAC_RANDOMIZATION_FORCE_ENABLED = true; private static final int NUM_EMPTY_SCAN_RESULTS = 19; private static final int NUM_NON_EMPTY_SCAN_RESULTS = 23; private static final int NUM_SCAN_UNKNOWN = 1; @@ -681,6 +683,9 @@ public class WifiMetricsTest extends WifiBaseTest { mWifiMetrics.setIsLocationEnabled(TEST_VAL_IS_LOCATION_ENABLED); mWifiMetrics.setIsScanningAlwaysEnabled(IS_SCANNING_ALWAYS_ENABLED); + mWifiMetrics.setVerboseLoggingEnabled(IS_VERBOSE_LOGGING_ENABLED); + mWifiMetrics.setEnhancedMacRandomizationForceEnabled( + IS_ENHANCED_MAC_RANDOMIZATION_FORCE_ENABLED); for (int i = 0; i < NUM_EMPTY_SCAN_RESULTS; i++) { mWifiMetrics.incrementEmptyScanResultCount(); @@ -1153,6 +1158,9 @@ public class WifiMetricsTest extends WifiBaseTest { TEST_VAL_IS_LOCATION_ENABLED, mDecodedProto.isLocationEnabled); assertEquals("mDecodedProto.isScanningAlwaysEnabled == IS_SCANNING_ALWAYS_ENABLED", IS_SCANNING_ALWAYS_ENABLED, mDecodedProto.isScanningAlwaysEnabled); + assertEquals(IS_VERBOSE_LOGGING_ENABLED, mDecodedProto.isVerboseLoggingEnabled); + assertEquals(IS_ENHANCED_MAC_RANDOMIZATION_FORCE_ENABLED, + mDecodedProto.isEnhancedMacRandomizationForceEnabled); assertEquals("mDecodedProto.numEmptyScanResults == NUM_EMPTY_SCAN_RESULTS", NUM_EMPTY_SCAN_RESULTS, mDecodedProto.numEmptyScanResults); assertEquals("mDecodedProto.numNonEmptyScanResults == NUM_NON_EMPTY_SCAN_RESULTS", diff --git a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java index 619bf0975..ebd128666 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java @@ -510,6 +510,9 @@ public class WifiServiceImplTest extends WifiBaseTest { public void testWifiMetricsDump() { mWifiServiceImpl.dump(new FileDescriptor(), new PrintWriter(new StringWriter()), new String[]{mWifiMetrics.PROTO_DUMP_ARG}); + verify(mWifiMetrics).setEnhancedMacRandomizationForceEnabled(anyBoolean()); + verify(mWifiMetrics).setIsScanningAlwaysEnabled(anyBoolean()); + verify(mWifiMetrics).setVerboseLoggingEnabled(anyBoolean()); verify(mWifiMetrics) .dump(any(FileDescriptor.class), any(PrintWriter.class), any(String[].class)); verify(mClientModeImpl, never()) |