summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2021-02-01 10:56:19 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2021-02-01 10:56:19 +0000
commitd4caba4dafb3bccd8b26342a792ed5f4286ada7d (patch)
tree53dc8d86ec295d9039a17d0cba071e2278f12013 /core/java
parent87d840adddab6dfbed044a6f08d4790ca465c111 (diff)
parentd8cc12a87bd7a87e961fdc080d0e07a1a6a0c400 (diff)
Merge changes Idcc9e32c,I58769bb7
* changes: Remove getFilteredNetworkState and add @NonNull in NetworkState. Add test coverage for get*NetworkInfo on metered networks.
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/net/NetworkState.java19
1 files changed, 15 insertions, 4 deletions
diff --git a/core/java/android/net/NetworkState.java b/core/java/android/net/NetworkState.java
index 713b6888376e..e1ef8b5ea5c9 100644
--- a/core/java/android/net/NetworkState.java
+++ b/core/java/android/net/NetworkState.java
@@ -16,6 +16,7 @@
package android.net;
+import android.annotation.NonNull;
import android.compat.annotation.UnsupportedAppUsage;
import android.os.Build;
import android.os.Parcel;
@@ -30,7 +31,8 @@ import android.util.Slog;
public class NetworkState implements Parcelable {
private static final boolean VALIDATE_ROAMING_STATE = false;
- public static final NetworkState EMPTY = new NetworkState(null, null, null, null, null, null);
+ // TODO: remove and make members @NonNull.
+ public static final NetworkState EMPTY = new NetworkState();
public final NetworkInfo networkInfo;
public final LinkProperties linkProperties;
@@ -40,9 +42,18 @@ public class NetworkState implements Parcelable {
public final String subscriberId;
public final String networkId;
- public NetworkState(NetworkInfo networkInfo, LinkProperties linkProperties,
- NetworkCapabilities networkCapabilities, Network network, String subscriberId,
- String networkId) {
+ private NetworkState() {
+ networkInfo = null;
+ linkProperties = null;
+ networkCapabilities = null;
+ network = null;
+ subscriberId = null;
+ networkId = null;
+ }
+
+ public NetworkState(@NonNull NetworkInfo networkInfo, @NonNull LinkProperties linkProperties,
+ @NonNull NetworkCapabilities networkCapabilities, @NonNull Network network,
+ String subscriberId, String networkId) {
this.networkInfo = networkInfo;
this.linkProperties = linkProperties;
this.networkCapabilities = networkCapabilities;