Wifi: add APIs to set/get max supported link speed

Add the following APIs:
getMaxSupportedTxLinkSpeed()
setMaxSupportedTxLinkSpeed()
getMaxSupportedRxLinkSpeed()
setMaxSupportedRxLinkSpeed()

Bug: 147390882
Test: atest android.net.wifi
Test: manual test with various APs
Change-Id: I7f3268b2842783f99c0a43d8b4996d0a7dd46c6e
This commit is contained in:
Kai Shi
2020-01-13 15:43:00 -08:00
parent 684c9a2e63
commit 5cb2b67aba
3 changed files with 83 additions and 0 deletions

View File

@@ -30574,6 +30574,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();

View File

@@ -123,11 +123,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
*/
@@ -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;
}
}
@@ -551,6 +565,15 @@ public class WifiInfo implements Parcelable {
return mTxLinkSpeed;
}
/**
* 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
@@ -559,6 +582,14 @@ public class WifiInfo implements Parcelable {
mTxLinkSpeed = txLinkSpeed;
}
/**
* 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.
@@ -569,6 +600,15 @@ public class WifiInfo implements Parcelable {
return mRxLinkSpeed;
}
/**
* 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
@@ -577,6 +617,14 @@ public class WifiInfo implements Parcelable {
mRxLinkSpeed = rxLinkSpeed;
}
/**
* 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.
@@ -853,7 +901,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)
@@ -906,6 +958,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} */
@@ -948,6 +1002,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;
}

View File

@@ -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());
}
}