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
This commit is contained in:
@@ -17,7 +17,6 @@
|
|||||||
package android.net;
|
package android.net;
|
||||||
|
|
||||||
import static android.net.ConnectivityManager.TYPE_WIFI;
|
import static android.net.ConnectivityManager.TYPE_WIFI;
|
||||||
import static android.net.ConnectivityManager.isNetworkTypeMobile;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.wifi.WifiInfo;
|
import android.net.wifi.WifiInfo;
|
||||||
@@ -25,7 +24,6 @@ import android.net.wifi.WifiManager;
|
|||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.service.NetworkIdentityProto;
|
import android.service.NetworkIdentityProto;
|
||||||
import android.telephony.Annotation.NetworkType;
|
import android.telephony.Annotation.NetworkType;
|
||||||
import android.util.Slog;
|
|
||||||
import android.util.proto.ProtoOutputStream;
|
import android.util.proto.ProtoOutputStream;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@@ -193,18 +191,9 @@ public class NetworkIdentity implements Comparable<NetworkIdentity> {
|
|||||||
boolean metered = !state.networkCapabilities.hasCapability(
|
boolean metered = !state.networkCapabilities.hasCapability(
|
||||||
NetworkCapabilities.NET_CAPABILITY_NOT_METERED);
|
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) {
|
if (state.networkId != null) {
|
||||||
networkId = state.networkId;
|
networkId = state.networkId;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user