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

Commit 55707d98 authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Chalard Jean
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.

Clean cherry-pick of ag/3813257

Test: atest android.net.cts.NetworkRequestTest
Bug: 74945408
Change-Id: Ib28de279efb8b33ab46aa64f580e10fe5f8720e3
Merged-In: I0d090ebb7d57689a061badcf593ae9a37d88f7ce
Merged-In: I539184f7385c1f288cfb77be8307e4463e07e9e6
parent e19b33e0
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -26057,6 +26057,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;
@@ -426,6 +428,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 : "") +