Class DataTransport
- java.lang.Object
-
- com.android.identity.DataTransport
-
- Direct Known Subclasses:
DataTransportHttp,DataTransportNfc
public abstract class DataTransport extends java.lang.ObjectAbstraction 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 sendNbytes 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.ContextmContextprotected DataTransportOptionsmOptionsprotected intmRolestatic intROLE_MDOCstatic intROLE_MDOC_READER
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract ConnectionMethodgetConnectionMethod()Returns aConnectionMethodinstance that can be used to connect to this transport.byte[]getMessage()Returns the next message received, if any.protected voidinhibitCallbacks()protected voidreportConnected()protected voidreportConnecting()protected voidreportConnectionMethodReady()protected voidreportDisconnected()protected voidreportError(java.lang.Throwable error)protected voidreportMessageProgress(long progress, long max)protected voidreportMessageReceived(byte[] data)protected voidreportTransportSpecificSessionTermination()
-
-
-
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
nullif 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 aConnectionMethodinstance 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
ConnectionMethodinstance 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.
-
-