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

Commit c76fda72 authored by Stephen Chen's avatar Stephen Chen
Browse files

Add meteredOverride field to WifiConfiguration.

This stores a user's metered selection. This will be set by
Settings -> Data Usage -> Network restrictions and used in conjunction
with WifiConfiguration.meteredHint to properly track a Wifi network's
metered state.

Bug: 33106464
Bug: 26545374
Test: runtest --path
frameworks/opt/net/wifi/tests/wifitests/src/com/android/server/wifi/util/XmlUtilTest.java
runtest --path
frameworks/opt/net/wifi/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java

Change-Id: I1a378ef2946c1b5b6091bba379f2ab48a15d29d8
parent 584b5cee
Loading
Loading
Loading
Loading
+18 −2
Original line number Diff line number Diff line
@@ -685,10 +685,20 @@ public class WifiConfiguration implements Parcelable {
    /**
     * @hide
     * A hint about whether or not the network represented by this WifiConfiguration
     * is metered.
     * is metered. This is hinted at via the meteredHint bit on DHCP results set in
     * {@link com.android.server.wifi.WifiStateMachine}, or via a network score in
     * {@link com.android.server.wifi.ExternalScoreEvaluator}.
     */
    public boolean meteredHint;

    /**
     * @hide
     * Indicates if a user has specified the WifiConfiguration to be metered. Users
     * can toggle if a network is metered within Settings -> Data Usage -> Network
     * Restrictions.
     */
    public boolean meteredOverride;

    /**
     * @hide
     * Setting this value will force scan results associated with this configuration to
@@ -1367,6 +1377,7 @@ public class WifiConfiguration implements Parcelable {
        didSelfAdd = false;
        ephemeral = false;
        meteredHint = false;
        meteredOverride = false;
        useExternalScores = false;
        validatedInternetAccess = false;
        mIpConfiguration = new IpConfiguration();
@@ -1470,9 +1481,11 @@ public class WifiConfiguration implements Parcelable {
        if (this.validatedInternetAccess) sbuf.append(" validatedInternetAccess");
        if (this.ephemeral) sbuf.append(" ephemeral");
        if (this.meteredHint) sbuf.append(" meteredHint");
        if (this.meteredOverride) sbuf.append(" meteredOverride");
        if (this.useExternalScores) sbuf.append(" useExternalScores");
        if (this.didSelfAdd || this.selfAdded || this.validatedInternetAccess
            || this.ephemeral || this.meteredHint || this.useExternalScores) {
            || this.ephemeral || this.meteredHint || this.meteredOverride
            || this.useExternalScores) {
            sbuf.append("\n");
        }
        sbuf.append(" KeyMgmt:");
@@ -1897,6 +1910,7 @@ public class WifiConfiguration implements Parcelable {
            validatedInternetAccess = source.validatedInternetAccess;
            ephemeral = source.ephemeral;
            meteredHint = source.meteredHint;
            meteredOverride = source.meteredOverride;
            useExternalScores = source.useExternalScores;
            if (source.visibility != null) {
                visibility = new Visibility(source.visibility);
@@ -1978,6 +1992,7 @@ public class WifiConfiguration implements Parcelable {
        dest.writeInt(validatedInternetAccess ? 1 : 0);
        dest.writeInt(ephemeral ? 1 : 0);
        dest.writeInt(meteredHint ? 1 : 0);
        dest.writeInt(meteredOverride ? 1 : 0);
        dest.writeInt(useExternalScores ? 1 : 0);
        dest.writeInt(creatorUid);
        dest.writeInt(lastConnectUid);
@@ -2049,6 +2064,7 @@ public class WifiConfiguration implements Parcelable {
                config.validatedInternetAccess = in.readInt() != 0;
                config.ephemeral = in.readInt() != 0;
                config.meteredHint = in.readInt() != 0;
                config.meteredOverride = in.readInt() != 0;
                config.useExternalScores = in.readInt() != 0;
                config.creatorUid = in.readInt();
                config.lastConnectUid = in.readInt();