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

Commit 845dae5c authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Android (Google) Code Review
Browse files

Merge "Move "metered" persistence to WifiConfiguration."

parents fc6d56bd 43d2a170
Loading
Loading
Loading
Loading
+2 −8
Original line number Diff line number Diff line
@@ -1720,14 +1720,8 @@ public class ConnectivityManager {
        // ignored
    }

    /**
     * Return quota status for the current active network, or {@code null} if no
     * network is active. Quota status can change rapidly, so these values
     * shouldn't be cached.
     *
     * @hide
     */
    @RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
    /** {@hide} */
    @Deprecated
    public NetworkQuotaInfo getActiveNetworkQuotaInfo() {
        try {
            return mService.getActiveNetworkQuotaInfo();
+1 −1
Original line number Diff line number Diff line
@@ -63,9 +63,9 @@ interface INetworkPolicyManager {
    int getRestrictBackgroundByCaller();

    void setDeviceIdleMode(boolean enabled);
    void setWifiMeteredOverride(String networkId, int meteredOverride);

    NetworkQuotaInfo getNetworkQuotaInfo(in NetworkState state);
    boolean isNetworkMetered(in NetworkState state);

    void factoryReset(String subscriber);
}
+1 −31
Original line number Diff line number Diff line
@@ -16,8 +16,8 @@

package android.net;

import android.os.Parcelable;
import android.os.Parcel;
import android.os.Parcelable;

import com.android.internal.annotations.VisibleForTesting;

@@ -121,7 +121,6 @@ public class NetworkInfo implements Parcelable {
    private boolean mIsFailover;
    private boolean mIsAvailable;
    private boolean mIsRoaming;
    private boolean mIsMetered;

    /**
     * @hide
@@ -154,7 +153,6 @@ public class NetworkInfo implements Parcelable {
                mIsFailover = source.mIsFailover;
                mIsAvailable = source.mIsAvailable;
                mIsRoaming = source.mIsRoaming;
                mIsMetered = source.mIsMetered;
            }
        }
    }
@@ -326,31 +324,6 @@ public class NetworkInfo implements Parcelable {
        }
    }

    /**
     * Returns if this network is metered. A network is classified as metered
     * when the user is sensitive to heavy data usage on that connection due to
     * monetary costs, data limitations or battery/performance issues. You
     * should check this before doing large data transfers, and warn the user or
     * delay the operation until another network is available.
     *
     * @return {@code true} if large transfers should be avoided, otherwise
     *         {@code false}.
     * @hide
     */
    public boolean isMetered() {
        synchronized (this) {
            return mIsMetered;
        }
    }

    /** {@hide} */
    @VisibleForTesting
    public void setMetered(boolean isMetered) {
        synchronized (this) {
            mIsMetered = isMetered;
        }
    }

    /**
     * Reports the current coarse-grained state of the network.
     * @return the coarse-grained state
@@ -434,7 +407,6 @@ public class NetworkInfo implements Parcelable {
            append(", failover: ").append(mIsFailover).
            append(", available: ").append(mIsAvailable).
            append(", roaming: ").append(mIsRoaming).
            append(", metered: ").append(mIsMetered).
            append("]");
            return builder.toString();
        }
@@ -457,7 +429,6 @@ public class NetworkInfo implements Parcelable {
            dest.writeInt(mIsFailover ? 1 : 0);
            dest.writeInt(mIsAvailable ? 1 : 0);
            dest.writeInt(mIsRoaming ? 1 : 0);
            dest.writeInt(mIsMetered ? 1 : 0);
            dest.writeString(mReason);
            dest.writeString(mExtraInfo);
        }
@@ -476,7 +447,6 @@ public class NetworkInfo implements Parcelable {
            netInfo.mIsFailover = in.readInt() != 0;
            netInfo.mIsAvailable = in.readInt() != 0;
            netInfo.mIsRoaming = in.readInt() != 0;
            netInfo.mIsMetered = in.readInt() != 0;
            netInfo.mReason = in.readString();
            netInfo.mExtraInfo = in.readString();
            return netInfo;
+1 −1
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ public class NetworkPolicy implements Parcelable, Comparable<NetworkPolicy> {
    public long limitBytes;
    public long lastWarningSnooze;
    public long lastLimitSnooze;
    public boolean metered;
    @Deprecated public boolean metered;
    public boolean inferred;

    private static final long DEFAULT_MTU = 1500;
+11 −0
Original line number Diff line number Diff line
@@ -26,6 +26,8 @@ import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.Signature;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiInfo;
import android.os.RemoteException;
import android.os.UserHandle;
import android.util.DebugUtils;
@@ -400,4 +402,13 @@ public class NetworkPolicyManager {
    public static boolean isProcStateAllowedWhileOnRestrictBackground(int procState) {
        return procState <= ActivityManager.PROCESS_STATE_FOREGROUND_SERVICE;
    }

    public static String resolveNetworkId(WifiConfiguration config) {
        return WifiInfo.removeDoubleQuotes(config.isPasspoint()
                ? config.providerFriendlyName : config.SSID);
    }

    public static String resolveNetworkId(String ssid) {
        return WifiInfo.removeDoubleQuotes(ssid);
    }
}
Loading