Include 6GHz in metrics and log

This commit includes the 6GHz band in tx/rx link speed metrics as well
as log for lowrssi.

Bug: 139354972
Test: atest FrameworksWifiTests
Change-Id: Ie70c7b905abe5c0a42b95ff02d519c2080eea180
Updated-PDD: TRUE
diff --git a/service/java/com/android/server/wifi/WifiMetrics.java b/service/java/com/android/server/wifi/WifiMetrics.java
index e23779e..a704f10 100644
--- a/service/java/com/android/server/wifi/WifiMetrics.java
+++ b/service/java/com/android/server/wifi/WifiMetrics.java
@@ -272,10 +272,17 @@
     private final IntCounter mTxLinkSpeedCount5gLow = new IntCounter();
     private final IntCounter mTxLinkSpeedCount5gMid = new IntCounter();
     private final IntCounter mTxLinkSpeedCount5gHigh = new IntCounter();
+    private final IntCounter mTxLinkSpeedCount6gLow = new IntCounter();
+    private final IntCounter mTxLinkSpeedCount6gMid = new IntCounter();
+    private final IntCounter mTxLinkSpeedCount6gHigh = new IntCounter();
+
     private final IntCounter mRxLinkSpeedCount2g = new IntCounter();
     private final IntCounter mRxLinkSpeedCount5gLow = new IntCounter();
     private final IntCounter mRxLinkSpeedCount5gMid = new IntCounter();
     private final IntCounter mRxLinkSpeedCount5gHigh = new IntCounter();
+    private final IntCounter mRxLinkSpeedCount6gLow = new IntCounter();
+    private final IntCounter mRxLinkSpeedCount6gMid = new IntCounter();
+    private final IntCounter mRxLinkSpeedCount6gHigh = new IntCounter();
 
     /** RSSI of the scan result for the last connection event*/
     private int mScanResultRssi = 0;
@@ -2159,8 +2166,14 @@
                 mTxLinkSpeedCount5gLow.increment(txLinkSpeed);
             } else if (frequency <= KnownBandsChannelHelper.BAND_5_GHZ_MID_END_FREQ) {
                 mTxLinkSpeedCount5gMid.increment(txLinkSpeed);
-            } else {
+            } else if (frequency <= KnownBandsChannelHelper.BAND_5_GHZ_HIGH_END_FREQ) {
                 mTxLinkSpeedCount5gHigh.increment(txLinkSpeed);
+            } else if (frequency <= KnownBandsChannelHelper.BAND_6_GHZ_LOW_END_FREQ) {
+                mTxLinkSpeedCount6gLow.increment(txLinkSpeed);
+            } else if (frequency <= KnownBandsChannelHelper.BAND_6_GHZ_MID_END_FREQ) {
+                mTxLinkSpeedCount6gMid.increment(txLinkSpeed);
+            } else if (frequency <= KnownBandsChannelHelper.BAND_6_GHZ_HIGH_END_FREQ) {
+                mTxLinkSpeedCount6gHigh.increment(txLinkSpeed);
             }
         }
     }
@@ -2184,8 +2197,14 @@
                 mRxLinkSpeedCount5gLow.increment(rxLinkSpeed);
             } else if (frequency <= KnownBandsChannelHelper.BAND_5_GHZ_MID_END_FREQ) {
                 mRxLinkSpeedCount5gMid.increment(rxLinkSpeed);
-            } else {
+            } else if (frequency <= KnownBandsChannelHelper.BAND_5_GHZ_HIGH_END_FREQ) {
                 mRxLinkSpeedCount5gHigh.increment(rxLinkSpeed);
+            } else if (frequency <= KnownBandsChannelHelper.BAND_6_GHZ_LOW_END_FREQ) {
+                mRxLinkSpeedCount6gLow.increment(rxLinkSpeed);
+            } else if (frequency <= KnownBandsChannelHelper.BAND_6_GHZ_MID_END_FREQ) {
+                mRxLinkSpeedCount6gMid.increment(rxLinkSpeed);
+            } else if (frequency <= KnownBandsChannelHelper.BAND_6_GHZ_HIGH_END_FREQ) {
+                mRxLinkSpeedCount6gHigh.increment(rxLinkSpeed);
             }
         }
     }
