From f565045348a5b7326959a82bf53247eb72c59c8b Mon Sep 17 00:00:00 2001 From: Remi NGUYEN VAN Date: Mon, 30 Nov 2020 15:52:46 +0900 Subject: [PATCH] Set NetworkIdentity subscriberId on all networks Instead of setting NetworkIdentity.subscriberId only on telephony networks, set it when provided on any network. At the moment only telephony is expected to have a subscriberId in its NetworkState anyway, and while there are plans for other network agents (wifi) to have a subscriberId, it should also be set in that case. This allows NetworkIdentity to stop depending on hidden network type APIs to determine if the network is mobile. Bug: 174436414 Test: atest FrameworksNetTests Change-Id: I4f09987f8737d1801342eb5d6d7c2b9968b466b0 --- core/java/android/net/NetworkIdentity.java | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/core/java/android/net/NetworkIdentity.java b/core/java/android/net/NetworkIdentity.java index efbfbf93f9..a0dc72d4ad 100644 --- a/core/java/android/net/NetworkIdentity.java +++ b/core/java/android/net/NetworkIdentity.java @@ -17,7 +17,6 @@ package android.net; import static android.net.ConnectivityManager.TYPE_WIFI; -import static android.net.ConnectivityManager.isNetworkTypeMobile; import android.content.Context; import android.net.wifi.WifiInfo; @@ -25,7 +24,6 @@ import android.net.wifi.WifiManager; import android.os.Build; import android.service.NetworkIdentityProto; import android.telephony.Annotation.NetworkType; -import android.util.Slog; import android.util.proto.ProtoOutputStream; import java.util.Objects; @@ -193,18 +191,9 @@ public class NetworkIdentity implements Comparable { boolean metered = !state.networkCapabilities.hasCapability( NetworkCapabilities.NET_CAPABILITY_NOT_METERED); - if (isNetworkTypeMobile(type)) { - if (state.subscriberId == null) { - if (state.networkInfo.getState() != NetworkInfo.State.DISCONNECTED && - state.networkInfo.getState() != NetworkInfo.State.UNKNOWN) { - Slog.w(TAG, "Active mobile network without subscriber! ni = " - + state.networkInfo); - } - } + subscriberId = state.subscriberId; - subscriberId = state.subscriberId; - - } else if (type == TYPE_WIFI) { + if (type == TYPE_WIFI) { if (state.networkId != null) { networkId = state.networkId; } else {