Merge "Wifi: Settings to have access to Wifi technology"
This commit is contained in:
committed by
Android (Google) Code Review
commit
924d989e85
@@ -29976,10 +29976,16 @@ package android.net.wifi {
|
||||
method public String getSSID();
|
||||
method public android.net.wifi.SupplicantState getSupplicantState();
|
||||
method @IntRange(from=0xffffffff) public int getTxLinkSpeedMbps();
|
||||
method public int getWifiTechnology();
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
field public static final String FREQUENCY_UNITS = "MHz";
|
||||
field public static final String LINK_SPEED_UNITS = "Mbps";
|
||||
field public static final int LINK_SPEED_UNKNOWN = -1; // 0xffffffff
|
||||
field public static final int WIFI_TECHNOLOGY_11AC = 5; // 0x5
|
||||
field public static final int WIFI_TECHNOLOGY_11AX = 6; // 0x6
|
||||
field public static final int WIFI_TECHNOLOGY_11N = 4; // 0x4
|
||||
field public static final int WIFI_TECHNOLOGY_LEGACY = 1; // 0x1
|
||||
field public static final int WIFI_TECHNOLOGY_UNKNOWN = 0; // 0x0
|
||||
}
|
||||
|
||||
public class WifiManager {
|
||||
|
||||
@@ -93,6 +93,7 @@ public class WifiUtils {
|
||||
if (bssid != null) {
|
||||
visibility.append(" ").append(bssid);
|
||||
}
|
||||
visibility.append(" technology = ").append(info.getWifiTechnology());
|
||||
visibility.append(" rssi=").append(info.getRssi());
|
||||
visibility.append(" ");
|
||||
visibility.append(" score=").append(info.score);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package android.net.wifi;
|
||||
|
||||
import android.annotation.IntDef;
|
||||
import android.annotation.IntRange;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.SystemApi;
|
||||
@@ -27,6 +28,8 @@ import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.net.Inet4Address;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
@@ -34,7 +37,7 @@ import java.util.EnumMap;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Describes the state of any Wifi connection that is active or
|
||||
* Describes the state of any Wi-Fi connection that is active or
|
||||
* is in the process of being set up.
|
||||
*/
|
||||
public class WifiInfo implements Parcelable {
|
||||
@@ -95,6 +98,47 @@ public class WifiInfo implements Parcelable {
|
||||
*/
|
||||
private int mRssi;
|
||||
|
||||
/**
|
||||
* Wi-Fi unknown technology
|
||||
*/
|
||||
public static final int WIFI_TECHNOLOGY_UNKNOWN = 0;
|
||||
|
||||
/**
|
||||
* Wi-Fi 802.11a/b/g
|
||||
*/
|
||||
public static final int WIFI_TECHNOLOGY_LEGACY = 1;
|
||||
|
||||
/**
|
||||
* Wi-Fi 802.11n
|
||||
*/
|
||||
public static final int WIFI_TECHNOLOGY_11N = 4;
|
||||
|
||||
/**
|
||||
* Wi-Fi 802.11ac
|
||||
*/
|
||||
public static final int WIFI_TECHNOLOGY_11AC = 5;
|
||||
|
||||
/**
|
||||
* Wi-Fi 802.11ax
|
||||
*/
|
||||
public static final int WIFI_TECHNOLOGY_11AX = 6;
|
||||
|
||||
/** @hide */
|
||||
@IntDef(prefix = { "WIFI_TECHNOLOGY_" }, value = {
|
||||
WIFI_TECHNOLOGY_UNKNOWN,
|
||||
WIFI_TECHNOLOGY_LEGACY,
|
||||
WIFI_TECHNOLOGY_11N,
|
||||
WIFI_TECHNOLOGY_11AC,
|
||||
WIFI_TECHNOLOGY_11AX
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface WifiTechnology{}
|
||||
|
||||
/**
|
||||
* Wi-Fi technology for the connection
|
||||
*/
|
||||
private @WifiTechnology int mWifiTechnology;
|
||||
|
||||
/**
|
||||
* The unit in which links speeds are expressed.
|
||||
*/
|
||||
@@ -286,6 +330,7 @@ public class WifiInfo implements Parcelable {
|
||||
txSuccessRate = source.txSuccessRate;
|
||||
rxSuccessRate = source.rxSuccessRate;
|
||||
score = source.score;
|
||||
mWifiTechnology = source.mWifiTechnology;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -373,6 +418,22 @@ public class WifiInfo implements Parcelable {
|
||||
mRssi = rssi;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Wi-Fi technology
|
||||
* @hide
|
||||
*/
|
||||
public void setWifiTechnology(@WifiTechnology int wifiTechnology) {
|
||||
mWifiTechnology = wifiTechnology;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get connection Wi-Fi technology
|
||||
* @return the connection Wi-Fi technology
|
||||
*/
|
||||
public @WifiTechnology int getWifiTechnology() {
|
||||
return mWifiTechnology;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current link speed in {@link #LINK_SPEED_UNITS}.
|
||||
* @return the link speed or {@link #LINK_SPEED_UNKNOWN} if link speed is unknown.
|
||||
@@ -679,6 +740,7 @@ public class WifiInfo implements Parcelable {
|
||||
.append(", MAC: ").append(mMacAddress == null ? none : mMacAddress)
|
||||
.append(", Supplicant state: ")
|
||||
.append(mSupplicantState == null ? none : mSupplicantState)
|
||||
.append(", Wi-Fi technology: ").append(mWifiTechnology)
|
||||
.append(", RSSI: ").append(mRssi)
|
||||
.append(", Link speed: ").append(mLinkSpeed).append(LINK_SPEED_UNITS)
|
||||
.append(", Tx Link speed: ").append(mTxLinkSpeed).append(LINK_SPEED_UNITS)
|
||||
@@ -734,6 +796,7 @@ public class WifiInfo implements Parcelable {
|
||||
dest.writeString(mNetworkSuggestionOrSpecifierPackageName);
|
||||
dest.writeString(mFqdn);
|
||||
dest.writeString(mProviderFriendlyName);
|
||||
dest.writeInt(mWifiTechnology);
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface {@hide} */
|
||||
@@ -775,6 +838,7 @@ public class WifiInfo implements Parcelable {
|
||||
info.mNetworkSuggestionOrSpecifierPackageName = in.readString();
|
||||
info.mFqdn = in.readString();
|
||||
info.mProviderFriendlyName = in.readString();
|
||||
info.mWifiTechnology = in.readInt();
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ public class WifiInfoTest {
|
||||
private static final String TEST_PACKAGE_NAME = "com.test.example";
|
||||
private static final String TEST_FQDN = "test.com";
|
||||
private static final String TEST_PROVIDER_NAME = "test";
|
||||
private static final int TEST_WIFI_TECHNOLOGY = WifiInfo.WIFI_TECHNOLOGY_11AC;
|
||||
|
||||
/**
|
||||
* Verify parcel write/read with WifiInfo.
|
||||
@@ -54,6 +55,7 @@ public class WifiInfoTest {
|
||||
writeWifiInfo.setFQDN(TEST_FQDN);
|
||||
writeWifiInfo.setProviderFriendlyName(TEST_PROVIDER_NAME);
|
||||
writeWifiInfo.setNetworkSuggestionOrSpecifierPackageName(TEST_PACKAGE_NAME);
|
||||
writeWifiInfo.setWifiTechnology(TEST_WIFI_TECHNOLOGY);
|
||||
|
||||
Parcel parcel = Parcel.obtain();
|
||||
writeWifiInfo.writeToParcel(parcel, 0);
|
||||
@@ -72,5 +74,6 @@ public class WifiInfoTest {
|
||||
assertEquals(TEST_PACKAGE_NAME, readWifiInfo.getNetworkSuggestionOrSpecifierPackageName());
|
||||
assertEquals(TEST_FQDN, readWifiInfo.getPasspointFqdn());
|
||||
assertEquals(TEST_PROVIDER_NAME, readWifiInfo.getPasspointProviderFriendlyName());
|
||||
assertEquals(TEST_WIFI_TECHNOLOGY, readWifiInfo.getWifiTechnology());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user