@@ -3656,10 +3675,18 @@
                 pw.println("mWifiLogProto.txLinkSpeedCount5gLow=" + mTxLinkSpeedCount5gLow);
                 pw.println("mWifiLogProto.txLinkSpeedCount5gMid=" + mTxLinkSpeedCount5gMid);
                 pw.println("mWifiLogProto.txLinkSpeedCount5gHigh=" + mTxLinkSpeedCount5gHigh);
+                pw.println("mWifiLogProto.txLinkSpeedCount6gLow=" + mTxLinkSpeedCount6gLow);
+                pw.println("mWifiLogProto.txLinkSpeedCount6gMid=" + mTxLinkSpeedCount6gMid);
+                pw.println("mWifiLogProto.txLinkSpeedCount6gHigh=" + mTxLinkSpeedCount6gHigh);
+
                 pw.println("mWifiLogProto.rxLinkSpeedCount2g=" + mRxLinkSpeedCount2g);
                 pw.println("mWifiLogProto.rxLinkSpeedCount5gLow=" + mRxLinkSpeedCount5gLow);
                 pw.println("mWifiLogProto.rxLinkSpeedCount5gMid=" + mRxLinkSpeedCount5gMid);
                 pw.println("mWifiLogProto.rxLinkSpeedCount5gHigh=" + mRxLinkSpeedCount5gHigh);
