Loading core/api/module-lib-current.txt +5 −5 Original line number Diff line number Diff line Loading @@ -59,13 +59,13 @@ package android.net { public final class NetworkStateSnapshot implements android.os.Parcelable { ctor public NetworkStateSnapshot(@NonNull android.net.Network, @NonNull android.net.NetworkCapabilities, @NonNull android.net.LinkProperties, @Nullable String, int); method public int describeContents(); method public int getLegacyType(); method @NonNull public android.net.LinkProperties getLinkProperties(); method @NonNull public android.net.Network getNetwork(); method @NonNull public android.net.NetworkCapabilities getNetworkCapabilities(); method @Nullable public String getSubscriberId(); method public void writeToParcel(@NonNull android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator<android.net.NetworkStateSnapshot> CREATOR; field public final int legacyType; field @NonNull public final android.net.LinkProperties linkProperties; field @NonNull public final android.net.Network network; field @NonNull public final android.net.NetworkCapabilities networkCapabilities; field @Nullable public final String subscriberId; } public class NetworkWatchlistManager { Loading core/java/android/net/NetworkIdentity.java +6 −6 Original line number Diff line number Diff line Loading @@ -186,19 +186,19 @@ public class NetworkIdentity implements Comparable<NetworkIdentity> { */ public static NetworkIdentity buildNetworkIdentity(Context context, NetworkStateSnapshot snapshot, boolean defaultNetwork, @NetworkType int subType) { final int legacyType = snapshot.legacyType; final int legacyType = snapshot.getLegacyType(); final String subscriberId = snapshot.subscriberId; final String subscriberId = snapshot.getSubscriberId(); String networkId = null; boolean roaming = !snapshot.networkCapabilities.hasCapability( boolean roaming = !snapshot.getNetworkCapabilities().hasCapability( NetworkCapabilities.NET_CAPABILITY_NOT_ROAMING); boolean metered = !snapshot.networkCapabilities.hasCapability( boolean metered = !snapshot.getNetworkCapabilities().hasCapability( NetworkCapabilities.NET_CAPABILITY_NOT_METERED); final int oemManaged = getOemBitfield(snapshot.networkCapabilities); final int oemManaged = getOemBitfield(snapshot.getNetworkCapabilities()); if (legacyType == TYPE_WIFI) { networkId = snapshot.networkCapabilities.getSsid(); networkId = snapshot.getNetworkCapabilities().getSsid(); if (networkId == null) { final WifiManager wifi = context.getSystemService(WifiManager.class); final WifiInfo info = wifi.getConnectionInfo(); Loading core/java/android/net/NetworkStateSnapshot.java +61 −31 Original line number Diff line number Diff line Loading @@ -37,47 +37,76 @@ import java.util.Objects; public final class NetworkStateSnapshot implements Parcelable { /** The network associated with this snapshot. */ @NonNull public final Network network; private final Network mNetwork; /** The {@link NetworkCapabilities} of the network associated with this snapshot. */ @NonNull public final NetworkCapabilities networkCapabilities; private final NetworkCapabilities mNetworkCapabilities; /** The {@link LinkProperties} of the network associated with this snapshot. */ @NonNull public final LinkProperties linkProperties; private final LinkProperties mLinkProperties; /** * The Subscriber Id of the network associated with this snapshot. See * {@link android.telephony.TelephonyManager#getSubscriberId()}. */ @Nullable public final String subscriberId; private final String mSubscriberId; /** * The legacy type of the network associated with this snapshot. See * {@code ConnectivityManager#TYPE_*}. */ public final int legacyType; private final int mLegacyType; public NetworkStateSnapshot(@NonNull Network network, @NonNull NetworkCapabilities networkCapabilities, @NonNull LinkProperties linkProperties, @Nullable String subscriberId, int legacyType) { this.network = Objects.requireNonNull(network); this.networkCapabilities = Objects.requireNonNull(networkCapabilities); this.linkProperties = Objects.requireNonNull(linkProperties); this.subscriberId = subscriberId; this.legacyType = legacyType; mNetwork = Objects.requireNonNull(network); mNetworkCapabilities = Objects.requireNonNull(networkCapabilities); mLinkProperties = Objects.requireNonNull(linkProperties); mSubscriberId = subscriberId; mLegacyType = legacyType; } /** @hide */ public NetworkStateSnapshot(@NonNull Parcel in) { network = in.readParcelable(null); networkCapabilities = in.readParcelable(null); linkProperties = in.readParcelable(null); subscriberId = in.readString(); legacyType = in.readInt(); mNetwork = in.readParcelable(null); mNetworkCapabilities = in.readParcelable(null); mLinkProperties = in.readParcelable(null); mSubscriberId = in.readString(); mLegacyType = in.readInt(); } /** Get the network associated with this snapshot */ @NonNull public Network getNetwork() { return mNetwork; } /** Get {@link NetworkCapabilities} of the network associated with this snapshot. */ @NonNull public NetworkCapabilities getNetworkCapabilities() { return mNetworkCapabilities; } /** Get the {@link LinkProperties} of the network associated with this snapshot. */ @NonNull public LinkProperties getLinkProperties() { return mLinkProperties; } /** Get the Subscriber Id of the network associated with this snapshot. */ @Nullable public String getSubscriberId() { return mSubscriberId; } /** Get the legacy type of the network associated with this snapshot. */ public int getLegacyType() { return mLegacyType; } @Override Loading @@ -87,11 +116,11 @@ public final class NetworkStateSnapshot implements Parcelable { @Override public void writeToParcel(@NonNull Parcel out, int flags) { out.writeParcelable(network, flags); out.writeParcelable(networkCapabilities, flags); out.writeParcelable(linkProperties, flags); out.writeString(subscriberId); out.writeInt(legacyType); out.writeParcelable(mNetwork, flags); out.writeParcelable(mNetworkCapabilities, flags); out.writeParcelable(mLinkProperties, flags); out.writeString(mSubscriberId); out.writeInt(mLegacyType); } @NonNull Loading @@ -115,26 +144,27 @@ public final class NetworkStateSnapshot implements Parcelable { if (this == o) return true; if (!(o instanceof NetworkStateSnapshot)) return false; NetworkStateSnapshot that = (NetworkStateSnapshot) o; return legacyType == that.legacyType && Objects.equals(network, that.network) && Objects.equals(networkCapabilities, that.networkCapabilities) && Objects.equals(linkProperties, that.linkProperties) && Objects.equals(subscriberId, that.subscriberId); return mLegacyType == that.mLegacyType && Objects.equals(mNetwork, that.mNetwork) && Objects.equals(mNetworkCapabilities, that.mNetworkCapabilities) && Objects.equals(mLinkProperties, that.mLinkProperties) && Objects.equals(mSubscriberId, that.mSubscriberId); } @Override public int hashCode() { return Objects.hash(network, networkCapabilities, linkProperties, subscriberId, legacyType); return Objects.hash(mNetwork, mNetworkCapabilities, mLinkProperties, mSubscriberId, mLegacyType); } @Override public String toString() { return "NetworkStateSnapshot{" + "network=" + network + ", networkCapabilities=" + networkCapabilities + ", linkProperties=" + linkProperties + ", subscriberId='" + NetworkIdentityUtils.scrubSubscriberId(subscriberId) + '\'' + ", legacyType=" + legacyType + "network=" + mNetwork + ", networkCapabilities=" + mNetworkCapabilities + ", linkProperties=" + mLinkProperties + ", subscriberId='" + NetworkIdentityUtils.scrubSubscriberId(mSubscriberId) + '\'' + ", legacyType=" + mLegacyType + '}'; } } services/core/java/com/android/server/ConnectivityService.java +3 −3 Original line number Diff line number Diff line Loading @@ -2179,11 +2179,11 @@ public class ConnectivityService extends IConnectivityManager.Stub for (NetworkStateSnapshot snapshot : getAllNetworkStateSnapshots()) { // NetworkStateSnapshot doesn't contain NetworkInfo, so need to fetch it from the // NetworkAgentInfo. final NetworkAgentInfo nai = getNetworkAgentInfoForNetwork(snapshot.network); final NetworkAgentInfo nai = getNetworkAgentInfoForNetwork(snapshot.getNetwork()); if (nai != null && nai.networkInfo.isConnected()) { result.add(new NetworkState(new NetworkInfo(nai.networkInfo), snapshot.linkProperties, snapshot.networkCapabilities, snapshot.network, snapshot.subscriberId)); snapshot.getLinkProperties(), snapshot.getNetworkCapabilities(), snapshot.getNetwork(), snapshot.getSubscriberId())); } } return result.toArray(new NetworkState[result.size()]); Loading services/core/java/com/android/server/net/NetworkPolicyManagerService.java +9 −9 Original line number Diff line number Diff line Loading @@ -1921,7 +1921,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { * Collect all ifaces from a {@link NetworkStateSnapshot} into the given set. */ private static void collectIfaces(ArraySet<String> ifaces, NetworkStateSnapshot snapshot) { ifaces.addAll(snapshot.linkProperties.getAllInterfaceNames()); ifaces.addAll(snapshot.getLinkProperties().getAllInterfaceNames()); } /** Loading Loading @@ -2002,7 +2002,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { mNetIdToSubId.clear(); final ArrayMap<NetworkStateSnapshot, NetworkIdentity> identified = new ArrayMap<>(); for (final NetworkStateSnapshot snapshot : snapshots) { mNetIdToSubId.put(snapshot.network.getNetId(), parseSubId(snapshot)); mNetIdToSubId.put(snapshot.getNetwork().getNetId(), parseSubId(snapshot)); // 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 Loading Loading @@ -2090,7 +2090,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 (final NetworkStateSnapshot snapshot : snapshots) { if (!snapshot.networkCapabilities.hasCapability(NET_CAPABILITY_NOT_METERED)) { if (!snapshot.getNetworkCapabilities().hasCapability(NET_CAPABILITY_NOT_METERED)) { matchingIfaces.clear(); collectIfaces(matchingIfaces, snapshot); for (int j = matchingIfaces.size() - 1; j >= 0; j--) { Loading Loading @@ -2126,14 +2126,14 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { mSubscriptionOpportunisticQuota.clear(); for (final NetworkStateSnapshot snapshot : snapshots) { if (!quotaEnabled) continue; if (snapshot.network == null) continue; final int subId = getSubIdLocked(snapshot.network); if (snapshot.getNetwork() == null) continue; final int subId = getSubIdLocked(snapshot.getNetwork()); final SubscriptionPlan plan = getPrimarySubscriptionPlanLocked(subId); if (plan == null) continue; final long quotaBytes; final long limitBytes = plan.getDataLimitBytes(); if (!snapshot.networkCapabilities.hasCapability(NET_CAPABILITY_NOT_ROAMING)) { if (!snapshot.getNetworkCapabilities().hasCapability(NET_CAPABILITY_NOT_ROAMING)) { // Clamp to 0 when roaming quotaBytes = 0; } else if (limitBytes == SubscriptionPlan.BYTES_UNKNOWN) { Loading @@ -2151,7 +2151,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { .truncatedTo(ChronoUnit.DAYS) .toInstant().toEpochMilli(); final long totalBytes = getTotalBytes( NetworkTemplate.buildTemplateMobileAll(snapshot.subscriberId), NetworkTemplate.buildTemplateMobileAll(snapshot.getSubscriberId()), start, startOfDay); final long remainingBytes = limitBytes - totalBytes; // Number of remaining days including current day Loading Loading @@ -5770,8 +5770,8 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { private int parseSubId(@NonNull NetworkStateSnapshot snapshot) { int subId = INVALID_SUBSCRIPTION_ID; if (snapshot.networkCapabilities.hasTransport(TRANSPORT_CELLULAR)) { NetworkSpecifier spec = snapshot.networkCapabilities.getNetworkSpecifier(); if (snapshot.getNetworkCapabilities().hasTransport(TRANSPORT_CELLULAR)) { NetworkSpecifier spec = snapshot.getNetworkCapabilities().getNetworkSpecifier(); if (spec instanceof TelephonyNetworkSpecifier) { subId = ((TelephonyNetworkSpecifier) spec).getSubscriptionId(); } Loading Loading
core/api/module-lib-current.txt +5 −5 Original line number Diff line number Diff line Loading @@ -59,13 +59,13 @@ package android.net { public final class NetworkStateSnapshot implements android.os.Parcelable { ctor public NetworkStateSnapshot(@NonNull android.net.Network, @NonNull android.net.NetworkCapabilities, @NonNull android.net.LinkProperties, @Nullable String, int); method public int describeContents(); method public int getLegacyType(); method @NonNull public android.net.LinkProperties getLinkProperties(); method @NonNull public android.net.Network getNetwork(); method @NonNull public android.net.NetworkCapabilities getNetworkCapabilities(); method @Nullable public String getSubscriberId(); method public void writeToParcel(@NonNull android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator<android.net.NetworkStateSnapshot> CREATOR; field public final int legacyType; field @NonNull public final android.net.LinkProperties linkProperties; field @NonNull public final android.net.Network network; field @NonNull public final android.net.NetworkCapabilities networkCapabilities; field @Nullable public final String subscriberId; } public class NetworkWatchlistManager { Loading
core/java/android/net/NetworkIdentity.java +6 −6 Original line number Diff line number Diff line Loading @@ -186,19 +186,19 @@ public class NetworkIdentity implements Comparable<NetworkIdentity> { */ public static NetworkIdentity buildNetworkIdentity(Context context, NetworkStateSnapshot snapshot, boolean defaultNetwork, @NetworkType int subType) { final int legacyType = snapshot.legacyType; final int legacyType = snapshot.getLegacyType(); final String subscriberId = snapshot.subscriberId; final String subscriberId = snapshot.getSubscriberId(); String networkId = null; boolean roaming = !snapshot.networkCapabilities.hasCapability( boolean roaming = !snapshot.getNetworkCapabilities().hasCapability( NetworkCapabilities.NET_CAPABILITY_NOT_ROAMING); boolean metered = !snapshot.networkCapabilities.hasCapability( boolean metered = !snapshot.getNetworkCapabilities().hasCapability( NetworkCapabilities.NET_CAPABILITY_NOT_METERED); final int oemManaged = getOemBitfield(snapshot.networkCapabilities); final int oemManaged = getOemBitfield(snapshot.getNetworkCapabilities()); if (legacyType == TYPE_WIFI) { networkId = snapshot.networkCapabilities.getSsid(); networkId = snapshot.getNetworkCapabilities().getSsid(); if (networkId == null) { final WifiManager wifi = context.getSystemService(WifiManager.class); final WifiInfo info = wifi.getConnectionInfo(); Loading
core/java/android/net/NetworkStateSnapshot.java +61 −31 Original line number Diff line number Diff line Loading @@ -37,47 +37,76 @@ import java.util.Objects; public final class NetworkStateSnapshot implements Parcelable { /** The network associated with this snapshot. */ @NonNull public final Network network; private final Network mNetwork; /** The {@link NetworkCapabilities} of the network associated with this snapshot. */ @NonNull public final NetworkCapabilities networkCapabilities; private final NetworkCapabilities mNetworkCapabilities; /** The {@link LinkProperties} of the network associated with this snapshot. */ @NonNull public final LinkProperties linkProperties; private final LinkProperties mLinkProperties; /** * The Subscriber Id of the network associated with this snapshot. See * {@link android.telephony.TelephonyManager#getSubscriberId()}. */ @Nullable public final String subscriberId; private final String mSubscriberId; /** * The legacy type of the network associated with this snapshot. See * {@code ConnectivityManager#TYPE_*}. */ public final int legacyType; private final int mLegacyType; public NetworkStateSnapshot(@NonNull Network network, @NonNull NetworkCapabilities networkCapabilities, @NonNull LinkProperties linkProperties, @Nullable String subscriberId, int legacyType) { this.network = Objects.requireNonNull(network); this.networkCapabilities = Objects.requireNonNull(networkCapabilities); this.linkProperties = Objects.requireNonNull(linkProperties); this.subscriberId = subscriberId; this.legacyType = legacyType; mNetwork = Objects.requireNonNull(network); mNetworkCapabilities = Objects.requireNonNull(networkCapabilities); mLinkProperties = Objects.requireNonNull(linkProperties); mSubscriberId = subscriberId; mLegacyType = legacyType; } /** @hide */ public NetworkStateSnapshot(@NonNull Parcel in) { network = in.readParcelable(null); networkCapabilities = in.readParcelable(null); linkProperties = in.readParcelable(null); subscriberId = in.readString(); legacyType = in.readInt(); mNetwork = in.readParcelable(null); mNetworkCapabilities = in.readParcelable(null); mLinkProperties = in.readParcelable(null); mSubscriberId = in.readString(); mLegacyType = in.readInt(); } /** Get the network associated with this snapshot */ @NonNull public Network getNetwork() { return mNetwork; } /** Get {@link NetworkCapabilities} of the network associated with this snapshot. */ @NonNull public NetworkCapabilities getNetworkCapabilities() { return mNetworkCapabilities; } /** Get the {@link LinkProperties} of the network associated with this snapshot. */ @NonNull public LinkProperties getLinkProperties() { return mLinkProperties; } /** Get the Subscriber Id of the network associated with this snapshot. */ @Nullable public String getSubscriberId() { return mSubscriberId; } /** Get the legacy type of the network associated with this snapshot. */ public int getLegacyType() { return mLegacyType; } @Override Loading @@ -87,11 +116,11 @@ public final class NetworkStateSnapshot implements Parcelable { @Override public void writeToParcel(@NonNull Parcel out, int flags) { out.writeParcelable(network, flags); out.writeParcelable(networkCapabilities, flags); out.writeParcelable(linkProperties, flags); out.writeString(subscriberId); out.writeInt(legacyType); out.writeParcelable(mNetwork, flags); out.writeParcelable(mNetworkCapabilities, flags); out.writeParcelable(mLinkProperties, flags); out.writeString(mSubscriberId); out.writeInt(mLegacyType); } @NonNull Loading @@ -115,26 +144,27 @@ public final class NetworkStateSnapshot implements Parcelable { if (this == o) return true; if (!(o instanceof NetworkStateSnapshot)) return false; NetworkStateSnapshot that = (NetworkStateSnapshot) o; return legacyType == that.legacyType && Objects.equals(network, that.network) && Objects.equals(networkCapabilities, that.networkCapabilities) && Objects.equals(linkProperties, that.linkProperties) && Objects.equals(subscriberId, that.subscriberId); return mLegacyType == that.mLegacyType && Objects.equals(mNetwork, that.mNetwork) && Objects.equals(mNetworkCapabilities, that.mNetworkCapabilities) && Objects.equals(mLinkProperties, that.mLinkProperties) && Objects.equals(mSubscriberId, that.mSubscriberId); } @Override public int hashCode() { return Objects.hash(network, networkCapabilities, linkProperties, subscriberId, legacyType); return Objects.hash(mNetwork, mNetworkCapabilities, mLinkProperties, mSubscriberId, mLegacyType); } @Override public String toString() { return "NetworkStateSnapshot{" + "network=" + network + ", networkCapabilities=" + networkCapabilities + ", linkProperties=" + linkProperties + ", subscriberId='" + NetworkIdentityUtils.scrubSubscriberId(subscriberId) + '\'' + ", legacyType=" + legacyType + "network=" + mNetwork + ", networkCapabilities=" + mNetworkCapabilities + ", linkProperties=" + mLinkProperties + ", subscriberId='" + NetworkIdentityUtils.scrubSubscriberId(mSubscriberId) + '\'' + ", legacyType=" + mLegacyType + '}'; } }
services/core/java/com/android/server/ConnectivityService.java +3 −3 Original line number Diff line number Diff line Loading @@ -2179,11 +2179,11 @@ public class ConnectivityService extends IConnectivityManager.Stub for (NetworkStateSnapshot snapshot : getAllNetworkStateSnapshots()) { // NetworkStateSnapshot doesn't contain NetworkInfo, so need to fetch it from the // NetworkAgentInfo. final NetworkAgentInfo nai = getNetworkAgentInfoForNetwork(snapshot.network); final NetworkAgentInfo nai = getNetworkAgentInfoForNetwork(snapshot.getNetwork()); if (nai != null && nai.networkInfo.isConnected()) { result.add(new NetworkState(new NetworkInfo(nai.networkInfo), snapshot.linkProperties, snapshot.networkCapabilities, snapshot.network, snapshot.subscriberId)); snapshot.getLinkProperties(), snapshot.getNetworkCapabilities(), snapshot.getNetwork(), snapshot.getSubscriberId())); } } return result.toArray(new NetworkState[result.size()]); Loading
services/core/java/com/android/server/net/NetworkPolicyManagerService.java +9 −9 Original line number Diff line number Diff line Loading @@ -1921,7 +1921,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { * Collect all ifaces from a {@link NetworkStateSnapshot} into the given set. */ private static void collectIfaces(ArraySet<String> ifaces, NetworkStateSnapshot snapshot) { ifaces.addAll(snapshot.linkProperties.getAllInterfaceNames()); ifaces.addAll(snapshot.getLinkProperties().getAllInterfaceNames()); } /** Loading Loading @@ -2002,7 +2002,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { mNetIdToSubId.clear(); final ArrayMap<NetworkStateSnapshot, NetworkIdentity> identified = new ArrayMap<>(); for (final NetworkStateSnapshot snapshot : snapshots) { mNetIdToSubId.put(snapshot.network.getNetId(), parseSubId(snapshot)); mNetIdToSubId.put(snapshot.getNetwork().getNetId(), parseSubId(snapshot)); // 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 Loading Loading @@ -2090,7 +2090,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 (final NetworkStateSnapshot snapshot : snapshots) { if (!snapshot.networkCapabilities.hasCapability(NET_CAPABILITY_NOT_METERED)) { if (!snapshot.getNetworkCapabilities().hasCapability(NET_CAPABILITY_NOT_METERED)) { matchingIfaces.clear(); collectIfaces(matchingIfaces, snapshot); for (int j = matchingIfaces.size() - 1; j >= 0; j--) { Loading Loading @@ -2126,14 +2126,14 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { mSubscriptionOpportunisticQuota.clear(); for (final NetworkStateSnapshot snapshot : snapshots) { if (!quotaEnabled) continue; if (snapshot.network == null) continue; final int subId = getSubIdLocked(snapshot.network); if (snapshot.getNetwork() == null) continue; final int subId = getSubIdLocked(snapshot.getNetwork()); final SubscriptionPlan plan = getPrimarySubscriptionPlanLocked(subId); if (plan == null) continue; final long quotaBytes; final long limitBytes = plan.getDataLimitBytes(); if (!snapshot.networkCapabilities.hasCapability(NET_CAPABILITY_NOT_ROAMING)) { if (!snapshot.getNetworkCapabilities().hasCapability(NET_CAPABILITY_NOT_ROAMING)) { // Clamp to 0 when roaming quotaBytes = 0; } else if (limitBytes == SubscriptionPlan.BYTES_UNKNOWN) { Loading @@ -2151,7 +2151,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { .truncatedTo(ChronoUnit.DAYS) .toInstant().toEpochMilli(); final long totalBytes = getTotalBytes( NetworkTemplate.buildTemplateMobileAll(snapshot.subscriberId), NetworkTemplate.buildTemplateMobileAll(snapshot.getSubscriberId()), start, startOfDay); final long remainingBytes = limitBytes - totalBytes; // Number of remaining days including current day Loading Loading @@ -5770,8 +5770,8 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { private int parseSubId(@NonNull NetworkStateSnapshot snapshot) { int subId = INVALID_SUBSCRIPTION_ID; if (snapshot.networkCapabilities.hasTransport(TRANSPORT_CELLULAR)) { NetworkSpecifier spec = snapshot.networkCapabilities.getNetworkSpecifier(); if (snapshot.getNetworkCapabilities().hasTransport(TRANSPORT_CELLULAR)) { NetworkSpecifier spec = snapshot.getNetworkCapabilities().getNetworkSpecifier(); if (spec instanceof TelephonyNetworkSpecifier) { subId = ((TelephonyNetworkSpecifier) spec).getSubscriptionId(); } Loading