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

Commit d778da33 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

API council requested tweaks to NetworkRequest.

If you put values into the Builder, you should be able to observe
those values on the built object.

Test: atest android.net.cts.NetworkRequestTest
Bug: 74945408
Change-Id: I9aacceb82c98f7881f0eb5e1106d89d469b816a7
parent ff23ffa8
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -27185,6 +27185,8 @@ package android.net {
  public class NetworkRequest implements android.os.Parcelable {
    method public int describeContents();
    method public boolean hasCapability(int);
    method public boolean hasTransport(int);
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.net.NetworkRequest> CREATOR;
  }
+16 −0
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
package android.net;

import android.annotation.NonNull;
import android.net.NetworkCapabilities.NetCapability;
import android.net.NetworkCapabilities.Transport;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Process;
@@ -427,6 +429,20 @@ public class NetworkRequest implements Parcelable {
        return type == Type.BACKGROUND_REQUEST;
    }

    /**
     * @see Builder#addCapability(int)
     */
    public boolean hasCapability(@NetCapability int capability) {
        return networkCapabilities.hasCapability(capability);
    }

    /**
     * @see Builder#addTransportType(int)
     */
    public boolean hasTransport(@Transport int transportType) {
        return networkCapabilities.hasTransport(transportType);
    }

    public String toString() {
        return "NetworkRequest [ " + type + " id=" + requestId +
                (legacyType != ConnectivityManager.TYPE_NONE ? ", legacyType=" + legacyType : "") +