From dfef3839956d64a6752ddc7cf10ef5fdf077a73b Mon Sep 17 00:00:00 2001 From: Kai Shi Date: Tue, 26 Feb 2019 14:55:09 -0800 Subject: [PATCH] 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 --- api/system-current.txt | 4 ++ proto/src/wifi.proto | 41 ++++++++++++++++++ .../android/net/wifi/WifiUsabilityStatsEntry.java | 48 +++++++++++++++++++++- .../net/wifi/WifiUsabilityStatsEntryTest.java | 8 +++- 4 files changed, 98 insertions(+), 3 deletions(-) diff --git a/api/system-current.txt b/api/system-current.txt index 30cc3a58769a..161ad9145bd4 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -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(); diff --git a/proto/src/wifi.proto b/proto/src/wifi.proto index 0d17f22e2edf..1bcc888db7a7 100644 --- a/proto/src/wifi.proto +++ b/proto/src/wifi.proto @@ -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 { diff --git a/wifi/java/android/net/wifi/WifiUsabilityStatsEntry.java b/wifi/java/android/net/wifi/WifiUsabilityStatsEntry.java index 51aa93a1c4c7..01176f223fe2 100644 --- a/wifi/java/android/net/wifi/WifiUsabilityStatsEntry.java +++ b/wifi/java/android/net/wifi/WifiUsabilityStatsEntry.java @@ -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; + } } diff --git a/wifi/tests/src/android/net/wifi/WifiUsabilityStatsEntryTest.java b/wifi/tests/src/android/net/wifi/WifiUsabilityStatsEntryTest.java index 8e371134fbd6..cd60f029dcce 100644 --- a/wifi/tests/src/android/net/wifi/WifiUsabilityStatsEntryTest.java +++ b/wifi/tests/src/android/net/wifi/WifiUsabilityStatsEntryTest.java @@ -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()); } } -- 2.11.0