Skip to content

SmartphoneDeviceManager

The device manager for this phone, the primary device.

Always connectable. Supports the data types of all registered SmartphoneSamplingPackages, and reports the phone's battery level.

Inheritance

Constructors

SmartphoneDeviceManager

SmartphoneDeviceManager([
  1. Smartphone? configuration
])

Properties

batteryEvents

Stream<int> get batteryEvents
override

The battery level (0-100) of this hardware device, each time it changes.

Empty by default.

batteryLevel

int get batteryLevel
override

The runtime battery level of this hardware device in percent (0-100). Returns null if unknown.

canConnect

bool get canConnect
override

Determines whether a connection can be made at this point in time to the device.

displayName

String? get displayName
override

A human-readable name for this device, or null if unknown.

supportedDataTypes

Set<DataType> get supportedDataTypes
override

The set of data types defining which data can be collected on this device.

Methods

createRegistration

SmartphoneRegistration createRegistration()
override

Creates a registration of this device for the deployment.

This method is used when a device is connected and a registration for this device is needed in the deployment and hence in the deployment service. The registration is typically created from the device information of the real device, e.g., the ID, name, and BLE address of the smartphone or a connected Bluetooth device.

onConfigure

void onConfigure()
override

Callback on configure.

When called, the configuration and the registration is available.

Is to be overridden in sub-classes. Note, however, that it must not be doing a lot of work on startup.

onConnect

Future<DeviceStatus> onConnect()
override

Callback on connect. Returns the DeviceStatus of the device.

Can be overridden for device-specific connection handling.

onDisconnect

Future<bool> onDisconnect()
override

Callback on disconnect.

This method is called after all sampling on this device has been stopped, and the device manager is trying to disconnect from the real device.

Is to be overridden in sub-classes and implement device-specific disconnection.

onRequestPermissions

Future<void> onRequestPermissions()
override

Callback on requestPermissions.

Can be overridden for device-specific permission handling.