SmartPhoneClientManager class
The singleton SmartPhoneClientManager() is the main entry point for CARP
Mobile Sensing.
Call configure before using this client.
It holds a set of Smartphone studies, which can been added, removed,
started, and stopped via the addStudy, removeStudy, startStudy,
and stopStudy methods.
A SmartPhoneClientManager is also a ChangeNotifier which notifies its
listeners on any changes to its list of studies. The events stream emits
and event when the state of the client changes.
Assuming a protocol as a StudyProtocol, this will configure and run a study
in a client manager:
// Create and configure a client manager for this phone.
await SmartPhoneClientManager().configure();
// Create a study based on a protocol.
await SmartPhoneClientManager().addStudyFromProtocol(protocol);
// Start sampling.
SmartPhoneClientManager().start();
Note that 'starting' a study does not start data collection. Use the methods resume and pause to resume and pause data collection.
- Inheritance
-
- Object
- ClientManager<
Smartphone, DeviceRegistration, SmartphoneStudy> - SmartPhoneClientManager
- Mixed-in types
Constructors
- SmartPhoneClientManager()
-
Get the singleton SmartPhoneClientManager.
factory
Properties
- askForPermissions → bool
-
Will this client manager ask for permission when a new study is deployed?
no setter
- dataCollectorFactory → DeviceDataCollectorFactory?
-
Determines which
DeviceDataCollectorto use to collect data locally on this primary device and this factory is used to createConnectedDeviceDataCollectorinstances for connected devices.no setterinherited - deploymentService → DeploymentService
-
The application service through which study deployments, to be run on
this client, can be managed and retrieved.
no setterinherited
- deviceController → DeviceController
-
no setter
-
events
→ Stream<
ClientManagerState> -
A stream of ClientManagerState events.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- isConfigured → bool
-
Determines whether a
DeviceRegistrationhas been configured for this client, which is necessary to start adding studies.no setterinherited -
measurements
→ Stream<
Measurement> -
The stream of all
Measurements collected by this client manager. This is the aggregation of all measurements collected by the studies running on this client.no setter - notificationController → NotificationManager?
-
The NotificationManager responsible for sending notification on AppTasks.
no setter
- proxy ↔ StudyDeploymentProxy?
-
getter/setter pairinherited
- registration → DeviceRegistration
-
The registration of this client.
no setterinherited
-
repository
→ ClientRepository<
SmartphoneStudy> -
Repository within which the state of this client is stored.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- state ↔ ClientManagerState
-
The runtime state of this client manager.
getter/setter pair
-
studies
→ List<
SmartphoneStudy> -
Get the studies running on this client device.
no setterinherited
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
addStudy(
SmartphoneStudy study) → Future< SmartphoneStudy> -
Add a
studywhich needs to be executed on this client. No deployment is attempted yet.override -
addStudyFromInvitation(
ActiveParticipationInvitation invitation) → Future< SmartphoneStudy> -
Add a study based on an
invitationwhich needs to be executed on this client. -
addStudyFromProtocol(
StudyProtocol protocol, [String? studyDeploymentId]) → Future< SmartphoneStudy> -
Create and add a study based on the
protocolwhich needs to be executed on this client. -
configure(
{DeviceRegistration? registration, DeploymentService? deploymentService, DeviceDataCollectorFactory? dataCollectorFactory, bool enableNotifications = true, bool enableBackgroundMode = true, String? backgroundNotificationTitle, String? backgroundNotificationText, bool askForPermissions = true}) → Future< void> -
Configure this SmartPhoneClientManager.
override
-
dispose(
) → void -
Called when this client is disposed. Will dispose all studies running
in this client.
override
-
getStudy(
String studyDeploymentId, String deviceRoleName) → SmartphoneStudy? -
Get the study with
studyDeploymentIdanddeviceRoleNamefrom this client manager. Returns null if no such study has been added.inherited -
getStudyController(
SmartphoneStudy study) → SmartphoneStudyController? -
Get the study controller for a
study. If a study controller is not available, a fresh controller will be created. -
getStudyDeploymentStatus(
SmartphoneStudy study) → Future< StudyDeploymentStatus?> -
Get the deployment status for the
studyfrom the deployment service. This updates the study's deployment status and sets the study's status accordingly. Returns null if the deployment status could not be retrieved from the deployment service or if the study has not been added to this client manager.inherited -
getStudyStatusList(
) → List< StudyStatus> -
Get the status for the studies which run on this client device.
Note that is the current status, and reflects the latest known status.
If you want an updated status from the deployment service, use
getStudyDeploymentStatusfor each study.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
pause(
) → void - Pause data sampling in all studies in this client manager.
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
removeStudy(
String studyDeploymentId, String deviceRoleName) → Future< void> -
Remove the study with
studyDeploymentIdanddeviceRoleNamefrom this client manager.override -
resume(
) → void - Resume data sampling in all studies in this client manager.
-
start(
) → void - Start data sampling in all studies in this client manager.
-
startStudy(
String studyDeploymentId, String deviceRoleName) → Future< void> -
Start the study with
studyDeploymentIdanddeviceRoleNamefrom this client manager. -
stopStudy(
String studyDeploymentId, String deviceRoleName) → Future< StudyStatus> -
Permanently stop collecting data for the study with id
studyDeploymentIdand mark it as stopped.override -
toString(
) → String -
A string representation of this object.
inherited
-
tryDeployment(
String studyDeploymentId, String deviceRoleName) → Future< StudyStatus> -
Verifies whether the device is ready for deployment of the study runtime
identified by
studyDeploymentIdanddeviceRoleName, and in case it is, deploys. In case already deployed, nothing happens and the status of the deployment is returned.inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited