diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java index 4714587449..49c3dc63e1 100644 --- a/core/java/android/net/ConnectivityManager.java +++ b/core/java/android/net/ConnectivityManager.java @@ -187,13 +187,19 @@ public class ConnectivityManager { * is for a network to which the connectivity manager was failing over * following a disconnect on another network. * Retrieve it with {@link android.content.Intent#getBooleanExtra(String,boolean)}. + * + * @deprecated See {@link NetworkInfo}. */ + @Deprecated public static final String EXTRA_IS_FAILOVER = "isFailover"; /** * The lookup key for a {@link NetworkInfo} object. This is supplied when * there is another network that it may be possible to connect to. Retrieve with * {@link android.content.Intent#getParcelableExtra(String)}. + * + * @deprecated See {@link NetworkInfo}. */ + @Deprecated public static final String EXTRA_OTHER_NETWORK_INFO = "otherNetwork"; /** * The lookup key for a boolean that indicates whether there is a @@ -214,7 +220,10 @@ public class ConnectivityManager { * may be passed up from the lower networking layers, and its * meaning may be specific to a particular network type. Retrieve * it with {@link android.content.Intent#getStringExtra(String)}. + * + * @deprecated See {@link NetworkInfo#getExtraInfo()}. */ + @Deprecated public static final String EXTRA_EXTRA_INFO = "extraInfo"; /** * The lookup key for an int that provides information about @@ -895,7 +904,9 @@ public class ConnectivityManager { * * @return a {@link NetworkInfo} object for the current default network * or {@code null} if no default network is currently active + * @deprecated See {@link NetworkInfo}. */ + @Deprecated @RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE) public NetworkInfo getActiveNetworkInfo() { try { @@ -1079,7 +1090,9 @@ public class ConnectivityManager { * @return a {@link NetworkInfo} object for the requested * network or {@code null} if the {@code Network} * is not valid. + * @deprecated See {@link NetworkInfo}. */ + @Deprecated @RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE) public NetworkInfo getNetworkInfo(Network network) { return getNetworkInfoForUid(network, Process.myUid(), false); diff --git a/core/java/android/net/NetworkInfo.java b/core/java/android/net/NetworkInfo.java index 1a1d2d3342..89d99617df 100644 --- a/core/java/android/net/NetworkInfo.java +++ b/core/java/android/net/NetworkInfo.java @@ -28,7 +28,20 @@ import java.util.EnumMap; * Describes the status of a network interface. *
Use {@link ConnectivityManager#getActiveNetworkInfo()} to get an instance that represents * the current network connection. + * + * @deprecated Callers should instead use the {@link ConnectivityManager.NetworkCallback} API to + * learn about connectivity changes, or switch to use + * {@link ConnectivityManager#getNetworkCapabilities} or + * {@link ConnectivityManager#getLinkProperties} to get information synchronously. Keep + * in mind that while callbacks are guaranteed to be called for every event in order, + * synchronous calls have no such constraints, and as such it is unadvisable to use the + * synchronous methods inside the callbacks as they will often not offer a view of + * networking that is consistent (that is: they may return a past or a future state with + * respect to the event being processed by the callback). Instead, callers are advised + * to only use the arguments of the callbacks, possibly memorizing the specific bits of + * information they need to keep from one callback to another. */ +@Deprecated public class NetworkInfo implements Parcelable { /** @@ -52,7 +65,10 @@ public class NetworkInfo implements Parcelable { *
FAILEDDISCONNECTEDBLOCKEDDISCONNECTED