Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9d1ae3b8 authored by Felipe Leme's avatar Felipe Leme Committed by Android (Google) Code Review
Browse files

Merge "Added support for WiFi frequency on WifiInfo (getter, settter, and...

Merge "Added support for WiFi frequency on WifiInfo (getter, settter, and frequency constant). Bug: 12767819"
parents 0f58bb3b 70a415e7
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -15516,6 +15516,7 @@ package android.net.wifi {
    method public int describeContents();
    method public java.lang.String getBSSID();
    method public static android.net.NetworkInfo.DetailedState getDetailedStateOf(android.net.wifi.SupplicantState);
    method public int getFrequency();
    method public boolean getHiddenSSID();
    method public int getIpAddress();
    method public int getLinkSpeed();
@@ -15525,6 +15526,7 @@ package android.net.wifi {
    method public java.lang.String getSSID();
    method public android.net.wifi.SupplicantState getSupplicantState();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final java.lang.String FREQUENCY_UNITS = "MHz";
    field public static final java.lang.String LINK_SPEED_UNITS = "Mbps";
  }
+24 −1
Original line number Diff line number Diff line
@@ -69,6 +69,10 @@ public class WifiInfo implements Parcelable {
    public static final String LINK_SPEED_UNITS = "Mbps";
    private int mLinkSpeed;

    /** Frequency in MHz */
    public static final String FREQUENCY_UNITS = "MHz";
    private int mFrequency;

    private InetAddress mIpAddress;
    private String mMacAddress;

@@ -86,6 +90,7 @@ public class WifiInfo implements Parcelable {
        mSupplicantState = SupplicantState.UNINITIALIZED;
        mRssi = -9999;
        mLinkSpeed = -1;
        mFrequency = -1;
    }

    /**
@@ -100,6 +105,7 @@ public class WifiInfo implements Parcelable {
            mNetworkId = source.mNetworkId;
            mRssi = source.mRssi;
            mLinkSpeed = source.mLinkSpeed;
            mFrequency = source.mFrequency;
            mIpAddress = source.mIpAddress;
            mMacAddress = source.mMacAddress;
            mMeteredHint = source.mMeteredHint;
@@ -178,6 +184,20 @@ public class WifiInfo implements Parcelable {
        this.mLinkSpeed = linkSpeed;
    }

    /**
     * Returns the current frequency in {@link #FREQUENCY_UNITS}.
     * @return the frequency.
     * @see #FREQUENCY_UNITS
     */
    public int getFrequency() {
        return mFrequency;
    }

    /** @hide */
    public void setFrequency(int frequency) {
        this.mFrequency = frequency;
    }

    /**
     * Record the MAC address of the WLAN interface
     * @param macAddress the MAC address in {@code XX:XX:XX:XX:XX:XX} form
@@ -303,7 +323,8 @@ public class WifiInfo implements Parcelable {
            append(", Supplicant state: ").
            append(mSupplicantState == null ? none : mSupplicantState).
            append(", RSSI: ").append(mRssi).
            append(", Link speed: ").append(mLinkSpeed).
            append(", Link speed: ").append(mLinkSpeed).append(LINK_SPEED_UNITS).
            append(", Frequency: ").append(mFrequency).append(FREQUENCY_UNITS).
            append(", Net ID: ").append(mNetworkId).
            append(", Metered hint: ").append(mMeteredHint);

@@ -320,6 +341,7 @@ public class WifiInfo implements Parcelable {
        dest.writeInt(mNetworkId);
        dest.writeInt(mRssi);
        dest.writeInt(mLinkSpeed);
        dest.writeInt(mFrequency);
        if (mIpAddress != null) {
            dest.writeByte((byte)1);
            dest.writeByteArray(mIpAddress.getAddress());
@@ -346,6 +368,7 @@ public class WifiInfo implements Parcelable {
                info.setNetworkId(in.readInt());
                info.setRssi(in.readInt());
                info.setLinkSpeed(in.readInt());
                info.setFrequency(in.readInt());
                if (in.readByte() == 1) {
                    try {
                        info.setInetAddress(InetAddress.getByAddress(in.createByteArray()));