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

Commit c2c7c4a1 authored by Junyu Lai's avatar Junyu Lai Committed by Automerger Merge Worker
Browse files

Merge changes from topic "removeNI" am: c2d62406 am: bd414490 am: 4bd67ddf am: 08078fe9

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1536707

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I32d967b7ec2c41d8fa0210b9fc8a25c7acac3bc1
parents e8592c1b 08078fe9
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ import java.util.Objects;

/**
 * Network definition that includes strong identity. Analogous to combining
 * {@link NetworkInfo} and an IMSI.
 * {@link NetworkCapabilities} and an IMSI.
 *
 * @hide
 */
@@ -160,7 +160,7 @@ public class NetworkIdentity implements Comparable<NetworkIdentity> {
     */
    public static NetworkIdentity buildNetworkIdentity(Context context, NetworkState state,
            boolean defaultNetwork, @NetworkType int subType) {
        final int type = state.networkInfo.getType();
        final int legacyType = state.legacyNetworkType;

        String subscriberId = null;
        String networkId = null;
@@ -171,7 +171,7 @@ public class NetworkIdentity implements Comparable<NetworkIdentity> {

        subscriberId = state.subscriberId;

        if (type == TYPE_WIFI) {
        if (legacyType == TYPE_WIFI) {
            if (state.networkCapabilities.getSsid() != null) {
                networkId = state.networkCapabilities.getSsid();
                if (networkId == null) {
@@ -184,7 +184,7 @@ public class NetworkIdentity implements Comparable<NetworkIdentity> {
            }
        }

        return new NetworkIdentity(type, subType, subscriberId, networkId, roaming, metered,
        return new NetworkIdentity(legacyType, subType, subscriberId, networkId, roaming, metered,
                defaultNetwork);
    }

+22 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.net;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.compat.annotation.UnsupportedAppUsage;
import android.os.Build;
import android.os.Parcel;
@@ -41,6 +42,7 @@ public class NetworkState implements Parcelable {
    public final Network network;
    public final String subscriberId;
    public final String networkId;
    public final int legacyNetworkType;

    private NetworkState() {
        networkInfo = null;
@@ -49,17 +51,35 @@ public class NetworkState implements Parcelable {
        network = null;
        subscriberId = null;
        networkId = null;
        legacyNetworkType = 0;
    }

    public NetworkState(int legacyNetworkType, @NonNull LinkProperties linkProperties,
            @NonNull NetworkCapabilities networkCapabilities, @NonNull Network network,
            @Nullable String subscriberId, @Nullable String networkId) {
        this(legacyNetworkType, new NetworkInfo(legacyNetworkType, 0, null, null), linkProperties,
                networkCapabilities, network, subscriberId, networkId);
    }

    // Constructor that used internally in ConnectivityService mainline module.
    public NetworkState(@NonNull NetworkInfo networkInfo, @NonNull LinkProperties linkProperties,
            @NonNull NetworkCapabilities networkCapabilities, @NonNull Network network,
            String subscriberId, String networkId) {
        this(networkInfo.getType(), networkInfo, linkProperties,
                networkCapabilities, network, subscriberId, networkId);
    }

    public NetworkState(int legacyNetworkType, @NonNull NetworkInfo networkInfo,
            @NonNull LinkProperties linkProperties,
            @NonNull NetworkCapabilities networkCapabilities, @NonNull Network network,
            String subscriberId, String networkId) {
        this.networkInfo = networkInfo;
        this.linkProperties = linkProperties;
        this.networkCapabilities = networkCapabilities;
        this.network = network;
        this.subscriberId = subscriberId;
        this.networkId = networkId;
        this.legacyNetworkType = legacyNetworkType;

        // This object is an atomic view of a network, so the various components
        // should always agree on roaming state.
@@ -80,6 +100,7 @@ public class NetworkState implements Parcelable {
        network = in.readParcelable(null);
        subscriberId = in.readString();
        networkId = in.readString();
        legacyNetworkType = in.readInt();
    }

    @Override
@@ -95,6 +116,7 @@ public class NetworkState implements Parcelable {
        out.writeParcelable(network, flags);
        out.writeString(subscriberId);
        out.writeString(networkId);
        out.writeInt(legacyNetworkType);
    }

    @UnsupportedAppUsage
+2 −1
Original line number Diff line number Diff line
@@ -1894,7 +1894,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
        final ArrayList<NetworkState> result = new ArrayList<>();
        for (Network network : getAllNetworks()) {
            final NetworkAgentInfo nai = getNetworkAgentInfoForNetwork(network);
            if (nai != null) {
            // TODO: Consider include SUSPENDED networks.
            if (nai != null && nai.networkInfo.isConnected()) {
                // TODO (b/73321673) : NetworkState contains a copy of the
                // NetworkCapabilities, which may contain UIDs of apps to which the
                // network applies. Should the UIDs be cleared so as not to leak or
+8 −10
Original line number Diff line number Diff line
@@ -1961,7 +1961,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
            if (state.network != null) {
                mNetIdToSubId.put(state.network.netId, parseSubId(state));
            }
            if (state.networkInfo != null && state.networkInfo.isConnected()) {

            // Policies matched by NPMS only match by subscriber ID or by ssid. Thus subtype
            // in the object created here is never used and its value doesn't matter, so use
            // NETWORK_TYPE_UNKNOWN.
@@ -1969,7 +1969,6 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
                    true, TelephonyManager.NETWORK_TYPE_UNKNOWN /* subType */);
            identified.put(state, ident);
        }
        }

        final ArraySet<String> newMeteredIfaces = new ArraySet<>();
        long lowestRule = Long.MAX_VALUE;
@@ -2043,8 +2042,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
        // One final pass to catch any metered ifaces that don't have explicitly
        // defined policies; typically Wi-Fi networks.
        for (NetworkState state : states) {
            if (state.networkInfo != null && state.networkInfo.isConnected()
                    && !state.networkCapabilities.hasCapability(NET_CAPABILITY_NOT_METERED)) {
            if (!state.networkCapabilities.hasCapability(NET_CAPABILITY_NOT_METERED)) {
                matchingIfaces.clear();
                collectIfaces(matchingIfaces, state);
                for (int j = matchingIfaces.size() - 1; j >= 0; j--) {
+73 −76
Original line number Diff line number Diff line
@@ -96,7 +96,6 @@ import android.net.LinkProperties;
import android.net.Network;
import android.net.NetworkCapabilities;
import android.net.NetworkIdentity;
import android.net.NetworkInfo;
import android.net.NetworkStack;
import android.net.NetworkState;
import android.net.NetworkStats;
@@ -1264,7 +1263,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {

    /**
     * Inspect all current {@link NetworkState} to derive mapping from {@code iface} to {@link
     * NetworkStatsHistory}. When multiple {@link NetworkInfo} are active on a single {@code iface},
     * NetworkStatsHistory}. When multiple networks are active on a single {@code iface},
     * they are combined under a single {@link NetworkIdentitySet}.
     */
    @GuardedBy("mStatsLock")
@@ -1294,8 +1293,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
        final boolean combineSubtypeEnabled = mSettings.getCombineSubtypeEnabled();
        final ArraySet<String> mobileIfaces = new ArraySet<>();
        for (NetworkState state : states) {
            if (state.networkInfo.isConnected()) {
                final boolean isMobile = isNetworkTypeMobile(state.networkInfo.getType());
            final boolean isMobile = isNetworkTypeMobile(state.legacyNetworkType);
            final boolean isDefault = ArrayUtils.contains(mDefaultNetworks, state.network);
            final int subType = combineSubtypeEnabled ? SUBTYPE_COMBINED
                    : getSubTypeForState(state);
@@ -1374,7 +1372,6 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
                }
            }
        }
        }

        mMobileIfaces = mobileIfaces.toArray(new String[mobileIfaces.size()]);
    }
Loading