Mark blanket offer as transport primary
This is done to ensure the blanket offer is always needed. Marking it as
primary should ensure it always outranks the server network created by
the reserved offer. If the blanket offer receives an onNetworkUnneeded,
the associated reservation is torn down.
Test: TH
Change-Id: I324345884fcf805a06e3251fc51b0ea9ea52b3b7
diff --git a/service/src/com/android/server/L2capNetworkProvider.java b/service/src/com/android/server/L2capNetworkProvider.java
index 3866cef..15c860b 100644
--- a/service/src/com/android/server/L2capNetworkProvider.java
+++ b/service/src/com/android/server/L2capNetworkProvider.java
@@ -104,10 +104,12 @@
* requests that do not have a NetworkSpecifier set.
*/
private class BlanketReservationOffer implements NetworkOfferCallback {
- // TODO: ensure that once the incoming request is satisfied, the blanket offer does not get
- // unneeded. This means the blanket offer must always outscore the reserved offer. This
- // might require setting the blanket offer as setTransportPrimary().
- public static final NetworkScore SCORE = new NetworkScore.Builder().build();
+ // Set as transport primary to ensure that the BlanketReservationOffer always outscores the
+ // ReservedServerOffer, because as soon as the BlanketReservationOffer receives an
+ // onNetworkUnneeded() callback, it will tear down the associated reserved offer.
+ public static final NetworkScore SCORE = new NetworkScore.Builder()
+ .setTransportPrimary(true)
+ .build();
// Note the missing NET_CAPABILITY_NOT_RESTRICTED marking the network as restricted.
public static final NetworkCapabilities CAPABILITIES;
static {