Class BitwardsService
Bitwards SDK for Android
Introduction
The BitwardsService class is the main class of Bitwards SDK through which the main function SDK are used. The main functions of Bitwards SDK are:
- initialization of SDK and login/logout of end user
- synchronization of SDK data
- scanning for Bluetooth Low Energy (BLE) based resources
- accessing resources, both BLE and NFC based resources
- getting list of known resources to the end user, and user profile data
In the following chapters we discuss these main functions in more detail.
Most of the operations offered by Bitwards SDK are asynchronous, i.e., an operation is triggered by a method and results of the operation are provided back with a callback functions. It is recommended, that all the Bitwards SDK methods are called using the main thread (UI thread) of the application. All callbacks are executed in the main thread.
NOTE: All documentation assumes that the developer is familiar with Android development.
Bitwards SDK setup
The instructions how to setup an Android Studio project to use Bitwards SDK can be found here: Bitwards SDK setup.
Initialize SDK and login end user
Bitwards SDK is intialized by obtaining a BitwardsService instance. BitwardsService instance is a singleton, i.e., the BitwardsService instance is always returned by this method.
IMPORTANT: Before attempting to initialize BitwardsService instance, the following must be checked:
- Application running on a device with Android 11 or older (Android SDK 30 or lower) must have ACCESS_FINE_LOCATION and the permission must be requested from the end user during run time. To setup the application with location permissions, please refer to Request location permissions documentation for details.
- Application running on a device with Android 12 or newer (Android SDK 31 or higher) must have BLUETOOTH_SCAN and BLUETOOTH_CONNECT, and the permission must be requested from the end user during run time. To setup the application with Bluetooth permissions, please refer to Bluetooth permissions documentation for details.
If the end user has not granted ACCESS_FINE_LOCATION permission in Android SDK version 30 or lower or BLUETOOTH_SCAN and BLUETOOTH_CONNECT permissions in Android SDK version 31 or higher, calling BitwardsService.getInstance(..) will throw a BitwardsException. Application must check if these permission have been granted by the end user and if not, request end user to grant them. It is recommended that application always checks these permissions during application startup as newer versions of Android may remove permissions from applications if they haven't been used for awhile.
Note: The requirement that device lock must be enabled in the device has been removed from the Bitwards SDK.
String license = "contains license that is obtained from Bitwards (currently not used)";
// Get BitwardsService instance which is singleton:
BitwardsService bws = BitwardsService.getInstance(context.getApplicationContext(),license);
BitwardsService instance cannot really be used for anything until and an end user is logged in with the BitwardsService instance. This can be done either by loggging in with a username and password, or an OAuth2 authentication token, if configuration allows it.
// Create credential with username and password (if username/password is used)
BitwardsCredential passwordCredential = new BitwardsCredential.Builder(BitwardsCredential.TYPE_USERNAME_PASSWORD)
.setUsername(USERNAME)
.setPassword(PASSWORD)
.build();
// Create credential with OAuth2 (if OAuth2 token is used)
BitwardsCredential oauth2Credential = new BitwardsCredential.Builder(BitwardsCredential.TYPE_OAUTH2_AUTH_TOKEN)
.setAuthenticationToken(AUTH_TOKEN)
.setAuthenticationDomain(AUTH_DOMAIN)
.build();
// Login with credential (this time OAuth2)
bws.login(oauth2Credential, new BitwardsService.ResultCallback() {
@Override
public void onSuccess() {
// Login was successful
}
@Override
public void onError(int errorCode) {
// Login failed
}
});
Setup callback for NFC based resources
Bitwards SDK can access resources via NFC. The opening over NFC will happen automatically, but if the application wants to receive a notifications for these events, it must setup the NFCResourceCallback.
// Setup callback for NFC based resources
bws.setNFCResourceCallback(new BitwardsService.NFCResourceCallback() {
@Override
public void onAccessGranted(BitwardsResource resource) {
// Access to a NFC based resource was granted
}
@Override
public void onAccessDenied(BitwardsResource resource, int reasonCode) {
// Access to a NFC based resource was denied
}
@Override
public void onError(BitwardsResource resource, int errorCode) {
// An error occurred when accessing a NFC based resoruce
}
});
Synchronize with backend server
Bitwards SDK must be synchronized periodically with the backend server to have all the data up to date. The SDK does synchronize automatically every 8 hours, but if the application wants to make sure that the data (e.g., known resource list) is refreshed, do synchronization.
// Synchronize Bitwards SDK's database with the backend server
bws.synchronize(new BitwardsService.ResultCallback() {
@Override
public void onSuccess() {
// Synchronization with the backend server was successful
}
@Override
public void onError(int errorCode) {
// Synchronization failed
}
});
Get known resource list
The known resource list is the list of resources that the end user either has access currently, or will have access in the future. The BitwardsResource instance can be used with accessResource(..) method to access the resource (e.g., open the resource).
// Obtain the known resource list
List<BitwardsResource> list = bws.getBitwardsResourceList();
Register/unregister for discovering resources nearby
The background scan can be used to discover nearby Bluetooth based resources (i.e., BLE resources). When a BackgroundScanCallback instance is registered with the Bitwards SDK, the given methods is used to indicate a resource nearby or that a resource has been lost (i.e., is not nearby anymore). The onResourceFound(..) callback is called approximately once a second per resource when it is nearby (i.e., the device where the application is running is able to Bluetooth advertisement messages from the resource).
// Instantiate BackgroundScanCallback instance
BitwardsService.BackgroundScanCallback callback = new BitwardsService.BackgroundScanCallback() {
@Override
public void onResourceFound(BitwardsResource resource) {
// a resource was found, is called multiple times; about once a second per nearby resource
// For instance, to obtain the Bluetooth signal strength (RSSI):
int rssi = resource.getRSSI();
// rssi value is typically between -30 to -99, where
// -30 means signal is strong (resource is relatively close), and
// -70 means signal is weak (resource is quite far away).
}
@Override
public void onResourceLost(BitwardsResource resource) {
// a previously found resource is not any more nearby
}
@Override
public void onError(int errorCode) {
// an error occurred during background scan; scan is stopped
}
};
// Register callback with BitwardsService for background scan callbacks
bws.registerBackgroundScanCallback(callback);
// Unregister callback when you are done with background scan callbacks
bws.unregisterBackgroundScanCallback(callback);
Access a resource
To access a resource (e.g., opening it) is executed with call to accessResource(..) method. Best practise is that the application first discovers nearby resources with the background scan callback, and then populates a list of available resources in the application UI. The end user then taps one of the available resources, which triggers calling of the accessResource(..) method with the indicates BitwardsResource instance.
// Accessing (e.g., opening) a particular resource
bws.accessResource(resource, new BitwardsService.BLEResourceCallback() {
@Override
public void onSelectResource(List<BitwardsResource> resources, BitwardsService.SelectResourceCallback callback) {
// In this case (i.e., resource was already indicated in the method call),
// this is not gonna be called because we are accessing directly the particular resource.
}
@Override
public void onResourceNotFound(BitwardsResource resource) {
// The BLE based resource was not found, i.e., it is not nearby.
}
@Override
public void onAccessGranted(BitwardsResource resource) {
// Access was granted to the BLE based resource.
}
@Override
public void onAccessDenied(BitwardsResource resource, int reasonCode) {
// Access was denied to the BLE based resource.
}
@Override
public void onError(BitwardsResource resource, int errorCode) {
// An error occurred while accessing to the BLE based resource.
// This is happens sometimes. Application can indicate the error
// in the UI, and the end user can try to access the resource again.
}
});
Discover and access a selected resource
This is one method call that does both the discovery (scans of known resources) as well as access a resource that was selected. Essentially, this is the same as using the background scan callback with access a discovered resource. The functionality is that first a two second bluetooth scan is performed. Second, a list of discovered known resources are returned with toSelectResource(..) callback. Third, a resource can be selected to be accessed and it is indicated with the SelectResourceCallback interface. Finally, the selected resource is accessed as before.
// Scanning for any available known resource and access the selected one (discover invalid input: '&' access)
bws.discoverAndAccessResource(new BitwardsService.BLEResourceCallback() {
@Override
public void onSelectResource(List<BitwardsResource> resources, BitwardsService.SelectResourceCallback callback) {
// Select among the discovered BLE based resources which one to open,
// resource with strongest bluetooth signal is first in the list
// As an example, we are going to select the resource with
// strongest bluetooth signal (i.e., first resource on the list)
callback.selectedResource(resources.get(0));
}
@Override
public void onResourceNotFound(BitwardsResource resource) {
// No resources were found during the scan phase.
}
@Override
public void onAccessGranted(BitwardsResource resource) {
// Access was granted for the selected resource
}
@Override
public void onAccessDenied(BitwardsResource resource, int reasonCode) {
// Access was denied for the selected resource
}
@Override
public void onError(BitwardsResource resource, int errorCode) {
// An error occurred while accessing the selected resource.
}
});
Logout end user
BitwardsService instance can be logged out from the backend server at anytime. After this, resources cannot be accessed anymore. BitwardsService must be logged back in in order to perform operations with resources.
// Logout from backend server
bws.logout(new BitwardsService.ResultCallback() {
@Override
public void onSuccess() {
// Logout with the backend server was successful
}
@Override
public void onError(int errorCode) {
// Logout failed
}
});
Utility functions
Enable error reporting
Bitwards SDK is capable of reporting error back to Bitwards servers, but this needs to be setup when application launches. Bitwards SDK uses ACRA for error reporting. All error reports are sent silently, i.e., end user will not notice this.
ACRA is setup the following way:
BitwardsService.Debug.initializeACRA(context, BuildConfig.class);
Application can also configure Bitwards SDK to do deeper diagnostics, which means Bitwards SDK sends error reports more frequently. The diagnostics is enabled the following way:
bws.setBitwardsConfig(new BitwardsConfig.Builder()
.setBoolean(BitwardsConfig.DIAGNOTICS_ENABLED, true)
.setOverWrite(true)
.build());
Error code to error string
Bitwards SDK has a lot of error codes. In order to get the textual representation for debugging purposes (and printed to logcat, for instance), the developer can use the following.
// The error code returned by Bitwards SDK (example)
int errorCode = 0;
// The error string representing the error code
String errorText = BitwardsService.Debug.getErrorString(errorCode);
// See more about the error code / string from Bitwards SDK javadoc
Getting error code from BitwardsException
The Bitwards error code can be obtained from Bitwards exception as follows:
try {
...
} catch (BitwardsException be) {
int errorCode = be.getErrorCode();
// process the error code
}
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceAuthenticationTokenExpiredCallback is used to notify UI that authentication token has expired.static interfaceBackground BLE scan callback for reporting found/lost resources.static interfaceCallback to deliver Installation request list or error of the operation.static interfaceDeprecated.static interfaceBitwardsResourceListUpdatedCallback is used to notify UI that BitwardsResource list has been updated from the server.static interfaceCallback to deliver Bitwards resource type list or error of the operation.static interfaceCallback to deliver Bitwards end user's profile data or error of the operation.static interfaceResource callback notifications when connecting and communicating with a resource using BLE.static interfaceBLEResourceConnectionStateCallback can be used instead of basic BLEResourceCallback interface.static interfaceResource callback notifications when the application also wants a callback when the resource maintenance phase during the communication has been completed.static classBluetoothProximityAccess class is used to handle Bluetooth proximity access functionality.static final classBitwardsService.Debug class is used to setup error reporting.static classLoginCallback can be used instead of ResultCallback when usinglogin(BitwardsCredential, ResultCallback)method.static interfaceResource callback notifications when connecting and communicating with a resource using NFC.static interfacestatic interfaceCallback to notify success or error of an operation.static interfaceSelect resource callback is used when more than one known resources were found. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe logged in end user does not have the permission to access the requested service.static final intThe application does not have the BLUETOOTH_CONNECT permission.static final intBitwardsService instance is already initialized.static final intBitwards end user is already logged in, BitwardsService instance is already connected to Bitwards backend environment.static final intAnother operation is already ongoing.static final intAuthentication token with the server has expired, sign in again needed.static final intBackground scan was stopped manually.static final intBitwards resource error: Bluetooth MAC address was invalid.static final intBitwards resource error: Resource is malfunctioning.static final intAn Bluetooth operation already active.static final intBitwards resource error: Accessed bluetooth device is not a resource.static final intBitward resource error: Bluetooth scan is already active.static final intBitwards resource error: Bluetooth scan failed.static final intBluetooth scan is not active.static final intBitwards resource error: Application does not have permission to use Bluetooth (needs access to permission).static final intDevice does not support Bluetooth.static final intBitwards resource error: Bluetooth is not on in the device.static final intBitwards resource error: Bluetooth was disabled during operation.static final intCallback is null.static final intCancel Bitwards resource reservation server communication error.static final intPassword change of the logged in Bitwards end user failed.static final intChanging the profile of the logged in Bitwards end user failed.static final intBitwards resource error: Bluetooth connection is already active.static final intBitwards resource error: Bluetooth GATT error occurred (try again).static final intBitwards resource error: GATT characteristic read failure.static final intGet location list server communication error.static final intGet the Bitwards resource list of the logged in Bitwards end user failed.static final intGetting the profile of the logged in Bitwards end user failed.static final intInitialization of BitwardsService instance failed.static final intInstallation is active.static final intInstallation failed.static final intInstallation is not active.static final intInstallation task was cancelledstatic final intInstallation task is not in pending mode (it has been already performed)static final intTesting access to the installed Bitwards resource failed, but installation was otherwise carried out successfully.static final intAndroid device's Location service is disabled.static final intLogin of the Bitwards end user to the Bitwards backend environment failed.static final intLogin failed because user does not exist.static final intLogin failed due to server error.static final intLogout of the logged in Bitwards end user from the Bitwards backend environment failed.static final intBitwards resource error: Application does not have NFC permission.static final intDevice does not support NFC.static final intThe application does not have the BLUETOOTH_CONNECT permission.static final intThe application does not have the BLUETOOTH_SCAN permission.static final intDevice is not connected to internet.static final intApplication does not have location permission (ACCESS_FINE_LOCATION).static final intApplication does not have NFC permission.static final intApplication does not have READ_DEVICE_STATE permissionstatic final intBitwardsService instance is not connected.static final intBitwardsService instance is not initialized.static final intBitwards end user is not logged in, BitwardsService instanced is not connected to Bitwards backend environment.static final intRefresh connection to server failed.static final intInstallation failed because the resoruce was already installed.static final intBitwards resource error: resource disconnected.static final intBitwardsResource instance is nullstatic final intBitwards resource error: resource was moved out of range.static final intOperation with Bitwards resource failed: application does not support the protocol resource is using, application update is required.static final intBitwards resource reservation server communication error.static final intBitwards resource error: connection to resource timed out.static final intBitwards resource error: unknown error occurred.static final intAnother Bitwards resource update process is active.static final intUpdate process of the Bitwards resource failed.static final intBitwards resource update process is not active.static final intBitwards resource update task was cancelled.static final intDeprecated.static final intCancel Bitwards resource reservation failed response by server.static final intInstallation failed because server failed to new Bitwards resource response by server.static final intGet location list failed response by server.static final intInstallation failed because internal error response by server.static final intInstallation failed because the Bitwards resource was already installed response by server.static final intBitwards resource reservation failed response by server.static final intInstallation failed because serial number already exists response by server.static final intTimeout occurredstatic final intAn unknown error occurred.static final intUnknown background scan mode.static final intInstallation task to be cancelled was not the active one.static final intWrong Bitwards resource update task was cancelled.static final intOperation with Bitwards resource failed: bad data.static final intOperation with Bitwards resource failed: token creation time in future.static final intOperation with Bitwards resource failed: delegation cache overrun.static final intOperation with Bitwards resource failed: delegation used.static final intOperation with Bitwards resource failed: token owner has illegal user role.static final intOperation with Bitwards resource failed: application does not have have a valid token for the resource.static final intOperation with Bitwards resource failed: access denied due to exception schedule.static final intOperation with Bitwards resource failed: access denied due to regular schedule access list.static final intOperation with Bitwards resource failed: operation failed due to resource's battery being critical.static final intOperation with Bitwards resource failed: peripheral communication failure occurred.static final intOperation with Bitwards resource failed: peripheral failure occurred.static final intOperation with Bitwards resource failed: resource is already reserved.static final intOperation with Bitwards resource failed: token is blacklisted.static final intOperation with Bitwards resource failed: wrong delegation.static final intOperation with Bitwards resource failed: bad signature.static final intOperation with Bitwards resource failed: token has wrong time window.static final intBluetooth scan mode: scan for Bitwards resources will report all found resources, including unknown ones.static final intBluetooth scan mode: scan for Bitwards resources will report only regular resources known by the logged in Bitwards end user.static final intBluetooth scan mode: scan for Bitwards resources will report only universal resources known by the logged in Bitwards end user. -
Method Summary
Modifier and TypeMethodDescriptionvoidaccessResource(BitwardsResource resource, BitwardsService.BLEResourceCallback callback) Attempt to connect to and access a Bitwards resource using BLE.voidchangePassword(String oldPassword, String newPassword) Deprecated.voidchangePassword(String oldPassword, String newPassword, BitwardsService.ResultCallback callback) Change password of the logged in Bitwards end user.voidconnect(String url, BitwardsCredential credential, BitwardsService.ResultCallback callback) Deprecated.voidconnect(String url, String username, String password, BitwardsService.ResultCallback callback) Deprecated.voidconnectToResource(BitwardsResource resource, BitwardsService.BLEResourceCallback callback) Deprecated.static voiddefaultOnMaintenanceComplete(ResourceInfo resource, ConfigurationInfo configuration) voiddeleteUserAccount(List<Long> accountIDs, BitwardsService.ResultCallback callback) todo add documentationvoidDeprecated.voiddisconnect(BitwardsService.ResultCallback callback) Deprecated.voidStart a bluetooth scan for discovering BLE based Bitwards resources that are known to end user.voiddiscoverAndAccessResource(BitwardsService.BLEResourceCallback callback, int mode) Start bluetooth scan for discovering BLE based Bitwards resources.Get the Bitwards admin info list of the logged in Bitwards end user.voidgetBitwardsInstallationRequestList(boolean sync, BitwardsService.BitwardsInstallationRequestListCallback callback) Get the Bitwards resource installation request list of the Bitwards end user.static BitwardsResourcegetBitwardsResource(ResourceInfo resourceInfo) Get the Bitwards resource list of the logged in Bitwards end user.getBitwardsResourceList(boolean sync) Deprecated.voidgetBitwardsResourceList(boolean sync, BitwardsService.BitwardsResourceListCallback callback) Deprecated.voidgetBitwardsResourceTypeList(boolean sync, BitwardsService.BitwardsResourceTypeListCallback callback) Get the resource type list of the Bitwards resources.Get profile properties of the logged in Bitwards end user.voidDeprecated.static final BitwardsServiceDeprecated.static final BitwardsServicegetInstance(android.content.Context context, String license) Get BitwardsService instance.Get the version of the BitwardsService instance.voidDeprecated.voidinitialize(BitwardsService.ResultCallback callback) Deprecated.booleanDeprecated.voidCheck if authentication token used with the Bitwards backend environment is valid.booleanCheck if BitwardsService instance has the background bluetooth scan is active.booleanDeprecated.booleanDeprecated.booleanCheck if BitwardsService instance is logged in to Bitwards backend environment.booleanCheck if the processing of NFC connections is paused.booleanCheck if BitwardsService instance has an asynchronous operation active.voidlogin(BitwardsCredential credential, BitwardsService.ResultCallback callback) Login to Bitwards backend environment.voidlogout()Log out from Bitwards backend environment.voidlogout(BitwardsService.ResultCallback callback) Deprecated.voidmaintainResource(BitwardsResource resource, BitwardsService.BLEResourceMaintenanceCallback callback) Attempt to connect to and execute maintenance with a Bitwards resource using BLE.voidpauseNfc()Pause processing of NFC connections from Bitwards resources.voidrefresh(BitwardsCredential credential, BitwardsService.ResultCallback callback) Refresh connection to Bitwards backend environment using new BitwardsCredential.voidRegister a BackgroundScanCallback instance to discover BLE based Bitwards resources that are known to the logged in Bitwards end user.voidregisterBackgroundScanCallback(BitwardsService.BackgroundScanCallback callback, int mode) Register a BackgroundScanCallback instance to discover BLE based Bitwards resources, optionally also unknown Bitwards resources to the logged in Bitwards end user are included.voidResume processing of NFC connections from Bitwards resources.voidscanAndAccessResource(BitwardsResource resource, long scanTime, BitwardsService.BLEResourceCallback callback) Scan for the given resource and if found, access the resource.voidDeprecated.voidscanForResource(BitwardsService.BLEResourceCallback callback, int mode) Deprecated.voidSet callback for receiving notifications when the authentiation token has expired.voidsetBitwardsConfig(BitwardsConfig config) Set default settings for BitwardsService instance.voidsetBitwardsResourceListUpdatedCallback(BitwardsService.BitwardsResourceListUpdatedCallback callback) Set the callback for receiving notifications when the list of Bitwards resources for the logged in Bitwards end user has been updated automatically.voidSet the callback for NFC based Bitwards resource event callbacks.voidsetNotifier(Class clazz) Set BitwardsService.Notifier class.voidDeprecated.voidstartBackgroundScan(BitwardsService.BackgroundScanCallback callback, int mode) Deprecated.voidStart Bitwards resource discovery for proximity access.voidStop the ongoing BLE background scan.voidStop Bitwards resource discovery for proximity access.voidsynchronize(BitwardsService.ResultCallback callback) Synchronize the local SDK database (e.g., Bitwards resource list and user data) with the Bitwards backend server.voidUnregister a BackgroundScanCallback instance.Deprecated.voidupdateBitwardsUser(BitwardsUser user, BitwardsService.BitwardsUserCallback callback) Change profile data of the logged in Bitwards end user.
-
Field Details
-
RESOURCE_SCAN_MODE_FULL
public static final int RESOURCE_SCAN_MODE_FULLBluetooth scan mode: scan for Bitwards resources will report all found resources, including unknown ones.- See Also:
-
RESOURCE_SCAN_MODE_KNOWN
public static final int RESOURCE_SCAN_MODE_KNOWNBluetooth scan mode: scan for Bitwards resources will report only regular resources known by the logged in Bitwards end user.- See Also:
-
RESOURCE_SCAN_MODE_UNIVERSAL
public static final int RESOURCE_SCAN_MODE_UNIVERSALBluetooth scan mode: scan for Bitwards resources will report only universal resources known by the logged in Bitwards end user.- See Also:
-
ERROR_BLUETOOTH_NO_PERMISSION
public static final int ERROR_BLUETOOTH_NO_PERMISSIONBitwards resource error: Application does not have permission to use Bluetooth (needs access to permission).- See Also:
-
ERROR_BLUETOOTH_NOT_ENABLED
public static final int ERROR_BLUETOOTH_NOT_ENABLEDBitwards resource error: Bluetooth is not on in the device.- See Also:
-
ERROR_BLE_SCAN_FAILED
public static final int ERROR_BLE_SCAN_FAILEDBitwards resource error: Bluetooth scan failed.- See Also:
-
ERROR_BAD_RESOURCE
public static final int ERROR_BAD_RESOURCEBitwards resource error: Resource is malfunctioning.- See Also:
-
ERROR_GATT_ERROR
public static final int ERROR_GATT_ERRORBitwards resource error: Bluetooth GATT error occurred (try again).- See Also:
-
ERROR_DEVICE_CONNECTION_ACTIVE
public static final int ERROR_DEVICE_CONNECTION_ACTIVEBitwards resource error: Bluetooth connection is already active.- See Also:
-
ERROR_BLE_SCAN_ALREADY_ACTIVE
public static final int ERROR_BLE_SCAN_ALREADY_ACTIVEBitward resource error: Bluetooth scan is already active.- See Also:
-
ERROR_BLE_NOT_RESOURCE
public static final int ERROR_BLE_NOT_RESOURCEBitwards resource error: Accessed bluetooth device is not a resource.- See Also:
-
ERROR_NFC_NO_PERMISSION
public static final int ERROR_NFC_NO_PERMISSIONBitwards resource error: Application does not have NFC permission.- See Also:
-
ERROR_BLUETOOTH_WAS_DISABLED
public static final int ERROR_BLUETOOTH_WAS_DISABLEDBitwards resource error: Bluetooth was disabled during operation.- See Also:
-
ERROR_BAD_MAC_ADDRESS
public static final int ERROR_BAD_MAC_ADDRESSBitwards resource error: Bluetooth MAC address was invalid.- See Also:
-
ERROR_RESOURCE_OUT_OF_RANGE
public static final int ERROR_RESOURCE_OUT_OF_RANGEBitwards resource error: resource was moved out of range.- See Also:
-
ERROR_RESOURCE_DISCONNECTED
public static final int ERROR_RESOURCE_DISCONNECTEDBitwards resource error: resource disconnected.- See Also:
-
ERROR_RESOURCE_TIMEOUT
public static final int ERROR_RESOURCE_TIMEOUTBitwards resource error: connection to resource timed out.- See Also:
-
ERROR_GATT_READ_FAILURE
public static final int ERROR_GATT_READ_FAILUREBitwards resource error: GATT characteristic read failure. This error should be treated as ERROR_BAD_RESOURCE.)- See Also:
-
ERROR_RESOURCE_UNKNOWN_ERROR
public static final int ERROR_RESOURCE_UNKNOWN_ERRORBitwards resource error: unknown error occurred.- See Also:
-
ERROR_UNKNOWN
public static final int ERROR_UNKNOWNAn unknown error occurred.- See Also:
-
ERROR_NO_INTERNET
public static final int ERROR_NO_INTERNETDevice is not connected to internet.- See Also:
-
ERROR_NOT_LOGGED_IN
public static final int ERROR_NOT_LOGGED_INBitwards end user is not logged in, BitwardsService instanced is not connected to Bitwards backend environment.- See Also:
-
ERROR_ALREADY_LOGGED_IN
public static final int ERROR_ALREADY_LOGGED_INBitwards end user is already logged in, BitwardsService instance is already connected to Bitwards backend environment.- See Also:
-
ERROR_LOGIN_FAILED
public static final int ERROR_LOGIN_FAILEDLogin of the Bitwards end user to the Bitwards backend environment failed.- See Also:
-
ERROR_LOGOUT_FAILED
public static final int ERROR_LOGOUT_FAILEDLogout of the logged in Bitwards end user from the Bitwards backend environment failed.- See Also:
-
ERROR_CHANGE_PASSWORD_FAILED
public static final int ERROR_CHANGE_PASSWORD_FAILEDPassword change of the logged in Bitwards end user failed.- See Also:
-
ERROR_GET_USER_PROFILE_FAILED
public static final int ERROR_GET_USER_PROFILE_FAILEDGetting the profile of the logged in Bitwards end user failed.- See Also:
-
ERROR_CHANGE_USER_PROFILE_FAILED
public static final int ERROR_CHANGE_USER_PROFILE_FAILEDChanging the profile of the logged in Bitwards end user failed.- See Also:
-
ERROR_GET_RESOURCE_LIST_FAILED
public static final int ERROR_GET_RESOURCE_LIST_FAILEDGet the Bitwards resource list of the logged in Bitwards end user failed.- See Also:
-
ERROR_INITIALIZATION_FAILED
public static final int ERROR_INITIALIZATION_FAILEDInitialization of BitwardsService instance failed.- See Also:
-
ERROR_NOT_INITIALIZED
public static final int ERROR_NOT_INITIALIZEDBitwardsService instance is not initialized.- See Also:
-
ERROR_ALREADY_INITIALIZED
public static final int ERROR_ALREADY_INITIALIZEDBitwardsService instance is already initialized.- See Also:
-
ERROR_NOT_CONNECTED
public static final int ERROR_NOT_CONNECTEDBitwardsService instance is not connected.- See Also:
-
ERROR_BLE_ALREADY_ACTIVE
public static final int ERROR_BLE_ALREADY_ACTIVEAn Bluetooth operation already active.- See Also:
-
ERROR_LOGIN_FAILED_DUE_TO_SERVER_ERROR
public static final int ERROR_LOGIN_FAILED_DUE_TO_SERVER_ERRORLogin failed due to server error.- See Also:
-
ERROR_CALLBACK_NULL
public static final int ERROR_CALLBACK_NULLCallback is null.- See Also:
-
ERROR_NO_LOCATION_PERMISSION
public static final int ERROR_NO_LOCATION_PERMISSIONApplication does not have location permission (ACCESS_FINE_LOCATION).- See Also:
-
ERROR_NO_NFC_PERMISSION
public static final int ERROR_NO_NFC_PERMISSIONApplication does not have NFC permission.- See Also:
-
ERROR_NO_READ_DEVICE_STATE_PERMISSION
public static final int ERROR_NO_READ_DEVICE_STATE_PERMISSIONApplication does not have READ_DEVICE_STATE permission- See Also:
-
ERROR_BLUETOOTH_NOT_AVAILABLE
public static final int ERROR_BLUETOOTH_NOT_AVAILABLEDevice does not support Bluetooth.- See Also:
-
ERROR_NFC_NOT_AVAILABLE
public static final int ERROR_NFC_NOT_AVAILABLEDevice does not support NFC.- See Also:
-
ERROR_BLE_SCAN_NOT_ACTIVE
public static final int ERROR_BLE_SCAN_NOT_ACTIVEBluetooth scan is not active.- See Also:
-
ERROR_SECURE_DEVICE_LOCK_NOT_ENABLED
Deprecated.Requirement of having device lock enabled has been removed from SDK, hence this error code has been deprecated.- See Also:
-
ERROR_ANOTHER_OPERATION_ONGOING
public static final int ERROR_ANOTHER_OPERATION_ONGOINGAnother operation is already ongoing.- See Also:
-
ERROR_TIMEOUT
public static final int ERROR_TIMEOUTTimeout occurred- See Also:
-
ERROR_RESOURCE_NULL
public static final int ERROR_RESOURCE_NULLBitwardsResource instance is null- See Also:
-
ERROR_AUTH_TOKEN_EXPIRED
public static final int ERROR_AUTH_TOKEN_EXPIREDAuthentication token with the server has expired, sign in again needed.- See Also:
-
ERROR_UNKNOWN_BACKGROUND_SCAN_MODE
public static final int ERROR_UNKNOWN_BACKGROUND_SCAN_MODEUnknown background scan mode.- See Also:
-
ERROR_INSTALLATION_NOT_ACTIVE
public static final int ERROR_INSTALLATION_NOT_ACTIVEInstallation is not active.- See Also:
-
ERROR_INSTALLATION_ACTIVE
public static final int ERROR_INSTALLATION_ACTIVEInstallation is active.- See Also:
-
ERROR_INSTALLATION_FAILED
public static final int ERROR_INSTALLATION_FAILEDInstallation failed.- See Also:
-
ERROR_RESOURCE_ALREADY_INSTALLED
public static final int ERROR_RESOURCE_ALREADY_INSTALLEDInstallation failed because the resoruce was already installed.- See Also:
-
ERROR_INSTALLATION_TASK_NOT_PENDING
public static final int ERROR_INSTALLATION_TASK_NOT_PENDINGInstallation task is not in pending mode (it has been already performed)- See Also:
-
ERROR_WRONG_INSTALLATION_TASK_CANCELLED
public static final int ERROR_WRONG_INSTALLATION_TASK_CANCELLEDInstallation task to be cancelled was not the active one.- See Also:
-
ERROR_INSTALLATION_TASK_CANCELLED
public static final int ERROR_INSTALLATION_TASK_CANCELLEDInstallation task was cancelled- See Also:
-
ERROR_SERVER_RESPONSE_RESOURCE_ALREADY_INSTALLED
public static final int ERROR_SERVER_RESPONSE_RESOURCE_ALREADY_INSTALLEDInstallation failed because the Bitwards resource was already installed response by server.- See Also:
-
ERROR_SERVER_RESPONSE_INTERNAL_ERROR
public static final int ERROR_SERVER_RESPONSE_INTERNAL_ERRORInstallation failed because internal error response by server.- See Also:
-
ERROR_SERVER_RESPONSE_FAILED_TO_ADD_NEW_RESOURCE_IN_SERVER
public static final int ERROR_SERVER_RESPONSE_FAILED_TO_ADD_NEW_RESOURCE_IN_SERVERInstallation failed because server failed to new Bitwards resource response by server.- See Also:
-
ERROR_SERVER_RESPONSE_SERIAL_NUMBER_ALREADY_EXISTS
public static final int ERROR_SERVER_RESPONSE_SERIAL_NUMBER_ALREADY_EXISTSInstallation failed because serial number already exists response by server.- See Also:
-
ERROR_SERVER_RESPONSE_CANCEL_RESOURCE_RESERVATION_FAILED
public static final int ERROR_SERVER_RESPONSE_CANCEL_RESOURCE_RESERVATION_FAILEDCancel Bitwards resource reservation failed response by server.- See Also:
-
ERROR_CANCEL_RESOURCE_RESERVATION_SERVER_COMMUNICATION
public static final int ERROR_CANCEL_RESOURCE_RESERVATION_SERVER_COMMUNICATIONCancel Bitwards resource reservation server communication error.- See Also:
-
ERROR_SERVER_RESPONSE_RESOURCE_RESERVATION_FAILED
public static final int ERROR_SERVER_RESPONSE_RESOURCE_RESERVATION_FAILEDBitwards resource reservation failed response by server.- See Also:
-
ERROR_RESOURCE_RESERVATION_SERVER_COMMUNICATION
public static final int ERROR_RESOURCE_RESERVATION_SERVER_COMMUNICATIONBitwards resource reservation server communication error.- See Also:
-
ERROR_SERVER_RESPONSE_GET_LOCATION_LIST_FAILED
public static final int ERROR_SERVER_RESPONSE_GET_LOCATION_LIST_FAILEDGet location list failed response by server.- See Also:
-
ERROR_GET_LOCATION_LIST_SERVER_COMMUNICATION
public static final int ERROR_GET_LOCATION_LIST_SERVER_COMMUNICATIONGet location list server communication error.- See Also:
-
ERROR_REFRESH_FAILED
public static final int ERROR_REFRESH_FAILEDRefresh connection to server failed.- See Also:
-
ERROR_INSTALLATION_TEST_FAILED
public static final int ERROR_INSTALLATION_TEST_FAILEDTesting access to the installed Bitwards resource failed, but installation was otherwise carried out successfully. All installation messages were delivered successfully, but testing the installation with test token failed.- See Also:
-
ERROR_LOCATION_SERVICE_DISABLED
public static final int ERROR_LOCATION_SERVICE_DISABLEDAndroid device's Location service is disabled. It needs to be enabled in order to have Bluetooth scanning to work.- See Also:
-
ERROR_RESOURCE_UPDATE_FAILED
public static final int ERROR_RESOURCE_UPDATE_FAILEDUpdate process of the Bitwards resource failed.- See Also:
-
ERROR_RESOURCE_UPDATE_ACTIVE
public static final int ERROR_RESOURCE_UPDATE_ACTIVEAnother Bitwards resource update process is active.- See Also:
-
ERROR_RESOURCE_UPDATE_TASK_CANCELLED
public static final int ERROR_RESOURCE_UPDATE_TASK_CANCELLEDBitwards resource update task was cancelled.- See Also:
-
ERROR_RESOURCE_UPDATE_NOT_ACTIVE
public static final int ERROR_RESOURCE_UPDATE_NOT_ACTIVEBitwards resource update process is not active.- See Also:
-
ERROR_WRONG_RESOURCE_UPDATE_TASK_CANCELLED
public static final int ERROR_WRONG_RESOURCE_UPDATE_TASK_CANCELLEDWrong Bitwards resource update task was cancelled.- See Also:
-
ERROR_BACKGROUND_SCAN_STOPPED
public static final int ERROR_BACKGROUND_SCAN_STOPPEDBackground scan was stopped manually.- See Also:
-
ERROR_ACCESS_FORBIDDEN
public static final int ERROR_ACCESS_FORBIDDENThe logged in end user does not have the permission to access the requested service.- See Also:
-
ERROR_LOGIN_FAILED_BECAUSE_USER_DOES_NOT_EXISTS
public static final int ERROR_LOGIN_FAILED_BECAUSE_USER_DOES_NOT_EXISTSLogin failed because user does not exist.- See Also:
-
ERROR_NO_BLUETOOTH_SCAN_PERMISSION
public static final int ERROR_NO_BLUETOOTH_SCAN_PERMISSIONThe application does not have the BLUETOOTH_SCAN permission.- See Also:
-
ERROR_NO_BLUETOOTH_CONNECT_PERMISSION
public static final int ERROR_NO_BLUETOOTH_CONNECT_PERMISSIONThe application does not have the BLUETOOTH_CONNECT permission.- See Also:
-
ERROR_ACCOUNT_DELETION_FAILED
public static final int ERROR_ACCOUNT_DELETION_FAILEDThe application does not have the BLUETOOTH_CONNECT permission.- See Also:
-
REASON_BAD_DATA
public static final int REASON_BAD_DATAOperation with Bitwards resource failed: bad data. -
REASON_WRONG_SIGNATURE
public static final int REASON_WRONG_SIGNATUREOperation with Bitwards resource failed: bad signature. -
REASON_WRONG_DELEGATION
public static final int REASON_WRONG_DELEGATIONOperation with Bitwards resource failed: wrong delegation. -
REASON_DELEGATION_USED
public static final int REASON_DELEGATION_USEDOperation with Bitwards resource failed: delegation used. -
REASON_DELEGATION_CACHE_OVERRUN
public static final int REASON_DELEGATION_CACHE_OVERRUNOperation with Bitwards resource failed: delegation cache overrun. -
REASON_TOKEN_BLACKLISTED
public static final int REASON_TOKEN_BLACKLISTEDOperation with Bitwards resource failed: token is blacklisted. -
REASON_WRONG_TIME_WINDOW
public static final int REASON_WRONG_TIME_WINDOWOperation with Bitwards resource failed: token has wrong time window. -
REASON_CREATIONTIME_IN_FUTURE
public static final int REASON_CREATIONTIME_IN_FUTUREOperation with Bitwards resource failed: token creation time in future. -
REASON_RESOURCE_ALREADY_RESERVED
public static final int REASON_RESOURCE_ALREADY_RESERVEDOperation with Bitwards resource failed: resource is already reserved. -
REASON_ILLEGAL_USER_ROLE
public static final int REASON_ILLEGAL_USER_ROLEOperation with Bitwards resource failed: token owner has illegal user role. -
REASON_PERIPHERAL_FAILURE
public static final int REASON_PERIPHERAL_FAILUREOperation with Bitwards resource failed: peripheral failure occurred. -
REASON_PERIPHERAL_COMMUNICATION_FAILURE
public static final int REASON_PERIPHERAL_COMMUNICATION_FAILUREOperation with Bitwards resource failed: peripheral communication failure occurred. -
REASON_OPERATION_FAILED_BATTERY_CRITICAL
public static final int REASON_OPERATION_FAILED_BATTERY_CRITICALOperation with Bitwards resource failed: operation failed due to resource's battery being critical. -
REASON_OPERATION_DENIED_BY_REGULAR_SCHEDULE
public static final int REASON_OPERATION_DENIED_BY_REGULAR_SCHEDULEOperation with Bitwards resource failed: access denied due to regular schedule access list. -
REASON_OPERATION_DENIED_BY_EXCEPTION_SCHEDULE
public static final int REASON_OPERATION_DENIED_BY_EXCEPTION_SCHEDULEOperation with Bitwards resource failed: access denied due to exception schedule. -
REASON_NO_VALID_TOKEN
public static final int REASON_NO_VALID_TOKENOperation with Bitwards resource failed: application does not have have a valid token for the resource. -
ERROR_RESOURCE_REQUIRES_APP_UPDATE
public static final int ERROR_RESOURCE_REQUIRES_APP_UPDATEOperation with Bitwards resource failed: application does not support the protocol resource is using, application update is required.
-
-
Method Details
-
defaultOnMaintenanceComplete
public static void defaultOnMaintenanceComplete(ResourceInfo resource, ConfigurationInfo configuration) -
getInstance
public static final BitwardsService getInstance(android.content.Context context, String license) throws BitwardsException Get BitwardsService instance. The BitwardsService instance is a singleton,i.e., this method always returns the same BitwardsService instance.- Parameters:
context- the application contextlicense- the Bitwards lisence (json file obtained from Bitwards)- Returns:
- BitwardsService instance (singleton)
- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
getInstance
Deprecated.Deprecated, usegetInstance(Context, String)instead.- Returns:
- BitwardsService instance.
- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
initialize
@Deprecated public void initialize(BitwardsService.ResultCallback callback) throws BitwardsException Deprecated.Deprecated, this method does not need to be used. BitwardsService instance is initialized whengetInstance(Context, String)method is called. Initialized BitwardsService instance. Must be called once, typically right after BitwardsService.getInstance(Context,String).- Parameters:
callback- the callback to return success notification or error code if something went wrong- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
initialize
Deprecated.Deprecated, this method does not need to be used. BitwardsService instance is initialized whengetInstance(Context, String)method is called. Initialized BitwardsService instance. Must be called once. Not recommended to be used, useinitialize(ResultCallback)instead.- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
connect
@Deprecated public void connect(String url, String username, String password, BitwardsService.ResultCallback callback) throws BitwardsException Deprecated.Deprecated, uselogin(BitwardsCredential, ResultCallback)instead. Connect (log in) to Bitwards backend environment. In other words, end user logs in to the server.- Parameters:
url- the url to Bitwards serverusername- end user's username (typically end user's email address)password- end user's passwordcallback- the callback to return success notification or error code if something went wrong- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
login
public void login(BitwardsCredential credential, BitwardsService.ResultCallback callback) throws BitwardsException Login to Bitwards backend environment. In other words, end user logs in to the server.- Parameters:
credential- end user's credentialcallback- the callback to return success notification or error code if something went wrong- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
connect
@Deprecated public void connect(String url, BitwardsCredential credential, BitwardsService.ResultCallback callback) throws BitwardsException Deprecated.Deprecated, uselogin(BitwardsCredential, ResultCallback)instead. Connect (log in) to Bitwards backend environment. In other words, end user logs in to the server.- Parameters:
url- the url to Bitwards servercredential- end user's credentialcallback- the callback to return success notification or error code if something went wrong- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
refresh
public void refresh(BitwardsCredential credential, BitwardsService.ResultCallback callback) throws BitwardsException Refresh connection to Bitwards backend environment using new BitwardsCredential. Connection to server is refreshed to use new credential without disconnecting from server (ie, there is no logout). This is typically done when the authentication token is about to expire.- Parameters:
credential- new end user's credentialcallback- the callback to return success notification or error code if something went wrong- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
logout
Deprecated.Deprecated, uselogout()instead.- Parameters:
callback- the callback to return success notification or error code if something went wrong- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
logout
Log out from Bitwards backend environment. In other words, end user logs out from the server.- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
disconnect
@Deprecated public void disconnect(BitwardsService.ResultCallback callback) throws BitwardsException Deprecated.Deprecated, uselogout()instead.- Parameters:
callback- the callback to return success notification or error code if something went wrong- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
disconnect
Deprecated.Deprecated, uselogout()instead.- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
isInitialized
Deprecated.Deprecated, this method does not need to be used. BitwardsService instance is always initialized successfully when usinggetInstance(Context, String), hence this method always returns boolean value true.- Returns:
- true if initialized, false if not.
-
isConnected
Deprecated.Deprecated, useisLoggedIn()instead. Check if BitwardsService instance is connected (logged in) to Bitwards backend environment. In other words, if end user is logged into the server or not.- Returns:
- true if connected (logged in), false if not.
-
isLoggedIn
public boolean isLoggedIn()Check if BitwardsService instance is logged in to Bitwards backend environment. In other words, if end user is logged into the server or not.- Returns:
- true if logged in, false if not.
-
isAuthenticationTokenValid
Deprecated.Deprecated, use
isAuthenticationTokenValid(ResultCallback)instead.Check if authentication token used with the Bitwards backend environment is valid. Calling this method may potentially take a long time as it may involve communication with the backend server, and
isAuthenticationTokenValid(ResultCallback)should be used instead.- Returns:
- true if authentication token valid, false if not.
- Throws:
BitwardsException
-
isAuthenticationTokenValid
Check if authentication token used with the Bitwards backend environment is valid. If the device does not have network connectivity, the authentication token is considered to be valid.- Parameters:
callback- if authentication token is valid, onSuccess() is called; otherwise onError() is called withERROR_AUTH_TOKEN_EXPIREDorERROR_NOT_LOGGED_INerror code.
-
isBackgroundScanActive
public boolean isBackgroundScanActive()Check if BitwardsService instance has the background bluetooth scan is active.- Returns:
- true if the background bluetooth scan is active, false if not.
-
isOperationActive
public boolean isOperationActive()Check if BitwardsService instance has an asynchronous operation active. BitwardsService instance can have only one asynchronous operation active at a time.- Returns:
- true if another asynchronous operation is active, false if not.
-
changePassword
public void changePassword(String oldPassword, String newPassword, BitwardsService.ResultCallback callback) throws BitwardsException Change password of the logged in Bitwards end user.- Parameters:
oldPassword- the old passwordnewPassword- the new passwordcallback- the callback to return success notification or error code if something went wrong- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
changePassword
@Deprecated public void changePassword(String oldPassword, String newPassword) throws BitwardsException Deprecated.Deprecated, usechangePassword(String, String, ResultCallback)instead. Change password of the logged in Bitwards end user.- Parameters:
oldPassword- the new passwordnewPassword- the old password- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
getBitwardsUser
@Deprecated public void getBitwardsUser(BitwardsService.BitwardsUserCallback callback) throws BitwardsException Deprecated.Deprecated, usegetBitwardsUser()instead. Get profile properties of the logged in Bitwards end user.- Parameters:
callback- the callback to return end user's profile properties or error code if something went wrong- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
getBitwardsUser
Get profile properties of the logged in Bitwards end user.- Returns:
- Bitwards user data
- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
updateBitwardsUser
public void updateBitwardsUser(BitwardsUser user, BitwardsService.BitwardsUserCallback callback) throws BitwardsException Change profile data of the logged in Bitwards end user.- Parameters:
user- the modified Bitwards end user profile datacallback- the callback to return updated end user profile data or error code if something went wrong- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
updateBitwardsUser
Deprecated.Deprecated, useupdateBitwardsUser(BitwardsUser, BitwardsUserCallback)instead. Change profile data of the logged in Bitwards end user.- Parameters:
user- the modified Bitwards end user profile data- Returns:
- the Bitwards end user profile data on the server after update.
- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
synchronize
Synchronize the local SDK database (e.g., Bitwards resource list and user data) with the Bitwards backend server.- Parameters:
callback- the callback to return success or error code if something went wrong- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
getBitwardsResourceList
@Deprecated public void getBitwardsResourceList(boolean sync, BitwardsService.BitwardsResourceListCallback callback) throws BitwardsException Deprecated.Deprecated, usegetBitwardsResourceList()instead, andsynchronize(ResultCallback)to synchronize the local SDK database with the Backend server. Get the Bitwards resource list of the logged in Bitwards end user, optionally synchronize the Bitwards resource list from the Bitwards backend environment.- Parameters:
sync- do synchronize with the server or notcallback- the callback to return list of end users's Bitwards resources or error code if something went wrong- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
getBitwardsInstallationRequestList
public void getBitwardsInstallationRequestList(boolean sync, BitwardsService.BitwardsInstallationRequestListCallback callback) throws BitwardsException Get the Bitwards resource installation request list of the Bitwards end user.- Parameters:
sync- do synchronize with the server or notcallback- the callback to return list of installation request or error code if something went wrong- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
getBitwardsResourceTypeList
public void getBitwardsResourceTypeList(boolean sync, BitwardsService.BitwardsResourceTypeListCallback callback) throws BitwardsException Get the resource type list of the Bitwards resources.- Parameters:
sync- do synchronize with the server or notcallback- the callback to return list of resource type or error code if something went wrong- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
getBitwardsResourceList
@Deprecated public List<BitwardsResource> getBitwardsResourceList(boolean sync) throws BitwardsException Deprecated.Deprecated, usegetBitwardsResourceList()instead, andsynchronize(ResultCallback)to synchronize the local SDK database with the Backend server. Get the Bitwards resource list of the logged in Bitwards end user.- Parameters:
sync- do synchronize with the server or not- Returns:
- list of Bitwards resources that the logged in end user knows about
- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
getBitwardsResourceList
Get the Bitwards resource list of the logged in Bitwards end user. Not recommended to be used, usegetBitwardsUser(BitwardsUserCallback)instead.- Returns:
- list of Bitwards resources that the logged in end user knows about.
- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
getBitwardsAdminIfoList
Get the Bitwards admin info list of the logged in Bitwards end user.- Returns:
- list of end users's account admin information
- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
deleteUserAccount
public void deleteUserAccount(List<Long> accountIDs, BitwardsService.ResultCallback callback) throws BitwardsException todo add documentation- Parameters:
callback- the callback to return success or error code if something went wrong- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
setNFCResourceCallback
public void setNFCResourceCallback(BitwardsService.NFCResourceCallback callback) throws BitwardsException Set the callback for NFC based Bitwards resource event callbacks. This callback is used when BitwardsService instance has communicating with a Bitwards resource over NFC.- Parameters:
callback- the callback for reporting result- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
discoverAndAccessResource
public void discoverAndAccessResource(BitwardsService.BLEResourceCallback callback) throws BitwardsException Start a bluetooth scan for discovering BLE based Bitwards resources that are known to end user. Result of the scan, i.e., list of discovered Bitwards resources will be reported back using the callback.- Parameters:
callback- the callback for reporting result- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
scanForResource
@Deprecated public void scanForResource(BitwardsService.BLEResourceCallback callback) throws BitwardsException Deprecated.Deprecated, usediscoverAndAccessResource(BLEResourceCallback)instead. Start a bluetooth scan for discovering BLE based Bitwards resources that are known to end user. Result of the scan, i.e., list of discovered Bitwards resources will be reported back using the callback.- Parameters:
callback- the callback for reporting result- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
discoverAndAccessResource
public void discoverAndAccessResource(BitwardsService.BLEResourceCallback callback, int mode) throws BitwardsException Start bluetooth scan for discovering BLE based Bitwards resources. Result of the scan, i.e., list of discovered Bitwards resources will be reported back using the callback.- Parameters:
callback- the callback for reporting resultmode- the mode of background scan (useRESOURCE_SCAN_MODE_FULLorRESOURCE_SCAN_MODE_KNOWNorRESOURCE_SCAN_MODE_UNIVERSAL).- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
scanForResource
@Deprecated public void scanForResource(BitwardsService.BLEResourceCallback callback, int mode) throws BitwardsException Deprecated.Deprecated, usediscoverAndAccessResource(BLEResourceCallback, int)instead. Start bluetooth scan for discovering BLE based Bitwards resources. Result of the scan, i.e., list of discovered Bitwards resources will be reported back using the callback.- Parameters:
callback- the callback for reporting resultmode- the mode of background scan (useRESOURCE_SCAN_MODE_FULLorRESOURCE_SCAN_MODE_KNOWNorRESOURCE_SCAN_MODE_UNIVERSAL).- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
maintainResource
public void maintainResource(BitwardsResource resource, BitwardsService.BLEResourceMaintenanceCallback callback) throws BitwardsException Attempt to connect to and execute maintenance with a Bitwards resource using BLE. Result of the connection attempt will be reported back using resource maintenance callback.- Parameters:
resource- the Bitwards resource to connect to.callback- the callback for reporting result of the maintenance- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
accessResource
public void accessResource(BitwardsResource resource, BitwardsService.BLEResourceCallback callback) throws BitwardsException Attempt to connect to and access a Bitwards resource using BLE. Result of the connection attempt will be reported back using resource callback.- Parameters:
resource- the Bitwards resource to connect to.callback- the callback for reporting result- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
scanAndAccessResource
public void scanAndAccessResource(BitwardsResource resource, long scanTime, BitwardsService.BLEResourceCallback callback) throws BitwardsException Scan for the given resource and if found, access the resource. Result of the scan and access attempt is reported back using resource callback.- Parameters:
resource- the Bitwards Resource to access.scanTime- the time in milliseconds how long to scan for the given resource. If resource is not found onResourceNotFound(..) is called.callback- the callback for reporting result- Throws:
BitwardsException
-
connectToResource
@Deprecated public void connectToResource(BitwardsResource resource, BitwardsService.BLEResourceCallback callback) throws BitwardsException Deprecated.Deprecated, useaccessResource(BitwardsResource, BLEResourceCallback)instead. Attempt to connect to and access a Bitwards resource using BLE. Result of the connection attempt will be reported back using resource callback.- Parameters:
resource- the Bitwards resource to connect to.callback- the callback for reporting result- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
startBackgroundScan
@Deprecated public void startBackgroundScan(BitwardsService.BackgroundScanCallback callback) throws BitwardsException Deprecated.Deprecated, useregisterBackgroundScanCallback(BackgroundScanCallback)instead. Start the BLE background scan to discover Bitwards resources that are known to Bitwards end user (see NOTE). Results of scan will be reported using the callback.
NOTE: This method is deprecated. UseregisterBackgroundScanCallback(BackgroundScanCallback)andunregisterBackgroundScanCallback(BackgroundScanCallback)to perform the discovery of Bitwards resources using BLE.- Parameters:
callback- the background scan callback interface for reporting found/lost Bitwards resources- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
startBackgroundScan
@Deprecated public void startBackgroundScan(BitwardsService.BackgroundScanCallback callback, int mode) throws BitwardsException Deprecated.Deprecated, useregisterBackgroundScanCallback(BackgroundScanCallback, int)instead. Start the BLE background scan to discover Bitwards resources, optionally also unknown Bitwards resources to Bitwards end user are included. Results of scan will be reported using the callback.
NOTE: This method is deprecated. UseregisterBackgroundScanCallback(BackgroundScanCallback,int)andunregisterBackgroundScanCallback(BackgroundScanCallback)to perform the discovery of Bitwards resources using BLE.- Parameters:
callback- the background scan callback interface for reporting found/lost Bitwards resourcesmode- the mode of background scan (useRESOURCE_SCAN_MODE_FULLorRESOURCE_SCAN_MODE_KNOWNorRESOURCE_SCAN_MODE_UNIVERSAL).- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
stopBackgroundScan
Stop the ongoing BLE background scan.NOTE: It is recommended not to use this method to stop the background scan. Each BackgroundScanCallback instance registered with
registerBackgroundScanCallback(BackgroundScanCallback)orregisterBackgroundScanCallback(BackgroundScanCallback, int)should be unregistered withunregisterBackgroundScanCallback(BackgroundScanCallback).If there are any existing BackgroundScanCallback instances registered with
registerBackgroundScanCallback(BackgroundScanCallback)orregisterBackgroundScanCallback(BackgroundScanCallback, int)methods, those are also stopped, and the corresponding callback instance will receiveBitwardsService.BackgroundScanCallback.onError(int)call with ERROR_BACKGROUND_SCAN_STOPPED as the error code.- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
registerBackgroundScanCallback
public void registerBackgroundScanCallback(BitwardsService.BackgroundScanCallback callback) throws BitwardsException Register a BackgroundScanCallback instance to discover BLE based Bitwards resources that are known to the logged in Bitwards end user.- Parameters:
callback- the background scan callback instance- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
registerBackgroundScanCallback
public void registerBackgroundScanCallback(BitwardsService.BackgroundScanCallback callback, int mode) throws BitwardsException Register a BackgroundScanCallback instance to discover BLE based Bitwards resources, optionally also unknown Bitwards resources to the logged in Bitwards end user are included.- Parameters:
callback- the callback instance to be registeredmode- the mode of background scan (useRESOURCE_SCAN_MODE_FULLorRESOURCE_SCAN_MODE_KNOWNorRESOURCE_SCAN_MODE_UNIVERSAL).- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
unregisterBackgroundScanCallback
public void unregisterBackgroundScanCallback(BitwardsService.BackgroundScanCallback callback) throws BitwardsException Unregister a BackgroundScanCallback instance.- Parameters:
callback- the callback instance to be unregistered- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
startBluetoothProximityAccess
public void startBluetoothProximityAccess(BitwardsService.BluetoothProximityAccess access) throws BitwardsException Start Bitwards resource discovery for proximity access.- Parameters:
access- the bluetooth proximity access instance for discovering and triggering proximity access Bitwards resources.- Throws:
BitwardsException- thrown if an exception occurred
-
stopBluetoothProximityAccess
public void stopBluetoothProximityAccess(BitwardsService.BluetoothProximityAccess access) throws BitwardsException Stop Bitwards resource discovery for proximity access.- Parameters:
access- the bluetooth proximity access instance that was previously used to start the discovery and triggering proximity access for Bitwards resources.- Throws:
BitwardsException- thrown if an exception occurred
-
pauseNfc
public void pauseNfc()Pause processing of NFC connections from Bitwards resources. The BitwardsService instance will not process any connections from NFC based Bitwards resources, i.e., they are ignored. This does not affect the status of the NFC adapter in the device (it is not turned off). -
resumeNfc
public void resumeNfc()Resume processing of NFC connections from Bitwards resources. The BitwardsService instance will process connections from NFC based Bitwards resources normally. This does not affect the status of the NFC adapter in the device (it is not turned on). -
isNfcPaused
public boolean isNfcPaused()Check if the processing of NFC connections is paused.- Returns:
- true, if processing of NFC connections is paused; false, if processing is not paused
-
getVersion
Get the version of the BitwardsService instance.- Returns:
- the version of the BitwardsService
-
getBitwardsResource
public static BitwardsResource getBitwardsResource(ResourceInfo resourceInfo) throws BitwardsLogicException - Throws:
BitwardsLogicException
-
setNotifier
Set BitwardsService.Notifier class. The class must be a real class, not an anonymous class. SeeBitwardsService.Notifierinterface for details.- Parameters:
clazz- a class that implementsBitwardsService.Notifierinterface
-
setBitwardsConfig
Set default settings for BitwardsService instance. Default settings are only set if there is no existing setting value.- Parameters:
config- the BitwardsConfig instance
-
setAuthenticationTokenExpiredCallback
public void setAuthenticationTokenExpiredCallback(BitwardsService.AuthenticationTokenExpiredCallback callback) Set callback for receiving notifications when the authentiation token has expired. This means that the connection to the server is not active any more.- Parameters:
callback- the callback
-
setBitwardsResourceListUpdatedCallback
public void setBitwardsResourceListUpdatedCallback(BitwardsService.BitwardsResourceListUpdatedCallback callback) Set the callback for receiving notifications when the list of Bitwards resources for the logged in Bitwards end user has been updated automatically. This typically happens when BitwardsService instance synchronizes the resource list with the Bitwards backend environment automatically.- Parameters:
callback- the callback
-