• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.net.wifi;
18 
19 import android.annotation.FlaggedApi;
20 import android.annotation.IntDef;
21 import android.annotation.IntRange;
22 import android.annotation.NonNull;
23 import android.annotation.SystemApi;
24 import android.os.Parcel;
25 import android.os.Parcelable;
26 import android.telephony.Annotation.NetworkType;
27 import android.util.Log;
28 import android.util.SparseArray;
29 
30 import androidx.annotation.Nullable;
31 
32 import com.android.wifi.flags.Flags;
33 
34 import java.lang.annotation.Retention;
35 import java.lang.annotation.RetentionPolicy;
36 import java.util.Arrays;
37 import java.util.Collections;
38 import java.util.List;
39 import java.util.NoSuchElementException;
40 
41 /**
42  * This class makes a subset of
43  * com.android.server.wifi.nano.WifiMetricsProto.WifiUsabilityStatsEntry parcelable.
44  *
45  * @hide
46  */
47 @SystemApi
48 public final class WifiUsabilityStatsEntry implements Parcelable {
49     private static final String TAG = "WifiUsabilityStatsEntry";
50 
51     /** @hide */
52     @Retention(RetentionPolicy.SOURCE)
53     @IntDef(prefix = {"LINK_STATE_"}, value = {
54             LINK_STATE_UNKNOWN,
55             LINK_STATE_NOT_IN_USE,
56             LINK_STATE_IN_USE})
57     public @interface LinkState {}
58 
59     /** @hide */
getLinkStateString(@inkState int state)60     public static String getLinkStateString(@LinkState int state) {
61         switch (state) {
62             case LINK_STATE_NOT_IN_USE:
63                 return "LINK_STATE_NOT_IN_USE";
64             case LINK_STATE_IN_USE:
65                 return "LINK_STATE_IN_USE";
66             default:
67                 return "LINK_STATE_UNKNOWN";
68         }
69     }
70 
71     /** Chip does not support reporting the state of the link. */
72     public static final int LINK_STATE_UNKNOWN = 0;
73     /**
74      * Link has not been in use since last report. It is placed in power save. All management,
75      * control and data frames for the MLO connection are carried over other links. In this state
76      * the link will not listen to beacons even in DTIM period and does not perform any
77      * GTK/IGTK/BIGTK updates but remains associated.
78      */
79     public static final int LINK_STATE_NOT_IN_USE = 1;
80     /**
81      * Link is in use. In presence of traffic, it is set to be power active. When the traffic
82      * stops, the link will go into power save mode and will listen for beacons every DTIM period.
83      */
84     public static final int LINK_STATE_IN_USE = 2;
85 
86     /** @hide */
87     @Retention(RetentionPolicy.SOURCE)
88     @IntDef(prefix = {"PROBE_STATUS_"}, value = {
89             PROBE_STATUS_UNKNOWN,
90             PROBE_STATUS_NO_PROBE,
91             PROBE_STATUS_SUCCESS,
92             PROBE_STATUS_FAILURE})
93     public @interface ProbeStatus {}
94 
95     /** Link probe status is unknown */
96     public static final int PROBE_STATUS_UNKNOWN = 0;
97     /** Link probe is not triggered */
98     public static final int PROBE_STATUS_NO_PROBE = 1;
99     /** Link probe is triggered and the result is success */
100     public static final int PROBE_STATUS_SUCCESS = 2;
101     /** Link probe is triggered and the result is failure */
102     public static final int PROBE_STATUS_FAILURE = 3;
103 
104     /** Absolute milliseconds from device boot when these stats were sampled */
105     private final long mTimeStampMillis;
106     /** The RSSI (in dBm) at the sample time */
107     private final int mRssi;
108     /** Link speed at the sample time in Mbps */
109     private final int mLinkSpeedMbps;
110     /** The total number of tx success counted from the last radio chip reset */
111     private final long mTotalTxSuccess;
112     /** The total number of MPDU data packet retries counted from the last radio chip reset */
113     private final long mTotalTxRetries;
114     /** The total number of tx bad counted from the last radio chip reset */
115     private final long mTotalTxBad;
116     /** The total number of rx success counted from the last radio chip reset */
117     private final long mTotalRxSuccess;
118     /** The total time the wifi radio is on in ms counted from the last radio chip reset */
119     private final long mTotalRadioOnTimeMillis;
120     /** The total time the wifi radio is doing tx in ms counted from the last radio chip reset */
121     private final long mTotalRadioTxTimeMillis;
122     /** The total time the wifi radio is doing rx in ms counted from the last radio chip reset */
123     private final long mTotalRadioRxTimeMillis;
124     /** The total time spent on all types of scans in ms counted from the last radio chip reset */
125     private final long mTotalScanTimeMillis;
126     /** The total time spent on nan scans in ms counted from the last radio chip reset */
127     private final long mTotalNanScanTimeMillis;
128     /** The total time spent on background scans in ms counted from the last radio chip reset */
129     private final long mTotalBackgroundScanTimeMillis;
130     /** The total time spent on roam scans in ms counted from the last radio chip reset */
131     private final long mTotalRoamScanTimeMillis;
132     /** The total time spent on pno scans in ms counted from the last radio chip reset */
133     private final long mTotalPnoScanTimeMillis;
134     /** The total time spent on hotspot2.0 scans and GAS exchange in ms counted from the last radio
135      * chip reset */
136     private final long mTotalHotspot2ScanTimeMillis;
137     /** The total time CCA is on busy status on the current frequency in ms counted from the last
138      * radio chip reset */
139     private final long mTotalCcaBusyFreqTimeMillis;
140     /** The total radio on time on the current frequency from the last radio chip reset */
141     private final long mTotalRadioOnFreqTimeMillis;
142     /** The total number of beacons received from the last radio chip reset */
143     private final long mTotalBeaconRx;
144     /** The status of link probe since last stats update */
145     @ProbeStatus private final int mProbeStatusSinceLastUpdate;
146     /** The elapsed time of the most recent link probe since last stats update */
147     private final int mProbeElapsedTimeSinceLastUpdateMillis;
148     /** The MCS rate of the most recent link probe since last stats update */
149     private final int mProbeMcsRateSinceLastUpdate;
150     /** Rx link speed at the sample time in Mbps */
151     private final int mRxLinkSpeedMbps;
152     /** @see #getTimeSliceDutyCycleInPercent() */
153     private final int mTimeSliceDutyCycleInPercent;
154 
155     private final int mWifiLinkCount;
156     /** Refer to WifiManager.MloMode */
157     private @WifiManager.MloMode int mMloMode;
158     /** The number of tx bytes transmitted on current interface */
159     private final long mTxTransmittedBytes;
160     /** The number of rx bytes transmitted on current interface */
161     private final long mRxTransmittedBytes;
162     /** The total number of LABEL_BAD event happens */
163     private final int mLabelBadEventCount;
164     /** The current WiFi state in framework */
165     private final int mWifiFrameworkState;
166     /** Downstream throughput estimation provided by Network Capabilities */
167     private final int mIsNetworkCapabilitiesDownstreamSufficient;
168     /** Upstream throughput estimation provided by Network Capabilities */
169     private final int mIsNetworkCapabilitiesUpstreamSufficient;
170     /** Downstream throughput estimation used in Network Selection */
171     private final int mIsThroughputPredictorDownstreamSufficient;
172     /** Upstream throughput estimation used in Network Selection */
173     private final int mIsThroughputPredictorUpstreamSufficient;
174     /** If bluetooth is connected */
175     private final boolean mIsBluetoothConnected;
176     /** UWB Adapter state */
177     private final int mUwbAdapterState;
178     /** Low Latency mode state */
179     private final boolean mIsLowLatencyActivated;
180     /** Maximum supported tx link speed in Mbps  */
181     private final int mMaxSupportedTxLinkSpeed;
182     /** Maximum supported rx link speed in Mbps  */
183     private final int mMaxSupportedRxLinkSpeed;
184     /** WiFi Voip mode state */
185     private final int mVoipMode;
186     /** Thread device role */
187     private final int mThreadDeviceRole;
188     /** Data stall status */
189     private final int mStatusDataStall;
190 
191     /** {@hide} */
192     @Retention(RetentionPolicy.SOURCE)
193     @IntDef(prefix = {"WME_ACCESS_CATEGORY_"}, value = {
194         WME_ACCESS_CATEGORY_BE,
195         WME_ACCESS_CATEGORY_BK,
196         WME_ACCESS_CATEGORY_VI,
197         WME_ACCESS_CATEGORY_VO})
198     public @interface WmeAccessCategory {}
199 
200     /**
201      * Wireless Multimedia Extensions (WME) Best Effort Access Category, IEEE Std 802.11-2020,
202      * Section 9.4.2.28, Table 9-155
203      */
204     public static final int WME_ACCESS_CATEGORY_BE = 0;
205     /**
206      * Wireless Multimedia Extensions (WME) Background Access Category, IEEE Std 802.11-2020,
207      * Section 9.4.2.28, Table 9-155
208      */
209     public static final int WME_ACCESS_CATEGORY_BK = 1;
210     /**
211      * Wireless Multimedia Extensions (WME) Video Access Category, IEEE Std 802.11-2020,
212      * Section 9.4.2.28, Table 9-155
213      */
214     public static final int WME_ACCESS_CATEGORY_VI = 2;
215     /**
216      * Wireless Multimedia Extensions (WME) Voice Access Category, IEEE Std 802.11-2020,
217      * Section 9.4.2.28, Table 9-155
218      */
219     public static final int WME_ACCESS_CATEGORY_VO = 3;
220     /** Number of WME Access Categories */
221     public static final int NUM_WME_ACCESS_CATEGORIES = 4;
222 
223     /**
224      * Data packet contention time statistics.
225      */
226     public static final class ContentionTimeStats implements Parcelable {
227         private long mContentionTimeMinMicros;
228         private long mContentionTimeMaxMicros;
229         private long mContentionTimeAvgMicros;
230         private long mContentionNumSamples;
231 
232         /** @hide */
ContentionTimeStats()233         public ContentionTimeStats() {
234         }
235 
236         /**
237          * Constructor function
238          * @param timeMin The minimum data packet contention time
239          * @param timeMax The maximum data packet contention time
240          * @param timeAvg The average data packet contention time
241          * @param numSamples The number of samples used to get the reported contention time
242          */
ContentionTimeStats(long timeMin, long timeMax, long timeAvg, long numSamples)243         public ContentionTimeStats(long timeMin, long timeMax, long timeAvg, long numSamples) {
244             this.mContentionTimeMinMicros = timeMin;
245             this.mContentionTimeMaxMicros = timeMax;
246             this.mContentionTimeAvgMicros = timeAvg;
247             this.mContentionNumSamples = numSamples;
248         }
249 
250         @Override
describeContents()251         public int describeContents() {
252             return 0;
253         }
254 
255         @Override
writeToParcel(@onNull Parcel dest, int flags)256         public void writeToParcel(@NonNull Parcel dest, int flags) {
257             dest.writeLong(mContentionTimeMinMicros);
258             dest.writeLong(mContentionTimeMaxMicros);
259             dest.writeLong(mContentionTimeAvgMicros);
260             dest.writeLong(mContentionNumSamples);
261         }
262 
263         /** Implement the Parcelable interface */
264         public static final @NonNull Creator<ContentionTimeStats> CREATOR =
265                 new Creator<ContentionTimeStats>() {
266             public ContentionTimeStats createFromParcel(Parcel in) {
267                 ContentionTimeStats stats = new ContentionTimeStats();
268                 stats.mContentionTimeMinMicros = in.readLong();
269                 stats.mContentionTimeMaxMicros = in.readLong();
270                 stats.mContentionTimeAvgMicros = in.readLong();
271                 stats.mContentionNumSamples = in.readLong();
272                 return stats;
273             }
274             public ContentionTimeStats[] newArray(int size) {
275                 return new ContentionTimeStats[size];
276             }
277         };
278 
279         /** Data packet min contention time in microseconds */
getContentionTimeMinMicros()280         public long getContentionTimeMinMicros() {
281             return mContentionTimeMinMicros;
282         }
283 
284         /** Data packet max contention time in microseconds */
getContentionTimeMaxMicros()285         public long getContentionTimeMaxMicros() {
286             return mContentionTimeMaxMicros;
287         }
288 
289         /** Data packet average contention time in microseconds */
getContentionTimeAvgMicros()290         public long getContentionTimeAvgMicros() {
291             return mContentionTimeAvgMicros;
292         }
293 
294         /**
295          * Number of data packets used for deriving the min, the max, and the average
296          * contention time
297          */
getContentionNumSamples()298         public long getContentionNumSamples() {
299             return mContentionNumSamples;
300         }
301     }
302     private final ContentionTimeStats[] mContentionTimeStats;
303 
304     /**
305      * Packet statistics.
306      */
307     /** @hide */
308     public static final class PacketStats implements Parcelable {
309         private long mTxSuccess;
310         private long mTxRetries;
311         private long mTxBad;
312         private long mRxSuccess;
313 
PacketStats()314         public PacketStats() {
315         }
316 
317         /**
318          * Constructor function
319          * @param txSuccess Number of successfully transmitted unicast data pkts (ACK rcvd)
320          * @param txRetries Number of transmitted unicast data retry pkts
321          * @param txBad Number of transmitted unicast data pkt losses (no ACK)
322          * @param rxSuccess Number of received unicast data packets
323          */
PacketStats(long txSuccess, long txRetries, long txBad, long rxSuccess)324         public PacketStats(long txSuccess, long txRetries, long txBad, long rxSuccess) {
325             this.mTxSuccess = txSuccess;
326             this.mTxRetries = txRetries;
327             this.mTxBad = txBad;
328             this.mRxSuccess = rxSuccess;
329         }
330 
331         @Override
describeContents()332         public int describeContents() {
333             return 0;
334         }
335 
336         @Override
writeToParcel(@onNull Parcel dest, int flags)337         public void writeToParcel(@NonNull Parcel dest, int flags) {
338             dest.writeLong(mTxSuccess);
339             dest.writeLong(mTxRetries);
340             dest.writeLong(mTxBad);
341             dest.writeLong(mRxSuccess);
342         }
343 
344         /** Implement the Parcelable interface */
345         public static final @NonNull Creator<PacketStats> CREATOR =
346                 new Creator<PacketStats>() {
347                     public PacketStats createFromParcel(Parcel in) {
348                         PacketStats stats = new PacketStats();
349                         stats.mTxSuccess = in.readLong();
350                         stats.mTxRetries = in.readLong();
351                         stats.mTxBad = in.readLong();
352                         stats.mRxSuccess = in.readLong();
353                         return stats;
354                     }
355                     public PacketStats[] newArray(int size) {
356                         return new PacketStats[size];
357                     }
358                 };
359 
360         /** Number of successfully transmitted unicast data pkts (ACK rcvd) */
getTxSuccess()361         public long getTxSuccess() {
362             return mTxSuccess;
363         }
364 
365         /** Number of transmitted unicast data retry pkts */
getTxRetries()366         public long getTxRetries() {
367             return mTxRetries;
368         }
369 
370         /** Number of transmitted unicast data pkt losses (no ACK) */
getTxBad()371         public long getTxBad() {
372             return mTxBad;
373         }
374 
375         /** Number of received unicast data packets */
getRxSuccess()376         public long getRxSuccess() {
377             return mRxSuccess;
378         }
379     }
380 
381     /** {@hide} */
382     @Retention(RetentionPolicy.SOURCE)
383     @IntDef(prefix = {"WIFI_PREAMBLE_"}, value = {
384         WIFI_PREAMBLE_OFDM,
385         WIFI_PREAMBLE_CCK,
386         WIFI_PREAMBLE_HT,
387         WIFI_PREAMBLE_VHT,
388         WIFI_PREAMBLE_HE,
389         WIFI_PREAMBLE_EHT,
390         WIFI_PREAMBLE_INVALID})
391     public @interface WifiPreambleType {}
392 
393     /** Preamble type for 802.11a/g, IEEE Std 802.11-2020, Section 17 */
394     public static final int WIFI_PREAMBLE_OFDM = 0;
395     /** Preamble type for 802.11b, IEEE Std 802.11-2020, Section 16 */
396     public static final int WIFI_PREAMBLE_CCK = 1;
397     /** Preamble type for 802.11n, IEEE Std 802.11-2020, Section 19 */
398     public static final int WIFI_PREAMBLE_HT = 2;
399     /** Preamble type for 802.11ac, IEEE Std 802.11-2020, Section 21 */
400     public static final int WIFI_PREAMBLE_VHT = 3;
401     /** Preamble type for 802.11ax, IEEE Std 802.11ax-2021, Section 27 */
402     public static final int WIFI_PREAMBLE_HE = 5;
403     /** Preamble type for 802.11be, IEEE Std 802.11be-2021, Section 36 */
404     public static final int WIFI_PREAMBLE_EHT = 6;
405     /** Invalid */
406     public static final int WIFI_PREAMBLE_INVALID = -1;
407 
408     /** {@hide} */
409     @Retention(RetentionPolicy.SOURCE)
410     @IntDef(prefix = {"WIFI_SPATIAL_STREAMS_"}, value = {
411         WIFI_SPATIAL_STREAMS_ONE,
412         WIFI_SPATIAL_STREAMS_TWO,
413         WIFI_SPATIAL_STREAMS_THREE,
414         WIFI_SPATIAL_STREAMS_FOUR,
415         WIFI_SPATIAL_STREAMS_INVALID})
416     public @interface WifiSpatialStreams {}
417 
418     /** Single stream, 1x1 */
419     public static final int WIFI_SPATIAL_STREAMS_ONE = 1;
420     /** Dual streams, 2x2 */
421     public static final int WIFI_SPATIAL_STREAMS_TWO = 2;
422     /** Three streams, 3x3 */
423     public static final int WIFI_SPATIAL_STREAMS_THREE = 3;
424     /** Four streams, 4x4 */
425     public static final int WIFI_SPATIAL_STREAMS_FOUR = 4;
426     /** Invalid */
427     public static final int WIFI_SPATIAL_STREAMS_INVALID = -1;
428 
429     /** {@hide} */
430     @Retention(RetentionPolicy.SOURCE)
431     @IntDef(prefix = {"WIFI_BANDWIDTH_"}, value = {
432         WIFI_BANDWIDTH_20_MHZ,
433         WIFI_BANDWIDTH_40_MHZ,
434         WIFI_BANDWIDTH_80_MHZ,
435         WIFI_BANDWIDTH_160_MHZ,
436         WIFI_BANDWIDTH_320_MHZ,
437         WIFI_BANDWIDTH_80P80_MHZ,
438         WIFI_BANDWIDTH_5_MHZ,
439         WIFI_BANDWIDTH_10_MHZ,
440         WIFI_BANDWIDTH_INVALID})
441     public @interface WifiChannelBandwidth {}
442 
443     /** Channel bandwidth: 20MHz */
444     public static final int WIFI_BANDWIDTH_20_MHZ = 0;
445     /** Channel bandwidth: 40MHz */
446     public static final int WIFI_BANDWIDTH_40_MHZ = 1;
447     /** Channel bandwidth: 80MHz */
448     public static final int WIFI_BANDWIDTH_80_MHZ = 2;
449     /** Channel bandwidth: 160MHz */
450     public static final int WIFI_BANDWIDTH_160_MHZ = 3;
451     /** Channel bandwidth: 80MHz + 80MHz */
452     public static final int WIFI_BANDWIDTH_80P80_MHZ = 4;
453     /** Channel bandwidth: 5MHz */
454     public static final int WIFI_BANDWIDTH_5_MHZ = 5;
455     /** Channel bandwidth: 10MHz */
456     public static final int WIFI_BANDWIDTH_10_MHZ = 6;
457     /** Channel bandwidth: 320MHz */
458     public static final int WIFI_BANDWIDTH_320_MHZ = 7;
459     /** Invalid */
460     public static final int WIFI_BANDWIDTH_INVALID = -1;
461 
462     /**
463      * Rate information and statistics: packet counters (tx/rx successful packets, retries, lost)
464      * indexed by preamble, bandwidth, number of spatial streams, MCS, and bit rate.
465      */
466     public static final class RateStats implements Parcelable {
467         @WifiPreambleType private int mPreamble;
468         @WifiSpatialStreams private int mNss;
469         @WifiChannelBandwidth private int mBw;
470         private int mRateMcsIdx;
471         private int mBitRateInKbps;
472         private int mTxMpdu;
473         private int mRxMpdu;
474         private int mMpduLost;
475         private int mRetries;
476 
477         /** @hide */
RateStats()478         public RateStats() {
479         }
480 
481         /**
482          * Constructor function.
483          * @param preamble Preamble information.
484          * @param nss Number of spatial streams.
485          * @param bw Bandwidth information.
486          * @param rateMcsIdx MCS index. OFDM/CCK rate code would be as per IEEE std in the units of
487          *                   0.5Mbps. HT/VHT/HE/EHT: it would be MCS index.
488          * @param bitRateInKbps Bitrate in units of 100 Kbps.
489          * @param txMpdu Number of successfully transmitted data packets (ACK received).
490          * @param rxMpdu Number of received data packets.
491          * @param mpduLost Number of data packet losses (no ACK).
492          * @param retries Number of data packet retries.
493          */
RateStats(@ifiPreambleType int preamble, @WifiSpatialStreams int nss, @WifiChannelBandwidth int bw, int rateMcsIdx, int bitRateInKbps, int txMpdu, int rxMpdu, int mpduLost, int retries)494         public RateStats(@WifiPreambleType int preamble, @WifiSpatialStreams int nss,
495                 @WifiChannelBandwidth int bw, int rateMcsIdx, int bitRateInKbps, int txMpdu,
496                 int rxMpdu, int mpduLost, int retries) {
497             this.mPreamble = preamble;
498             this.mNss = nss;
499             this.mBw = bw;
500             this.mRateMcsIdx = rateMcsIdx;
501             this.mBitRateInKbps = bitRateInKbps;
502             this.mTxMpdu = txMpdu;
503             this.mRxMpdu = rxMpdu;
504             this.mMpduLost = mpduLost;
505             this.mRetries = retries;
506         }
507 
508         @Override
describeContents()509         public int describeContents() {
510             return 0;
511         }
512 
513         @Override
writeToParcel(@onNull Parcel dest, int flags)514         public void writeToParcel(@NonNull Parcel dest, int flags) {
515             dest.writeInt(mPreamble);
516             dest.writeInt(mNss);
517             dest.writeInt(mBw);
518             dest.writeInt(mRateMcsIdx);
519             dest.writeInt(mBitRateInKbps);
520             dest.writeInt(mTxMpdu);
521             dest.writeInt(mRxMpdu);
522             dest.writeInt(mMpduLost);
523             dest.writeInt(mRetries);
524         }
525 
526         /** Implement the Parcelable interface */
527         public static final @NonNull Creator<RateStats> CREATOR = new Creator<RateStats>() {
528             public RateStats createFromParcel(Parcel in) {
529                 RateStats stats = new RateStats();
530                 stats.mPreamble = in.readInt();
531                 stats.mNss = in.readInt();
532                 stats.mBw = in.readInt();
533                 stats.mRateMcsIdx = in.readInt();
534                 stats.mBitRateInKbps = in.readInt();
535                 stats.mTxMpdu = in.readInt();
536                 stats.mRxMpdu = in.readInt();
537                 stats.mMpduLost = in.readInt();
538                 stats.mRetries = in.readInt();
539                 return stats;
540             }
541             public RateStats[] newArray(int size) {
542                 return new RateStats[size];
543             }
544         };
545 
546         /** Preamble information, see {@link WifiPreambleType} */
getPreamble()547         @WifiPreambleType public int getPreamble() {
548             return mPreamble;
549         }
550 
551         /** Number of spatial streams, see {@link WifiSpatialStreams} */
getNumberOfSpatialStreams()552         @WifiSpatialStreams public int getNumberOfSpatialStreams() {
553             return mNss;
554         }
555 
556         /** Bandwidth information, see {@link WifiChannelBandwidth} */
getBandwidthInMhz()557         @WifiChannelBandwidth public int getBandwidthInMhz() {
558             return mBw;
559         }
560 
561         /**
562          * MCS index. OFDM/CCK rate code would be as per IEEE std in the units of 0.5Mbps.
563          * HT/VHT/HE/EHT: it would be MCS index
564          */
getRateMcsIdx()565         public int getRateMcsIdx() {
566             return mRateMcsIdx;
567         }
568 
569         /** Bitrate in units of a hundred Kbps */
getBitRateInKbps()570         public int getBitRateInKbps() {
571             return mBitRateInKbps;
572         }
573 
574         /** Number of successfully transmitted data packets (ACK received) */
getTxMpdu()575         public int getTxMpdu() {
576             return mTxMpdu;
577         }
578 
579         /** Number of received data packets */
getRxMpdu()580         public int getRxMpdu() {
581             return mRxMpdu;
582         }
583 
584         /** Number of data packet losses (no ACK) */
getMpduLost()585         public int getMpduLost() {
586             return mMpduLost;
587         }
588 
589         /** Number of data packet retries */
getRetries()590         public int getRetries() {
591             return mRetries;
592         }
593     }
594     private final RateStats[] mRateStats;
595 
596     /**
597      * Per peer statistics for WiFi the link
598      */
599     /** @hide */
600     public static final class PeerInfo implements Parcelable {
601         private int mStaCount;
602         private int mChanUtil;
603         private RateStats[] mRateStats;
604 
PeerInfo()605         public PeerInfo() {
606         }
607 
608         /**
609          * Constructor function.
610          * @param staCount Station count
611          * @param chanUtil Channel utilization
612          * @param rateStats Per rate statistics on this WiFi peer
613          */
PeerInfo(int staCount, int chanUtil, RateStats[] rateStats)614         public PeerInfo(int staCount, int chanUtil, RateStats[] rateStats) {
615             this.mStaCount = staCount;
616             this.mChanUtil = chanUtil;
617             this.mRateStats = rateStats;
618         }
619 
620         @Override
describeContents()621         public int describeContents() {
622             return 0;
623         }
624 
625         @Override
writeToParcel(@onNull Parcel dest, int flags)626         public void writeToParcel(@NonNull Parcel dest, int flags) {
627             dest.writeInt(mStaCount);
628             dest.writeInt(mChanUtil);
629             dest.writeTypedArray(mRateStats, flags);
630         }
631 
632         /** Implement the Parcelable interface */
633         public static final @NonNull Creator<PeerInfo> CREATOR = new Creator<PeerInfo>() {
634             public PeerInfo createFromParcel(Parcel in) {
635                 PeerInfo stats = new PeerInfo();
636                 stats.mStaCount = in.readInt();
637                 stats.mChanUtil = in.readInt();
638                 stats.mRateStats = in.createTypedArray(RateStats.CREATOR);
639                 return stats;
640             }
641             public PeerInfo[] newArray(int size) {
642                 return new PeerInfo[size];
643             }
644         };
645 
646         /** Station count */
getStaCount()647         public int getStaCount() {
648             return mStaCount;
649         }
650 
651         /** Channel utilization */
getChanUtil()652         public int getChanUtil() {
653             return mChanUtil;
654         }
655 
656         /** Per rate statistics */
getRateStats()657         public List<RateStats> getRateStats() {
658             if (mRateStats != null) {
659                 return Arrays.asList(mRateStats);
660             }
661             return Collections.emptyList();
662         }
663     }
664 
665     /**
666      * Scan Results who have the same freq with current WiFi link
667      */
668     /** @hide */
669     public static final class ScanResultWithSameFreq implements Parcelable {
670         private long mScanResultTimestampMicros;
671         private int mRssi;
672         private int mFrequencyMhz;
673 
ScanResultWithSameFreq()674         public ScanResultWithSameFreq() {
675         }
676 
677         /**
678          * Constructor function.
679          * @param scanResultTimestampMicros Timestamp in microseconds (since boot) when this result
680          *                                  was last seen.
681          * @param rssi                      The detected signal level in dBm
682          * @param frequencyMhz              The center frequency of the primary 20 MHz frequency
683          *                                  (in MHz) of the channel
684          */
ScanResultWithSameFreq(long scanResultTimestampMicros, int rssi, int frequencyMhz)685         public ScanResultWithSameFreq(long scanResultTimestampMicros, int rssi, int frequencyMhz) {
686             this.mScanResultTimestampMicros = scanResultTimestampMicros;
687             this.mRssi = rssi;
688             this.mFrequencyMhz = frequencyMhz;
689         }
690 
691         @Override
describeContents()692         public int describeContents() {
693             return 0;
694         }
695 
696         @Override
writeToParcel(@onNull Parcel dest, int flags)697         public void writeToParcel(@NonNull Parcel dest, int flags) {
698             dest.writeLong(mScanResultTimestampMicros);
699             dest.writeInt(mRssi);
700             dest.writeInt(mFrequencyMhz);
701         }
702 
703         /** Implement the Parcelable interface */
704         public static final @NonNull Creator<ScanResultWithSameFreq> CREATOR =
705                 new Creator<ScanResultWithSameFreq>() {
706                     public ScanResultWithSameFreq createFromParcel(Parcel in) {
707                         ScanResultWithSameFreq scanResultWithSameFreq =
708                                 new ScanResultWithSameFreq();
709                         scanResultWithSameFreq.mScanResultTimestampMicros = in.readLong();
710                         scanResultWithSameFreq.mRssi = in.readInt();
711                         scanResultWithSameFreq.mFrequencyMhz = in.readInt();
712                         return scanResultWithSameFreq;
713                         }
714                     public ScanResultWithSameFreq[] newArray(int size) {
715                         return new ScanResultWithSameFreq[size];
716                     }
717                 };
718 
719         /** timestamp in microseconds (since boot) when this result was last seen */
getScanResultTimestampMicros()720         public long getScanResultTimestampMicros() {
721             return mScanResultTimestampMicros;
722         }
723 
724         /** The detected signal level in dBm */
getRssi()725         public int getRssi() {
726             return mRssi;
727         }
728 
729         /** The center frequency of the primary 20 MHz frequency (in MHz) of the channel */
getFrequency()730         public int getFrequency() {
731             return mFrequencyMhz;
732         }
733     }
734 
735     /**
736      * Wifi link layer radio stats.
737      */
738     public static final class RadioStats implements Parcelable {
739         /**
740          * Invalid radio id.
741          * @hide
742          */
743         public static final int INVALID_RADIO_ID = -1;
744         private int mRadioId;
745         private long mTotalRadioOnTimeMillis;
746         private long mTotalRadioTxTimeMillis;
747         private long mTotalRadioRxTimeMillis;
748         private long mTotalScanTimeMillis;
749         private long mTotalNanScanTimeMillis;
750         private long mTotalBackgroundScanTimeMillis;
751         private long mTotalRoamScanTimeMillis;
752         private long mTotalPnoScanTimeMillis;
753         private long mTotalHotspot2ScanTimeMillis;
754         private int[] mTxTimeMsPerLevel;
755 
756         /** @hide */
RadioStats()757         public RadioStats() {
758         }
759 
760         /**
761          * Constructor function
762          * @param radioId Firmware/Hardware implementation specific persistent value for this
763          *                device, identifying the radio interface for which the stats are produced.
764          * @param onTime The total time the wifi radio is on in ms counted from the last radio
765          *               chip reset
766          * @param txTime The total time the wifi radio is transmitting in ms counted from the last
767          *               radio chip reset
768          * @param rxTime The total time the wifi radio is receiving in ms counted from the last
769          *               radio chip reset
770          * @param onTimeScan The total time spent on all types of scans in ms counted from the
771          *                   last radio chip reset
772          * @param onTimeNanScan The total time spent on nan scans in ms counted from the last radio
773          *                      chip reset
774          * @param onTimeBackgroundScan The total time spent on background scans in ms counted from
775          *                             the last radio chip reset
776          * @param onTimeRoamScan The total time spent on roam scans in ms counted from the last
777          *                       radio chip reset
778          * @param onTimePnoScan The total time spent on pno scans in ms counted from the last radio
779          *                      chip reset
780          * @param onTimeHs20Scan The total time spent on hotspot2.0 scans and GAS exchange in ms
781          *                       counted from the last radio chip reset
782          */
RadioStats(int radioId, long onTime, long txTime, long rxTime, long onTimeScan, long onTimeNanScan, long onTimeBackgroundScan, long onTimeRoamScan, long onTimePnoScan, long onTimeHs20Scan)783         public RadioStats(int radioId, long onTime, long txTime, long rxTime, long onTimeScan,
784                 long onTimeNanScan, long onTimeBackgroundScan, long onTimeRoamScan,
785                 long onTimePnoScan, long onTimeHs20Scan) {
786             this.mRadioId = radioId;
787             this.mTotalRadioOnTimeMillis = onTime;
788             this.mTotalRadioTxTimeMillis = txTime;
789             this.mTotalRadioRxTimeMillis = rxTime;
790             this.mTotalScanTimeMillis = onTimeScan;
791             this.mTotalNanScanTimeMillis = onTimeNanScan;
792             this.mTotalBackgroundScanTimeMillis = onTimeBackgroundScan;
793             this.mTotalRoamScanTimeMillis = onTimeRoamScan;
794             this.mTotalPnoScanTimeMillis = onTimePnoScan;
795             this.mTotalHotspot2ScanTimeMillis = onTimeHs20Scan;
796         }
797 
798         /**
799          * Constructor function
800          * @param radioId Firmware/Hardware implementation specific persistent value for this
801          *                device, identifying the radio interface for which the stats are produced.
802          * @param onTime The total time the wifi radio is on in ms counted from the last radio
803          *               chip reset
804          * @param txTime The total time the wifi radio is transmitting in ms counted from the last
805          *               radio chip reset
806          * @param rxTime The total time the wifi radio is receiving in ms counted from the last
807          *               radio chip reset
808          * @param onTimeScan The total time spent on all types of scans in ms counted from the
809          *                   last radio chip reset
810          * @param onTimeNanScan The total time spent on nan scans in ms counted from the last radio
811          *                      chip reset
812          * @param onTimeBackgroundScan The total time spent on background scans in ms counted from
813          *                             the last radio chip reset
814          * @param onTimeRoamScan The total time spent on roam scans in ms counted from the last
815          *                       radio chip reset
816          * @param onTimePnoScan The total time spent on pno scans in ms counted from the last radio
817          *                      chip reset
818          * @param onTimeHs20Scan The total time spent on hotspot2.0 scans and GAS exchange in ms
819          *                       counted from the last radio chip reset
820          * @param txTimeMsPerLevel Time for which the radio is in active tranmission per tx level
821          */
822         /** @hide */
RadioStats(int radioId, long onTime, long txTime, long rxTime, long onTimeScan, long onTimeNanScan, long onTimeBackgroundScan, long onTimeRoamScan, long onTimePnoScan, long onTimeHs20Scan, int[] txTimeMsPerLevel)823         public RadioStats(int radioId, long onTime, long txTime, long rxTime, long onTimeScan,
824                 long onTimeNanScan, long onTimeBackgroundScan, long onTimeRoamScan,
825                 long onTimePnoScan, long onTimeHs20Scan, int[] txTimeMsPerLevel) {
826             this.mRadioId = radioId;
827             this.mTotalRadioOnTimeMillis = onTime;
828             this.mTotalRadioTxTimeMillis = txTime;
829             this.mTotalRadioRxTimeMillis = rxTime;
830             this.mTotalScanTimeMillis = onTimeScan;
831             this.mTotalNanScanTimeMillis = onTimeNanScan;
832             this.mTotalBackgroundScanTimeMillis = onTimeBackgroundScan;
833             this.mTotalRoamScanTimeMillis = onTimeRoamScan;
834             this.mTotalPnoScanTimeMillis = onTimePnoScan;
835             this.mTotalHotspot2ScanTimeMillis = onTimeHs20Scan;
836             this.mTxTimeMsPerLevel = txTimeMsPerLevel;
837         }
838 
839         @Override
describeContents()840         public int describeContents() {
841             return 0;
842         }
843 
844         @Override
writeToParcel(@onNull Parcel dest, int flags)845         public void writeToParcel(@NonNull Parcel dest, int flags) {
846             dest.writeInt(mRadioId);
847             dest.writeLong(mTotalRadioOnTimeMillis);
848             dest.writeLong(mTotalRadioTxTimeMillis);
849             dest.writeLong(mTotalRadioRxTimeMillis);
850             dest.writeLong(mTotalScanTimeMillis);
851             dest.writeLong(mTotalNanScanTimeMillis);
852             dest.writeLong(mTotalBackgroundScanTimeMillis);
853             dest.writeLong(mTotalRoamScanTimeMillis);
854             dest.writeLong(mTotalPnoScanTimeMillis);
855             dest.writeLong(mTotalHotspot2ScanTimeMillis);
856             dest.writeIntArray(mTxTimeMsPerLevel);
857         }
858 
859         /** Implement the Parcelable interface */
860         public static final @NonNull Creator<RadioStats> CREATOR =
861                 new Creator<RadioStats>() {
862                     public RadioStats createFromParcel(Parcel in) {
863                         RadioStats stats = new RadioStats();
864                         stats.mRadioId = in.readInt();
865                         stats.mTotalRadioOnTimeMillis = in.readLong();
866                         stats.mTotalRadioTxTimeMillis = in.readLong();
867                         stats.mTotalRadioRxTimeMillis = in.readLong();
868                         stats.mTotalScanTimeMillis = in.readLong();
869                         stats.mTotalNanScanTimeMillis = in.readLong();
870                         stats.mTotalBackgroundScanTimeMillis = in.readLong();
871                         stats.mTotalRoamScanTimeMillis = in.readLong();
872                         stats.mTotalPnoScanTimeMillis = in.readLong();
873                         stats.mTotalHotspot2ScanTimeMillis = in.readLong();
874                         stats.mTxTimeMsPerLevel = in.createIntArray();
875                         return stats;
876                     }
877                     public RadioStats[] newArray(int size) {
878                         return new RadioStats[size];
879                     }
880                 };
881 
882         /**
883          * Firmware/Hardware implementation specific persistent value for this
884          * device, identifying the radio interface for which the stats are produced.
885          */
getRadioId()886         public long getRadioId() {
887             return mRadioId;
888         }
889 
890         /** The total time the wifi radio is on in ms counted from the last radio chip reset */
getTotalRadioOnTimeMillis()891         public long getTotalRadioOnTimeMillis() {
892             return mTotalRadioOnTimeMillis;
893         }
894 
895         /**
896          * The total time the wifi radio is transmitting in ms counted from the last radio chip
897          * reset
898          */
getTotalRadioTxTimeMillis()899         public long getTotalRadioTxTimeMillis() {
900             return mTotalRadioTxTimeMillis;
901         }
902 
903         /**
904          * The total time the wifi radio is receiving in ms counted from the last radio chip reset
905          */
getTotalRadioRxTimeMillis()906         public long getTotalRadioRxTimeMillis() {
907             return mTotalRadioRxTimeMillis;
908         }
909 
910         /**
911          * The total time spent on all types of scans in ms counted from the last radio chip reset
912          */
getTotalScanTimeMillis()913         public long getTotalScanTimeMillis() {
914             return mTotalScanTimeMillis;
915         }
916 
917         /** The total time spent on nan scans in ms counted from the last radio chip reset */
getTotalNanScanTimeMillis()918         public long getTotalNanScanTimeMillis() {
919             return mTotalNanScanTimeMillis;
920         }
921 
922         /** The total time spent on background scans in ms counted from the last radio chip reset */
getTotalBackgroundScanTimeMillis()923         public long getTotalBackgroundScanTimeMillis() {
924             return mTotalBackgroundScanTimeMillis;
925         }
926 
927         /** The total time spent on roam scans in ms counted from the last radio chip reset */
getTotalRoamScanTimeMillis()928         public long getTotalRoamScanTimeMillis() {
929             return mTotalRoamScanTimeMillis;
930         }
931 
932         /** The total time spent on pno scans in ms counted from the last radio chip reset */
getTotalPnoScanTimeMillis()933         public long getTotalPnoScanTimeMillis() {
934             return mTotalPnoScanTimeMillis;
935         }
936 
937         /**
938          * The total time spent on hotspot2.0 scans and GAS exchange in ms counted from the
939          * last radio chip reset
940          */
getTotalHotspot2ScanTimeMillis()941         public long getTotalHotspot2ScanTimeMillis() {
942             return mTotalHotspot2ScanTimeMillis;
943         }
944         /**
945          * Time for which the radio is in active tranmission per tx level
946          */
947         /** @hide */
getTxTimeMsPerLevel()948         public int[] getTxTimeMsPerLevel() {
949             return mTxTimeMsPerLevel;
950         }
951     }
952     private final RadioStats[] mRadioStats;
953     private final int mChannelUtilizationRatio;
954     private final boolean mIsThroughputSufficient;
955     private final boolean mIsWifiScoringEnabled;
956     private final boolean mIsCellularDataAvailable;
957     private final @NetworkType int mCellularDataNetworkType;
958     private final int mCellularSignalStrengthDbm;
959     private final int mCellularSignalStrengthDb;
960     private final boolean mIsSameRegisteredCell;
961 
962     /**
963      * Link specific statistics.
964      *
965      * @hide
966      */
967     public static final class LinkStats implements Parcelable {
968         /** Link identifier (0 to 14) */
969         private final int mLinkId;
970         /** Link state as listed {@link LinkState} */
971         private final @LinkState int mState;
972         /** Radio identifier */
973         private final int mRadioId;
974         /** The RSSI (in dBm) at the sample time */
975         private final int mRssi;
976         /** Frequency of the link in MHz */
977         private final int mFrequencyMhz;
978         /** RSSI of management frames on this WiFi link */
979         private final int mRssiMgmt;
980         /** Channel bandwidth on this WiFi link */
981         @WifiChannelBandwidth private int mChannelWidth;
982         /** Center frequency (MHz) first segment on this WiFi link */
983         private final int mCenterFreqFirstSegment;
984         /** Center frequency (MHz) second segment on this WiFi link */
985         private final int mCenterFreqSecondSegment;
986         /** Tx Link speed at the sample time in Mbps */
987         private final int mTxLinkSpeedMbps;
988         /** Rx link speed at the sample time in Mbps */
989         private final int mRxLinkSpeedMbps;
990         /** The total number of tx success counted from the last radio chip reset */
991         private final long mTotalTxSuccess;
992         /** The total number of MPDU data packet retries counted from the last radio chip reset */
993         private final long mTotalTxRetries;
994         /** The total number of tx bad counted from the last radio chip reset */
995         private final long mTotalTxBad;
996         /** The total number of rx success counted from the last radio chip reset */
997         private final long mTotalRxSuccess;
998         /** The total number of beacons received from the last radio chip reset */
999         private final long mTotalBeaconRx;
1000         /** @see #WifiUsabilityStatsEntry#getTimeSliceDutyCycleInPercent() */
1001         private final int mTimeSliceDutyCycleInPercent;
1002         /**
1003          * The total time CCA is on busy status on the link frequency in ms counted from the last
1004          * radio chip reset
1005          */
1006         private final long mTotalCcaBusyFreqTimeMillis;
1007         /** The total radio on time on the link frequency in ms from the last radio chip reset */
1008         private final long mTotalRadioOnFreqTimeMillis;
1009         /** Data packet contention time statistics */
1010         private final ContentionTimeStats[] mContentionTimeStats;
1011         /** Rate information and statistics */
1012         private final RateStats[] mRateStats;
1013         /** Packet statistics */
1014         private final PacketStats[] mPacketStats;
1015         /** Peer statistics */
1016         private final PeerInfo[] mPeerInfo;
1017         /** Scan results who have the same frequency with this WiFi link */
1018         private final ScanResultWithSameFreq[] mScanResultsWithSameFreq;
1019 
1020         /** @hide */
LinkStats()1021         public LinkStats() {
1022             mLinkId = MloLink.INVALID_MLO_LINK_ID;
1023             mState = LINK_STATE_UNKNOWN;
1024             mRssi = WifiInfo.INVALID_RSSI;
1025             mRadioId = RadioStats.INVALID_RADIO_ID;
1026             mFrequencyMhz = 0;
1027             mRssiMgmt = 0;
1028             mChannelWidth = WIFI_BANDWIDTH_20_MHZ;
1029             mCenterFreqFirstSegment = 0;
1030             mCenterFreqSecondSegment = 0;
1031             mTxLinkSpeedMbps = WifiInfo.LINK_SPEED_UNKNOWN;
1032             mRxLinkSpeedMbps = WifiInfo.LINK_SPEED_UNKNOWN;
1033             mTotalTxSuccess = 0;
1034             mTotalTxRetries = 0;
1035             mTotalTxBad = 0;
1036             mTotalRxSuccess = 0;
1037             mTotalBeaconRx = 0;
1038             mTimeSliceDutyCycleInPercent = 0;
1039             mTotalCcaBusyFreqTimeMillis = 0;
1040             mTotalRadioOnFreqTimeMillis = 0;
1041             mContentionTimeStats = null;
1042             mRateStats = null;
1043             mPacketStats = null;
1044             mPeerInfo = null;
1045             mScanResultsWithSameFreq = null;
1046         }
1047 
1048         /** @hide
1049          * Constructor function
1050          *
1051          * @param linkId                      Identifier of the link.
1052          * @param radioId                     Identifier of the radio on which the link is operating
1053          *                                    currently.
1054          * @param rssi                        Link Rssi (in dBm) at sample time.
1055          * @param frequencyMhz                Frequency of the link in MHz
1056          * @param rssiMgmt                    RSSI of management frames on this WiFi link
1057          * @param channelWidth                channel width of WiFi link
1058          * @param centerFreqFirstSegment      Center frequency (MHz) of first segment
1059          * @param centerFreqSecondSegment     Center frequency (MHz) of second segment
1060          * @param txLinkSpeedMpbs             Transmit link speed in Mpbs at sample time.
1061          * @param rxLinkSpeedMpbs             Receive link speed in Mbps at sample time.
1062          * @param totalTxSuccess              Total number of Tx success.
1063          * @param totalTxRetries              Total packet retries.
1064          * @param totalTxBad                  Total number of bad packets.
1065          * @param totalRxSuccess              Total number of good receive packets.
1066          * @param totalBeaconRx               Total number of beacon received.
1067          * @param timeSliceDutyCycleInPercent Duty cycle of the connection.
1068          * @param totalCcaBusyFreqTimeMillis  Total CCA is on busy status on the link frequency from
1069          *                                    the last radio chip reset.
1070          * @param totalRadioOnFreqTimeMillis  Total Radio on time on the link frequency from the
1071          *                                    last radio chip reset.
1072          * @param contentionTimeStats         Data packet contention time statistics.
1073          * @param rateStats                   Rate information.
1074          * @param packetStats                 Packet statistics.
1075          * @param peerInfo                    Peer statistics.
1076          * @param scanResultsWithSameFreq     Scan results who have the same frequency with this
1077          *                                    WiFi link.
1078          */
LinkStats(int linkId, int state, int radioId, int rssi, int frequencyMhz, int rssiMgmt, @WifiChannelBandwidth int channelWidth, int centerFreqFirstSegment, int centerFreqSecondSegment, int txLinkSpeedMpbs, int rxLinkSpeedMpbs, long totalTxSuccess, long totalTxRetries, long totalTxBad, long totalRxSuccess, long totalBeaconRx, int timeSliceDutyCycleInPercent, long totalCcaBusyFreqTimeMillis, long totalRadioOnFreqTimeMillis, ContentionTimeStats[] contentionTimeStats, RateStats[] rateStats, PacketStats[] packetStats, PeerInfo[] peerInfo, ScanResultWithSameFreq[] scanResultsWithSameFreq)1079         public LinkStats(int linkId, int state, int radioId, int rssi, int frequencyMhz,
1080                 int rssiMgmt, @WifiChannelBandwidth int channelWidth, int centerFreqFirstSegment,
1081                 int centerFreqSecondSegment, int txLinkSpeedMpbs, int rxLinkSpeedMpbs,
1082                 long totalTxSuccess, long totalTxRetries, long totalTxBad, long totalRxSuccess,
1083                 long totalBeaconRx, int timeSliceDutyCycleInPercent,
1084                 long totalCcaBusyFreqTimeMillis, long totalRadioOnFreqTimeMillis,
1085                 ContentionTimeStats[] contentionTimeStats, RateStats[] rateStats,
1086                 PacketStats[] packetStats, PeerInfo[] peerInfo,
1087                 ScanResultWithSameFreq[] scanResultsWithSameFreq) {
1088             this.mLinkId = linkId;
1089             this.mState = state;
1090             this.mRadioId = radioId;
1091             this.mRssi = rssi;
1092             this.mFrequencyMhz = frequencyMhz;
1093             this.mRssiMgmt = rssiMgmt;
1094             this.mChannelWidth = channelWidth;
1095             this.mCenterFreqFirstSegment = centerFreqFirstSegment;
1096             this.mCenterFreqSecondSegment = centerFreqSecondSegment;
1097             this.mTxLinkSpeedMbps = txLinkSpeedMpbs;
1098             this.mRxLinkSpeedMbps = rxLinkSpeedMpbs;
1099             this.mTotalTxSuccess = totalTxSuccess;
1100             this.mTotalTxRetries = totalTxRetries;
1101             this.mTotalTxBad = totalTxBad;
1102             this.mTotalRxSuccess = totalRxSuccess;
1103             this.mTotalBeaconRx = totalBeaconRx;
1104             this.mTimeSliceDutyCycleInPercent = timeSliceDutyCycleInPercent;
1105             this.mTotalCcaBusyFreqTimeMillis = totalCcaBusyFreqTimeMillis;
1106             this.mTotalRadioOnFreqTimeMillis = totalRadioOnFreqTimeMillis;
1107             this.mContentionTimeStats = contentionTimeStats;
1108             this.mRateStats = rateStats;
1109             this.mPacketStats = packetStats;
1110             this.mPeerInfo = peerInfo;
1111             this.mScanResultsWithSameFreq = scanResultsWithSameFreq;
1112         }
1113 
1114         @Override
describeContents()1115         public int describeContents() {
1116             return 0;
1117         }
1118 
1119         @Override
writeToParcel(@onNull Parcel dest, int flags)1120         public void writeToParcel(@NonNull Parcel dest, int flags) {
1121             dest.writeInt(mLinkId);
1122             dest.writeInt(mState);
1123             dest.writeInt(mRadioId);
1124             dest.writeInt(mRssi);
1125             dest.writeInt(mFrequencyMhz);
1126             dest.writeInt(mRssiMgmt);
1127             dest.writeInt(mChannelWidth);
1128             dest.writeInt(mCenterFreqFirstSegment);
1129             dest.writeInt(mCenterFreqSecondSegment);
1130             dest.writeInt(mTxLinkSpeedMbps);
1131             dest.writeInt(mRxLinkSpeedMbps);
1132             dest.writeLong(mTotalTxSuccess);
1133             dest.writeLong(mTotalTxRetries);
1134             dest.writeLong(mTotalTxBad);
1135             dest.writeLong(mTotalRxSuccess);
1136             dest.writeLong(mTotalBeaconRx);
1137             dest.writeInt(mTimeSliceDutyCycleInPercent);
1138             dest.writeLong(mTotalCcaBusyFreqTimeMillis);
1139             dest.writeLong(mTotalRadioOnFreqTimeMillis);
1140             dest.writeTypedArray(mContentionTimeStats, flags);
1141             dest.writeTypedArray(mRateStats, flags);
1142             dest.writeTypedArray(mPacketStats, flags);
1143             dest.writeTypedArray(mPeerInfo, flags);
1144             dest.writeTypedArray(mScanResultsWithSameFreq, flags);
1145         }
1146 
1147         /** Implement the Parcelable interface */
1148         @NonNull
1149         public static final Creator<LinkStats> CREATOR =
1150                 new Creator<>() {
1151                     public LinkStats createFromParcel(Parcel in) {
1152                         return new LinkStats(in.readInt(), in.readInt(), in.readInt(), in.readInt(),
1153                                 in.readInt(), in.readInt(), in.readInt(), in.readInt(),
1154                                 in.readInt(), in.readInt(), in.readInt(), in.readLong(),
1155                                 in.readLong(), in.readLong(), in.readLong(), in.readLong(),
1156                                 in.readInt(), in.readLong(), in.readLong(),
1157                                 in.createTypedArray(ContentionTimeStats.CREATOR),
1158                                 in.createTypedArray(RateStats.CREATOR),
1159                                 in.createTypedArray(PacketStats.CREATOR),
1160                                 in.createTypedArray(PeerInfo.CREATOR),
1161                                 in.createTypedArray(ScanResultWithSameFreq.CREATOR));
1162                     }
1163 
1164                     public LinkStats[] newArray(int size) {
1165                         return new LinkStats[size];
1166                     }
1167                 };
1168     }
1169 
1170     /** Link stats per link */
1171     private final SparseArray<LinkStats> mLinkStats;
1172 
1173     /** Constructor function {@hide} */
WifiUsabilityStatsEntry(long timeStampMillis, int rssi, int linkSpeedMbps, long totalTxSuccess, long totalTxRetries, long totalTxBad, long totalRxSuccess, long totalRadioOnTimeMillis, long totalRadioTxTimeMillis, long totalRadioRxTimeMillis, long totalScanTimeMillis, long totalNanScanTimeMillis, long totalBackgroundScanTimeMillis, long totalRoamScanTimeMillis, long totalPnoScanTimeMillis, long totalHotspot2ScanTimeMillis, long totalCcaBusyFreqTimeMillis, long totalRadioOnFreqTimeMillis, long totalBeaconRx, @ProbeStatus int probeStatusSinceLastUpdate, int probeElapsedTimeSinceLastUpdateMillis, int probeMcsRateSinceLastUpdate, int rxLinkSpeedMbps, int timeSliceDutyCycleInPercent, ContentionTimeStats[] contentionTimeStats, RateStats[] rateStats, RadioStats[] radiostats, int channelUtilizationRatio, boolean isThroughputSufficient, boolean isWifiScoringEnabled, boolean isCellularDataAvailable, @NetworkType int cellularDataNetworkType, int cellularSignalStrengthDbm, int cellularSignalStrengthDb, boolean isSameRegisteredCell, SparseArray<LinkStats> linkStats, int wifiLinkCount, @WifiManager.MloMode int mloMode, long txTransmittedBytes, long rxTransmittedBytes, int labelBadEventCount, int wifiFrameworkState, int isNetworkCapabilitiesDownstreamSufficient, int isNetworkCapabilitiesUpstreamSufficient, int isThroughputPredictorDownstreamSufficient, int isThroughputPredictorUpstreamSufficient, boolean isBluetoothConnected, int uwbAdapterState, boolean isLowLatencyActivated, int maxSupportedTxLinkSpeed, int maxSupportedRxLinkSpeed, int voipMode, int threadDeviceRole, int statusDataStall)1174     public WifiUsabilityStatsEntry(long timeStampMillis, int rssi, int linkSpeedMbps,
1175             long totalTxSuccess, long totalTxRetries, long totalTxBad, long totalRxSuccess,
1176             long totalRadioOnTimeMillis, long totalRadioTxTimeMillis, long totalRadioRxTimeMillis,
1177             long totalScanTimeMillis, long totalNanScanTimeMillis,
1178             long totalBackgroundScanTimeMillis,
1179             long totalRoamScanTimeMillis, long totalPnoScanTimeMillis,
1180             long totalHotspot2ScanTimeMillis,
1181             long totalCcaBusyFreqTimeMillis, long totalRadioOnFreqTimeMillis, long totalBeaconRx,
1182             @ProbeStatus int probeStatusSinceLastUpdate, int probeElapsedTimeSinceLastUpdateMillis,
1183             int probeMcsRateSinceLastUpdate, int rxLinkSpeedMbps,
1184             int timeSliceDutyCycleInPercent, ContentionTimeStats[] contentionTimeStats,
1185             RateStats[] rateStats, RadioStats[] radiostats, int channelUtilizationRatio,
1186             boolean isThroughputSufficient, boolean isWifiScoringEnabled,
1187             boolean isCellularDataAvailable, @NetworkType int cellularDataNetworkType,
1188             int cellularSignalStrengthDbm, int cellularSignalStrengthDb,
1189             boolean isSameRegisteredCell, SparseArray<LinkStats> linkStats,
1190             int wifiLinkCount, @WifiManager.MloMode int mloMode,
1191             long txTransmittedBytes, long rxTransmittedBytes, int labelBadEventCount,
1192             int wifiFrameworkState, int isNetworkCapabilitiesDownstreamSufficient,
1193             int isNetworkCapabilitiesUpstreamSufficient,
1194             int isThroughputPredictorDownstreamSufficient,
1195             int isThroughputPredictorUpstreamSufficient, boolean isBluetoothConnected,
1196             int uwbAdapterState, boolean isLowLatencyActivated, int maxSupportedTxLinkSpeed,
1197             int maxSupportedRxLinkSpeed, int voipMode, int threadDeviceRole, int statusDataStall) {
1198         mTimeStampMillis = timeStampMillis;
1199         mRssi = rssi;
1200         mLinkSpeedMbps = linkSpeedMbps;
1201         mTotalTxSuccess = totalTxSuccess;
1202         mTotalTxRetries = totalTxRetries;
1203         mTotalTxBad = totalTxBad;
1204         mTotalRxSuccess = totalRxSuccess;
1205         mTotalRadioOnTimeMillis = totalRadioOnTimeMillis;
1206         mTotalRadioTxTimeMillis = totalRadioTxTimeMillis;
1207         mTotalRadioRxTimeMillis = totalRadioRxTimeMillis;
1208         mTotalScanTimeMillis = totalScanTimeMillis;
1209         mTotalNanScanTimeMillis = totalNanScanTimeMillis;
1210         mTotalBackgroundScanTimeMillis = totalBackgroundScanTimeMillis;
1211         mTotalRoamScanTimeMillis = totalRoamScanTimeMillis;
1212         mTotalPnoScanTimeMillis = totalPnoScanTimeMillis;
1213         mTotalHotspot2ScanTimeMillis = totalHotspot2ScanTimeMillis;
1214         mTotalCcaBusyFreqTimeMillis = totalCcaBusyFreqTimeMillis;
1215         mTotalRadioOnFreqTimeMillis = totalRadioOnFreqTimeMillis;
1216         mTotalBeaconRx = totalBeaconRx;
1217         mProbeStatusSinceLastUpdate = probeStatusSinceLastUpdate;
1218         mProbeElapsedTimeSinceLastUpdateMillis = probeElapsedTimeSinceLastUpdateMillis;
1219         mProbeMcsRateSinceLastUpdate = probeMcsRateSinceLastUpdate;
1220         mRxLinkSpeedMbps = rxLinkSpeedMbps;
1221         mTimeSliceDutyCycleInPercent = timeSliceDutyCycleInPercent;
1222         mContentionTimeStats = contentionTimeStats;
1223         mRateStats = rateStats;
1224         mRadioStats = radiostats;
1225         mChannelUtilizationRatio = channelUtilizationRatio;
1226         mIsThroughputSufficient = isThroughputSufficient;
1227         mIsWifiScoringEnabled = isWifiScoringEnabled;
1228         mIsCellularDataAvailable = isCellularDataAvailable;
1229         mCellularDataNetworkType = cellularDataNetworkType;
1230         mCellularSignalStrengthDbm = cellularSignalStrengthDbm;
1231         mCellularSignalStrengthDb = cellularSignalStrengthDb;
1232         mIsSameRegisteredCell = isSameRegisteredCell;
1233         mLinkStats = linkStats;
1234         mWifiLinkCount = wifiLinkCount;
1235         mMloMode = mloMode;
1236         mTxTransmittedBytes = txTransmittedBytes;
1237         mRxTransmittedBytes = rxTransmittedBytes;
1238         mLabelBadEventCount = labelBadEventCount;
1239         mWifiFrameworkState = wifiFrameworkState;
1240         mIsNetworkCapabilitiesDownstreamSufficient = isNetworkCapabilitiesDownstreamSufficient;
1241         mIsNetworkCapabilitiesUpstreamSufficient = isNetworkCapabilitiesUpstreamSufficient;
1242         mIsThroughputPredictorDownstreamSufficient = isThroughputPredictorDownstreamSufficient;
1243         mIsThroughputPredictorUpstreamSufficient = isThroughputPredictorUpstreamSufficient;
1244         mIsBluetoothConnected = isBluetoothConnected;
1245         mUwbAdapterState = uwbAdapterState;
1246         mIsLowLatencyActivated = isLowLatencyActivated;
1247         mMaxSupportedTxLinkSpeed = maxSupportedTxLinkSpeed;
1248         mMaxSupportedRxLinkSpeed = maxSupportedRxLinkSpeed;
1249         mVoipMode = voipMode;
1250         mThreadDeviceRole = threadDeviceRole;
1251         mStatusDataStall = statusDataStall;
1252     }
1253 
1254     /** Implement the Parcelable interface */
describeContents()1255     public int describeContents() {
1256         return 0;
1257     }
1258 
1259     /** Implement the Parcelable interface */
writeToParcel(Parcel dest, int flags)1260     public void writeToParcel(Parcel dest, int flags) {
1261         dest.writeLong(mTimeStampMillis);
1262         dest.writeInt(mRssi);
1263         dest.writeInt(mLinkSpeedMbps);
1264         dest.writeLong(mTotalTxSuccess);
1265         dest.writeLong(mTotalTxRetries);
1266         dest.writeLong(mTotalTxBad);
1267         dest.writeLong(mTotalRxSuccess);
1268         dest.writeLong(mTotalRadioOnTimeMillis);
1269         dest.writeLong(mTotalRadioTxTimeMillis);
1270         dest.writeLong(mTotalRadioRxTimeMillis);
1271         dest.writeLong(mTotalScanTimeMillis);
1272         dest.writeLong(mTotalNanScanTimeMillis);
1273         dest.writeLong(mTotalBackgroundScanTimeMillis);
1274         dest.writeLong(mTotalRoamScanTimeMillis);
1275         dest.writeLong(mTotalPnoScanTimeMillis);
1276         dest.writeLong(mTotalHotspot2ScanTimeMillis);
1277         dest.writeLong(mTotalCcaBusyFreqTimeMillis);
1278         dest.writeLong(mTotalRadioOnFreqTimeMillis);
1279         dest.writeLong(mTotalBeaconRx);
1280         dest.writeInt(mProbeStatusSinceLastUpdate);
1281         dest.writeInt(mProbeElapsedTimeSinceLastUpdateMillis);
1282         dest.writeInt(mProbeMcsRateSinceLastUpdate);
1283         dest.writeInt(mRxLinkSpeedMbps);
1284         dest.writeInt(mTimeSliceDutyCycleInPercent);
1285         dest.writeTypedArray(mContentionTimeStats, flags);
1286         dest.writeTypedArray(mRateStats, flags);
1287         dest.writeTypedArray(mRadioStats, flags);
1288         dest.writeInt(mChannelUtilizationRatio);
1289         dest.writeBoolean(mIsThroughputSufficient);
1290         dest.writeBoolean(mIsWifiScoringEnabled);
1291         dest.writeBoolean(mIsCellularDataAvailable);
1292         dest.writeInt(mCellularDataNetworkType);
1293         dest.writeInt(mCellularSignalStrengthDbm);
1294         dest.writeInt(mCellularSignalStrengthDb);
1295         dest.writeBoolean(mIsSameRegisteredCell);
1296         dest.writeSparseArray(mLinkStats);
1297         dest.writeInt(mWifiLinkCount);
1298         dest.writeInt(mMloMode);
1299         dest.writeLong(mTxTransmittedBytes);
1300         dest.writeLong(mRxTransmittedBytes);
1301         dest.writeInt(mLabelBadEventCount);
1302         dest.writeInt(mWifiFrameworkState);
1303         dest.writeInt(mIsNetworkCapabilitiesDownstreamSufficient);
1304         dest.writeInt(mIsNetworkCapabilitiesUpstreamSufficient);
1305         dest.writeInt(mIsThroughputPredictorDownstreamSufficient);
1306         dest.writeInt(mIsThroughputPredictorUpstreamSufficient);
1307         dest.writeBoolean(mIsBluetoothConnected);
1308         dest.writeInt(mUwbAdapterState);
1309         dest.writeBoolean(mIsLowLatencyActivated);
1310         dest.writeInt(mMaxSupportedTxLinkSpeed);
1311         dest.writeInt(mMaxSupportedRxLinkSpeed);
1312         dest.writeInt(mVoipMode);
1313         dest.writeInt(mThreadDeviceRole);
1314         dest.writeInt(mStatusDataStall);
1315     }
1316 
1317     /** Implement the Parcelable interface */
1318     public static final @android.annotation.NonNull Creator<WifiUsabilityStatsEntry> CREATOR =
1319             new Creator<WifiUsabilityStatsEntry>() {
1320         public WifiUsabilityStatsEntry createFromParcel(Parcel in) {
1321             return new WifiUsabilityStatsEntry(
1322                     in.readLong(), in.readInt(),
1323                     in.readInt(), in.readLong(), in.readLong(),
1324                     in.readLong(), in.readLong(), in.readLong(),
1325                     in.readLong(), in.readLong(), in.readLong(),
1326                     in.readLong(), in.readLong(), in.readLong(),
1327                     in.readLong(), in.readLong(), in.readLong(),
1328                     in.readLong(), in.readLong(), in.readInt(),
1329                     in.readInt(), in.readInt(), in.readInt(),
1330                     in.readInt(), in.createTypedArray(ContentionTimeStats.CREATOR),
1331                     in.createTypedArray(RateStats.CREATOR),
1332                     in.createTypedArray(RadioStats.CREATOR),
1333                     in.readInt(), in.readBoolean(), in.readBoolean(),
1334                     in.readBoolean(), in.readInt(), in.readInt(),
1335                     in.readInt(), in.readBoolean(),
1336                     in.readSparseArray(LinkStats.class.getClassLoader()), in.readInt(),
1337                     in.readInt(), in.readLong(), in.readLong(), in.readInt(), in.readInt(),
1338                     in.readInt(), in.readInt(), in.readInt(), in.readInt(), in.readBoolean(),
1339                     in.readInt(), in.readBoolean(), in.readInt(), in.readInt(), in.readInt(),
1340                     in.readInt(), in.readInt()
1341             );
1342         }
1343 
1344         public WifiUsabilityStatsEntry[] newArray(int size) {
1345             return new WifiUsabilityStatsEntry[size];
1346         }
1347     };
1348 
1349     /** Get identifiers of the links if multi link configuration exists.
1350      *
1351      * @return An array of link identifiers if exists, otherwise null.
1352      */
1353     @Nullable
getLinkIds()1354     public int[] getLinkIds() {
1355         if (mLinkStats == null) return null;
1356         int[] result = new int[mLinkStats.size()];
1357         for (int i = 0; i < mLinkStats.size(); i++) {
1358             result[i] = mLinkStats.keyAt(i);
1359         }
1360         return result;
1361     }
1362 
1363     /**
1364      * Get link state. Refer {@link LinkState}.
1365      *
1366      * @param linkId Identifier of the link.
1367      * @return Link state.
1368      * @throws NoSuchElementException if linkId is invalid.
1369      */
getLinkState(int linkId)1370     public @LinkState int getLinkState(int linkId) {
1371         if (mLinkStats.contains(linkId)) return mLinkStats.get(linkId).mState;
1372         throw new NoSuchElementException("linkId is invalid - " + linkId);
1373     }
1374 
1375     /** Absolute milliseconds from device boot when these stats were sampled */
getTimeStampMillis()1376     public long getTimeStampMillis() {
1377         return mTimeStampMillis;
1378     }
1379 
1380     /**
1381      * The RSSI (in dBm) at the sample time. In case of Multi Link Operation (MLO), returned RSSI is
1382      * the highest of all associated links.
1383      *
1384      * @return the RSSI.
1385      */
getRssi()1386     public int getRssi() {
1387         return mRssi;
1388     }
1389 
1390     /** The RSSI (in dBm) of the link at the sample time.
1391      *
1392      * @param linkId Identifier of the link.
1393      * @return RSSI in dBm.
1394      * @throws NoSuchElementException if linkId is invalid.
1395      */
getRssi(int linkId)1396     public int getRssi(int linkId) {
1397         if (mLinkStats.contains(linkId)) return mLinkStats.get(linkId).mRssi;
1398         throw new NoSuchElementException("linkId is invalid - " + linkId);
1399     }
1400 
1401     /**
1402      * Get firmware/hardware implementation specific persistent value for this
1403      * device, identifying the radio interface for which the stats are produced.
1404      *
1405      * @param linkId Identifier of the link.
1406      * @return Radio identifier.
1407      * @throws NoSuchElementException if linkId is invalid.
1408      */
getRadioId(int linkId)1409     public long getRadioId(int linkId) {
1410         if (mLinkStats.contains(linkId)) return mLinkStats.get(linkId).mRadioId;
1411         throw new NoSuchElementException("linkId is invalid - " + linkId);
1412     }
1413 
1414     /**
1415      * Get frequency of specific WiFi link
1416      *
1417      * @param linkId Identifier of the link.
1418      * @return Frequency in Mhz
1419      * @throws NoSuchElementException if linkId is invalid.
1420      */
1421     /** @hide */
getFrequencyMhz(int linkId)1422     public int getFrequencyMhz(int linkId) {
1423         if (mLinkStats.contains(linkId)) return mLinkStats.get(linkId).mFrequencyMhz;
1424         throw new NoSuchElementException("linkId is invalid - " + linkId);
1425     }
1426 
1427     /**
1428      * Get RSSI of management frames on this WiFi link
1429      *
1430      * @param linkId Identifier of the link.
1431      * @return RSSI of management frames on this WiFi link
1432      * @throws NoSuchElementException if linkId is invalid.
1433      */
1434     /** @hide */
getRssiMgmt(int linkId)1435     public int getRssiMgmt(int linkId) {
1436         if (mLinkStats.contains(linkId)) return mLinkStats.get(linkId).mRssiMgmt;
1437         throw new NoSuchElementException("linkId is invalid - " + linkId);
1438     }
1439 
1440     /**
1441      * Get channel width of this WiFi link
1442      *
1443      * @param linkId Identifier of the link.
1444      * @return channel width of this WiFi link
1445      * @throws NoSuchElementException if linkId is invalid.
1446      */
1447     /** @hide */
getChannelWidth(int linkId)1448     public int getChannelWidth(int linkId) {
1449         if (mLinkStats.contains(linkId)) {
1450             return mLinkStats.get(linkId).mChannelWidth;
1451         }
1452         throw new NoSuchElementException("linkId is invalid - " + linkId);
1453     }
1454 
1455     /**
1456      * Get center frequency (MHz) of first segment of this WiFi link
1457      *
1458      * @param linkId Identifier of the link.
1459      * @return center frequency (MHz) of first segment of this WiFi link
1460      * @throws NoSuchElementException if linkId is invalid.
1461      */
1462     /** @hide */
getCenterFreqFirstSegment(int linkId)1463     public int getCenterFreqFirstSegment(int linkId) {
1464         if (mLinkStats.contains(linkId)) {
1465             return mLinkStats.get(linkId).mCenterFreqFirstSegment;
1466         }
1467         throw new NoSuchElementException("linkId is invalid - " + linkId);
1468     }
1469 
1470     /**
1471      * Get center frequency (MHz) of second segment of this WiFi link
1472      *
1473      * @param linkId Identifier of the link.
1474      * @return center frequency (MHz) of second segment of this WiFi link
1475      * @throws NoSuchElementException if linkId is invalid.
1476      */
1477     /** @hide */
getCenterFreqSecondSegment(int linkId)1478     public int getCenterFreqSecondSegment(int linkId) {
1479         if (mLinkStats.contains(linkId)) {
1480             return mLinkStats.get(linkId).mCenterFreqSecondSegment;
1481         }
1482         throw new NoSuchElementException("linkId is invalid - " + linkId);
1483     }
1484 
1485     /** Link speed at the sample time in Mbps. In case of Multi Link Operation (MLO), returned value
1486      *  is the current link speed of the associated link with the highest RSSI.
1487      *
1488      * @return Link speed in Mpbs or {@link WifiInfo#LINK_SPEED_UNKNOWN} if link speed is unknown.
1489      */
getLinkSpeedMbps()1490     public int getLinkSpeedMbps() {
1491         return mLinkSpeedMbps;
1492     }
1493 
1494     /**
1495      * Tx Link speed of the link at the sample time in Mbps.
1496      *
1497      * @param linkId Identifier of the link.
1498      * @return Transmit link speed in Mpbs or {@link WifiInfo#LINK_SPEED_UNKNOWN} if link speed
1499      * is unknown.
1500      * @throws NoSuchElementException if linkId is invalid.
1501      */
getTxLinkSpeedMbps(int linkId)1502     public int getTxLinkSpeedMbps(int linkId) {
1503         if (mLinkStats.contains(linkId)) return mLinkStats.get(linkId).mTxLinkSpeedMbps;
1504         throw new NoSuchElementException("linkId is invalid - " + linkId);
1505     }
1506 
1507     /**
1508      * The total number of tx success counted from the last radio chip reset.  In case of Multi
1509      * Link Operation (MLO), the returned value is the sum of total number of tx success on all
1510      * associated links.
1511      *
1512      * @return total tx success count.
1513      */
getTotalTxSuccess()1514     public long getTotalTxSuccess() {
1515         return mTotalTxSuccess;
1516     }
1517 
1518     /**
1519      * The total number of tx success on a link counted from the last radio chip reset.
1520      *
1521      * @param linkId Identifier of the link.
1522      * @return total tx success count.
1523      * @throws NoSuchElementException if linkId is invalid.
1524      */
getTotalTxSuccess(int linkId)1525     public long getTotalTxSuccess(int linkId) {
1526         if (mLinkStats.contains(linkId)) return mLinkStats.get(linkId).mTotalTxSuccess;
1527         throw new NoSuchElementException("linkId is invalid - " + linkId);
1528     }
1529 
1530     /**
1531      * The total number of MPDU data packet retries counted from the last radio chip reset. In
1532      * case of Multi Link Operation (MLO), the returned value is the sum of total number of MPDU
1533      * data packet retries on all associated links.
1534      *
1535      * @return total tx retries count.
1536      */
getTotalTxRetries()1537     public long getTotalTxRetries() {
1538         return mTotalTxRetries;
1539     }
1540 
1541     /**
1542      * The total number of MPDU data packet retries on a link counted from the last radio chip
1543      * reset.
1544      *
1545      * @param linkId Identifier of the link.
1546      * @return total tx retries count.
1547      * @throws NoSuchElementException if linkId is invalid.
1548      */
getTotalTxRetries(int linkId)1549     public long getTotalTxRetries(int linkId) {
1550         if (mLinkStats.contains(linkId)) return mLinkStats.get(linkId).mTotalTxRetries;
1551         throw new NoSuchElementException("linkId is invalid - " + linkId);
1552     }
1553 
1554     /**
1555      * The total number of tx bad counted from the last radio chip reset. In case of Multi Link
1556      * Operation (MLO), the returned value is the sum of total number of tx bad on all associated
1557      * links.
1558      *
1559      * @return total tx bad count.
1560      */
getTotalTxBad()1561     public long getTotalTxBad() {
1562         return mTotalTxBad;
1563     }
1564 
1565     /**
1566      * The total number of tx bad on a link counted from the last radio chip reset.
1567      *
1568      * @param linkId Identifier of the link.
1569      * @return total tx bad count.
1570      * @throws NoSuchElementException if linkId is invalid.
1571      */
getTotalTxBad(int linkId)1572     public long getTotalTxBad(int linkId) {
1573         if (mLinkStats.contains(linkId)) return mLinkStats.get(linkId).mTotalTxBad;
1574         throw new NoSuchElementException("linkId is invalid - " + linkId);
1575     }
1576 
1577     /**
1578      * The total number of rx success counted from the last radio chip reset. In case of Multi
1579      * Link Operation (MLO), the returned value is the sum of total number of rx success on all
1580      * associated links.
1581      *
1582      * @return total rx success count.
1583      */
getTotalRxSuccess()1584     public long getTotalRxSuccess() {
1585         return mTotalRxSuccess;
1586     }
1587 
1588     /**
1589      * The total number of rx success on a link counted from the last radio chip reset.
1590      *
1591      * @param linkId Identifier of the link.
1592      * @return total rx success count.
1593      * @throws NoSuchElementException if linkId is invalid.
1594      */
getTotalRxSuccess(int linkId)1595     public long getTotalRxSuccess(int linkId) {
1596         if (mLinkStats.contains(linkId)) return mLinkStats.get(linkId).mTotalRxSuccess;
1597         throw new NoSuchElementException("linkId is invalid - " + linkId);
1598     }
1599 
1600     /** The total time the wifi radio is on in ms counted from the last radio chip reset */
getTotalRadioOnTimeMillis()1601     public long getTotalRadioOnTimeMillis() {
1602         return mTotalRadioOnTimeMillis;
1603     }
1604 
1605     /** The total time the wifi radio is doing tx in ms counted from the last radio chip reset */
getTotalRadioTxTimeMillis()1606     public long getTotalRadioTxTimeMillis() {
1607         return mTotalRadioTxTimeMillis;
1608     }
1609 
1610     /** The total time the wifi radio is doing rx in ms counted from the last radio chip reset */
getTotalRadioRxTimeMillis()1611     public long getTotalRadioRxTimeMillis() {
1612         return mTotalRadioRxTimeMillis;
1613     }
1614 
1615     /** The total time spent on all types of scans in ms counted from the last radio chip reset */
getTotalScanTimeMillis()1616     public long getTotalScanTimeMillis() {
1617         return mTotalScanTimeMillis;
1618     }
1619 
1620     /** The total time spent on nan scans in ms counted from the last radio chip reset */
getTotalNanScanTimeMillis()1621     public long getTotalNanScanTimeMillis() {
1622         return mTotalNanScanTimeMillis;
1623     }
1624 
1625     /** The total time spent on background scans in ms counted from the last radio chip reset */
getTotalBackgroundScanTimeMillis()1626     public long getTotalBackgroundScanTimeMillis() {
1627         return mTotalBackgroundScanTimeMillis;
1628     }
1629 
1630     /** The total time spent on roam scans in ms counted from the last radio chip reset */
getTotalRoamScanTimeMillis()1631     public long getTotalRoamScanTimeMillis() {
1632         return mTotalRoamScanTimeMillis;
1633     }
1634 
1635     /** The total time spent on pno scans in ms counted from the last radio chip reset */
getTotalPnoScanTimeMillis()1636     public long getTotalPnoScanTimeMillis() {
1637         return mTotalPnoScanTimeMillis;
1638     }
1639 
1640     /** The total time spent on hotspot2.0 scans and GAS exchange in ms counted from the last radio
1641      * chip reset */
getTotalHotspot2ScanTimeMillis()1642     public long getTotalHotspot2ScanTimeMillis() {
1643         return mTotalHotspot2ScanTimeMillis;
1644     }
1645 
1646     /**
1647      * The total time CCA is on busy status on the current frequency in ms counted from the last
1648      * radio chip reset.In case of Multi Link Operation (MLO), returned value is the total time
1649      * CCA is on busy status on the current frequency of the associated link with the highest
1650      * RSSI.
1651      */
getTotalCcaBusyFreqTimeMillis()1652     public long getTotalCcaBusyFreqTimeMillis() {
1653         return mTotalCcaBusyFreqTimeMillis;
1654     }
1655 
1656     /**
1657      * The total time CCA is on busy status on the link frequency in ms counted from the last radio
1658      * chip reset.
1659      *
1660      * @param linkId Identifier of the link.
1661      * @return total time CCA is on busy status for the link in ms.
1662      * @throws NoSuchElementException if linkId is invalid.
1663      */
1664     @FlaggedApi(Flags.FLAG_ANDROID_V_WIFI_API)
getTotalCcaBusyFreqTimeMillis(int linkId)1665     public long getTotalCcaBusyFreqTimeMillis(int linkId) {
1666         if (mLinkStats.contains(linkId)) return mLinkStats.get(linkId).mTotalCcaBusyFreqTimeMillis;
1667         throw new NoSuchElementException("linkId is invalid - " + linkId);
1668     }
1669 
1670     /**
1671      * The total radio on time on the current frequency from the last radio chip reset. In case of
1672      * Multi Link Operation (MLO), returned value is the total time radio on time on the current
1673      * frequency of the associated link with the highest RSSI.
1674      */
getTotalRadioOnFreqTimeMillis()1675     public long getTotalRadioOnFreqTimeMillis() {
1676         return mTotalRadioOnFreqTimeMillis;
1677     }
1678 
1679     /**
1680      * The total radio on time on the link frequency from the last radio chip reset
1681      *
1682      * @param linkId Identifier of the link.
1683      * @return The total radio on time for the link in ms.
1684      * @throws NoSuchElementException if linkId is invalid.
1685      */
1686     @FlaggedApi(Flags.FLAG_ANDROID_V_WIFI_API)
getTotalRadioOnFreqTimeMillis(int linkId)1687     public long getTotalRadioOnFreqTimeMillis(int linkId) {
1688         if (mLinkStats.contains(linkId)) return mLinkStats.get(linkId).mTotalRadioOnFreqTimeMillis;
1689         throw new NoSuchElementException("linkId is invalid - " + linkId);
1690     }
1691 
1692     /**
1693      * The total number of beacons received from the last radio chip reset. In case of Multi Link
1694      * Operation (MLO), the returned value is the beacons received on the associated link with
1695      * the highest RSSI.
1696      *
1697      * @return total beacons received.
1698      */
getTotalBeaconRx()1699     public long getTotalBeaconRx() {
1700         return mTotalBeaconRx;
1701     }
1702 
1703     /**
1704      * The total number of beacons received from the last radio chip reset.
1705      *
1706      * @param linkId Identifier of the link.
1707      * @return total beacons received.
1708      * @throws NoSuchElementException if linkId is invalid.
1709      */
getTotalBeaconRx(int linkId)1710     public long getTotalBeaconRx(int linkId) {
1711         if (mLinkStats.contains(linkId)) return mLinkStats.get(linkId).mTotalBeaconRx;
1712         throw new NoSuchElementException("linkId is invalid - " + linkId);
1713     }
1714 
1715     /** The status of link probe since last stats update */
getProbeStatusSinceLastUpdate()1716     @ProbeStatus public int getProbeStatusSinceLastUpdate() {
1717         return mProbeStatusSinceLastUpdate;
1718     }
1719 
1720     /** The elapsed time of the most recent link probe since last stats update */
getProbeElapsedTimeSinceLastUpdateMillis()1721     public int getProbeElapsedTimeSinceLastUpdateMillis() {
1722         return mProbeElapsedTimeSinceLastUpdateMillis;
1723     }
1724 
1725     /** The MCS rate of the most recent link probe since last stats update */
getProbeMcsRateSinceLastUpdate()1726     public int getProbeMcsRateSinceLastUpdate() {
1727         return mProbeMcsRateSinceLastUpdate;
1728     }
1729 
1730     /**
1731      * Rx link speed at the sample time in Mbps. In case of Multi Link Operation (MLO), returned
1732      * value is the receive link speed of the associated link with the highest RSSI.
1733      *
1734      * @return Receive link speed in Mbps or {@link WifiInfo#LINK_SPEED_UNKNOWN} if link speed
1735      * is unknown.
1736      */
getRxLinkSpeedMbps()1737     public int getRxLinkSpeedMbps() {
1738         return mRxLinkSpeedMbps;
1739     }
1740 
1741     /**
1742      * Rx Link speed of the link at the sample time in Mbps.
1743      *
1744      * @param linkId Identifier of the link.
1745      * @return Receive link speed in Mbps or {@link WifiInfo#LINK_SPEED_UNKNOWN} if link speed
1746      * is unknown.
1747      * @throws NoSuchElementException if linkId is invalid.
1748      */
getRxLinkSpeedMbps(int linkId)1749     public int getRxLinkSpeedMbps(int linkId) {
1750         if (mLinkStats.contains(linkId)) return mLinkStats.get(linkId).mRxLinkSpeedMbps;
1751         throw new NoSuchElementException("linkId is invalid - " + linkId);
1752     }
1753 
1754     /**
1755      * Duty cycle of the connection.
1756      * If this connection is being served using time slicing on a radio with one or more interfaces
1757      * (i.e MCC), then this method returns the duty cycle assigned to this interface in percent.
1758      * If no concurrency or not using time slicing during concurrency (i.e SCC or DBS), set to 100.
1759      * In case of Multi Link Operation (MLO), returned value is the duty cycle of the associated
1760      * link with the highest RSSI.
1761      *
1762      * @return duty cycle in percent if known.
1763      * @throws NoSuchElementException if the duty cycle is unknown (not provided by the HAL).
1764      */
getTimeSliceDutyCycleInPercent()1765     public @IntRange(from = 0, to = 100) int getTimeSliceDutyCycleInPercent() {
1766         if (mTimeSliceDutyCycleInPercent == -1) {
1767             throw new NoSuchElementException("Unknown value");
1768         }
1769         return mTimeSliceDutyCycleInPercent;
1770     }
1771 
1772     /**
1773      * Duty cycle of the connection for a link.
1774      * If this connection is being served using time slicing on a radio with one or more interfaces
1775      * (i.e MCC) and links, then this method returns the duty cycle assigned to this interface in
1776      * percent for the link. If no concurrency or not using time slicing during concurrency (i.e SCC
1777      * or DBS), set to 100.
1778      *
1779      * @param linkId Identifier of the link.
1780      * @return duty cycle in percent if known.
1781      * @throws NoSuchElementException if the duty cycle is unknown (not provided by the HAL) or
1782      * linkId is invalid.
1783      */
getTimeSliceDutyCycleInPercent(int linkId)1784     public @IntRange(from = 0, to = 100) int getTimeSliceDutyCycleInPercent(int linkId) {
1785         if (!mLinkStats.contains(linkId)) {
1786             throw new NoSuchElementException("linkId is invalid - " + linkId);
1787         }
1788         if (mLinkStats.get(linkId).mTimeSliceDutyCycleInPercent == -1) {
1789             throw new NoSuchElementException("Unknown value");
1790         }
1791         return mLinkStats.get(linkId).mTimeSliceDutyCycleInPercent;
1792     }
1793 
1794     /**
1795      * Data packet contention time statistics for Access Category. In case of Multi Link
1796      * Operation (MLO), the returned value is the contention stats of the associated link with the
1797      * highest RSSI.
1798      *
1799      * @param ac The access category, see {@link WmeAccessCategory}.
1800      * @return The contention time statistics, see {@link ContentionTimeStats}
1801      */
1802     @NonNull
getContentionTimeStats(@meAccessCategory int ac)1803     public ContentionTimeStats getContentionTimeStats(@WmeAccessCategory int ac) {
1804         if (mContentionTimeStats != null
1805                 && mContentionTimeStats.length == NUM_WME_ACCESS_CATEGORIES) {
1806             return mContentionTimeStats[ac];
1807         }
1808         Log.e(TAG, "The ContentionTimeStats is not filled out correctly: "
1809                 + Arrays.toString(mContentionTimeStats));
1810         return new ContentionTimeStats();
1811     }
1812 
1813     /**
1814      * Data packet contention time statistics of a link for Access Category.
1815      *
1816      * @param linkId Identifier of the link.
1817      * @param ac The access category, see {@link WmeAccessCategory}.
1818      * @return The contention time statistics, see {@link ContentionTimeStats}.
1819      * @throws NoSuchElementException if linkId is invalid.
1820      */
1821     @NonNull
getContentionTimeStats(int linkId, @WmeAccessCategory int ac)1822     public ContentionTimeStats getContentionTimeStats(int linkId, @WmeAccessCategory int ac) {
1823         if (!mLinkStats.contains(linkId)) {
1824             throw new NoSuchElementException("linkId is invalid - " + linkId);
1825         }
1826         ContentionTimeStats[] linkContentionTimeStats = mLinkStats.get(
1827                 linkId).mContentionTimeStats;
1828         if (linkContentionTimeStats != null
1829                 && linkContentionTimeStats.length == NUM_WME_ACCESS_CATEGORIES) {
1830             return linkContentionTimeStats[ac];
1831         }
1832         Log.e(TAG, "The ContentionTimeStats is not filled out correctly: "
1833                 + Arrays.toString(mContentionTimeStats));
1834         return new ContentionTimeStats();
1835     }
1836 
1837     /**
1838      * Packet statistics of a WiFi link for Access Category.
1839      *
1840      * @param linkId Identifier of the link.
1841      * @param ac The access category, see {@link WmeAccessCategory}.
1842      * @return The packet statistics, see {@link PacketStats}.
1843      * @throws NoSuchElementException if linkId is invalid.
1844      */
1845     /** @hide */
1846     @NonNull
getPacketStats(int linkId, @WmeAccessCategory int ac)1847     public PacketStats getPacketStats(int linkId, @WmeAccessCategory int ac) {
1848         if (!mLinkStats.contains(linkId)) {
1849             throw new NoSuchElementException("linkId is invalid - " + linkId);
1850         }
1851         PacketStats[] linkPacketStats = mLinkStats.get(
1852                 linkId).mPacketStats;
1853         if (linkPacketStats != null
1854                 && linkPacketStats.length == NUM_WME_ACCESS_CATEGORIES) {
1855             return linkPacketStats[ac];
1856         }
1857         Log.e(TAG, "The PacketStats is not filled out correctly");
1858         return new PacketStats();
1859     }
1860 
1861     /**
1862      * Rate information and statistics, which are ordered by preamble, modulation and coding scheme
1863      * (MCS), and number of spatial streams (NSS). In case of Multi Link Operation (MLO), the
1864      * returned rate information is that of the associated link with the highest RSSI.
1865      *
1866      * @return A list of rate statistics in the form of a list of {@link RateStats} objects.
1867      *         Depending on the link type, the list is created following the order of:
1868      *         - HT (IEEE Std 802.11-2020, Section 19): LEGACY rates (1Mbps, ..., 54Mbps),
1869      *           HT MCS0, ..., MCS15;
1870      *         - VHT (IEEE Std 802.11-2020, Section 21): LEGACY rates (1Mbps, ..., 54Mbps),
1871      *           VHT MCS0/NSS1, ..., VHT MCS11/NSS1, VHT MCSO/NSS2, ..., VHT MCS11/NSS2;
1872      *         - HE (IEEE Std 802.11ax-2020, Section 27): LEGACY rates (1Mbps, ..., 54Mbps),
1873      *           HE MCS0/NSS1, ..., HE MCS11/NSS1, HE MCSO/NSS2, ..., HE MCS11/NSS2.
1874      *         - EHT (IEEE std 802.11be-2021, Section 36): Legacy rates (1Mbps, ..., 54Mbps),
1875      *           EHT MSC0/NSS1, ..., EHT MCS14/NSS1, EHT MCS0/NSS2, ..., EHT MCS14/NSS2.
1876      */
1877     @NonNull
getRateStats()1878     public List<RateStats> getRateStats() {
1879         if (mRateStats != null) {
1880             return Arrays.asList(mRateStats);
1881         }
1882         return Collections.emptyList();
1883     }
1884 
1885     /**
1886      * Rate information and statistics, which are ordered by preamble, modulation and coding scheme
1887      * (MCS), and number of spatial streams (NSS) for link.
1888      *
1889      * @param linkId Identifier of the link.
1890      * @return A list of rate statistics in the form of a list of {@link RateStats} objects.
1891      *         Depending on the link type, the list is created following the order of:
1892      *         - HT (IEEE Std 802.11-2020, Section 19): LEGACY rates (1Mbps, ..., 54Mbps),
1893      *           HT MCS0, ..., MCS15;
1894      *         - VHT (IEEE Std 802.11-2020, Section 21): LEGACY rates (1Mbps, ..., 54Mbps),
1895      *           VHT MCS0/NSS1, ..., VHT MCS11/NSS1, VHT MCSO/NSS2, ..., VHT MCS11/NSS2;
1896      *         - HE (IEEE Std 802.11ax-2020, Section 27): LEGACY rates (1Mbps, ..., 54Mbps),
1897      *           HE MCS0/NSS1, ..., HE MCS11/NSS1, HE MCSO/NSS2, ..., HE MCS11/NSS2.
1898      *         - EHT (IEEE std 802.11be-2021, Section 36): Legacy rates (1Mbps, ..., 54Mbps),
1899      *           EHT MSC0/NSS1, ..., EHT MCS14/NSS1, EHT MCS0/NSS2, ..., EHT MCS14/NSS2.
1900      * @throws NoSuchElementException if linkId is invalid.
1901      */
1902     @NonNull
getRateStats(int linkId)1903     public List<RateStats> getRateStats(int linkId) {
1904         if (mLinkStats.contains(linkId)) {
1905             RateStats[] rateStats = mLinkStats.get(linkId).mRateStats;
1906             if (rateStats != null) return Arrays.asList(rateStats);
1907             return Collections.emptyList();
1908         }
1909         throw new NoSuchElementException("linkId is invalid - " + linkId);
1910     }
1911 
1912     /**
1913      * Rate information and statistics, which are ordered by preamble, modulation and coding scheme
1914      * (MCS), and number of spatial streams (NSS) for WiFi peer.
1915      *
1916      * @param linkId Identifier of the link.
1917      * @param peerIndex Identifier of PeerInfo.
1918      * @return A list of rate statistics in the form of a list of {@link RateStats} objects.
1919      *         Depending on the link type, the list is created following the order of:
1920      *         - HT (IEEE Std 802.11-2020, Section 19): LEGACY rates (1Mbps, ..., 54Mbps),
1921      *           HT MCS0, ..., MCS15;
1922      *         - VHT (IEEE Std 802.11-2020, Section 21): LEGACY rates (1Mbps, ..., 54Mbps),
1923      *           VHT MCS0/NSS1, ..., VHT MCS11/NSS1, VHT MCSO/NSS2, ..., VHT MCS11/NSS2;
1924      *         - HE (IEEE Std 802.11ax-2020, Section 27): LEGACY rates (1Mbps, ..., 54Mbps),
1925      *           HE MCS0/NSS1, ..., HE MCS11/NSS1, HE MCSO/NSS2, ..., HE MCS11/NSS2.
1926      *         - EHT (IEEE std 802.11be-2021, Section 36): Legacy rates (1Mbps, ..., 54Mbps),
1927      *           EHT MSC0/NSS1, ..., EHT MCS14/NSS1, EHT MCS0/NSS2, ..., EHT MCS14/NSS2.
1928      * @throws NoSuchElementException if linkId is invalid.
1929      */
1930     /** @hide */
1931     @NonNull
getRateStats(int linkId, int peerIndex)1932     public List<RateStats> getRateStats(int linkId, int peerIndex) {
1933         if (mLinkStats.contains(linkId)) {
1934             if (getPeerInfo(linkId).size() > 0 && peerIndex < getPeerInfo(linkId).size()) {
1935                 RateStats[] rateStats = mLinkStats.get(linkId).mPeerInfo[peerIndex].mRateStats;
1936                 if (rateStats != null) return Arrays.asList(rateStats);
1937             }
1938             return Collections.emptyList();
1939         }
1940         throw new NoSuchElementException("linkId is invalid - " + linkId);
1941     }
1942 
1943     /**
1944      * Peer information and statistics
1945      *
1946      * @param linkId Identifier of the link.
1947      * @return A list of peer statistics in the form of a list of {@link PeerInfo} objects.
1948      * @throws NoSuchElementException if linkId is invalid.
1949      */
1950     /** @hide */
1951     @NonNull
getPeerInfo(int linkId)1952     public List<PeerInfo> getPeerInfo(int linkId) {
1953         if (mLinkStats.contains(linkId)) {
1954             PeerInfo[] peerInfo = mLinkStats.get(linkId).mPeerInfo;
1955             if (peerInfo != null) return Arrays.asList(peerInfo);
1956             return Collections.emptyList();
1957         }
1958         throw new NoSuchElementException("linkId is invalid - " + linkId);
1959     }
1960 
1961     /**
1962      * Scan results who have the same frequency with this WiFi link
1963      *
1964      * @param linkId Identifier of the link.
1965      * @return An array of Scan results who have the same frequency with this WiFi link
1966      * @throws NoSuchElementException if linkId is invalid.
1967      */
1968     /** @hide */
1969     @NonNull
getScanResultsWithSameFreq(int linkId)1970     public ScanResultWithSameFreq[] getScanResultsWithSameFreq(int linkId) {
1971         if (mLinkStats.contains(linkId)) {
1972             ScanResultWithSameFreq[] scanResultsWithSameFreq =
1973                 mLinkStats.get(linkId).mScanResultsWithSameFreq;
1974             return scanResultsWithSameFreq;
1975         }
1976         throw new NoSuchElementException("linkId is invalid - " + linkId);
1977     }
1978 
1979     /**
1980      * Radio stats from all the radios, see {@link RadioStats#getRadioId()}
1981      * @return A list of Wifi link layer radio stats, see {@link RadioStats}
1982      */
1983     @NonNull
getWifiLinkLayerRadioStats()1984     public List<RadioStats> getWifiLinkLayerRadioStats() {
1985         if (mRadioStats != null) {
1986             return Arrays.asList(mRadioStats);
1987         }
1988         return Collections.emptyList();
1989     }
1990 
1991     /**
1992      * Channel utilization ratio on the current channel.
1993      *
1994      * @return The channel utilization ratio (value) in the range of [0, 255], where x corresponds
1995      *         to (x * 100 / 255)%, or -1 indicating that there is no valid value to return.
1996      */
getChannelUtilizationRatio()1997     public @IntRange(from = -1, to = 255) int getChannelUtilizationRatio() {
1998         return mChannelUtilizationRatio;
1999     }
2000 
2001     /**
2002      * Indicate whether current link layer (L2) throughput is sufficient.  L2 throughput is
2003      * sufficient when one of the following conditions is met: 1) L3 throughput is low and L2
2004      * throughput is above its low threshold; 2) L3 throughput is not low and L2 throughput over L3
2005      * throughput ratio is above a threshold; 3) L3 throughput is not low and L2 throughput is
2006      * above its high threshold.
2007      *
2008      * @return true if it is sufficient or false if it is insufficient.
2009      */
isThroughputSufficient()2010     public boolean isThroughputSufficient() {
2011         return mIsThroughputSufficient;
2012     }
2013 
2014     /**
2015      * Indicate whether Wi-Fi scoring is enabled by the user,
2016      * see {@link WifiManager#setWifiScoringEnabled(boolean)}.
2017      *
2018      * @return true if it is enabled.
2019      */
isWifiScoringEnabled()2020     public boolean isWifiScoringEnabled() {
2021         return mIsWifiScoringEnabled;
2022     }
2023 
2024     /**
2025      * Indicate whether Cellular data is available.
2026      *
2027      * @return true if it is available and false otherwise.
2028      */
isCellularDataAvailable()2029     public boolean isCellularDataAvailable() {
2030         return mIsCellularDataAvailable;
2031     }
2032 
2033     /** Cellular data network type currently in use on the device for data transmission */
getCellularDataNetworkType()2034     @NetworkType public int getCellularDataNetworkType() {
2035         return mCellularDataNetworkType;
2036     }
2037 
2038     /**
2039      * Cellular signal strength in dBm, NR: CsiRsrp, LTE: Rsrp, WCDMA/TDSCDMA: Rscp,
2040      * CDMA: Rssi, EVDO: Rssi, GSM: Rssi
2041      */
getCellularSignalStrengthDbm()2042     public int getCellularSignalStrengthDbm() {
2043         return mCellularSignalStrengthDbm;
2044     }
2045 
2046     /**
2047      * Cellular signal strength in dB, NR: CsiSinr, LTE: Rsrq, WCDMA: EcNo, TDSCDMA: invalid,
2048      * CDMA: Ecio, EVDO: SNR, GSM: invalid
2049      */
getCellularSignalStrengthDb()2050     public int getCellularSignalStrengthDb() {
2051         return mCellularSignalStrengthDb;
2052     }
2053 
2054     /** Whether the primary registered cell of current entry is same as that of previous entry */
isSameRegisteredCell()2055     public boolean isSameRegisteredCell() {
2056         return mIsSameRegisteredCell;
2057     }
2058 
2059     /** @hide */
getWifiLinkCount()2060     public int getWifiLinkCount() {
2061         return mWifiLinkCount;
2062     }
2063 
2064     /** @hide */
getMloMode()2065     public int getMloMode() {
2066         return mMloMode;
2067     }
2068 
2069     /** @hide */
getTxTransmittedBytes()2070     public long getTxTransmittedBytes() {
2071         return mTxTransmittedBytes;
2072     }
2073 
2074     /** @hide */
getRxTransmittedBytes()2075     public long getRxTransmittedBytes() {
2076         return mRxTransmittedBytes;
2077     }
2078 
2079     /** @hide */
getLabelBadEventCount()2080     public long getLabelBadEventCount() {
2081         return mLabelBadEventCount;
2082     }
2083 
2084     /** @hide */
getWifiFrameworkState()2085     public int getWifiFrameworkState() {
2086         return mWifiFrameworkState;
2087     }
2088 
2089     /** @hide */
isNetworkCapabilitiesDownstreamSufficient()2090     public int isNetworkCapabilitiesDownstreamSufficient() {
2091         return mIsNetworkCapabilitiesDownstreamSufficient;
2092     }
2093 
2094     /** @hide */
isNetworkCapabilitiesUpstreamSufficient()2095     public int isNetworkCapabilitiesUpstreamSufficient() {
2096         return mIsNetworkCapabilitiesUpstreamSufficient;
2097     }
2098 
2099     /** @hide */
isThroughputPredictorDownstreamSufficient()2100     public int isThroughputPredictorDownstreamSufficient() {
2101         return mIsThroughputPredictorDownstreamSufficient;
2102     }
2103 
2104     /** @hide */
isThroughputPredictorUpstreamSufficient()2105     public int isThroughputPredictorUpstreamSufficient() {
2106         return mIsThroughputPredictorUpstreamSufficient;
2107     }
2108 
2109     /** @hide */
isBluetoothConnected()2110     public boolean isBluetoothConnected() {
2111         return mIsBluetoothConnected;
2112     }
2113 
2114     /** @hide */
getUwbAdapterState()2115     public int getUwbAdapterState() {
2116         return mUwbAdapterState;
2117     }
2118 
2119     /** @hide */
getLowLatencyModeState()2120     public boolean getLowLatencyModeState() {
2121         return mIsLowLatencyActivated;
2122     }
2123 
2124     /** @hide */
getMaxSupportedTxLinkSpeed()2125     public int getMaxSupportedTxLinkSpeed() {
2126         return mMaxSupportedTxLinkSpeed;
2127     }
2128 
2129     /** @hide */
getMaxSupportedRxLinkSpeed()2130     public int getMaxSupportedRxLinkSpeed() {
2131         return mMaxSupportedRxLinkSpeed;
2132     }
2133 
2134     /** @hide */
getVoipMode()2135     public int getVoipMode() {
2136         return mVoipMode;
2137     }
2138 
2139     /** @hide */
getThreadDeviceRole()2140     public int getThreadDeviceRole() {
2141         return mThreadDeviceRole;
2142     }
2143 
2144     /** @hide */
getStatusDataStall()2145     public int getStatusDataStall() {
2146         return mStatusDataStall;
2147     }
2148 }
2149