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
This commit is contained in:
@@ -20080,9 +20080,11 @@ package android.net {
|
|||||||
|
|
||||||
public class ScoredNetwork implements android.os.Parcelable {
|
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);
|
||||||
|
ctor public ScoredNetwork(android.net.NetworkKey, android.net.RssiCurve, boolean);
|
||||||
method public int describeContents();
|
method public int describeContents();
|
||||||
method public void writeToParcel(android.os.Parcel, int);
|
method public void writeToParcel(android.os.Parcel, int);
|
||||||
field public static final android.os.Parcelable.Creator<android.net.ScoredNetwork> CREATOR;
|
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.NetworkKey networkKey;
|
||||||
field public final android.net.RssiCurve rssiCurve;
|
field public final android.net.RssiCurve rssiCurve;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,16 @@ public class ScoredNetwork implements Parcelable {
|
|||||||
*/
|
*/
|
||||||
public final RssiCurve rssiCurve;
|
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}.
|
* 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.
|
* the scorer may choose to issue an out-of-band update at any time.
|
||||||
*/
|
*/
|
||||||
public ScoredNetwork(NetworkKey networkKey, RssiCurve rssiCurve) {
|
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.networkKey = networkKey;
|
||||||
this.rssiCurve = rssiCurve;
|
this.rssiCurve = rssiCurve;
|
||||||
|
this.meteredHint = meteredHint;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ScoredNetwork(Parcel in) {
|
private ScoredNetwork(Parcel in) {
|
||||||
@@ -65,6 +93,7 @@ public class ScoredNetwork implements Parcelable {
|
|||||||
} else {
|
} else {
|
||||||
rssiCurve = null;
|
rssiCurve = null;
|
||||||
}
|
}
|
||||||
|
meteredHint = in.readByte() != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -81,6 +110,7 @@ public class ScoredNetwork implements Parcelable {
|
|||||||
} else {
|
} else {
|
||||||
out.writeByte((byte) 0);
|
out.writeByte((byte) 0);
|
||||||
}
|
}
|
||||||
|
out.writeByte((byte) (meteredHint ? 1 : 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -90,18 +120,20 @@ public class ScoredNetwork implements Parcelable {
|
|||||||
|
|
||||||
ScoredNetwork that = (ScoredNetwork) o;
|
ScoredNetwork that = (ScoredNetwork) o;
|
||||||
|
|
||||||
return Objects.equals(networkKey, that.networkKey) &&
|
return Objects.equals(networkKey, that.networkKey)
|
||||||
Objects.equals(rssiCurve, that.rssiCurve);
|
&& Objects.equals(rssiCurve, that.rssiCurve)
|
||||||
|
&& Objects.equals(meteredHint, that.meteredHint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(networkKey, rssiCurve);
|
return Objects.hash(networkKey, rssiCurve, meteredHint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ScoredNetwork[key=" + networkKey + ",score=" + rssiCurve + "]";
|
return "ScoredNetwork[key=" + networkKey + ",score=" + rssiCurve
|
||||||
|
+ ",meteredHint=" + meteredHint + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Parcelable.Creator<ScoredNetwork> CREATOR =
|
public static final Parcelable.Creator<ScoredNetwork> CREATOR =
|
||||||
|
|||||||
Reference in New Issue
Block a user