-
- All Implemented Interfaces:
-
android.os.IBinder.DeathRecipient,io.grpc.binder.internal.LeakSafeOneWayBinder.TransactionHandler
@ThreadSafe() public abstract class BinderTransport implements LeakSafeOneWayBinder.TransactionHandler, IBinder.DeathRecipient
Base class for binder-based gRPC transport.
This is used on both the client and service sides of the transport.
A note on synchronization. The nature of this class's interaction with each stream (bi-directional communication between gRPC calls and binder transactions) means that acquiring multiple locks in two different orders can happen easily. E.g. binder transactions will arrive in this class, and need to passed to a stream instance, whereas gRPC calls on a stream instance will need to call into this class to send a transaction (possibly waiting for the transport to become ready).
The split between Outbound & Inbound helps reduce this risk, but not entirely remove it.
For this reason, while most state within this class is guarded by this instance, methods exposed to individual stream instances need to use atomic or volatile types, since those calls will already be synchronized on the individual RPC objects.
IMPORTANT: This implementation must comply with this published wire format. https://github.com/grpc/proposal/blob/master/L73-java-binderchannel/wireformat.md
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classBinderTransport.BinderClientTransportConcrete client-side transport implementation.
public final classBinderTransport.BinderServerTransportConcrete server-side transport implementation.
-
Field Summary
Fields Modifier and Type Field Description public final static Attributes.Key<Integer>REMOTE_UIDpublic final static Attributes.Key<String>SERVER_AUTHORITYpublic final static Attributes.Key<InboundParcelablePolicy>INBOUND_PARCELABLE_POLICYpublic final static intWIRE_FORMAT_VERSIONpublic final static intEARLIEST_SUPPORTED_WIRE_FORMAT_VERSIONpublic final static intSETUP_TRANSPORTpublic final static intSHUTDOWN_TRANSPORTprivate final ScheduledExecutorServicescheduledExecutorServiceprivate final InternalLogIdlogIdprotected Attributesattributes
-
Method Summary
Modifier and Type Method Description final ScheduledExecutorServicegetScheduledExecutorService()final InternalLogIdgetLogId()final synchronized AttributesgetAttributes()final ListenableFuture<InternalChannelz.SocketStats>getStats()synchronized voidbinderDied()final booleanhandleTransaction(int code, Parcel parcel)-
Methods inherited from class io.grpc.binder.internal.LeakSafeOneWayBinder.TransactionHandler
handleTransaction -
Methods inherited from class android.os.IBinder.DeathRecipient
binderDied -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
getScheduledExecutorService
final ScheduledExecutorService getScheduledExecutorService()
-
getLogId
final InternalLogId getLogId()
-
getAttributes
final synchronized Attributes getAttributes()
-
getStats
final ListenableFuture<InternalChannelz.SocketStats> getStats()
-
binderDied
synchronized void binderDied()
-
handleTransaction
final boolean handleTransaction(int code, Parcel parcel)
-
-
-
-