Merge "Deprecate NetworkInfo"

This commit is contained in:
Junyu Lai
2018-12-21 09:56:39 +00:00
committed by Gerrit Code Review
2 changed files with 37 additions and 0 deletions

View File

@@ -187,13 +187,19 @@ public class ConnectivityManager {
* is for a network to which the connectivity manager was failing over * is for a network to which the connectivity manager was failing over
* following a disconnect on another network. * following a disconnect on another network.
* Retrieve it with {@link android.content.Intent#getBooleanExtra(String,boolean)}. * Retrieve it with {@link android.content.Intent#getBooleanExtra(String,boolean)}.
*
* @deprecated See {@link NetworkInfo}.
*/ */
@Deprecated
public static final String EXTRA_IS_FAILOVER = "isFailover"; public static final String EXTRA_IS_FAILOVER = "isFailover";
/** /**
* The lookup key for a {@link NetworkInfo} object. This is supplied when * 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 * there is another network that it may be possible to connect to. Retrieve with
* {@link android.content.Intent#getParcelableExtra(String)}. * {@link android.content.Intent#getParcelableExtra(String)}.
*
* @deprecated See {@link NetworkInfo}.
*/ */
@Deprecated
public static final String EXTRA_OTHER_NETWORK_INFO = "otherNetwork"; public static final String EXTRA_OTHER_NETWORK_INFO = "otherNetwork";
/** /**
* The lookup key for a boolean that indicates whether there is a * 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 * may be passed up from the lower networking layers, and its
* meaning may be specific to a particular network type. Retrieve * meaning may be specific to a particular network type. Retrieve
* it with {@link android.content.Intent#getStringExtra(String)}. * it with {@link android.content.Intent#getStringExtra(String)}.
*
* @deprecated See {@link NetworkInfo#getExtraInfo()}.
*/ */
@Deprecated
public static final String EXTRA_EXTRA_INFO = "extraInfo"; public static final String EXTRA_EXTRA_INFO = "extraInfo";
/** /**
* The lookup key for an int that provides information about * 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 * @return a {@link NetworkInfo} object for the current default network
* or {@code null} if no default network is currently active * or {@code null} if no default network is currently active
* @deprecated See {@link NetworkInfo}.
*/ */
@Deprecated
@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE) @RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
public NetworkInfo getActiveNetworkInfo() { public NetworkInfo getActiveNetworkInfo() {
try { try {
@@ -1079,7 +1090,9 @@ public class ConnectivityManager {
* @return a {@link NetworkInfo} object for the requested * @return a {@link NetworkInfo} object for the requested
* network or {@code null} if the {@code Network} * network or {@code null} if the {@code Network}
* is not valid. * is not valid.
* @deprecated See {@link NetworkInfo}.
*/ */
@Deprecated
@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE) @RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
public NetworkInfo getNetworkInfo(Network network) { public NetworkInfo getNetworkInfo(Network network) {
return getNetworkInfoForUid(network, Process.myUid(), false); return getNetworkInfoForUid(network, Process.myUid(), false);

View File

@@ -28,7 +28,20 @@ import java.util.EnumMap;
* Describes the status of a network interface. * Describes the status of a network interface.
* <p>Use {@link ConnectivityManager#getActiveNetworkInfo()} to get an instance that represents * <p>Use {@link ConnectivityManager#getActiveNetworkInfo()} to get an instance that represents
* the current network connection. * 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 { public class NetworkInfo implements Parcelable {
/** /**
@@ -52,7 +65,10 @@ public class NetworkInfo implements Parcelable {
* <tr><td><code>FAILED</code></td><td><code>DISCONNECTED</code></td></tr> * <tr><td><code>FAILED</code></td><td><code>DISCONNECTED</code></td></tr>
* <tr><td><code>BLOCKED</code></td><td><code>DISCONNECTED</code></td></tr> * <tr><td><code>BLOCKED</code></td><td><code>DISCONNECTED</code></td></tr>
* </table> * </table>
*
* @deprecated See {@link NetworkInfo}.
*/ */
@Deprecated
public enum State { public enum State {
CONNECTING, CONNECTED, SUSPENDED, DISCONNECTING, DISCONNECTED, UNKNOWN CONNECTING, CONNECTED, SUSPENDED, DISCONNECTING, DISCONNECTED, UNKNOWN
} }
@@ -61,7 +77,10 @@ public class NetworkInfo implements Parcelable {
* The fine-grained state of a network connection. This level of detail * The fine-grained state of a network connection. This level of detail
* is probably of interest to few applications. Most should use * is probably of interest to few applications. Most should use
* {@link android.net.NetworkInfo.State State} instead. * {@link android.net.NetworkInfo.State State} instead.
*
* @deprecated See {@link NetworkInfo}.
*/ */
@Deprecated
public enum DetailedState { public enum DetailedState {
/** Ready to start data connection setup. */ /** Ready to start data connection setup. */
IDLE, IDLE,
@@ -463,8 +482,10 @@ public class NetworkInfo implements Parcelable {
* Set the extraInfo field. * Set the extraInfo field.
* @param extraInfo an optional {@code String} providing addditional network state * @param extraInfo an optional {@code String} providing addditional network state
* information passed up from the lower networking layers. * information passed up from the lower networking layers.
* @deprecated See {@link NetworkInfo#getExtraInfo}.
* @hide * @hide
*/ */
@Deprecated
public void setExtraInfo(String extraInfo) { public void setExtraInfo(String extraInfo) {
synchronized (this) { synchronized (this) {
this.mExtraInfo = extraInfo; this.mExtraInfo = extraInfo;
@@ -488,7 +509,10 @@ public class NetworkInfo implements Parcelable {
* Report the extra information about the network state, if any was * Report the extra information about the network state, if any was
* provided by the lower networking layers. * provided by the lower networking layers.
* @return the extra information, or null if not available * @return the extra information, or null if not available
* @deprecated Use other services e.g. WifiManager to get additional information passed up from
* the lower networking layers.
*/ */
@Deprecated
public String getExtraInfo() { public String getExtraInfo() {
synchronized (this) { synchronized (this) {
return mExtraInfo; return mExtraInfo;