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

Commit 85870d63 authored by Jeremy Joslin's avatar Jeremy Joslin
Browse files

Add a meteredHint to ScoredNetwork.

API changes to allow a meteredHint to be passed
from a network scorer through to the wifi subsystem.

BUG:27702356
Change-Id: Ic466852d855af54c1754c4663388f24f54ed0691
parent 2a73c7fb
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -20080,9 +20080,11 @@ package android.net {
  public class ScoredNetwork implements android.os.Parcelable {
    ctor public ScoredNetwork(android.net.NetworkKey, android.net.RssiCurve);
    ctor public ScoredNetwork(android.net.NetworkKey, android.net.RssiCurve, boolean);
    method public int describeContents();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.net.ScoredNetwork> CREATOR;
    field public final boolean meteredHint;
    field public final android.net.NetworkKey networkKey;
    field public final android.net.RssiCurve rssiCurve;
  }
+36 −4
Original line number Diff line number Diff line
@@ -42,6 +42,16 @@ public class ScoredNetwork implements Parcelable {
     */
    public final RssiCurve rssiCurve;

    /**
     * A boolean value that indicates whether or not the network is believed to be metered.
     *
     * <p>A network can be classified as metered if the user would be
     * sensitive to heavy data usage on that connection due to monetary costs,
     * data limitations or battery/performance issues. A typical example would
     * be a wifi connection where the user would be charged for usage.
     */
    public final boolean meteredHint;

    /**
     * Construct a new {@link ScoredNetwork}.
     *
@@ -54,8 +64,26 @@ public class ScoredNetwork implements Parcelable {
     *     the scorer may choose to issue an out-of-band update at any time.
     */
    public ScoredNetwork(NetworkKey networkKey, RssiCurve rssiCurve) {
        this(networkKey, rssiCurve, false /* meteredHint */);
    }

    /**
     * Construct a new {@link ScoredNetwork}.
     *
     * @param networkKey the {@link NetworkKey} uniquely identifying this network.
     * @param rssiCurve the {@link RssiCurve} representing the scores for this network based on the
     *     RSSI. This field is optional, and may be skipped to represent a network which the scorer
     *     has opted not to score at this time. Passing a null value here is strongly preferred to
     *     not returning any {@link ScoredNetwork} for a given {@link NetworkKey} because it
     *     indicates to the system not to request scores for this network in the future, although
     *     the scorer may choose to issue an out-of-band update at any time.
     * @param meteredHint A boolean value indicating whether or not the network is believed to be
     *     metered.
     */
    public ScoredNetwork(NetworkKey networkKey, RssiCurve rssiCurve, boolean meteredHint) {
        this.networkKey = networkKey;
        this.rssiCurve = rssiCurve;
        this.meteredHint = meteredHint;
    }

    private ScoredNetwork(Parcel in) {
@@ -65,6 +93,7 @@ public class ScoredNetwork implements Parcelable {
        } else {
            rssiCurve = null;
        }
        meteredHint = in.readByte() != 0;
    }

    @Override
@@ -81,6 +110,7 @@ public class ScoredNetwork implements Parcelable {
        } else {
            out.writeByte((byte) 0);
        }
        out.writeByte((byte) (meteredHint ? 1 : 0));
    }

    @Override
@@ -90,18 +120,20 @@ public class ScoredNetwork implements Parcelable {

        ScoredNetwork that = (ScoredNetwork) o;

        return Objects.equals(networkKey, that.networkKey) &&
                Objects.equals(rssiCurve, that.rssiCurve);
        return Objects.equals(networkKey, that.networkKey)
            && Objects.equals(rssiCurve, that.rssiCurve)
            && Objects.equals(meteredHint, that.meteredHint);
    }

    @Override
    public int hashCode() {
        return Objects.hash(networkKey, rssiCurve);
        return Objects.hash(networkKey, rssiCurve, meteredHint);
    }

    @Override
    public String toString() {
        return "ScoredNetwork[key=" + networkKey + ",score=" + rssiCurve + "]";
        return "ScoredNetwork[key=" + networkKey + ",score=" + rssiCurve
            + ",meteredHint=" + meteredHint + "]";
    }

    public static final Parcelable.Creator<ScoredNetwork> CREATOR =