@@ -87,13 +87,6 @@ public final class BinderClientTransport extends BinderTransport
8787 @ GuardedBy ("this" )
8888 private ScheduledFuture <?> readyTimeoutFuture ; // != null iff timeout scheduled.
8989
90- @ GuardedBy ("this" )
91- @ Nullable
92- private ListenableFuture <Status > authResultFuture ; // null before we check auth.
93-
94- @ GuardedBy ("this" )
95- @ Nullable
96- private ListenableFuture <Status > preAuthResultFuture ; // null before we pre-auth.
9790
9891 /**
9992 * Constructs a new transport instance.
@@ -195,7 +188,8 @@ private void preAuthorize(ServiceInfo serviceInfo) {
195188 // unauthorized server a chance to run, but the connection will still fail by SecurityPolicy
196189 // check later in handshake. Pre-auth remains effective at mitigating abuse because malware
197190 // can't typically control the exact timing of its installation.
198- preAuthResultFuture = checkServerAuthorizationAsync (serviceInfo .applicationInfo .uid );
191+ ListenableFuture <Status > preAuthResultFuture =
192+ register (checkServerAuthorizationAsync (serviceInfo .applicationInfo .uid ));
199193 Futures .addCallback (
200194 preAuthResultFuture ,
201195 new FutureCallback <Status >() {
@@ -316,9 +310,6 @@ void notifyTerminated() {
316310 readyTimeoutFuture .cancel (false );
317311 readyTimeoutFuture = null ;
318312 }
319- cancelAsyncIfNeeded (preAuthResultFuture );
320- cancelAsyncIfNeeded (authResultFuture );
321-
322313 serviceBinding .unbind ();
323314 clientTransportListener .transportTerminated ();
324315 }
@@ -337,7 +328,8 @@ protected void handleSetupTransport(Parcel parcel) {
337328 shutdownInternal (
338329 Status .UNAVAILABLE .withDescription ("Malformed SETUP_TRANSPORT data" ), true );
339330 } else {
340- authResultFuture = checkServerAuthorizationAsync (remoteUid );
331+ ListenableFuture <Status > authResultFuture =
332+ register (checkServerAuthorizationAsync (remoteUid ));
341333 Futures .addCallback (
342334 authResultFuture ,
343335 new FutureCallback <Status >() {
@@ -396,16 +388,6 @@ protected void handlePingResponse(Parcel parcel) {
396388 pingTracker .onPingResponse (parcel .readInt ());
397389 }
398390
399- /**
400- * Enqueues a future for cancellation later, on another thread.
401- * Useful when the caller wants to cancel while holding locks but the future is visible to
402- * user code which might have added listeners to run on directExecutor().
403- */
404- private void cancelAsyncIfNeeded (@ Nullable ListenableFuture <?> future ) {
405- if (future != null && !future .isDone ()) {
406- offloadExecutor .execute (() -> future .cancel (false ));
407- }
408- }
409391
410392 private static ClientStream newFailingClientStream (
411393 Status failure , Attributes attributes , Metadata headers , ClientStreamTracer [] tracers ) {
0 commit comments