Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dfef3839 authored by Kai Shi's avatar Kai Shi
Browse files

Wifi usability: add four new fields to report the latest celluar signal

strength

cellularDataNetworkType
cellularSignalStrengthDbm
cellularSignalStrengthDb
isSameRegisteredCell

Bug: 123095038
Test: Unit tests for Wifi: frameworks/base/wifi/tests/runtest.sh

Change-Id: I090e2ab1a327894dfc84e6ce880e887311e1df7d
parent c00ee569
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -4936,6 +4936,10 @@ package android.net.wifi {
  public final class WifiUsabilityStatsEntry implements android.os.Parcelable {
    method public int describeContents();
    method public int getCellularDataNetworkType();
    method public int getCellularSignalStrengthDb();
    method public int getCellularSignalStrengthDbm();
    method public boolean getIsSameRegisteredCell();
    method public int getLinkSpeedMbps();
    method public int getProbeElapsedTimeSinceLastUpdateMillis();
    method public int getProbeMcsRateSinceLastUpdate();
+41 −0
Original line number Diff line number Diff line
@@ -1880,6 +1880,33 @@ message WifiUsabilityStatsEntry {
    PROBE_STATUS_FAILURE = 3;
  }

  // Codes for cellular data network type
  enum CellularDataNetworkType {
    // Unknown network
    NETWORK_TYPE_UNKNOWN = 0;

    // GSM network
    NETWORK_TYPE_GSM = 1;

    // CDMA network
    NETWORK_TYPE_CDMA = 2;

    // CDMA EVDO network
    NETWORK_TYPE_EVDO_0 = 3;

    // WCDMA network
    NETWORK_TYPE_UMTS = 4;

    // TDSCDMA network
    NETWORK_TYPE_TD_SCDMA = 5;

    // LTE network
    NETWORK_TYPE_LTE = 6;

    // NR network
    NETWORK_TYPE_NR = 7;
  }

  // Absolute milliseconds from device boot when these stats were sampled
  optional int64 time_stamp_ms = 1;

@@ -1971,6 +1998,20 @@ message WifiUsabilityStatsEntry {
  // Whether current entry is for the same BSSID on the same frequency compared
  // to last entry
  optional bool is_same_bssid_and_freq = 29;

  // Cellular data network type currently in use on the device for data transmission
  optional CellularDataNetworkType cellular_data_network_type = 30;

  // Cellular signal strength in dBm, NR: CsiRsrp, LTE: Rsrp, WCDMA/TDSCDMA: Rscp,
  // CDMA: Rssi, EVDO: Rssi, GSM: Rssi
  optional int32 cellular_signal_strength_dbm = 31;

  // Cellular signal strength in dB, NR: CsiSinr, LTE: Rsrq, WCDMA: EcNo, TDSCDMA: invalid,
  // CDMA: Ecio, EVDO: SNR, GSM: invalid */
  optional int32 cellular_signal_strength_db = 32;

  // Whether the primary registered cell of current entry is same as that of previous entry
  optional bool is_same_registered_cell = 33;
}

message WifiUsabilityStats {
+46 −2
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.annotation.IntDef;
import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;
import android.telephony.TelephonyManager.NetworkType;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -98,6 +99,10 @@ public final class WifiUsabilityStatsEntry implements Parcelable {
    private final int mProbeMcsRateSinceLastUpdate;
    /** Rx link speed at the sample time in Mbps */
    private final int mRxLinkSpeedMbps;
    private final @NetworkType int mCellularDataNetworkType;
    private final int mCellularSignalStrengthDbm;
    private final int mCellularSignalStrengthDb;
    private final boolean mIsSameRegisteredCell;

    /** Constructor function {@hide} */
    public WifiUsabilityStatsEntry(long timeStampMillis, int rssi, int linkSpeedMbps,
@@ -109,7 +114,10 @@ public final class WifiUsabilityStatsEntry implements Parcelable {
            long totalHotspot2ScanTimeMillis,
            long totalCcaBusyFreqTimeMillis, long totalRadioOnFreqTimeMillis, long totalBeaconRx,
            @ProbeStatus int probeStatusSinceLastUpdate, int probeElapsedTimeSinceLastUpdateMillis,
            int probeMcsRateSinceLastUpdate, int rxLinkSpeedMbps) {
            int probeMcsRateSinceLastUpdate, int rxLinkSpeedMbps,
            @NetworkType int cellularDataNetworkType,
            int cellularSignalStrengthDbm, int cellularSignalStrengthDb,
            boolean isSameRegisteredCell) {
        mTimeStampMillis = timeStampMillis;
        mRssi = rssi;
        mLinkSpeedMbps = linkSpeedMbps;
@@ -133,6 +141,10 @@ public final class WifiUsabilityStatsEntry implements Parcelable {
        mProbeElapsedTimeSinceLastUpdateMillis = probeElapsedTimeSinceLastUpdateMillis;
        mProbeMcsRateSinceLastUpdate = probeMcsRateSinceLastUpdate;
        mRxLinkSpeedMbps = rxLinkSpeedMbps;
        mCellularDataNetworkType = cellularDataNetworkType;
        mCellularSignalStrengthDbm = cellularSignalStrengthDbm;
        mCellularSignalStrengthDb = cellularSignalStrengthDb;
        mIsSameRegisteredCell = isSameRegisteredCell;
    }

    /** Implement the Parcelable interface */
@@ -165,6 +177,10 @@ public final class WifiUsabilityStatsEntry implements Parcelable {
        dest.writeInt(mProbeElapsedTimeSinceLastUpdateMillis);
        dest.writeInt(mProbeMcsRateSinceLastUpdate);
        dest.writeInt(mRxLinkSpeedMbps);
        dest.writeInt(mCellularDataNetworkType);
        dest.writeInt(mCellularSignalStrengthDbm);
        dest.writeInt(mCellularSignalStrengthDb);
        dest.writeBoolean(mIsSameRegisteredCell);
    }

    /** Implement the Parcelable interface */
@@ -179,7 +195,9 @@ public final class WifiUsabilityStatsEntry implements Parcelable {
                    in.readLong(), in.readLong(), in.readLong(),
                    in.readLong(), in.readLong(), in.readLong(),
                    in.readLong(), in.readLong(), in.readInt(),
                    in.readInt(), in.readInt(), in.readInt()
                    in.readInt(), in.readInt(), in.readInt(),
                    in.readInt(), in.readInt(), in.readInt(),
                    in.readBoolean()
            );
        }

@@ -304,4 +322,30 @@ public final class WifiUsabilityStatsEntry implements Parcelable {
    public int getRxLinkSpeedMbps() {
        return mRxLinkSpeedMbps;
    }

    /** Cellular data network type currently in use on the device for data transmission */
    @NetworkType public int getCellularDataNetworkType() {
        return mCellularDataNetworkType;
    }

    /**
     * Cellular signal strength in dBm, NR: CsiRsrp, LTE: Rsrp, WCDMA/TDSCDMA: Rscp,
     * CDMA: Rssi, EVDO: Rssi, GSM: Rssi
     */
    public int getCellularSignalStrengthDbm() {
        return mCellularSignalStrengthDbm;
    }

    /**
     * Cellular signal strength in dB, NR: CsiSinr, LTE: Rsrq, WCDMA: EcNo, TDSCDMA: invalid,
     * CDMA: Ecio, EVDO: SNR, GSM: invalid
     */
    public int getCellularSignalStrengthDb() {
        return mCellularSignalStrengthDb;
    }

    /** Whether the primary registered cell of current entry is same as that of previous entry */
    public boolean getIsSameRegisteredCell() {
        return mIsSameRegisteredCell;
    }
}
+7 −1
Original line number Diff line number Diff line
@@ -74,7 +74,8 @@ public class WifiUsabilityStatsEntryTest {

    private static WifiUsabilityStatsEntry createResult() {
        return new WifiUsabilityStatsEntry(
                0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22
                0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
                14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, true
        );
    }

@@ -111,5 +112,10 @@ public class WifiUsabilityStatsEntryTest {
        assertEquals(expected.getProbeMcsRateSinceLastUpdate(),
                actual.getProbeMcsRateSinceLastUpdate());
        assertEquals(expected.getRxLinkSpeedMbps(), actual.getRxLinkSpeedMbps());
        assertEquals(expected.getCellularDataNetworkType(), actual.getCellularDataNetworkType());
        assertEquals(expected.getCellularSignalStrengthDbm(),
                actual.getCellularSignalStrengthDbm());
        assertEquals(expected.getCellularSignalStrengthDb(), actual.getCellularSignalStrengthDb());
        assertEquals(expected.getIsSameRegisteredCell(), actual.getIsSameRegisteredCell());
    }
}