DeviceSamplingPackage
The built-in sampling package for collecting information about the phone and the app.
Registered automatically in the SamplingPackageRegistry. Add a Measure with one of the measure types below to a task in your protocol to use it. All measures use the Smartphone primary device. It collects:
- device info (hardware and operating system information)
- installed app info (name, package name, version, etc.)
- battery level and charging status
- screen events (on/off/unlocked)
- app lifecycle events (inactive, hidden, paused, resumed, detached)
- free memory (physical and virtual)
- local time zone (e.g. "Europe/Copenhagen")
- heartbeat (periodic heartbeat from the device)
Screen events are only available on Android.
protocol.addTaskControl(
ImmediateTrigger(),
BackgroundTask(measures: [
Measure(type: DeviceSamplingPackage.BATTERY_STATE),
Measure(type: DeviceSamplingPackage.SCREEN_EVENT),
]),
phone,
);
- Inheritance
-
- Object
- SamplingPackage
- SmartphoneSamplingPackage
- DeviceSamplingPackage
Constructors
DeviceSamplingPackage
Constants
APPLICATION_INFORMATION
Measure type for collection of basic application information like app name, package name, version, etc.
- One-time measure.
- Uses the Smartphone primary device for data collection.
- No sampling configuration needed.
APP_LIFECYCLE_EVENT
Measure type for app lifecycle state events (inactive, hidden, paused, resumed, detached).
- Event-based measure.
- Uses the Smartphone primary device for data collection.
- No sampling configuration needed.
BATTERY_STATE
Measure type for collection of battery level and charging status.
- Event-based measure.
- Uses the Smartphone primary device for data collection.
- Use IntervalSamplingConfiguration for configuration. Default is 20 seconds interval. Only changes are reported.
DEVICE_INFORMATION
Measure type for collection of basic device information like device name, model, manufacturer, operating system, and hardware profile.
- One-time measure.
- Uses the Smartphone primary device for data collection.
- No sampling configuration needed.
FREE_MEMORY
Measure type for collection of free physical and virtual memory.
- Event-based measure.
- Uses the Smartphone primary device for data collection.
- Use IntervalSamplingConfiguration for configuration. Default is 10 minutes interval.
HEARTBEAT
Measure type for a periodic heartbeat from the phone. Used to calculate sampling coverage over time.
- Event-based measure.
- Uses the Smartphone primary device for data collection.
- Use IntervalSamplingConfiguration for configuration. Default is 15 minutes interval.
SCREEN_EVENT
Measure type for collection of screen events (on/off/unlocked).
- Event-based measure.
- Android only.
- Uses the Smartphone primary device for data collection.
- No sampling configuration needed.
TIMEZONE
Measure type for collection of the time zone of the device. See List of tz database time zones for an overview of timezones.
- One-time measure.
- Uses the Smartphone primary device for data collection.
- No sampling configuration needed.
Properties
samplingSchemes
The default sampling schemes for all dataTypes in this package.
All sampling packages should define a DataTypeSamplingScheme for each data type.
Methods
create
Creates a new Probe of the specified type. Note that type should be one of the dataTypes that this package supports. Returns null if a probe cannot be created for the type.
onRegister
Called when this package is registered in the SamplingPackageRegistry.
Use it to register JSON deserialization functions and data transformers.