@@ -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.
@@ -193,7 +186,8 @@ private void preAuthorize(ServiceInfo serviceInfo) {
193186 // unauthorized server a chance to run, but the connection will still fail by SecurityPolicy
194187 // check later in handshake. Pre-auth remains effective at mitigating abuse because malware
195188 // can't typically control the exact timing of its installation.
196- preAuthResultFuture = checkServerAuthorizationAsync (serviceInfo .applicationInfo .uid );
189+ ListenableFuture <Status > preAuthResultFuture =
190+ register (checkServerAuthorizationAsync (serviceInfo .applicationInfo .uid ));
197191 Futures .addCallback (
198192 preAuthResultFuture ,
199193 new FutureCallback <Status >() {
@@ -314,12 +308,6 @@ void notifyTerminated() {
314308 readyTimeoutFuture .cancel (false );
315309 readyTimeoutFuture = null ;
316310 }
317- if (preAuthResultFuture != null ) {
318- preAuthResultFuture .cancel (false ); // No effect if already complete.
319- }
320- if (authResultFuture != null ) {
321- authResultFuture .cancel (false ); // No effect if already complete.
322- }
323311 serviceBinding .unbind ();
324312 clientTransportListener .transportTerminated ();
325313 }
@@ -339,7 +327,8 @@ protected void handleSetupTransport(Parcel parcel) {
339327 } else {
340328 restrictIncomingBinderToCallsFrom (remoteUid );
341329 attributes = setSecurityAttrs (attributes , remoteUid );
342- authResultFuture = checkServerAuthorizationAsync (remoteUid );
330+ ListenableFuture <Status > authResultFuture =
331+ register (checkServerAuthorizationAsync (remoteUid ));
343332 Futures .addCallback (
344333 authResultFuture ,
345334 new FutureCallback <Status >() {
@@ -398,6 +387,7 @@ protected void handlePingResponse(Parcel parcel) {
398387 pingTracker .onPingResponse (parcel .readInt ());
399388 }
400389
390+
401391 private static ClientStream newFailingClientStream (
402392 Status failure , Attributes attributes , Metadata headers , ClientStreamTracer [] tracers ) {
403393 StatsTraceContext statsTraceContext =
0 commit comments