Enable QUIC connection close by default in ConnectivityService

This feature will be controlled by the caller.
Cronet calls the register/unregisterQuicConnectionClosePayload APIs only
when the Chromium experiment flag is enabled
(http://crrev.com/c/6421621/).

This CL also updates testRegisterQuicConnectionClosePayload
to be skipped on U or older releases since FIREWALL_CHAIN_BACKGROUND is
supported on V or higher releases.

Flag: EXEMPT guarded by chromium flag
Bug: 311792075
Test: TH
Change-Id: Ib008e63c585cfe8775b25783cd55b0873bb5e2f0
This commit is contained in:
Motomu Utsumi 2025-04-25 14:56:11 +09:00
commit 2ea5939672
3 changed files with 11 additions and 4 deletions

View file

@ -2157,7 +2157,10 @@ public class ConnectivityService extends IConnectivityManager.Stub {
mL2capNetworkProvider = mDeps.makeL2capNetworkProvider(mContext);
mCloseQuicConnection = mDeps.isFeatureEnabled(context, CLOSE_QUIC_CONNECTION);
// QUIC connection close is triggered by freezer (U+) or background firewall chain (V+).
// TODO: Allow other firewall chains to close QUIC connection and enable this flag on T+
mCloseQuicConnection = mDeps.isAtLeastU()
&& mDeps.isFeatureNotChickenedOut(context, CLOSE_QUIC_CONNECTION);
if (mCloseQuicConnection) {
mQuicConnectionCloser = mDeps.makeQuicConnectionCloser(mNetworkForNetId, mHandler);
} else {

View file

@ -4358,8 +4358,11 @@ public class ConnectivityManagerTest {
});
}
// This test is skipped on U and older releases because QUIC connection close can be triggered
// by the freezer (U+) or the background firewall chain (V+), but the freezer cannot be tested.
// TODO: Enable this test on T+ once other firewall chains can trigger QUIC connection close.
@Test
@IgnoreUpTo(Build.VERSION_CODES.R)
@IgnoreUpTo(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
@ConnectivityModuleTest
@AppModeFull(reason = "Cannot create test network in instant app mode")
public void testRegisterQuicConnectionClosePayload_blockNetwork() throws Exception {
@ -4384,8 +4387,9 @@ public class ConnectivityManagerTest {
true /* blockNetwork */, false /* expectPacketSent */);
}
// TODO: Enable this test on T+ once other firewall chains can trigger QUIC connection close.
@Test
@IgnoreUpTo(Build.VERSION_CODES.R)
@IgnoreUpTo(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
@ConnectivityModuleTest
@AppModeFull(reason = "Cannot create test network in instant app mode")
public void testRegisterQuicConnectionClosePayload_closeSocket() throws Exception {

View file

@ -2188,7 +2188,6 @@ public class ConnectivityServiceTest {
case ConnectivityFlags.USE_DECLARED_METHODS_FOR_CALLBACKS:
case ConnectivityFlags.QUEUE_CALLBACKS_FOR_FROZEN_APPS:
case ConnectivityFlags.BACKGROUND_FIREWALL_CHAIN:
case ConnectivityFlags.CLOSE_QUIC_CONNECTION:
case ConnectivityService.KEY_DESTROY_FROZEN_SOCKETS_VERSION:
return true;
default:
@ -2209,6 +2208,7 @@ public class ConnectivityServiceTest {
case ConnectivityFlags.USE_DECLARED_METHODS_FOR_CALLBACKS:
case ConnectivityFlags.QUEUE_CALLBACKS_FOR_FROZEN_APPS:
case ConnectivityFlags.QUEUE_NETWORK_AGENT_EVENTS_IN_SYSTEM_SERVER:
case ConnectivityFlags.CLOSE_QUIC_CONNECTION:
return true;
default:
throw new UnsupportedOperationException("Unknown flag " + name