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

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

Merge changes from topic "removeNI" am: c2d62406 am: bd414490

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

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Iec45cb7f553f08e4e3ec91827964a8eec8f96a91
parents 35fbb8cb bd414490
Loading
Loading
Loading
Loading
+4 −4
Original line number Original line Diff line number Diff line
@@ -32,7 +32,7 @@ import java.util.Objects;


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


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


        subscriberId = state.subscriberId;
        subscriberId = state.subscriberId;


        if (type == TYPE_WIFI) {
        if (legacyType == TYPE_WIFI) {
            if (state.networkCapabilities.getSsid() != null) {
            if (state.networkCapabilities.getSsid() != null) {
                networkId = state.networkCapabilities.getSsid();
                networkId = state.networkCapabilities.getSsid();
                if (networkId == null) {
                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);
                defaultNetwork);
    }
    }


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


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


    private NetworkState() {
    private NetworkState() {
        networkInfo = null;
        networkInfo = null;
@@ -49,17 +51,35 @@ public class NetworkState implements Parcelable {
        network = null;
        network = null;
        subscriberId = null;
        subscriberId = null;
        networkId = 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,
    public NetworkState(@NonNull NetworkInfo networkInfo, @NonNull LinkProperties linkProperties,
            @NonNull NetworkCapabilities networkCapabilities, @NonNull Network network,
            @NonNull NetworkCapabilities networkCapabilities, @NonNull Network network,
            String subscriberId, String networkId) {
            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.networkInfo = networkInfo;
        this.linkProperties = linkProperties;
        this.linkProperties = linkProperties;
        this.networkCapabilities = networkCapabilities;
        this.networkCapabilities = networkCapabilities;
        this.network = network;
        this.network = network;
        this.subscriberId = subscriberId;
        this.subscriberId = subscriberId;
        this.networkId = networkId;
        this.networkId = networkId;
        this.legacyNetworkType = legacyNetworkType;


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


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


    @UnsupportedAppUsage
    @UnsupportedAppUsage
+2 −1
Original line number Original line Diff line number Diff line
@@ -1894,7 +1894,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
        final ArrayList<NetworkState> result = new ArrayList<>();
        final ArrayList<NetworkState> result = new ArrayList<>();
        for (Network network : getAllNetworks()) {
        for (Network network : getAllNetworks()) {
            final NetworkAgentInfo nai = getNetworkAgentInfoForNetwork(network);
            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
                // TODO (b/73321673) : NetworkState contains a copy of the
                // NetworkCapabilities, which may contain UIDs of apps to which the
                // NetworkCapabilities, which may contain UIDs of apps to which the
                // network applies. Should the UIDs be cleared so as not to leak or
                // network applies. Should the UIDs be cleared so as not to leak or
+8 −10
Original line number Original line Diff line number Diff line
@@ -1962,7 +1962,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
            if (state.network != null) {
            if (state.network != null) {
                mNetIdToSubId.put(state.network.netId, parseSubId(state));
                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
            // 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
            // in the object created here is never used and its value doesn't matter, so use
            // NETWORK_TYPE_UNKNOWN.
            // NETWORK_TYPE_UNKNOWN.
@@ -1970,7 +1970,6 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
                    true, TelephonyManager.NETWORK_TYPE_UNKNOWN /* subType */);
                    true, TelephonyManager.NETWORK_TYPE_UNKNOWN /* subType */);
            identified.put(state, ident);
            identified.put(state, ident);
        }
        }
        }


        final ArraySet<String> newMeteredIfaces = new ArraySet<>();
        final ArraySet<String> newMeteredIfaces = new ArraySet<>();
        long lowestRule = Long.MAX_VALUE;
        long lowestRule = Long.MAX_VALUE;
@@ -2044,8 +2043,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
        // One final pass to catch any metered ifaces that don't have explicitly
        // One final pass to catch any metered ifaces that don't have explicitly
        // defined policies; typically Wi-Fi networks.
        // defined policies; typically Wi-Fi networks.
        for (NetworkState state : states) {
        for (NetworkState state : states) {
            if (state.networkInfo != null && state.networkInfo.isConnected()
            if (!state.networkCapabilities.hasCapability(NET_CAPABILITY_NOT_METERED)) {
                    && !state.networkCapabilities.hasCapability(NET_CAPABILITY_NOT_METERED)) {
                matchingIfaces.clear();
                matchingIfaces.clear();
                collectIfaces(matchingIfaces, state);
                collectIfaces(matchingIfaces, state);
                for (int j = matchingIfaces.size() - 1; j >= 0; j--) {
                for (int j = matchingIfaces.size() - 1; j >= 0; j--) {
+73 −76
Original line number Original line Diff line number Diff line
@@ -96,7 +96,6 @@ import android.net.LinkProperties;
import android.net.Network;
import android.net.Network;
import android.net.NetworkCapabilities;
import android.net.NetworkCapabilities;
import android.net.NetworkIdentity;
import android.net.NetworkIdentity;
import android.net.NetworkInfo;
import android.net.NetworkStack;
import android.net.NetworkStack;
import android.net.NetworkState;
import android.net.NetworkState;
import android.net.NetworkStats;
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
     * 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}.
     * they are combined under a single {@link NetworkIdentitySet}.
     */
     */
    @GuardedBy("mStatsLock")
    @GuardedBy("mStatsLock")
@@ -1294,8 +1293,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
        final boolean combineSubtypeEnabled = mSettings.getCombineSubtypeEnabled();
        final boolean combineSubtypeEnabled = mSettings.getCombineSubtypeEnabled();
        final ArraySet<String> mobileIfaces = new ArraySet<>();
        final ArraySet<String> mobileIfaces = new ArraySet<>();
        for (NetworkState state : states) {
        for (NetworkState state : states) {
            if (state.networkInfo.isConnected()) {
            final boolean isMobile = isNetworkTypeMobile(state.legacyNetworkType);
                final boolean isMobile = isNetworkTypeMobile(state.networkInfo.getType());
            final boolean isDefault = ArrayUtils.contains(mDefaultNetworks, state.network);
            final boolean isDefault = ArrayUtils.contains(mDefaultNetworks, state.network);
            final int subType = combineSubtypeEnabled ? SUBTYPE_COMBINED
            final int subType = combineSubtypeEnabled ? SUBTYPE_COMBINED
                    : getSubTypeForState(state);
                    : getSubTypeForState(state);
@@ -1374,7 +1372,6 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
                }
                }
            }
            }
        }
        }
        }


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