diff options
| author | 2020-01-17 19:03:48 +0000 | |
|---|---|---|
| committer | 2020-01-17 19:03:48 +0000 | |
| commit | 85f8385f42d8ab44f6f873fcc235188077d95178 (patch) | |
| tree | a61cf96433e526f4f83ab200cc2de5969af23d48 | |
| parent | 17b76c623886c2575849c33266b233a51a982793 (diff) | |
| parent | 5cb2b67abac3af188ee1bdafa3602094a9f20b6d (diff) | |
Merge "Wifi: add APIs to set/get max supported link speed"
| -rw-r--r-- | api/current.txt | 2 | ||||
| -rw-r--r-- | wifi/java/android/net/wifi/WifiInfo.java | 56 | ||||
| -rw-r--r-- | wifi/tests/src/android/net/wifi/WifiInfoTest.java | 25 |
3 files changed, 83 insertions, 0 deletions
diff --git a/api/current.txt b/api/current.txt index 119f0478fe4b..0b35d64651ab 100644 --- a/api/current.txt +++ b/api/current.txt @@ -30626,6 +30626,8 @@ package android.net.wifi { method public int getIpAddress(); method public int getLinkSpeed(); method public String getMacAddress(); + method public int getMaxSupportedRxLinkSpeedMbps(); + method public int getMaxSupportedTxLinkSpeedMbps(); method public int getNetworkId(); method @Nullable public String getPasspointFqdn(); method @Nullable public String getPasspointProviderFriendlyName(); diff --git a/wifi/java/android/net/wifi/WifiInfo.java b/wifi/java/android/net/wifi/WifiInfo.java index 7cd00b9dbb56..f2a875b43538 100644 --- a/wifi/java/android/net/wifi/WifiInfo.java +++ b/wifi/java/android/net/wifi/WifiInfo.java @@ -124,11 +124,21 @@ public class WifiInfo implements Parcelable { private int mTxLinkSpeed; /** + * Max supported Tx(transmit) link speed in Mbps + */ + private int mMaxSupportedTxLinkSpeed; + + /** * Rx(receive) Link speed in Mbps */ private int mRxLinkSpeed; /** + * Max supported Rx(receive) link speed in Mbps + */ + private int mMaxSupportedRxLinkSpeed; + + /** * Frequency in MHz */ public static final String FREQUENCY_UNITS = "MHz"; @@ -303,6 +313,8 @@ public class WifiInfo implements Parcelable { setLinkSpeed(LINK_SPEED_UNKNOWN); setTxLinkSpeedMbps(LINK_SPEED_UNKNOWN); setRxLinkSpeedMbps(LINK_SPEED_UNKNOWN); + setMaxSupportedTxLinkSpeedMbps(LINK_SPEED_UNKNOWN); + setMaxSupportedRxLinkSpeedMbps(LINK_SPEED_UNKNOWN); setFrequency(-1); setMeteredHint(false); setEphemeral(false); @@ -356,6 +368,8 @@ public class WifiInfo implements Parcelable { mRxSuccessRate = source.mRxSuccessRate; score = source.score; mWifiStandard = source.mWifiStandard; + mMaxSupportedTxLinkSpeed = source.mMaxSupportedTxLinkSpeed; + mMaxSupportedRxLinkSpeed = source.mMaxSupportedRxLinkSpeed; } } @@ -552,6 +566,15 @@ public class WifiInfo implements Parcelable { } /** + * Returns the maximum supported transmit link speed in Mbps + * @return the max supported tx link speed or {@link #LINK_SPEED_UNKNOWN} if link speed is + * unknown. @see #LINK_SPEED_UNKNOWN + */ + public int getMaxSupportedTxLinkSpeedMbps() { + return mMaxSupportedTxLinkSpeed; + } + + /** * Update the last transmitted packet bit rate in Mbps. * @hide */ @@ -560,6 +583,14 @@ public class WifiInfo implements Parcelable { } /** + * Set the maximum supported transmit link speed in Mbps + * @hide + */ + public void setMaxSupportedTxLinkSpeedMbps(int maxSupportedTxLinkSpeed) { + mMaxSupportedTxLinkSpeed = maxSupportedTxLinkSpeed; + } + + /** * Returns the current receive link speed in Mbps. * @return the Rx link speed or {@link #LINK_SPEED_UNKNOWN} if link speed is unknown. * @see #LINK_SPEED_UNKNOWN @@ -570,6 +601,15 @@ public class WifiInfo implements Parcelable { } /** + * Returns the maximum supported receive link speed in Mbps + * @return the max supported Rx link speed or {@link #LINK_SPEED_UNKNOWN} if link speed is + * unknown. @see #LINK_SPEED_UNKNOWN + */ + public int getMaxSupportedRxLinkSpeedMbps() { + return mMaxSupportedRxLinkSpeed; + } + + /** * Update the last received packet bit rate in Mbps. * @hide */ @@ -578,6 +618,14 @@ public class WifiInfo implements Parcelable { } /** + * Set the maximum supported receive link speed in Mbps + * @hide + */ + public void setMaxSupportedRxLinkSpeedMbps(int maxSupportedRxLinkSpeed) { + mMaxSupportedRxLinkSpeed = maxSupportedRxLinkSpeed; + } + + /** * Returns the current frequency in {@link #FREQUENCY_UNITS}. * @return the frequency. * @see #FREQUENCY_UNITS @@ -864,7 +912,11 @@ public class WifiInfo implements Parcelable { .append(", RSSI: ").append(mRssi) .append(", Link speed: ").append(mLinkSpeed).append(LINK_SPEED_UNITS) .append(", Tx Link speed: ").append(mTxLinkSpeed).append(LINK_SPEED_UNITS) + .append(", Max Supported Tx Link speed: ") + .append(mMaxSupportedTxLinkSpeed).append(LINK_SPEED_UNITS) .append(", Rx Link speed: ").append(mRxLinkSpeed).append(LINK_SPEED_UNITS) + .append(", Max Supported Rx Link speed: ") + .append(mMaxSupportedRxLinkSpeed).append(LINK_SPEED_UNITS) .append(", Frequency: ").append(mFrequency).append(FREQUENCY_UNITS) .append(", Net ID: ").append(mNetworkId) .append(", Metered hint: ").append(mMeteredHint) @@ -917,6 +969,8 @@ public class WifiInfo implements Parcelable { dest.writeString(mFqdn); dest.writeString(mProviderFriendlyName); dest.writeInt(mWifiStandard); + dest.writeInt(mMaxSupportedTxLinkSpeed); + dest.writeInt(mMaxSupportedRxLinkSpeed); } /** Implement the Parcelable interface {@hide} */ @@ -959,6 +1013,8 @@ public class WifiInfo implements Parcelable { info.mFqdn = in.readString(); info.mProviderFriendlyName = in.readString(); info.mWifiStandard = in.readInt(); + info.mMaxSupportedTxLinkSpeed = in.readInt(); + info.mMaxSupportedRxLinkSpeed = in.readInt(); return info; } diff --git a/wifi/tests/src/android/net/wifi/WifiInfoTest.java b/wifi/tests/src/android/net/wifi/WifiInfoTest.java index f7612341d4b3..af85ce05f23b 100644 --- a/wifi/tests/src/android/net/wifi/WifiInfoTest.java +++ b/wifi/tests/src/android/net/wifi/WifiInfoTest.java @@ -39,6 +39,8 @@ public class WifiInfoTest { private static final String TEST_FQDN = "test.com"; private static final String TEST_PROVIDER_NAME = "test"; private static final int TEST_WIFI_STANDARD = ScanResult.WIFI_STANDARD_11AC; + private static final int TEST_MAX_SUPPORTED_TX_LINK_SPEED_MBPS = 866; + private static final int TEST_MAX_SUPPORTED_RX_LINK_SPEED_MBPS = 1200; /** * Verify parcel write/read with WifiInfo. @@ -56,6 +58,8 @@ public class WifiInfoTest { writeWifiInfo.setProviderFriendlyName(TEST_PROVIDER_NAME); writeWifiInfo.setAppPackageName(TEST_PACKAGE_NAME); writeWifiInfo.setWifiStandard(TEST_WIFI_STANDARD); + writeWifiInfo.setMaxSupportedTxLinkSpeedMbps(TEST_MAX_SUPPORTED_TX_LINK_SPEED_MBPS); + writeWifiInfo.setMaxSupportedRxLinkSpeedMbps(TEST_MAX_SUPPORTED_RX_LINK_SPEED_MBPS); Parcel parcel = Parcel.obtain(); writeWifiInfo.writeToParcel(parcel, 0); @@ -75,5 +79,26 @@ public class WifiInfoTest { assertEquals(TEST_FQDN, readWifiInfo.getPasspointFqdn()); assertEquals(TEST_PROVIDER_NAME, readWifiInfo.getPasspointProviderFriendlyName()); assertEquals(TEST_WIFI_STANDARD, readWifiInfo.getWifiStandard()); + assertEquals(TEST_MAX_SUPPORTED_TX_LINK_SPEED_MBPS, + readWifiInfo.getMaxSupportedTxLinkSpeedMbps()); + assertEquals(TEST_MAX_SUPPORTED_RX_LINK_SPEED_MBPS, + readWifiInfo.getMaxSupportedRxLinkSpeedMbps()); + } + + /** + * Verify values after reset() + */ + @Test + public void testWifiInfoResetValue() throws Exception { + WifiInfo wifiInfo = new WifiInfo(); + wifiInfo.reset(); + assertEquals(WifiInfo.LINK_SPEED_UNKNOWN, wifiInfo.getMaxSupportedTxLinkSpeedMbps()); + assertEquals(WifiInfo.LINK_SPEED_UNKNOWN, wifiInfo.getMaxSupportedRxLinkSpeedMbps()); + assertEquals(WifiInfo.LINK_SPEED_UNKNOWN, wifiInfo.getTxLinkSpeedMbps()); + assertEquals(WifiInfo.LINK_SPEED_UNKNOWN, wifiInfo.getRxLinkSpeedMbps()); + assertEquals(WifiInfo.INVALID_RSSI, wifiInfo.getRssi()); + assertEquals(WifiManager.UNKNOWN_SSID, wifiInfo.getSSID()); + assertEquals(null, wifiInfo.getBSSID()); + assertEquals(-1, wifiInfo.getNetworkId()); } } |