+                pw.println("mWifiLogProto.rxLinkSpeedCount6gLow=" + mRxLinkSpeedCount6gLow);
+                pw.println("mWifiLogProto.rxLinkSpeedCount6gMid=" + mRxLinkSpeedCount6gMid);
+                pw.println("mWifiLogProto.rxLinkSpeedCount6gHigh=" + mRxLinkSpeedCount6gHigh);
+
                 pw.println("mWifiLogProto.numIpRenewalFailure="
                         + mWifiLogProto.numIpRenewalFailure);
                 pw.println("mWifiLogProto.connectionDurationStats="
@@ -4116,9 +4143,9 @@
             for (int i = 0; i < mConnectToNetworkNotificationActionCount.size(); i++) {
                 ConnectToNetworkNotificationAndActionCount keyVal =
                         new ConnectToNetworkNotificationAndActionCount();
-                int key = mConnectToNetworkNotificationActionCount.keyAt(i);
-                keyVal.notification = key / CONNECT_TO_NETWORK_NOTIFICATION_ACTION_KEY_MULTIPLIER;
-                keyVal.action = key % CONNECT_TO_NETWORK_NOTIFICATION_ACTION_KEY_MULTIPLIER;
+                int k = mConnectToNetworkNotificationActionCount.keyAt(i);
+                keyVal.notification =  k / CONNECT_TO_NETWORK_NOTIFICATION_ACTION_KEY_MULTIPLIER;
+                keyVal.action = k % CONNECT_TO_NETWORK_NOTIFICATION_ACTION_KEY_MULTIPLIER;
                 keyVal.recommender =
                         ConnectToNetworkNotificationAndActionCount.RECOMMENDER_OPEN;
                 keyVal.count = mConnectToNetworkNotificationActionCount.valueAt(i);
@@ -4319,10 +4346,18 @@
             mWifiLogProto.txLinkSpeedCount5GLow = mTxLinkSpeedCount5gLow.toProto();
             mWifiLogProto.txLinkSpeedCount5GMid = mTxLinkSpeedCount5gMid.toProto();
             mWifiLogProto.txLinkSpeedCount5GHigh = mTxLinkSpeedCount5gHigh.toProto();
+            mWifiLogProto.txLinkSpeedCount6GLow = mTxLinkSpeedCount6gLow.toProto();
+            mWifiLogProto.txLinkSpeedCount6GMid = mTxLinkSpeedCount6gMid.toProto();
+            mWifiLogProto.txLinkSpeedCount6GHigh = mTxLinkSpeedCount6gHigh.toProto();
+
             mWifiLogProto.rxLinkSpeedCount2G = mRxLinkSpeedCount2g.toProto();
             mWifiLogProto.rxLinkSpeedCount5GLow = mRxLinkSpeedCount5gLow.toProto();
             mWifiLogProto.rxLinkSpeedCount5GMid = mRxLinkSpeedCount5gMid.toProto();
             mWifiLogProto.rxLinkSpeedCount5GHigh = mRxLinkSpeedCount5gHigh.toProto();
+            mWifiLogProto.rxLinkSpeedCount6GLow = mRxLinkSpeedCount6gLow.toProto();
+            mWifiLogProto.rxLinkSpeedCount6GMid = mRxLinkSpeedCount6gMid.toProto();
+            mWifiLogProto.rxLinkSpeedCount6GHigh = mRxLinkSpeedCount6gHigh.toProto();
+
             HealthMonitorMetrics healthMonitorMetrics = mWifiHealthMonitor.buildProto();
             if (healthMonitorMetrics != null) {
                 mWifiLogProto.healthMonitorMetrics = healthMonitorMetrics;
@@ -4468,10 +4503,16 @@
             mTxLinkSpeedCount5gLow.clear();
             mTxLinkSpeedCount5gMid.clear();
             mTxLinkSpeedCount5gHigh.clear();
+            mTxLinkSpeedCount6gLow.clear();
+            mTxLinkSpeedCount6gMid.clear();
+            mTxLinkSpeedCount6gHigh.clear();
             mRxLinkSpeedCount2g.clear();
             mRxLinkSpeedCount5gLow.clear();
             mRxLinkSpeedCount5gMid.clear();
             mRxLinkSpeedCount5gHigh.clear();
+            mRxLinkSpeedCount6gLow.clear();
+            mRxLinkSpeedCount6gMid.clear();
+            mRxLinkSpeedCount6gHigh.clear();
             mWifiAlertReasonCounts.clear();
             mWifiScoreCounts.clear();
             mWifiUsabilityScoreCounts.clear();
diff --git a/service/java/com/android/server/wifi/WifiNetworkSelector.java b/service/java/com/android/server/wifi/WifiNetworkSelector.java
index f59a50f..50078b6 100644
--- a/service/java/com/android/server/wifi/WifiNetworkSelector.java
+++ b/service/java/com/android/server/wifi/WifiNetworkSelector.java
@@ -400,9 +400,15 @@
 
             // Skip network with too weak signals.
             if (isSignalTooWeak(scanResult)) {
-                lowRssi.append(scanId).append("(")
-                        .append(scanResult.is24GHz() ? "2.4GHz" : "5GHz")
-                        .append(")").append(scanResult.level).append(" / ");
+                lowRssi.append(scanId);
+                if (scanResult.is24GHz()) {
+                    lowRssi.append("(2.4GHz)");
+                } else if (scanResult.is5GHz()) {
+                    lowRssi.append("(5GHz)");
+                } else if (scanResult.is6GHz()) {
+                    lowRssi.append("(6GHz)");
+                }
+                lowRssi.append(scanResult.level).append(" / ");
                 continue;
             }
 
diff --git a/service/proto/src/metrics.proto b/service/proto/src/metrics.proto
index 349543d..01ad650 100644
--- a/service/proto/src/metrics.proto
+++ b/service/proto/src/metrics.proto
@@ -715,6 +715,24 @@
 
   // Long version code of wifi mainline module, 0 means not available.
   optional int64 mainline_module_version = 201;
+
+  // Histogram of Tx link speed at 6G low band
+  repeated Int32Count tx_link_speed_count_6g_low = 202;
+
+  // Histogram of Tx link speed at 6G middle band
+  repeated Int32Count tx_link_speed_count_6g_mid = 203;
+
+  // Histogram of Tx link speed at 6G high band
+  repeated Int32Count tx_link_speed_count_6g_high = 204;
+
+  // Histogram of Rx link speed at 6G low band
+  repeated Int32Count rx_link_speed_count_6g_low = 205;
+
+  // Histogram of Rx link speed at 6G middle band
+  repeated Int32Count rx_link_speed_count_6g_mid = 206;
+
+  // Histogram of Rx link speed at 6G high band
+  repeated Int32Count rx_link_speed_count_6g_high = 207;
 }
 
 // Information that gets logged for every WiFi connection.