[FUI06] Stop using NetworkInfo in NetworkState from external callers
This is achieved by:
1. Use legacy network type inside NetworkState to replace the
needs of referencing NetworkInfo.getType().
2. Let getAllNetworkState only return networks with isConnected()
equals true. This allows callers such as NPMS or NSS does not
have to reference to NetworkInfo.isConnected().
Test: atest FrameworksNetTests NetworkPolicyManagerServiceTest
Bug: 174123988
Change-Id: I1c4eb08d18ca973eb8f41d06258872eabc0006b8
This commit is contained in:
parent
c6bf15898a
commit
dddf2b6a02
1 changed files with 8 additions and 2 deletions
|
|
@ -41,6 +41,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,6 +50,7 @@ public class NetworkState implements Parcelable {
|
|||
network = null;
|
||||
subscriberId = null;
|
||||
networkId = null;
|
||||
legacyNetworkType = 0;
|
||||
}
|
||||
|
||||
public NetworkState(@NonNull NetworkInfo networkInfo, @NonNull LinkProperties linkProperties,
|
||||
|
|
@ -60,6 +62,8 @@ public class NetworkState implements Parcelable {
|
|||
this.network = network;
|
||||
this.subscriberId = subscriberId;
|
||||
this.networkId = networkId;
|
||||
// TODO: Pass legacyNetworkType directly from parameters and remove NetworkInfo.
|
||||
this.legacyNetworkType = this.networkInfo.getType();
|
||||
|
||||
// This object is an atomic view of a network, so the various components
|
||||
// should always agree on roaming state.
|
||||
|
|
@ -80,6 +84,7 @@ public class NetworkState implements Parcelable {
|
|||
network = in.readParcelable(null);
|
||||
subscriberId = in.readString();
|
||||
networkId = in.readString();
|
||||
legacyNetworkType = in.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -95,6 +100,7 @@ public class NetworkState implements Parcelable {
|
|||
out.writeParcelable(network, flags);
|
||||
out.writeString(subscriberId);
|
||||
out.writeString(networkId);
|
||||
out.writeInt(legacyNetworkType);
|
||||
}
|
||||
|
||||
@UnsupportedAppUsage
|
||||
|
|
|
|||
Loading…
Reference in a new issue