Merge "wifi: Add SAP generation indication API"
This commit is contained in:
@@ -7204,6 +7204,7 @@ package android.net.wifi {
|
||||
method public int getBandwidth();
|
||||
method @Nullable public android.net.MacAddress getBssid();
|
||||
method public int getFrequency();
|
||||
method public int getWifiStandard();
|
||||
method public void writeToParcel(@NonNull android.os.Parcel, int);
|
||||
field public static final int CHANNEL_WIDTH_160MHZ = 6; // 0x6
|
||||
field public static final int CHANNEL_WIDTH_20MHZ = 2; // 0x2
|
||||
|
||||
@@ -292,6 +292,7 @@ package android.net.wifi {
|
||||
method public int getBandwidth();
|
||||
method @Nullable public android.net.MacAddress getBssid();
|
||||
method public int getFrequency();
|
||||
method public int getWifiStandard();
|
||||
method public void writeToParcel(@NonNull android.os.Parcel, int);
|
||||
field public static final int CHANNEL_WIDTH_160MHZ = 6; // 0x6
|
||||
field public static final int CHANNEL_WIDTH_20MHZ = 2; // 0x2
|
||||
|
||||
@@ -86,8 +86,6 @@ public final class SoftApInfo implements Parcelable {
|
||||
*/
|
||||
public static final int CHANNEL_WIDTH_160MHZ = 6;
|
||||
|
||||
|
||||
|
||||
/** The frequency which AP resides on. */
|
||||
private int mFrequency = 0;
|
||||
|
||||
@@ -98,6 +96,11 @@ public final class SoftApInfo implements Parcelable {
|
||||
@Nullable
|
||||
private MacAddress mBssid;
|
||||
|
||||
/**
|
||||
* The operational mode of the AP.
|
||||
*/
|
||||
private @WifiAnnotations.WifiStandard int mWifiStandard = ScanResult.WIFI_STANDARD_UNKNOWN;
|
||||
|
||||
/**
|
||||
* Get the frequency which AP resides on.
|
||||
*/
|
||||
@@ -162,6 +165,27 @@ public final class SoftApInfo implements Parcelable {
|
||||
mBssid = bssid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the operational mode of the AP.
|
||||
*
|
||||
* @param wifiStandard values from {@link ScanResult}'s {@code WIFI_STANDARD_}
|
||||
* @hide
|
||||
*/
|
||||
public void setWifiStandard(@WifiAnnotations.WifiStandard int wifiStandard) {
|
||||
mWifiStandard = wifiStandard;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the operational mode of the AP.
|
||||
* @return valid values from {@link ScanResult}'s {@code WIFI_STANDARD_}
|
||||
*/
|
||||
public @WifiAnnotations.WifiStandard int getWifiStandard() {
|
||||
if (!SdkLevelUtil.isAtLeastS()) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
return mWifiStandard;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
@@ -170,6 +194,7 @@ public final class SoftApInfo implements Parcelable {
|
||||
mFrequency = source.mFrequency;
|
||||
mBandwidth = source.mBandwidth;
|
||||
mBssid = source.mBssid;
|
||||
mWifiStandard = source.mWifiStandard;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,6 +216,7 @@ public final class SoftApInfo implements Parcelable {
|
||||
dest.writeInt(mFrequency);
|
||||
dest.writeInt(mBandwidth);
|
||||
dest.writeParcelable(mBssid, flags);
|
||||
dest.writeInt(mWifiStandard);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@@ -201,6 +227,7 @@ public final class SoftApInfo implements Parcelable {
|
||||
info.mFrequency = in.readInt();
|
||||
info.mBandwidth = in.readInt();
|
||||
info.mBssid = in.readParcelable(MacAddress.class.getClassLoader());
|
||||
info.mWifiStandard = in.readInt();
|
||||
return info;
|
||||
}
|
||||
|
||||
@@ -215,8 +242,9 @@ public final class SoftApInfo implements Parcelable {
|
||||
StringBuilder sbuf = new StringBuilder();
|
||||
sbuf.append("SoftApInfo{");
|
||||
sbuf.append("bandwidth= ").append(mBandwidth);
|
||||
sbuf.append(",frequency= ").append(mFrequency);
|
||||
sbuf.append(", frequency= ").append(mFrequency);
|
||||
if (mBssid != null) sbuf.append(",bssid=").append(mBssid.toString());
|
||||
sbuf.append(", wifiStandard= ").append(mWifiStandard);
|
||||
sbuf.append("}");
|
||||
return sbuf.toString();
|
||||
}
|
||||
@@ -228,11 +256,12 @@ public final class SoftApInfo implements Parcelable {
|
||||
SoftApInfo softApInfo = (SoftApInfo) o;
|
||||
return mFrequency == softApInfo.mFrequency
|
||||
&& mBandwidth == softApInfo.mBandwidth
|
||||
&& Objects.equals(mBssid, softApInfo.mBssid);
|
||||
&& Objects.equals(mBssid, softApInfo.mBssid)
|
||||
&& mWifiStandard == softApInfo.mWifiStandard;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(mFrequency, mBandwidth, mBssid);
|
||||
return Objects.hash(mFrequency, mBandwidth, mBssid, mWifiStandard);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package android.net.wifi;
|
||||
|
||||
import android.net.MacAddress;
|
||||
import android.net.wifi.util.SdkLevelUtil;
|
||||
import android.os.Parcel;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -40,6 +41,7 @@ public class SoftApInfoTest {
|
||||
info.setFrequency(2412);
|
||||
info.setBandwidth(SoftApInfo.CHANNEL_WIDTH_20MHZ);
|
||||
info.setBssid(MacAddress.fromString("aa:bb:cc:dd:ee:ff"));
|
||||
info.setWifiStandard(ScanResult.WIFI_STANDARD_LEGACY);
|
||||
|
||||
|
||||
SoftApInfo copiedInfo = new SoftApInfo(info);
|
||||
@@ -57,6 +59,7 @@ public class SoftApInfoTest {
|
||||
info.setFrequency(2412);
|
||||
info.setBandwidth(SoftApInfo.CHANNEL_WIDTH_20MHZ);
|
||||
info.setBssid(MacAddress.fromString("aa:bb:cc:dd:ee:ff"));
|
||||
info.setWifiStandard(ScanResult.WIFI_STANDARD_LEGACY);
|
||||
|
||||
Parcel parcelW = Parcel.obtain();
|
||||
info.writeToParcel(parcelW, 0);
|
||||
@@ -72,4 +75,19 @@ public class SoftApInfoTest {
|
||||
assertEquals(info.hashCode(), fromParcel.hashCode());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Verifies the initial value same as expected.
|
||||
*/
|
||||
@Test
|
||||
public void testInitialValue() throws Exception {
|
||||
SoftApInfo info = new SoftApInfo();
|
||||
assertEquals(info.getFrequency(), 0);
|
||||
assertEquals(info.getBandwidth(), SoftApInfo.CHANNEL_WIDTH_INVALID);
|
||||
if (SdkLevelUtil.isAtLeastS()) {
|
||||
assertEquals(info.getBssid(), null);
|
||||
assertEquals(info.getWifiStandard(), ScanResult.WIFI_STANDARD_UNKNOWN);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user