From 517c2e319de557f72abc113e3c7e18ca615d585c Mon Sep 17 00:00:00 2001 From: Patrick Rohr Date: Tue, 26 Nov 2024 10:35:39 -0800 Subject: [PATCH] Adds a new RESERVATION request type RESERVATION requests allow supporting networks which require a two step configuration mechanism, such as IP over L2cap networks. In the case of IP over L2cap, the NetworkProvider must first create a BluetoothServerSocket to generate a PSM. That PSM must then be communicated back to the app to be included in a BluetoothAdvertisement before the network can be established. Using a RESERVATION request eliminates the need for the side-channel APIs that have historically been used to solve this problem. RESERVATION requests are handled by "blanket" NetworkOffers which generate a NetworkOffer specific to the rservation in response. The requests includes a reservationId (copied from the requestId) in its NetworkCapabilities which is considered in matching. Test: TH Change-Id: I3665d843fc3fa6dd6a7223eb84d7cf2fdeeea0a1 --- framework/src/android/net/NetworkRequest.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/framework/src/android/net/NetworkRequest.java b/framework/src/android/net/NetworkRequest.java index 89572b3e7a..4cc3c613cb 100644 --- a/framework/src/android/net/NetworkRequest.java +++ b/framework/src/android/net/NetworkRequest.java @@ -193,6 +193,16 @@ public class NetworkRequest implements Parcelable { * callbacks about the single, highest scoring current network * (if any) that matches the specified NetworkCapabilities, or * + * - RESERVATION requests behave identically to those of type REQUEST. + * For example, unlike LISTEN, they cause networks to remain + * connected, and they match exactly one network (the best one). + * A RESERVATION generates a unique reservationId in its + * NetworkCapabilities by copying the requestId which affects + * matching. A NetworkProvider can register a "blanket" NetworkOffer + * with reservationId = MATCH_ALL_RESERVATIONS to indicate that it + * is capable of generating NetworkOffers in response to RESERVATION + * requests. + * * - TRACK_DEFAULT, which causes the framework to issue callbacks for * the single, highest scoring current network (if any) that will * be chosen for an app, but which cannot cause the framework to @@ -229,6 +239,7 @@ public class NetworkRequest implements Parcelable { BACKGROUND_REQUEST, TRACK_SYSTEM_DEFAULT, LISTEN_FOR_BEST, + RESERVATION, }; /** @@ -703,7 +714,7 @@ public class NetworkRequest implements Parcelable { * @hide */ public boolean isRequest() { - return type == Type.REQUEST || type == Type.BACKGROUND_REQUEST; + return type == Type.REQUEST || type == Type.BACKGROUND_REQUEST || type == Type.RESERVATION; } /**