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

Commit d5b5576d authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Android Git Automerger
Browse files

am 5b41696c: am a8fb5803: Merge "Offer to "merge" subscribers for data usage." into lmp-mr1-dev

* commit '5b41696c':
  Offer to "merge" subscribers for data usage.
parents 87dd3428 5b41696c
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -68,9 +68,6 @@ interface IConnectivityManager

    boolean requestRouteToHostAddress(int networkType, in byte[] hostAddress);

    /** Policy control over specific {@link NetworkStateTracker}. */
    void setPolicyDataEnable(int networkType, boolean enabled);

    int tether(String iface);

    int untether(String iface);
+20 −10
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.telephony.TelephonyManager;
import android.util.Slog;

import java.util.Objects;

@@ -35,6 +36,8 @@ import java.util.Objects;
 * @hide
 */
public class NetworkIdentity implements Comparable<NetworkIdentity> {
    private static final String TAG = "NetworkIdentity";

    /**
     * When enabled, combine all {@link #mSubType} together under
     * {@link #SUBTYPE_COMBINED}.
@@ -132,6 +135,18 @@ public class NetworkIdentity implements Comparable<NetworkIdentity> {
        }
    }

    /**
     * Scrub given IMSI on production builds.
     */
    public static String[] scrubSubscriberId(String[] subscriberId) {
        if (subscriberId == null) return null;
        final String[] res = new String[subscriberId.length];
        for (int i = 0; i < res.length; i++) {
            res[i] = NetworkIdentity.scrubSubscriberId(subscriberId[i]);
        }
        return res;
    }

    /**
     * Build a {@link NetworkIdentity} from the given {@link NetworkState},
     * assuming that any mobile networks are using the current IMSI.
@@ -140,23 +155,18 @@ public class NetworkIdentity implements Comparable<NetworkIdentity> {
        final int type = state.networkInfo.getType();
        final int subType = state.networkInfo.getSubtype();

        // TODO: consider moving subscriberId over to LinkCapabilities, so it
        // comes from an authoritative source.

        String subscriberId = null;
        String networkId = null;
        boolean roaming = false;

        if (isNetworkTypeMobile(type)) {
            final TelephonyManager telephony = (TelephonyManager) context.getSystemService(
                    Context.TELEPHONY_SERVICE);
            roaming = telephony.isNetworkRoaming();
            if (state.subscriberId != null) {
                subscriberId = state.subscriberId;
            } else {
                subscriberId = telephony.getSubscriberId();
            if (state.subscriberId == null) {
                Slog.w(TAG, "Active mobile network without subscriber!");
            }

            subscriberId = state.subscriberId;
            roaming = state.networkInfo.isRoaming();

        } else if (type == TYPE_WIFI) {
            if (state.networkId != null) {
                networkId = state.networkId;
+14 −3
Original line number Diff line number Diff line
@@ -20,15 +20,18 @@ import android.os.Parcel;
import android.os.Parcelable;

/**
 * A grab-bag of information (metadata, policies, properties, etc) about a {@link Network}.
 * A grab-bag of information (metadata, policies, properties, etc) about a
 * {@link Network}. Since this contains PII, it should not be sent outside the
 * system.
 *
 * @hide
 */
public class NetworkMisc implements Parcelable {

    /**
     * If the {@link Network} is a VPN, whether apps are allowed to bypass the VPN. This is set by
     * a {@link VpnService} and used by {@link ConnectivityService} when creating a VPN.
     * If the {@link Network} is a VPN, whether apps are allowed to bypass the
     * VPN. This is set by a {@link VpnService} and used by
     * {@link ConnectivityManager} when creating a VPN.
     */
    public boolean allowBypass;

@@ -41,6 +44,11 @@ public class NetworkMisc implements Parcelable {
     */
    public boolean explicitlySelected;

    /**
     * For mobile networks, this is the subscriber ID (such as IMSI).
     */
    public String subscriberId;

    public NetworkMisc() {
    }

@@ -48,6 +56,7 @@ public class NetworkMisc implements Parcelable {
        if (nm != null) {
            allowBypass = nm.allowBypass;
            explicitlySelected = nm.explicitlySelected;
            subscriberId = nm.subscriberId;
        }
    }

@@ -60,6 +69,7 @@ public class NetworkMisc implements Parcelable {
    public void writeToParcel(Parcel out, int flags) {
        out.writeInt(allowBypass ? 1 : 0);
        out.writeInt(explicitlySelected ? 1 : 0);
        out.writeString(subscriberId);
    }

    public static final Creator<NetworkMisc> CREATOR = new Creator<NetworkMisc>() {
@@ -68,6 +78,7 @@ public class NetworkMisc implements Parcelable {
            NetworkMisc networkMisc = new NetworkMisc();
            networkMisc.allowBypass = in.readInt() != 0;
            networkMisc.explicitlySelected = in.readInt() != 0;
            networkMisc.subscriberId = in.readString();
            return networkMisc;
        }

+1 −1
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ public class NetworkPolicy implements Parcelable, Comparable<NetworkPolicy> {
    public static final long LIMIT_DISABLED = -1;
    public static final long SNOOZE_NEVER = -1;

    public final NetworkTemplate template;
    public NetworkTemplate template;
    public int cycleDay;
    public String cycleTimezone;
    public long warningBytes;
+0 −7
Original line number Diff line number Diff line
@@ -30,15 +30,9 @@ public class NetworkState implements Parcelable {
    public final LinkProperties linkProperties;
    public final NetworkCapabilities networkCapabilities;
    public final Network network;
    /** Currently only used by testing. */
    public final String subscriberId;
    public final String networkId;

    public NetworkState(NetworkInfo networkInfo, LinkProperties linkProperties,
            NetworkCapabilities networkCapabilities, Network network) {
        this(networkInfo, linkProperties, networkCapabilities, network, null, null);
    }

    public NetworkState(NetworkInfo networkInfo, LinkProperties linkProperties,
            NetworkCapabilities networkCapabilities, Network network, String subscriberId,
            String networkId) {
@@ -85,5 +79,4 @@ public class NetworkState implements Parcelable {
            return new NetworkState[size];
        }
    };

}
Loading