Class BinderWrapperImpl
-
- All Implemented Interfaces:
-
net.ballmerlabs.scatterbrainsdk.BinderWrapper
@Singleton() public final class BinderWrapperImpl implements BinderWrapper
-
-
Constructor Summary
Constructors Constructor Description BinderWrapperImpl(Context context, ScatterbrainBroadcastReceiver broadcastReceiver, BinderProvider binderProvider)
-
Method Summary
Modifier and Type Method Description final ContextgetContext()UnitstartService()Starts the scatterbrain router if stopped. UnitunbindService()disconnects from the binder interface IdentitygetIdentity(UUID fingerprint)Gets a single identity by fingerprint. ByteArraysign(Identity identity, ByteArray data)Cryptographically signs data using a stored identity. LiveData<RouterState>observeRouterState()Observe router state BooleanisDiscovering()Returns true if the RoutingService is currently discovering Booleanverify(Identity identity, ByteArray data, ByteArray sig)Cryptographically verifies a detached signature using a stored identity This function requires net.ballmerlabs.scatterroutingservice.permission. List<Identity>getIdentities()Gets a list of all known identities. UnitbindService(Long timeout)Attempts a connection to the scatterbrain service UnitstopService()Stops the scatterbrain router if started. Flow<List<Identity>>observeIdentities()returns an asynchronous flow of identities received after this function is called in real time. Flow<ScatterMessage>getScatterMessages(String application)returns a list of all stored message objects for a given application requires net.ballmerlabs.scatterroutingservice.permission. Flow<ScatterMessage>getScatterMessages(String application, Date since)returns a list of all stored messages for a given application after a given date. Flow<ScatterMessage>getScatterMessages(String application, Date start, Date end)returns a list of all stored messages for a given application between two dates. UnitrescanPeers()Attempts to reconnect to known local peers Flow<List<ScatterMessage>>observeMessages(String application)returns an asynchronous flow of all messages received after this functions is called filtered by a given application identifier. IdentitygenerateIdentity(String name)generates and returns a scatterbrain identity with ACLs matching the calling application only If additional applications need access to this identity they can be assigned via the Scatterbrain app. UnitauthorizeIdentity(Identity identity, String packageName)Adds an ACL to an identity authorizing an app to use it. UnitdeauthorizeIdentity(Identity identity, String packageName)Removes an ACL authorizing an app to use an identity. List<NamePackage>getPermissions(Identity identity)Gets a list of ACLs associated with a given identity object. UnitsendMessage(ScatterMessage message)Enqueues a Scatterbrain message to the datastore. UnitsendMessage(List<ScatterMessage> messages)Enqueues multiple Scatterbrain messages to the datastore. UnitsendMessage(ScatterMessage message, UUID identity)Enqueues a message to the datastore and signs it with a given identity. UnitsendMessage(List<ScatterMessage> messages, UUID identity)Enqueues a list of messages to the datastore and signs it with a given identity. UnitsendMessage(ScatterMessage message, Identity identity)Enqueues a message to the datastore and signs it with a given identity. UnitsendMessage(List<ScatterMessage> messages, Identity identity)Enqueues a list of messages to the datastore and signs it with a given identity. List<NamePackage>getPackages()Gets a list of packages declaring a Scatterbrain compatible BroadcastReceiver. BooleanremoveIdentity(Identity identity)Deletes an identity. PermissionStatusgetPermissionStatus()Gets the current critical permissions granted to the router. UnitdumpDatastore(Uri uri)UnitstartDiscover()Starts active discovery using default transport modules This function requires net.ballmerlabs.scatterroutingservice.permission. UnitstartPassive()Starts passive discovery using the default radio module. UnitstopDiscover()Stops active discovery This function requires net.ballmerlabs.scatterroutingservice.permission. UnitstopPassive()Stops passive discovery This function requires net.ballmerlabs.scatterroutingservice.permission. Unitregister()Unregisters the internal BroadcastReceiver for Scatterbrain events. Unitunregister()Unregisters Scatterbrain broadcast receivers BooleanisConnected()Checks if this SDK is connected to a running Scatterbrain router LiveData<BinderWrapper.Companion.BinderState>observeBinderState()Returns a LiveData providing the current connection state -
-
Constructor Detail
-
BinderWrapperImpl
BinderWrapperImpl(Context context, ScatterbrainBroadcastReceiver broadcastReceiver, BinderProvider binderProvider)
-
-
Method Detail
-
getContext
final Context getContext()
-
startService
Unit startService()
Starts the scatterbrain router if stopped. Requires net.ballmerlabs.scatterroutingservice.permission.ADMIN permission
-
unbindService
Unit unbindService()
disconnects from the binder interface
-
getIdentity
Identity getIdentity(UUID fingerprint)
Gets a single identity by fingerprint. requires net.ballmerlabs.scatterroutingservice.permission.ACCESS permission
-
sign
ByteArray sign(Identity identity, ByteArray data)
Cryptographically signs data using a stored identity. This function requires net.ballmerlabs.scatterroutingservice.permission.ACCESS permission
- Parameters:
identity- identity objectdata- bytes to sign
-
observeRouterState
LiveData<RouterState> observeRouterState()
Observe router state
-
isDiscovering
Boolean isDiscovering()
Returns true if the RoutingService is currently discovering
-
verify
Boolean verify(Identity identity, ByteArray data, ByteArray sig)
Cryptographically verifies a detached signature using a stored identity This function requires net.ballmerlabs.scatterroutingservice.permission.ACCESS permission
- Parameters:
identity- identity object to verify withdata- data to verifysig- detached signature generated by sign()
-
getIdentities
List<Identity> getIdentities()
Gets a list of all known identities. requires net.ballmerlabs.scatterroutingservice.permission.ACCESS permission
-
bindService
Unit bindService(Long timeout)
Attempts a connection to the scatterbrain service
-
stopService
Unit stopService()
Stops the scatterbrain router if started. Requires net.ballmerlabs.scatterroutingservice.permission.ADMIN permission
-
observeIdentities
@ExperimentalCoroutinesApi() Flow<List<Identity>> observeIdentities()
returns an asynchronous flow of identities received after this function is called in real time. requires net.ballmerlabs.scatterroutingservice.permission.ACCESS permission
-
getScatterMessages
Flow<ScatterMessage> getScatterMessages(String application)
returns a list of all stored message objects for a given application requires net.ballmerlabs.scatterroutingservice.permission.ACCESS permission
- Parameters:
application- application identifier
-
getScatterMessages
Flow<ScatterMessage> getScatterMessages(String application, Date since)
returns a list of all stored messages for a given application after a given date. requires net.ballmerlabs.scatterroutingservice.permission.ACCESS permission
- Parameters:
application- application identifiersince- restrict messages after this date
-
getScatterMessages
Flow<ScatterMessage> getScatterMessages(String application, Date start, Date end)
returns a list of all stored messages for a given application between two dates. requires net.ballmerlabs.scatterroutingservice.permission.ACCESS permission
- Parameters:
application- application identifierstart- start dateend- end data
-
rescanPeers
Unit rescanPeers()
Attempts to reconnect to known local peers
-
observeMessages
@ExperimentalCoroutinesApi() Flow<List<ScatterMessage>> observeMessages(String application)
returns an asynchronous flow of all messages received after this functions is called filtered by a given application identifier. requires net.ballmerlabs.scatterroutingservice.permission.ACCESS permission
- Parameters:
application- application idenifier
-
generateIdentity
Identity generateIdentity(String name)
generates and returns a scatterbrain identity with ACLs matching the calling application only If additional applications need access to this identity they can be assigned via the Scatterbrain app. This requires net.ballmerlabs.scatterroutingservice.permission.ACCESS permission
- Parameters:
name- human readable name associated with identity
-
authorizeIdentity
Unit authorizeIdentity(Identity identity, String packageName)
Adds an ACL to an identity authorizing an app to use it. This function requires net.ballmerlabs.scatterroutingservice.permission.SUPERUSER and is currently not available to 3rd party applications
- Parameters:
identity- identity objectpackageName- android app package name
-
deauthorizeIdentity
Unit deauthorizeIdentity(Identity identity, String packageName)
Removes an ACL authorizing an app to use an identity. This function requires net.ballmerlabs.scatterroutingservice.permission.SUPERUSER and is currently not available to 3rd party applications
- Parameters:
identity- identity objectpackageName- android app package name
-
getPermissions
List<NamePackage> getPermissions(Identity identity)
Gets a list of ACLs associated with a given identity object. This function requires net.ballmerlabs.scatterroutingservice.permission.SUPERUSER permission and is currently not available to 3rd party applications
- Parameters:
identity- identity object
-
sendMessage
Unit sendMessage(ScatterMessage message)
Enqueues a Scatterbrain message to the datastore. The messages will be sent as soon as a peer is available This function requires net.ballmerlabs.scatterroutingservice.permission.ACCESS permission
- Parameters:
message- message to send
-
sendMessage
Unit sendMessage(List<ScatterMessage> messages)
Enqueues multiple Scatterbrain messages to the datastore. The messages will be sent as soon as a peer is available This function requires net.ballmerlabs.scatterroutingservice.permission.ACCESS permission
- Parameters:
messages- message to send
-
sendMessage
Unit sendMessage(ScatterMessage message, UUID identity)
Enqueues a message to the datastore and signs it with a given identity. This function requires net.ballmerlabs.scatterroutingservice.permission.ACCESS permission but the calling package must have accesss to the identity
- Parameters:
message- message to sendidentity- identity to sign with
-
sendMessage
Unit sendMessage(List<ScatterMessage> messages, UUID identity)
Enqueues a list of messages to the datastore and signs it with a given identity. This function requires net.ballmerlabs.scatterroutingservice.permission.ACCESS permission but the calling package must have accesss to the identity
- Parameters:
messages- messages to sendidentity- identity to sign with
-
sendMessage
Unit sendMessage(ScatterMessage message, Identity identity)
Enqueues a message to the datastore and signs it with a given identity. This function requires net.ballmerlabs.scatterroutingservice.permission.ACCESS permission but the calling package must have accesss to the identity
- Parameters:
message- message to sendidentity- identity to sign with
-
sendMessage
Unit sendMessage(List<ScatterMessage> messages, Identity identity)
Enqueues a list of messages to the datastore and signs it with a given identity. This function requires net.ballmerlabs.scatterroutingservice.permission.ACCESS permission but the calling package must have accesss to the identity
- Parameters:
messages- messages to sendidentity- identity to sign with
-
getPackages
List<NamePackage> getPackages()
Gets a list of packages declaring a Scatterbrain compatible BroadcastReceiver. This function requires net.ballmerlabs.scatterroutingservice.permission.SUPERUSER permission and is currently not available to 3rd party applications
-
removeIdentity
Boolean removeIdentity(Identity identity)
Deletes an identity. This function requires net.ballmerlabs.scatterroutingservice.permission.SUPERUSER and is currently not available to 3rd party applications
- Parameters:
identity- identity object
-
getPermissionStatus
PermissionStatus getPermissionStatus()
Gets the current critical permissions granted to the router. This should be used to prompt the user to open Scatterbrain and grant permissions
-
dumpDatastore
Unit dumpDatastore(Uri uri)
-
startDiscover
Unit startDiscover()
Starts active discovery using default transport modules This function requires net.ballmerlabs.scatterroutingservice.permission.ADMIN permission
-
startPassive
Unit startPassive()
Starts passive discovery using the default radio module. This usually uses less power than active discovery for most transport modules but may skip peers that are also in passive mode This function requires net.ballmerlabs.scatterroutingservice.permission.ADMIN permission
-
stopDiscover
Unit stopDiscover()
Stops active discovery This function requires net.ballmerlabs.scatterroutingservice.permission.ADMIN permission
-
stopPassive
Unit stopPassive()
Stops passive discovery This function requires net.ballmerlabs.scatterroutingservice.permission.ADMIN permission
-
register
Unit register()
Unregisters the internal BroadcastReceiver for Scatterbrain events. This must be called to use the Scatterbrain SDK
-
unregister
Unit unregister()
Unregisters Scatterbrain broadcast receivers
-
isConnected
Boolean isConnected()
Checks if this SDK is connected to a running Scatterbrain router
-
observeBinderState
LiveData<BinderWrapper.Companion.BinderState> observeBinderState()
Returns a LiveData providing the current connection state
-
-
-
-