summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Junyu Lai <junyulai@google.com> 2018-12-21 09:56:39 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2018-12-21 09:56:39 +0000
commita244ccd86df47c87a56449bcd8438e181e564985 (patch)
tree08592d7205c200f50cc08d9bb4fcf9a81b9a89c6
parent667dba5c14a9359c13116d31a51409c8bf05bdad (diff)
parent3822c8a26d5b9cd1550319d1f425d20c71b2cda5 (diff)
Merge "Deprecate NetworkInfo"
-rwxr-xr-xapi/current.txt18
-rw-r--r--core/java/android/net/ConnectivityManager.java13
-rw-r--r--core/java/android/net/NetworkInfo.java24
3 files changed, 46 insertions, 9 deletions
diff --git a/api/current.txt b/api/current.txt
index 6bf98d245f50..cec0fa39b9d3 100755
--- a/api/current.txt
+++ b/api/current.txt
@@ -27225,7 +27225,7 @@ package android.net {
method public void addDefaultNetworkActiveListener(android.net.ConnectivityManager.OnNetworkActiveListener);
method public boolean bindProcessToNetwork(android.net.Network);
method public android.net.Network getActiveNetwork();
- method public android.net.NetworkInfo getActiveNetworkInfo();
+ method public deprecated android.net.NetworkInfo getActiveNetworkInfo();
method public deprecated android.net.NetworkInfo[] getAllNetworkInfo();
method public android.net.Network[] getAllNetworks();
method public deprecated boolean getBackgroundDataSetting();
@@ -27236,7 +27236,7 @@ package android.net {
method public int getMultipathPreference(android.net.Network);
method public android.net.NetworkCapabilities getNetworkCapabilities(android.net.Network);
method public deprecated android.net.NetworkInfo getNetworkInfo(int);
- method public android.net.NetworkInfo getNetworkInfo(android.net.Network);
+ method public deprecated android.net.NetworkInfo getNetworkInfo(android.net.Network);
method public deprecated int getNetworkPreference();
method public byte[] getNetworkWatchlistConfigHash();
method public static deprecated android.net.Network getProcessDefaultNetwork();
@@ -27270,14 +27270,14 @@ package android.net {
field public static final deprecated int DEFAULT_NETWORK_PREFERENCE = 1; // 0x1
field public static final java.lang.String EXTRA_CAPTIVE_PORTAL = "android.net.extra.CAPTIVE_PORTAL";
field public static final java.lang.String EXTRA_CAPTIVE_PORTAL_URL = "android.net.extra.CAPTIVE_PORTAL_URL";
- field public static final java.lang.String EXTRA_EXTRA_INFO = "extraInfo";
- field public static final java.lang.String EXTRA_IS_FAILOVER = "isFailover";
+ field public static final deprecated java.lang.String EXTRA_EXTRA_INFO = "extraInfo";
+ field public static final deprecated java.lang.String EXTRA_IS_FAILOVER = "isFailover";
field public static final java.lang.String EXTRA_NETWORK = "android.net.extra.NETWORK";
field public static final deprecated java.lang.String EXTRA_NETWORK_INFO = "networkInfo";
field public static final java.lang.String EXTRA_NETWORK_REQUEST = "android.net.extra.NETWORK_REQUEST";
field public static final java.lang.String EXTRA_NETWORK_TYPE = "networkType";
field public static final java.lang.String EXTRA_NO_CONNECTIVITY = "noConnectivity";
- field public static final java.lang.String EXTRA_OTHER_NETWORK_INFO = "otherNetwork";
+ field public static final deprecated java.lang.String EXTRA_OTHER_NETWORK_INFO = "otherNetwork";
field public static final java.lang.String EXTRA_REASON = "reason";
field public static final int MULTIPATH_PREFERENCE_HANDOVER = 1; // 0x1
field public static final int MULTIPATH_PREFERENCE_PERFORMANCE = 4; // 0x4
@@ -27577,10 +27577,10 @@ package android.net {
field public static final int TRANSPORT_WIFI_AWARE = 5; // 0x5
}
- public class NetworkInfo implements android.os.Parcelable {
+ public deprecated class NetworkInfo implements android.os.Parcelable {
method public int describeContents();
method public deprecated android.net.NetworkInfo.DetailedState getDetailedState();
- method public java.lang.String getExtraInfo();
+ method public deprecated java.lang.String getExtraInfo();
method public deprecated java.lang.String getReason();
method public deprecated android.net.NetworkInfo.State getState();
method public deprecated int getSubtype();
@@ -27596,7 +27596,7 @@ package android.net {
field public static final android.os.Parcelable.Creator<android.net.NetworkInfo> CREATOR;
}
- public static final class NetworkInfo.DetailedState extends java.lang.Enum {
+ public static final deprecated class NetworkInfo.DetailedState extends java.lang.Enum {
method public static android.net.NetworkInfo.DetailedState valueOf(java.lang.String);
method public static final android.net.NetworkInfo.DetailedState[] values();
enum_constant public static final android.net.NetworkInfo.DetailedState AUTHENTICATING;
@@ -27614,7 +27614,7 @@ package android.net {
enum_constant public static final android.net.NetworkInfo.DetailedState VERIFYING_POOR_LINK;
}
- public static final class NetworkInfo.State extends java.lang.Enum {
+ public static final deprecated class NetworkInfo.State extends java.lang.Enum {
method public static android.net.NetworkInfo.State valueOf(java.lang.String);
method public static final android.net.NetworkInfo.State[] values();
enum_constant public static final android.net.NetworkInfo.State CONNECTED;
diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java
index 47145874490f..49c3dc63e151 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 1a1d2d33424c..89d99617dfbf 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.
* <p>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 {
* <tr><td><code>FAILED</code></td><td><code>DISCONNECTED</code></td></tr>
* <tr><td><code>BLOCKED</code></td><td><code>DISCONNECTED</code></td></tr>
* </table>
+ *
+ * @deprecated See {@link NetworkInfo}.
*/
+ @Deprecated
public enum State {
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
* is probably of interest to few applications. Most should use
* {@link android.net.NetworkInfo.State State} instead.
+ *
+ * @deprecated See {@link NetworkInfo}.
*/
+ @Deprecated
public enum DetailedState {
/** Ready to start data connection setup. */
IDLE,
@@ -463,8 +482,10 @@ public class NetworkInfo implements Parcelable {
* Set the extraInfo field.
* @param extraInfo an optional {@code String} providing addditional network state
* information passed up from the lower networking layers.
+ * @deprecated See {@link NetworkInfo#getExtraInfo}.
* @hide
*/
+ @Deprecated
public void setExtraInfo(String extraInfo) {
synchronized (this) {
this.mExtraInfo = extraInfo;
@@ -488,7 +509,10 @@ public class NetworkInfo implements Parcelable {
* Report the extra information about the network state, if any was
* provided by the lower networking layers.
* @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() {
synchronized (this) {
return mExtraInfo;