SamplingPackageRegistry
The singleton registry of all SamplingPackages used in an app.
An app registers each external sampling package here at startup, before it configures the SmartPhoneClientManager. The registry then knows which measure types, Probes and devices are available on this phone.
Key points:
- The built-in DeviceSamplingPackage, SensorSamplingPackage and MonitoringSamplingPackage are always registered.
- register also adds the package's data types to CarpDataTypes and its DeviceManager to the DeviceController.
- create makes a new Probe for a measure type; used by the executors.
See the CAMS GitHub repo for an overview of available sampling packages.
SamplingPackageRegistry().register(ContextSamplingPackage());
await SmartPhoneClientManager().configure();
Constructors
SamplingPackageRegistry
Returns the singleton SamplingPackageRegistry.
Properties
dataTypes
The combined list of all data types in all packages.
packages
The registered packages, in registration order.
samplingSchemes
The combined sampling schemes for all measure types in all packages.
Used as the last fallback for a Probe.samplingConfiguration and to find the permissions a measure needs.
Methods
create
Creates a new Probe for the data type.
Asks the first registered package that supports type to create the probe, and sets the probe's Probe.deviceManager to the package's device manager. If more than one package supports type, a warning is logged.
Returns null if no probe is found for type, e.g., when the probe is not available on this OS or its package is not registered.
lookup
- String type
Returns the SamplingPackages that support the data type.
Typically, only one package supports a specific type. However, if more than one package does, all packages are returned. Can be an empty list.
register
- SamplingPackage package
Registers package.
Also adds the package's data types to CarpDataTypes, registers its SamplingPackage.deviceManager in the DeviceController, and calls SamplingPackage.onRegister.