Class DataTransport
- java.lang.Object
-
- com.android.identity.DataTransport
-
- Direct Known Subclasses:
DataTransportHttp
,DataTransportNfc
public abstract class DataTransport extends java.lang.Object
Abstraction for data transfer between prover and verifier devices.The data transfer is packetized, that is, data is delivered at the same granularity as it is sent. For example, if
sendMessage(byte[])
is used to sendN
bytes then this blob is what the remote peer will receive in theDataTransport.Listener.onMessageReceived()
callback.Instances constructed from subclasses deriving from this class must be inert when constructed, that is, they must not do anything. This constraint exists to easily facilitate factory-patterns.
If an unrecoverable error is detected, this is conveyed using the
DataTransport.Listener.onError(Throwable)
callback.This class can be used to implement both provers and verifiers.
-
-
Field Summary
Fields Modifier and Type Field Description protected android.content.Context
mContext
protected DataTransportOptions
mOptions
protected int
mRole
static int
ROLE_MDOC
static int
ROLE_MDOC_READER
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract ConnectionMethod
getConnectionMethod()
Returns aConnectionMethod
instance that can be used to connect to this transport.byte[]
getMessage()
Returns the next message received, if any.protected void
inhibitCallbacks()
protected void
reportConnected()
protected void
reportConnecting()
protected void
reportConnectionMethodReady()
protected void
reportDisconnected()
protected void
reportError(java.lang.Throwable error)
protected void
reportMessageProgress(long progress, long max)
protected void
reportMessageReceived(byte[] data)
protected void
reportTransportSpecificSessionTermination()
-
-
-
Field Detail
-
ROLE_MDOC
public static final int ROLE_MDOC
- See Also:
- Constant Field Values
-
ROLE_MDOC_READER
public static final int ROLE_MDOC_READER
- See Also:
- Constant Field Values
-
mContext
protected final android.content.Context mContext
-
mRole
protected final int mRole
-
mOptions
protected final DataTransportOptions mOptions
-
-
Method Detail
-
getMessage
@Nullable public byte[] getMessage()
Returns the next message received, if any.- Returns:
- the next message or
null
if none is available.
-
inhibitCallbacks
protected void inhibitCallbacks()
-
reportConnectionMethodReady
protected void reportConnectionMethodReady()
-
reportConnecting
protected void reportConnecting()
-
reportConnected
protected void reportConnected()
-
reportDisconnected
protected void reportDisconnected()
-
reportMessageReceived
protected void reportMessageReceived(@NonNull byte[] data)
-
reportMessageProgress
protected void reportMessageProgress(long progress, long max)
-
reportTransportSpecificSessionTermination
protected void reportTransportSpecificSessionTermination()
-
reportError
protected void reportError(@NonNull java.lang.Throwable error)
-
getConnectionMethod
@NonNull public abstract ConnectionMethod getConnectionMethod()
Returns aConnectionMethod
instance that can be used to connect to this transport.This is used for listening transports where the address to listen on is not known until the connection has been set up for example if dynamic TCP port assignments are used or cloud relays.
For most data transports this will return the same
ConnectionMethod
instance that was passed at construction time. However for some transports where the address to listen on is not known until the connection have been set up (for example dynamic TCP listening port assignments or when a cloud relay is in use) it will differ.This cannot be called until the
DataTransport.Listener.onConnectionMethodReady()
callback has been fired.- Returns:
- A
ConnectionMethod
-derived instance.
-
-