Class TransferManager
-
- All Implemented Interfaces:
-
com.scytales.mvalid.sdk.engagement.DeviceEngagementCapable
,com.scytales.mvalid.sdk.retrieval.TerminableTransfer
,com.scytales.mvalid.sdk.retrieval.Transfer
,com.scytales.mvalid.sdk.retrieval.TransferProgressListenable
,com.scytales.mvalid.sdk.retrieval.TransferReceiveDependent
public final class TransferManager implements Transfer<D>, TransferReceiveDependent, TransferProgressListenable, DeviceEngagementCapable, TerminableTransfer
A Singleton Transfer implementation which is configured to support all available Transfer implementations (com.example.demo.api.retrieval.device.BLETransfer, com.example.demo.api.retrieval.device.NFCTransfer, com.example.demo.api.retrieval.server.WebAPITransfer)
For android SDK >= 31
- android.Manifest.permission.BLUETOOTH_ADVERTISE
- android.Manifest.permission.BLUETOOTH_SCAN
- android.Manifest.permission.BLUETOOTH_CONNECT
For android SDK <31
- android.Manifest.permission.ACCESS_FINE_LOCATION
- android.Manifest.permission.ACCESS_COARSE_LOCATION
public class SomeActivity extends
implements DeviceEngagementCallback, TransferReceiveCallback, TransferProgressListener { private static final String TAG = "SomeActivity"; private static final Config TM_CONFIG = new Config() .setTransferPriority(HANDOVER_QR, TRANSFER_BLE) .setTransferPriority(HANDOVER_NFC, HANDOVER_NFC); private Map<String, Map<String, Map<String, Boolean>>> docRequests = ... private TransferManager transferManager; private SessionManager sessionManager; @Override protected void onCreate(@NullableAppCompatActivity
savedInstanceState) { super.onCreate(savedInstanceState); try { transferManager = TransferManager.getInstance(this, TRANSFER_MANAGER_CONFIG); transferManager.setTransferReceiveCallback(this); transferManager.setProgressListener(this); transferManager.enableDeviceEngagement(this,this); } catch (SDKException e) { // handle exception } } @Override public void onEngage(@NonNull Received<EngagementReceived> engagementReceived) { engagementReceived.run( failure -> { android.util.Log.e(TAG, failure.toString()); }, success -> { DeviceEngagement deviceEngagement = success.getDeviceEngagement(); Handover handover = success.getHandover(); try { sessionManager = new SessionManager(deviceEngagement, handover); transferManager.forHandover(handover); transferManager.forDeviceEngagement(deviceEngagement); Request request = Request.create(docRequests, sessionManager); transferManager.send(request); } catch (SDKException e) {android.os.Bundle
.e(TAG, e.getMessage(), e); } }); } @Override public void onProgressEvent(@NonNull TransferProgressEvent event) {android.util.Log
.d(TAG, event.toString()); } @Override public void onReceive(@NonNull Received<TransferReceived> transferReceived) { transferReceived.run( failure -> {android.util.Log
.e(TAG, failure.toString()); }, success -> { success.runForDevice(receivedBytes -> { SessionData sessionData = sessionManager.decryptResponse(receivedBytes); // do stuff with decrypted }); success.runForServer(receivedBytes -> { // do stuff with receivedBytes }); } }android.util.Log
Config config = new Config() TransferManager transferManager = TransferManager.getInstance(context, config);
Configure when device engagement is done through QR to first try device transfer using ble and if it not available then try using webAPI.
Config config = new Config() config.setTransferPriority(HANDOVER_QR, TRANSFER_BLE, TRANSFER_WEB_API);
Configure to use BLE when device engagement is done with QR and use NFC transfer when device engagement is done with NFC.
Config config = new Config() config.setTransferPriority(HANDOVER_QR, TRANSFER_BLE); config.setTransferPriority(HANDOVER_NFC, TRANSFER_NFC);
Configure to use only webAPI, for both QR and NFC device engagement.
Config config = new Config() config.setTransferPriority(HANDOVER_QR, TRANSFER_WEB_API); config.setTransferPriority(HANDOVER_NFC, TRANSFER_WEB_API);
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final class
TransferManager.Config
The type Config.
-
Field Summary
Fields Modifier and Type Field Description public TransferManager.Config
config
public volatile SessionManager
sessionManager
-
Constructor Summary
Constructors Constructor Description TransferManager(Context context, TransferManager.Config config)
Instantiates a new Transfer manager.
-
Method Summary
-
-
Constructor Detail
-
TransferManager
TransferManager(Context context, TransferManager.Config config)
Instantiates a new Transfer manager.- Parameters:
context
- the contextconfig
- the config
-
-
Method Detail
-
getConfig
@Nullable() TransferManager.Config getConfig()
Gets config.
-
setConfig
TransferManager setConfig(@NonNull() TransferManager.Config config)
Sets config.
- Parameters:
config
- the config
-
getSessionManager
@Nullable() SessionManager getSessionManager()
Gets session manager.
-
unsetTransferProgressListener
@NonNull() TransferManager unsetTransferProgressListener()
Unset transfer progress listener transfer progress listenable.
-
enableDeviceEngagement
@NonNull()@MainThread() TransferManager enableDeviceEngagement(@NonNull() ComponentActivity activity, @NonNull() DeviceEngagementCallback callback)
Enables deviceEngagement detection.
- Parameters:
activity
- the activitycallback
- the callback
-
scanQR
void scanQR(QRDeviceEngagementContract.Options options)
Scan qr.
- Parameters:
options
- the options
-
scanQR
void scanQR()
Scan qr.
-
setNFCTimeout
TransferManager setNFCTimeout(int timeoutInMillis)
Sets nfc timeout.
- Parameters:
timeoutInMillis
- the timeout in millis
-
setWebAPIConnectionTimeout
TransferManager setWebAPIConnectionTimeout(int timeoutInMillis)
Sets web api connection timeout.
- Parameters:
timeoutInMillis
- the timeout in millis
-
setWebAPIReadTimeout
TransferManager setWebAPIReadTimeout(int timeoutInMillis)
Sets web api read timeout.
- Parameters:
timeoutInMillis
- the timeout in millis
-
sendTermination
void sendTermination()
Send termination.
-
setTransferReceiveCallback
@NonNull() TransferManager setTransferReceiveCallback(@NonNull() TransferReceiveCallback callback)
Sets transfer receive callback.
- Parameters:
callback
- the callback
-
setTransferProgressListener
@NonNull() TransferManager setTransferProgressListener(@NonNull() TransferProgressListener listener)
Sets transfer progress listener.
- Parameters:
listener
- the listener
-
setWebAPITrustAllCertificates
TransferManager setWebAPITrustAllCertificates(boolean trustStatus)
-
-
-
-