@ThreadSafe public abstract class BinderTransport extends java.lang.Object implements LeakSafeOneWayBinder.TransactionHandler, android.os.IBinder.DeathRecipient
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
| Modifier and Type | Class and Description |
|---|---|
static class |
BinderTransport.BinderClientTransport
Concrete client-side transport implementation.
|
static class |
BinderTransport.BinderServerTransport
Concrete server-side transport implementation.
|
protected static class |
BinderTransport.TransportState
The states of this transport.
|
| Modifier and Type | Field and Description |
|---|---|
protected io.grpc.Attributes |
attributes |
static int |
EARLIEST_SUPPORTED_WIRE_FORMAT_VERSION
The version code of the earliest wire format we support.
|
static io.grpc.Attributes.Key<InboundParcelablePolicy> |
INBOUND_PARCELABLE_POLICY
A transport attribute to hold the
InboundParcelablePolicy. |
protected java.util.concurrent.ConcurrentHashMap<java.lang.Integer,io.grpc.binder.internal.Inbound<?>> |
ongoingCalls |
static io.grpc.Attributes.Key<java.lang.Integer> |
REMOTE_UID
Attribute used to store the Android UID of the remote app.
|
static io.grpc.Attributes.Key<java.lang.String> |
SERVER_AUTHORITY
The authority of the server.
|
static int |
SETUP_TRANSPORT
Sent from the client to host service binder to initiate a new transport, and from the host to
the binder.
|
static int |
SHUTDOWN_TRANSPORT
Send to shutdown the transport from either end.
|
protected io.grpc.Status |
shutdownStatus |
static int |
WIRE_FORMAT_VERSION
Version code for this wire format.
|
| Modifier and Type | Method and Description |
|---|---|
void |
binderDied() |
protected io.grpc.binder.internal.Inbound<?> |
createInbound(int callId) |
io.grpc.Attributes |
getAttributes() |
io.grpc.InternalLogId |
getLogId() |
java.util.concurrent.ScheduledExecutorService |
getScheduledExecutorService() |
com.google.common.util.concurrent.ListenableFuture<io.grpc.InternalChannelz.SocketStats> |
getStats() |
protected void |
handlePingResponse(android.os.Parcel parcel) |
protected void |
handleSetupTransport(android.os.Parcel parcel) |
boolean |
handleTransaction(int code,
android.os.Parcel parcel) |
protected void |
sendPing(int id) |
protected boolean |
setOutgoingBinder(OneWayBinderProxy binder) |
protected void |
unregisterInbound(io.grpc.binder.internal.Inbound<?> inbound) |
@Internal public static final io.grpc.Attributes.Key<java.lang.Integer> REMOTE_UID
@Internal public static final io.grpc.Attributes.Key<java.lang.String> SERVER_AUTHORITY
@Internal public static final io.grpc.Attributes.Key<InboundParcelablePolicy> INBOUND_PARCELABLE_POLICY
InboundParcelablePolicy.@Internal public static final int WIRE_FORMAT_VERSION
Should this change, we should still endeavor to support earlier wire-format versions. If
that's not possible, EARLIEST_SUPPORTED_WIRE_FORMAT_VERSION should be updated below.
@Internal public static final int EARLIEST_SUPPORTED_WIRE_FORMAT_VERSION
@Internal public static final int SETUP_TRANSPORT
@Internal public static final int SHUTDOWN_TRANSPORT
protected final java.util.concurrent.ConcurrentHashMap<java.lang.Integer,io.grpc.binder.internal.Inbound<?>> ongoingCalls
protected io.grpc.Attributes attributes
@Nullable protected io.grpc.Status shutdownStatus
public final java.util.concurrent.ScheduledExecutorService getScheduledExecutorService()
public final com.google.common.util.concurrent.ListenableFuture<io.grpc.InternalChannelz.SocketStats> getStats()
public final io.grpc.InternalLogId getLogId()
public final io.grpc.Attributes getAttributes()
protected boolean setOutgoingBinder(OneWayBinderProxy binder)
public void binderDied()
binderDied in interface android.os.IBinder.DeathRecipientprotected void sendPing(int id)
throws io.grpc.StatusException
io.grpc.StatusExceptionprotected void unregisterInbound(io.grpc.binder.internal.Inbound<?> inbound)
public final boolean handleTransaction(int code,
android.os.Parcel parcel)
handleTransaction in interface LeakSafeOneWayBinder.TransactionHandler@Nullable protected io.grpc.binder.internal.Inbound<?> createInbound(int callId)
protected void handleSetupTransport(android.os.Parcel parcel)
protected void handlePingResponse(android.os.Parcel parcel)