Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9dbdb7a0 authored by Aaron Huang's avatar Aaron Huang Committed by Gerrit Code Review
Browse files

Merge "Update NetworkInfo public API."

parents 97cc9b62 48413166
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -29201,6 +29201,7 @@ package android.net {
  }
  }
  @Deprecated public class NetworkInfo implements android.os.Parcelable {
  @Deprecated public class NetworkInfo implements android.os.Parcelable {
    ctor @Deprecated public NetworkInfo(int, int, @Nullable String, @Nullable String);
    method @Deprecated public int describeContents();
    method @Deprecated public int describeContents();
    method @Deprecated @NonNull public android.net.NetworkInfo.DetailedState getDetailedState();
    method @Deprecated @NonNull public android.net.NetworkInfo.DetailedState getDetailedState();
    method @Deprecated public String getExtraInfo();
    method @Deprecated public String getExtraInfo();
@@ -29215,6 +29216,7 @@ package android.net {
    method @Deprecated public boolean isConnectedOrConnecting();
    method @Deprecated public boolean isConnectedOrConnecting();
    method @Deprecated public boolean isFailover();
    method @Deprecated public boolean isFailover();
    method @Deprecated public boolean isRoaming();
    method @Deprecated public boolean isRoaming();
    method @Deprecated public void setDetailedState(@NonNull android.net.NetworkInfo.DetailedState, @Nullable String, @Nullable String);
    method @Deprecated public void writeToParcel(android.os.Parcel, int);
    method @Deprecated public void writeToParcel(android.os.Parcel, int);
    field @Deprecated @NonNull public static final android.os.Parcelable.Creator<android.net.NetworkInfo> CREATOR;
    field @Deprecated @NonNull public static final android.os.Parcelable.Creator<android.net.NetworkInfo> CREATOR;
  }
  }
+19 −6
Original line number Original line Diff line number Diff line
@@ -17,9 +17,11 @@
package android.net;
package android.net;


import android.annotation.NonNull;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.compat.annotation.UnsupportedAppUsage;
import android.compat.annotation.UnsupportedAppUsage;
import android.os.Parcel;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable;
import android.telephony.Annotation.NetworkType;


import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.annotations.VisibleForTesting;


@@ -150,10 +152,19 @@ public class NetworkInfo implements Parcelable {
    private boolean mIsRoaming;
    private boolean mIsRoaming;


    /**
    /**
     * @hide
     * Create a new instance of NetworkInfo.
     *
     * This may be useful for apps to write unit tests.
     *
     * @param type the legacy type of the network, as one of the ConnectivityManager.TYPE_*
     *             constants.
     * @param subtype the subtype if applicable, as one of the TelephonyManager.NETWORK_TYPE_*
     *                constants.
     * @param typeName a human-readable string for the network type, or an empty string or null.
     * @param subtypeName a human-readable string for the subtype, or an empty string or null.
     */
     */
    @UnsupportedAppUsage
    public NetworkInfo(int type, @NetworkType int subtype,
    public NetworkInfo(int type, int subtype, String typeName, String subtypeName) {
            @Nullable String typeName, @Nullable String subtypeName) {
        if (!ConnectivityManager.isNetworkTypeValid(type)
        if (!ConnectivityManager.isNetworkTypeValid(type)
                && type != ConnectivityManager.TYPE_NONE) {
                && type != ConnectivityManager.TYPE_NONE) {
            throw new IllegalArgumentException("Invalid network type: " + type);
            throw new IllegalArgumentException("Invalid network type: " + type);
@@ -462,17 +473,19 @@ public class NetworkInfo implements Parcelable {


    /**
    /**
     * Sets the fine-grained state of the network.
     * Sets the fine-grained state of the network.
     *
     * This is only useful for testing.
     *
     * @param detailedState the {@link DetailedState}.
     * @param detailedState the {@link DetailedState}.
     * @param reason a {@code String} indicating the reason for the state change,
     * @param reason a {@code String} indicating the reason for the state change,
     * if one was supplied. May be {@code null}.
     * if one was supplied. May be {@code null}.
     * @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 Use {@link NetworkCapabilities} instead.
     * @deprecated Use {@link NetworkCapabilities} instead.
     * @hide
     */
     */
    @Deprecated
    @Deprecated
    @UnsupportedAppUsage
    public void setDetailedState(@NonNull DetailedState detailedState, @Nullable String reason,
    public void setDetailedState(DetailedState detailedState, String reason, String extraInfo) {
            @Nullable String extraInfo) {
        synchronized (this) {
        synchronized (this) {
            this.mDetailedState = detailedState;
            this.mDetailedState = detailedState;
            this.mState = stateMap.get(detailedState);
            this.mState = stateMap.get(detailedState);