diff --git a/example/lib/l10n/app_en.arb b/example/lib/l10n/app_en.arb index 2647a5f..2b16cb3 100644 --- a/example/lib/l10n/app_en.arb +++ b/example/lib/l10n/app_en.arb @@ -1,4 +1,24 @@ { + "@_SENSORS_PLUS": {}, + "sensorsPlusTitleOrientation": "Orientation", + "sensorsPlusTitleAccelerometer": "Accelerometer", + "sensorsPlusTitleCompass": "Compass", + "sensorsPlusTitleTap": "Tap", + "sensorsPlusTitleALS": "ALS", + "sensorsPlusTitleProximity": "Proximity", + "sensorsPlusTitleGyroscope": "Gyroscope", + "sensorsPlusTitleMagnetometer": "Magnetometer", + "sensorsPlusNotFound": "Sensor not found", + "sensorsPlusSubtitle": "Sensor key: {name}", + "@sensorsPlusSubtitle": { + "placeholders": { + "name": { + "type": "String", + "example": "orientationsensor" + } + } + }, + "@_PROVIDER": {}, "providerTitle": "Provider", "providerSubtitle": "Simple example use provider package", diff --git a/example/lib/l10n/app_ru.arb b/example/lib/l10n/app_ru.arb index b8bd5e4..326f2bc 100644 --- a/example/lib/l10n/app_ru.arb +++ b/example/lib/l10n/app_ru.arb @@ -1,4 +1,24 @@ { + "@_SENSORS_PLUS": {}, + "sensorsPlusTitleOrientation": "Ориентация", + "sensorsPlusTitleAccelerometer": "Акселерометр", + "sensorsPlusTitleCompass": "Компас", + "sensorsPlusTitleTap": "Нажмите", + "sensorsPlusTitleALS": "ALS", + "sensorsPlusTitleProximity": "Датчик приближения", + "sensorsPlusTitleGyroscope": "Гироскоп", + "sensorsPlusTitleMagnetometer": "Магнитометр", + "sensorsPlusNotFound": "Датчик не найден", + "sensorsPlusSubtitle": "Ключ датчика: {name}", + "@sensorsPlusSubtitle": { + "placeholders": { + "name": { + "type": "String", + "example": "orientationsensor" + } + } + }, + "@_PROVIDER": {}, "providerTitle": "Provider", "providerSubtitle": "Простой пример использования пакета provider", diff --git a/example/lib/packages/flutter_keyboard_visibility/page.dart b/example/lib/packages/flutter_keyboard_visibility/page.dart index 59f9a37..fa22dcd 100644 --- a/example/lib/packages/flutter_keyboard_visibility/page.dart +++ b/example/lib/packages/flutter_keyboard_visibility/page.dart @@ -99,7 +99,7 @@ class _FlutterKeyboardVisibilityPageState title: l10n.flutterKeyboardVisibilityTitleHeight, desc: l10n.flutterKeyboardVisibilityDescHeight, value: _keyboardHeight, - builder: (value) => value.toInt().toString(), + builder: (value) => value?.toInt().toString(), ), ), const SizedBox(height: 20), diff --git a/example/lib/packages/sensors_plus/page.dart b/example/lib/packages/sensors_plus/page.dart index 427bb33..7304772 100644 --- a/example/lib/packages/sensors_plus/page.dart +++ b/example/lib/packages/sensors_plus/page.dart @@ -5,10 +5,15 @@ import 'package:flutter_example_packages/base/di/app_di.dart'; import 'package:flutter_example_packages/base/package/package.dart'; import 'package:flutter_example_packages/widgets/base/export.dart'; import 'package:flutter_example_packages/widgets/blocks/block_info_package.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_item.dart'; import 'package:flutter_example_packages/widgets/layouts/block_layout.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:sensors_plus/sensors_plus.dart'; -import 'package:sensors_plus_aurora/orientation_event.dart'; +import 'package:sensors_plus_aurora/events/als_event.dart'; +import 'package:sensors_plus_aurora/events/compass_event.dart'; +import 'package:sensors_plus_aurora/events/orientation_event.dart'; +import 'package:sensors_plus_aurora/events/proximity_event.dart'; +import 'package:sensors_plus_aurora/events/tap_event.dart'; import 'package:sensors_plus_aurora/sensors_plus_aurora.dart'; import 'model.dart'; @@ -26,42 +31,59 @@ class SensorsPlusPage extends AppStatefulWidget { } class _SensorsPlusPageState extends AppState { - OrientationEvent orientation = OrientationEvent.undefined; - AccelerometerEvent accelerometer = AccelerometerEvent(0, 0, 0); + Stream? _orientationEvents; + Stream? _accelerometerEvents; + Stream? _compassEvents; + Stream? _tapEvents; + Stream? _alsEvents; + Stream? _proximityEvents; + Stream? _gyroscopeEvents; + Stream? _magnetometerEvents; @override void initState() { super.initState(); - /// Accelerometer change - accelerometerEvents.listen( - (AccelerometerEvent event) { - if (mounted) { - setState(() { - accelerometer = event; - }); - } - }, - onError: (error) { - debugPrint(error.toString()); - }, - cancelOnError: true, - ); - - /// Only Aurora OS orientation change - orientationEvents?.listen( - (OrientationEvent event) { - if (mounted) { - setState(() { - orientation = event; - }); - } - }, - onError: (error) { - debugPrint(error.toString()); - }, - cancelOnError: true, - ); + try { + _orientationEvents = orientationEvents; + } catch (e) { + debugPrint(e.toString()); + } + try { + _accelerometerEvents = accelerometerEvents; + } catch (e) { + debugPrint(e.toString()); + } + try { + _compassEvents = compassEvents; + } catch (e) { + debugPrint(e.toString()); + } + try { + _tapEvents = tapEvents; + } catch (e) { + debugPrint(e.toString()); + } + try { + _alsEvents = alsEvents; + } catch (e) { + debugPrint(e.toString()); + } + try { + _proximityEvents = proximityEvents; + } catch (e) { + debugPrint(e.toString()); + } + try { + _gyroscopeEvents = gyroscopeEvents; + } catch (e) { + debugPrint(e.toString()); + } + try { + _magnetometerEvents = magnetometerEvents; + } catch (e) { + debugPrint(e.toString()); + } } @override @@ -81,12 +103,101 @@ class _SensorsPlusPageState extends AppState { crossAxisAlignment: CrossAxisAlignment.start, children: [ BlockInfoPackage(widget.package), - Center( - child: Text('Orientation: $orientation'), + Visibility( + visible: _orientationEvents != null, + child: BlockItem( + isShowProgress: false, + title: l10n.sensorsPlusTitleOrientation, + desc: l10n.sensorsPlusSubtitle('orientationsensor'), + stream: _orientationEvents, + builder: (value) => value == null + ? l10n.sensorsPlusNotFound + : value.toString(), + ), + ), + Visibility( + visible: _accelerometerEvents != null, + child: BlockItem( + isShowProgress: false, + title: l10n.sensorsPlusTitleAccelerometer, + desc: l10n.sensorsPlusSubtitle('accelerometersensor'), + stream: _accelerometerEvents, + builder: (value) => value == null + ? l10n.sensorsPlusNotFound + : value.toString(), + ), + ), + Visibility( + visible: _compassEvents != null, + child: BlockItem( + isShowProgress: false, + title: l10n.sensorsPlusTitleCompass, + desc: l10n.sensorsPlusSubtitle('compasssensor'), + stream: _compassEvents, + builder: (value) => value == null + ? l10n.sensorsPlusNotFound + : value.toString(), + ), + ), + Visibility( + visible: _tapEvents != null, + child: BlockItem( + isShowProgress: false, + title: l10n.sensorsPlusTitleTap, + desc: l10n.sensorsPlusSubtitle('tapsensor'), + stream: _tapEvents, + builder: (value) => value == null + ? l10n.sensorsPlusNotFound + : value.toString(), + ), + ), + Visibility( + visible: _alsEvents != null, + child: BlockItem( + isShowProgress: false, + title: l10n.sensorsPlusTitleALS, + desc: l10n.sensorsPlusSubtitle('alssensor'), + stream: _alsEvents, + builder: (value) => value == null + ? l10n.sensorsPlusNotFound + : value.toString(), + ), + ), + Visibility( + visible: _proximityEvents != null, + child: BlockItem( + isShowProgress: false, + title: l10n.sensorsPlusTitleProximity, + desc: l10n.sensorsPlusSubtitle('proximitysensor'), + stream: _proximityEvents, + builder: (value) => value == null + ? l10n.sensorsPlusNotFound + : value.toString(), + ), + ), + Visibility( + visible: _gyroscopeEvents != null, + child: BlockItem( + isShowProgress: false, + title: l10n.sensorsPlusTitleGyroscope, + desc: l10n.sensorsPlusSubtitle('rotationsensor'), + stream: _gyroscopeEvents, + builder: (value) => value == null + ? l10n.sensorsPlusNotFound + : value.toString(), + ), ), - const SizedBox(height: 20,), - Center( - child: Text('Accelerometer: $accelerometer'), + Visibility( + visible: _magnetometerEvents != null, + child: BlockItem( + isShowProgress: false, + title: l10n.sensorsPlusTitleMagnetometer, + desc: l10n.sensorsPlusSubtitle('magnetometersensor'), + stream: _magnetometerEvents, + builder: (value) => value == null + ? l10n.sensorsPlusNotFound + : value.toString(), + ), ), ], ), diff --git a/example/lib/packages/translator/page.dart b/example/lib/packages/translator/page.dart index 7d2fafd..eb75e5d 100644 --- a/example/lib/packages/translator/page.dart +++ b/example/lib/packages/translator/page.dart @@ -45,7 +45,7 @@ class _TranslatorPageState extends AppState { title: l10n.translatorTitle, desc: l10n.translatorSubtitle, future: model.translate(l10n.translatorText), - builder: (value) => value.text, + builder: (value) => value?.text, ), ], ), diff --git a/example/lib/widgets/blocks/block_item.dart b/example/lib/widgets/blocks/block_item.dart index 57fe8ad..042ddab 100644 --- a/example/lib/widgets/blocks/block_item.dart +++ b/example/lib/widgets/blocks/block_item.dart @@ -15,6 +15,7 @@ class BlockItem extends AppStatelessWidget { this.future, this.stream, this.builder, + this.isShowProgress = true, }); final String? title; @@ -22,7 +23,8 @@ class BlockItem extends AppStatelessWidget { final T? value; final Stream? stream; final Future? future; - final Function(T)? builder; + final Function(T?)? builder; + final bool isShowProgress; AsyncWidgetBuilder get widgetBuilder => (BuildContext context, AsyncSnapshot snapshot) { @@ -47,14 +49,14 @@ class BlockItem extends AppStatelessWidget { ], ), ), - if (snapshot.hasData) + if (!isShowProgress) TextBodyMedium( builder == null ? snapshot.data.toString() - : builder?.call(snapshot.data as T), + : builder?.call(snapshot.data), fontWeight: FontWeight.bold, ), - if (!snapshot.hasData) + if (isShowProgress) const SizedBox( width: 16, height: 16, diff --git a/packages/sensors_plus/sensors_plus_aurora/README.md b/packages/sensors_plus/sensors_plus_aurora/README.md index 6bcd18c..b004c18 100644 --- a/packages/sensors_plus/sensors_plus_aurora/README.md +++ b/packages/sensors_plus/sensors_plus_aurora/README.md @@ -12,11 +12,119 @@ Therefore, you have to include `sensors_plus_aurora` alongside `sensors_plus` as ```yaml dependencies: sensors_plus: ^3.0.2 - sensors_plus_aurora: ^0.0.0 # @todo Not published + sensors_plus_aurora: + path: # path to folder with plugin +``` + +## Features + +- accelerometerEvents - A broadcast stream of events from the device accelerometer. +- gyroscopeEvents - A broadcast stream of events from the device gyroscope. +- magnetometerEvents - A broadcast stream of events from the device magnetometer. +- orientationEvents - A broadcast stream of events from the Aurora OS device orientation. +- compassEvents - A broadcast stream of events from the Aurora OS device compass. +- tapEvents - A broadcast stream of events from the Aurora OS device tap. +- alsEvents - A broadcast stream of events from the Aurora OS device ALS. +- proximityEvents - A broadcast stream of events from the Aurora OS device proximity. + +***.dart** + +```spec +BuildRequires: pkgconfig(sensord-qt5) ``` ***.dart** ```dart -// @todo +import 'package:sensors_plus/sensors_plus.dart'; +import 'package:sensors_plus_aurora/events/als_event.dart'; +import 'package:sensors_plus_aurora/events/compass_event.dart'; +import 'package:sensors_plus_aurora/events/orientation_event.dart'; +import 'package:sensors_plus_aurora/events/proximity_event.dart'; +import 'package:sensors_plus_aurora/events/tap_event.dart'; +import 'package:sensors_plus_aurora/sensors_plus_aurora.dart'; + +/// Package sensors_plus +/// +/// A broadcast stream of events from the device accelerometer. +accelerometerEvents.listen( + (AccelerometerEvent event) { + debugPrint(event.toString()); + }, + onError: (error) { + debugPrint(error.toString()); + } +); + +/// A broadcast stream of events from the device gyroscope. +gyroscopeEvents.listen( + (GyroscopeEvent event) { + debugPrint(event.toString()); + }, + onError: (error) { + debugPrint(error.toString()); + } +); + +/// A broadcast stream of events from the device magnetometer. +magnetometerEvents.listen( + (MagnetometerEvent event) { + debugPrint(event.toString()); + }, + onError: (error) { + debugPrint(error.toString()); + } +); + +/// Custom Aurora OS events +/// +/// A broadcast stream of events from the Aurora OS device orientation. +orientationEvents?.listen( + (OrientationEvent event) { + debugPrint(event.toString()); + }, + onError: (error) { + debugPrint(error.toString()); + } +); + +/// A broadcast stream of events from the Aurora OS device compass. +compassEvents?.listen( + (CompassEvent event) { + debugPrint(event.toString()); + }, + onError: (error) { + debugPrint(error.toString()); + } +); + +/// A broadcast stream of events from the Aurora OS device tap. +tapEvents?.listen( + (TapEvent event) { + debugPrint(event.toString()); + }, + onError: (error) { + debugPrint(error.toString()); + } +); + +/// A broadcast stream of events from the Aurora OS device ALS. +alsEvents?.listen( + (ALSEvent event) { + debugPrint(event.toString()); + }, + onError: (error) { + debugPrint(error.toString()); + } +); + +/// A broadcast stream of events from the Aurora OS device proximity. +proximityEvents?.listen( + (ProximityEvent event) { + debugPrint(event.toString()); + }, + onError: (error) { + debugPrint(error.toString()); + } +); ``` diff --git a/packages/sensors_plus/sensors_plus_aurora/aurora/include/sensors_plus_aurora/sensors_plus_aurora_plugin.h b/packages/sensors_plus/sensors_plus_aurora/aurora/include/sensors_plus_aurora/sensors_plus_aurora_plugin.h index 2e121ab..e7cc98c 100644 --- a/packages/sensors_plus/sensors_plus_aurora/aurora/include/sensors_plus_aurora/sensors_plus_aurora_plugin.h +++ b/packages/sensors_plus/sensors_plus_aurora/aurora/include/sensors_plus_aurora/sensors_plus_aurora_plugin.h @@ -11,13 +11,19 @@ #include -#include -#include +#include +#include #include +#include +#include +#include +#include +#include +#include class PLUGIN_EXPORT SensorsPlusAuroraPlugin final - : public QObject - , public PluginInterface + : public QObject, + public PluginInterface { Q_OBJECT @@ -25,19 +31,54 @@ public: void RegisterWithRegistrar(PluginRegistrar ®istrar) override; public slots: - void eventSensorOrientation(const Unsigned &data); - void eventSensorAccelerometer(const XYZ& data); + void EventSensorOrientation(const Unsigned &data); + void EventSensorAccelerometer(const XYZ &data); + void EventSensorCompass(const Compass &data); + void EventSensorTap(const Tap &data); + void EventSensorALS(const Unsigned &data); + void EventSensorProximity(const Proximity &data); + void EventSensorRotation(const XYZ &data); + void EventSensorMagnetometer(const MagneticField &data); private: - void onMethodCall(const MethodCall &call); - void onListenSensorOrientation(); - void onListenSensorAccelerometer(); - void unimplemented(const MethodCall &call); + template + bool RegisterSensorInterface(QString sensor); + void EventChannelNull(std::string channel); + void EventChannelData(std::string channel, std::vector result); + + void EnableSensorOrientation(); + void DisableSensorOrientation(); + + void EnableSensorAccelerometer(); + void DisableSensorAccelerometer(); + + void EnableSensorCompass(); + void DisableSensorCompass(); + + void EnableSensorTap(); + void DisableSensorTap(); + + void EnableSensorALS(); + void DisableSensorALS(); + + void EnableSensorProximity(); + void DisableSensorProximity(); + + void EnableSensorRotation(); + void DisableSensorRotation(); + + void EnableSensorMagnetometer(); + void DisableSensorMagnetometer(); private: - bool m_isSendSensorOrientation = false; - bool m_isSendSensorAccelerometer = false; - AbstractSensorChannelInterface *m_iface = nullptr; + OrientationSensorChannelInterface *m_ifaceOrientation = nullptr; + AccelerometerSensorChannelInterface *m_ifaceAccelerometer = nullptr; + CompassSensorChannelInterface *m_ifaceCompass = nullptr; + TapSensorChannelInterface *m_ifaceTap = nullptr; + ALSSensorChannelInterface *m_ifaceALS = nullptr; + ProximitySensorChannelInterface *m_ifaceProximity = nullptr; + RotationSensorChannelInterface *m_ifaceRotation = nullptr; + MagnetometerSensorChannelInterface *m_ifaceMagnetometer = nullptr; }; #endif /* FLUTTER_PLUGIN_SENSORS_PLUS_AURORA_PLUGIN_H */ diff --git a/packages/sensors_plus/sensors_plus_aurora/aurora/sensors_plus_aurora_plugin.cpp b/packages/sensors_plus/sensors_plus_aurora/aurora/sensors_plus_aurora_plugin.cpp index 8aced7e..225ab74 100644 --- a/packages/sensors_plus/sensors_plus_aurora/aurora/sensors_plus_aurora_plugin.cpp +++ b/packages/sensors_plus/sensors_plus_aurora/aurora/sensors_plus_aurora_plugin.cpp @@ -10,164 +10,515 @@ #include #include #include +#include +#include +#include +#include +#include +#include + +namespace KeyChannel +{ + constexpr auto Orientation = "sensors_plus_aurora_orientationsensor"; + constexpr auto Accelerometer = "sensors_plus_aurora_accelerometersensor"; + constexpr auto Compass = "sensors_plus_aurora_compasssensor"; + constexpr auto Tap = "sensors_plus_aurora_tapsensor"; + constexpr auto ALS = "sensors_plus_aurora_alssensor"; + constexpr auto Proximity = "sensors_plus_aurora_proximitysensor"; + constexpr auto Rotation = "sensors_plus_aurora_rotationsensor"; + constexpr auto Magnetometer = "sensors_plus_aurora_magnetometersensor"; +} -static AbstractSensorChannelInterface *ifaceOrientation; -static AbstractSensorChannelInterface *ifaceAccelerometer; +namespace KeySensor +{ + constexpr auto Orientation = "orientationsensor"; + constexpr auto Accelerometer = "accelerometersensor"; + constexpr auto Compass = "compasssensor"; + constexpr auto Tap = "tapsensor"; + constexpr auto ALS = "alssensor"; + constexpr auto Proximity = "proximitysensor"; + constexpr auto Rotation = "rotationsensor"; + constexpr auto Magnetometer = "magnetometersensor"; +} /* namespace */ -namespace { +void SensorsPlusAuroraPlugin::RegisterWithRegistrar(PluginRegistrar ®istrar) +{ + registrar.RegisterEventChannel( + KeyChannel::Orientation, MethodCodecType::Standard, + [this](const Encodable &) + { EnableSensorOrientation(); return EventResponse(); }, + [this](const Encodable &) + { DisableSensorOrientation(); return EventResponse(); }); + + registrar.RegisterEventChannel( + KeyChannel::Accelerometer, MethodCodecType::Standard, + [this](const Encodable &) + { EnableSensorAccelerometer(); return EventResponse(); }, + [this](const Encodable &) + { DisableSensorAccelerometer(); return EventResponse(); }); + + registrar.RegisterEventChannel( + KeyChannel::Compass, MethodCodecType::Standard, + [this](const Encodable &) + { EnableSensorCompass(); return EventResponse(); }, + [this](const Encodable &) + { DisableSensorCompass(); return EventResponse(); }); + + registrar.RegisterEventChannel( + KeyChannel::Tap, MethodCodecType::Standard, + [this](const Encodable &) + { EnableSensorTap(); return EventResponse(); }, + [this](const Encodable &) + { DisableSensorTap(); return EventResponse(); }); + + registrar.RegisterEventChannel( + KeyChannel::ALS, MethodCodecType::Standard, + [this](const Encodable &) + { EnableSensorALS(); return EventResponse(); }, + [this](const Encodable &) + { DisableSensorALS(); return EventResponse(); }); + + registrar.RegisterEventChannel( + KeyChannel::Proximity, MethodCodecType::Standard, + [this](const Encodable &) + { EnableSensorProximity(); return EventResponse(); }, + [this](const Encodable &) + { DisableSensorProximity(); return EventResponse(); }); + + registrar.RegisterEventChannel( + KeyChannel::Rotation, MethodCodecType::Standard, + [this](const Encodable &) + { EnableSensorRotation(); return EventResponse(); }, + [this](const Encodable &) + { DisableSensorRotation(); return EventResponse(); }); + + registrar.RegisterEventChannel( + KeyChannel::Magnetometer, MethodCodecType::Standard, + [this](const Encodable &) + { EnableSensorMagnetometer(); return EventResponse(); }, + [this](const Encodable &) + { DisableSensorMagnetometer(); return EventResponse(); }); +} -constexpr auto METHOD_LISTEN_SENSOR = "listenSensor"; +template +bool SensorsPlusAuroraPlugin::RegisterSensorInterface(QString sensor) +{ + SensorManagerInterface &sm = SensorManagerInterface::instance(); + if (!sm.isValid()) + { + return false; + } -} /* namespace */ + QDBusReply reply(sm.loadPlugin(sensor)); + if (!reply.isValid() || !reply.value()) + { + return false; + } -void SensorsPlusAuroraPlugin::RegisterWithRegistrar(PluginRegistrar ®istrar) + sm.registerSensorInterface(sensor); + + return true; +} + +void SensorsPlusAuroraPlugin::EventChannelNull(std::string channel) +{ + EventChannel(channel, MethodCodecType::Standard).SendEvent(nullptr); +} + +void SensorsPlusAuroraPlugin::EventChannelData(std::string channel, std::vector result) +{ + EventChannel(channel, MethodCodecType::Standard).SendEvent(result); +} + +/** + * Orientation + */ +void SensorsPlusAuroraPlugin::EnableSensorOrientation() +{ + if (m_ifaceOrientation == nullptr) + { + if (!RegisterSensorInterface(KeySensor::Orientation)) + { + EventChannelNull(KeyChannel::Orientation); + return; + } + + m_ifaceOrientation = OrientationSensorChannelInterface::interface(KeySensor::Orientation); + + if (!m_ifaceOrientation) + { + EventChannelNull(KeyChannel::Orientation); + return; + } + + connect(m_ifaceOrientation, + SIGNAL(orientationChanged(const Unsigned &)), + this, + SLOT(EventSensorOrientation(const Unsigned &))); + } + + m_ifaceOrientation->start(); + EventSensorOrientation(m_ifaceOrientation->orientation()); +} + +void SensorsPlusAuroraPlugin::DisableSensorOrientation() { - registrar.RegisterMethodChannel("sensors_plus_aurora", - MethodCodecType::Standard, - [this](const MethodCall &call) { this->onMethodCall(call); }); - - registrar.RegisterEventChannel( - "sensors_aurora_orientation", - MethodCodecType::Standard, - [this](const Encodable &) - { - this->m_isSendSensorOrientation = true; - onListenSensorOrientation(); - return EventResponse(); - }, - [this](const Encodable &) - { - this->m_isSendSensorOrientation = false; - return EventResponse(); - }); - - registrar.RegisterEventChannel( - "sensors_aurora_accelerometer", - MethodCodecType::Standard, - [this](const Encodable &) - { - this->m_isSendSensorAccelerometer = true; - onListenSensorAccelerometer(); - return EventResponse(); - }, - [this](const Encodable &) - { - this->m_isSendSensorAccelerometer = false; - return EventResponse(); - }); -} - -void SensorsPlusAuroraPlugin::onMethodCall(const MethodCall &call) -{ - const auto &method = call.GetMethod(); - - if (method == "listenSensor") { - // onListenSensor(); + if (m_ifaceOrientation == nullptr) + { return; } - unimplemented(call); + m_ifaceOrientation->stop(); +} + +void SensorsPlusAuroraPlugin::EventSensorOrientation(const Unsigned &data) +{ + std::vector result; + result.push_back(data.x()); + EventChannelData(KeyChannel::Orientation, result); } -void SensorsPlusAuroraPlugin::onListenSensorOrientation() +/** + * Accelerometer + */ +void SensorsPlusAuroraPlugin::EnableSensorAccelerometer() { - if (ifaceOrientation != nullptr) { + if (m_ifaceAccelerometer == nullptr) + { + if (!RegisterSensorInterface(KeySensor::Accelerometer)) + { + EventChannelNull(KeyChannel::Accelerometer); + return; + } + + m_ifaceAccelerometer = AccelerometerSensorChannelInterface::interface(KeySensor::Accelerometer); + + if (!m_ifaceAccelerometer) + { + EventChannelNull(KeyChannel::Accelerometer); + return; + } + + connect(m_ifaceAccelerometer, + SIGNAL(dataAvailable(const XYZ &)), + this, + SLOT(EventSensorAccelerometer(const XYZ &))); + } + + m_ifaceAccelerometer->start(); + EventSensorAccelerometer(m_ifaceAccelerometer->get()); +} + +void SensorsPlusAuroraPlugin::DisableSensorAccelerometer() +{ + if (m_ifaceAccelerometer == nullptr) + { return; } - SensorManagerInterface &sm = SensorManagerInterface::instance(); - if (!sm.isValid()) { - qDebug() << "Failed to create SensorManagerInterface"; - exit(0); + m_ifaceAccelerometer->stop(); +} + +void SensorsPlusAuroraPlugin::EventSensorAccelerometer(const XYZ &data) +{ + std::vector result; + result.push_back(data.x()); + result.push_back(data.y()); + result.push_back(data.z()); + EventChannelData(KeyChannel::Accelerometer, result); +} + +/** + * Compass + */ +void SensorsPlusAuroraPlugin::EnableSensorCompass() +{ + if (m_ifaceCompass == nullptr) + { + if (!RegisterSensorInterface(KeySensor::Compass)) + { + EventChannelNull(KeyChannel::Compass); + return; + } + + m_ifaceCompass = CompassSensorChannelInterface::interface(KeySensor::Compass); + + if (!m_ifaceCompass) + { + EventChannelNull(KeyChannel::Compass); + return; + } + + connect(m_ifaceCompass, + SIGNAL(dataAvailable(const Compass &)), + this, + SLOT(EventSensorCompass(const Compass &))); } - QDBusReply reply(sm.loadPlugin("orientationsensor")); - if (!reply.isValid() || !reply.value()) { - qDebug() << "Failed to load plugin"; - exit(0); + m_ifaceCompass->start(); + EventSensorCompass(m_ifaceCompass->get()); +} + +void SensorsPlusAuroraPlugin::DisableSensorCompass() +{ + if (m_ifaceCompass == nullptr) + { + return; } - sm.registerSensorInterface("orientationsensor"); + m_ifaceCompass->stop(); +} - ifaceOrientation = OrientationSensorChannelInterface::interface("orientationsensor"); +void SensorsPlusAuroraPlugin::EventSensorCompass(const Compass &data) +{ + std::vector result; + result.push_back(data.degrees()); + result.push_back(data.level()); + EventChannelData(KeyChannel::Compass, result); +} - if (!ifaceOrientation) { - qDebug() << "Cannot get OrientationSensorChannelInterface"; - exit(0); +/** + * Tap + */ +void SensorsPlusAuroraPlugin::EnableSensorTap() +{ + if (m_ifaceTap == nullptr) + { + if (!RegisterSensorInterface(KeySensor::Tap)) + { + EventChannelNull(KeyChannel::Tap); + return; + } + + m_ifaceTap = TapSensorChannelInterface::interface(KeySensor::Tap); + + if (!m_ifaceTap) + { + EventChannelNull(KeyChannel::Tap); + return; + } + + connect(m_ifaceTap, + SIGNAL(dataAvailable(const Tap &)), + this, + SLOT(EventSensorTap(const Tap &))); } - connect(ifaceOrientation, - SIGNAL(orientationChanged(const Unsigned&)), - this, - SLOT(eventSensorOrientation(const Unsigned&)) - ); + m_ifaceTap->start(); +} + +void SensorsPlusAuroraPlugin::DisableSensorTap() +{ + if (m_ifaceTap == nullptr) + { + return; + } + + m_ifaceTap->stop(); +} - ifaceOrientation->start(); +void SensorsPlusAuroraPlugin::EventSensorTap(const Tap &data) +{ + std::vector result; + result.push_back(static_cast(data.direction())); + result.push_back(static_cast(data.type())); + EventChannelData(KeyChannel::Tap, result); } -void SensorsPlusAuroraPlugin::eventSensorOrientation(const Unsigned &data) +/** + * ALS + */ +void SensorsPlusAuroraPlugin::EnableSensorALS() { - if (this->m_isSendSensorOrientation) + if (m_ifaceALS == nullptr) { - EventChannel("sensors_aurora_orientation", MethodCodecType::Standard) - .SendEvent(data.x()); + if (!RegisterSensorInterface(KeySensor::ALS)) + { + EventChannelNull(KeyChannel::ALS); + return; + } + + m_ifaceALS = ALSSensorChannelInterface::interface(KeySensor::ALS); + + if (!m_ifaceALS) + { + EventChannelNull(KeyChannel::ALS); + return; + } + + connect(m_ifaceALS, + SIGNAL(ALSChanged(const Unsigned &)), + this, + SLOT(EventSensorALS(const Unsigned &))); } + + m_ifaceALS->start(); + EventSensorALS(m_ifaceALS->lux()); } -void SensorsPlusAuroraPlugin::onListenSensorAccelerometer() +void SensorsPlusAuroraPlugin::DisableSensorALS() { - if (ifaceAccelerometer != nullptr) { + if (m_ifaceALS == nullptr) + { return; } - SensorManagerInterface &sm = SensorManagerInterface::instance(); - if (!sm.isValid()) { - qDebug() << "Failed to create SensorManagerInterface"; - exit(0); + m_ifaceALS->stop(); +} + +void SensorsPlusAuroraPlugin::EventSensorALS(const Unsigned &data) +{ + std::vector result; + result.push_back(data.x()); + EventChannelData(KeyChannel::ALS, result); +} + +/** + * Proximity + */ +void SensorsPlusAuroraPlugin::EnableSensorProximity() +{ + if (m_ifaceProximity == nullptr) + { + if (!RegisterSensorInterface(KeySensor::Proximity)) + { + EventChannelNull(KeyChannel::Proximity); + return; + } + + m_ifaceProximity = ProximitySensorChannelInterface::interface(KeySensor::Proximity); + + if (!m_ifaceProximity) + { + EventChannelNull(KeyChannel::Proximity); + return; + } + + connect(m_ifaceProximity, + SIGNAL(reflectanceDataAvailable(const Proximity &)), + this, + SLOT(EventSensorProximity(const Proximity &))); } - QDBusReply reply(sm.loadPlugin("accelerometersensor")); - if (!reply.isValid() || !reply.value()) { - qDebug() << "Failed to load plugin"; - exit(0); + m_ifaceProximity->start(); + EventSensorProximity(m_ifaceProximity->proximityReflectance()); +} + +void SensorsPlusAuroraPlugin::DisableSensorProximity() +{ + if (m_ifaceProximity == nullptr) + { + return; } - sm.registerSensorInterface("accelerometersensor"); + m_ifaceProximity->stop(); +} - ifaceAccelerometer = AccelerometerSensorChannelInterface::interface("accelerometersensor"); +void SensorsPlusAuroraPlugin::EventSensorProximity(const Proximity &data) +{ + std::vector result; + result.push_back(data.withinProximity() ? 1 : 0); + EventChannelData(KeyChannel::Proximity, result); +} - if (!ifaceAccelerometer) { - qDebug() << "Cannot get AccelerometerSensorChannelInterface"; - exit(0); +/** + * Rotation + */ +void SensorsPlusAuroraPlugin::EnableSensorRotation() +{ + if (m_ifaceRotation == nullptr) + { + if (!RegisterSensorInterface(KeySensor::Rotation)) + { + EventChannelNull(KeyChannel::Rotation); + return; + } + + m_ifaceRotation = RotationSensorChannelInterface::interface(KeySensor::Rotation); + + if (!m_ifaceRotation) + { + EventChannelNull(KeyChannel::Rotation); + return; + } + + connect(m_ifaceRotation, + SIGNAL(dataAvailable(const XYZ &)), + this, + SLOT(EventSensorRotation(const XYZ &))); } - connect(ifaceAccelerometer, - SIGNAL(dataAvailable(const XYZ&)), - this, - SLOT(eventSensorAccelerometer(const XYZ&)) - ); + m_ifaceRotation->start(); + EventSensorRotation(m_ifaceRotation->rotation()); +} - ifaceAccelerometer->start(); +void SensorsPlusAuroraPlugin::DisableSensorRotation() +{ + if (m_ifaceRotation == nullptr) + { + return; + } + + m_ifaceRotation->stop(); } -void SensorsPlusAuroraPlugin::eventSensorAccelerometer(const XYZ& data) +void SensorsPlusAuroraPlugin::EventSensorRotation(const XYZ &data) +{ + std::vector result; + result.push_back(data.x()); + result.push_back(data.y()); + result.push_back(data.z()); + EventChannelData(KeyChannel::Rotation, result); +} + +/** + * Magnetometer + */ +void SensorsPlusAuroraPlugin::EnableSensorMagnetometer() { - if (this->m_isSendSensorAccelerometer) + if (m_ifaceMagnetometer == nullptr) { - std::vector result; + if (!RegisterSensorInterface(KeySensor::Magnetometer)) + { + EventChannelNull(KeyChannel::Magnetometer); + return; + } + + m_ifaceMagnetometer = MagnetometerSensorChannelInterface::interface(KeySensor::Magnetometer); + + if (!m_ifaceMagnetometer) + { + EventChannelNull(KeyChannel::Magnetometer); + return; + } + + connect(m_ifaceMagnetometer, + SIGNAL(dataAvailable(const MagneticField &)), + this, + SLOT(EventSensorMagnetometer(const MagneticField &))); + } - result.push_back(data.x()); - result.push_back(data.y()); - result.push_back(data.z()); + m_ifaceMagnetometer->start(); + EventSensorMagnetometer(m_ifaceMagnetometer->magneticField()); +} - EventChannel("sensors_aurora_accelerometer", MethodCodecType::Standard) - .SendEvent(result); +void SensorsPlusAuroraPlugin::DisableSensorMagnetometer() +{ + if (m_ifaceMagnetometer == nullptr) + { + return; } + + m_ifaceMagnetometer->stop(); } -void SensorsPlusAuroraPlugin::unimplemented(const MethodCall &call) +void SensorsPlusAuroraPlugin::EventSensorMagnetometer(const MagneticField &data) { - call.SendSuccessResponse(nullptr); + std::vector result; + result.push_back(data.x()); + result.push_back(data.y()); + result.push_back(data.z()); + EventChannelData(KeyChannel::Magnetometer, result); } #include "moc_sensors_plus_aurora_plugin.cpp" diff --git a/packages/sensors_plus/sensors_plus_aurora/lib/events/als_event.dart b/packages/sensors_plus/sensors_plus_aurora/lib/events/als_event.dart new file mode 100644 index 0000000..c23368c --- /dev/null +++ b/packages/sensors_plus/sensors_plus_aurora/lib/events/als_event.dart @@ -0,0 +1,11 @@ +// SPDX-FileCopyrightText: Copyright 2023 Open Mobile Platform LLC +// SPDX-License-Identifier: BSD-3-Clause + +class ALSEvent { + ALSEvent(this.degrees); + + final int degrees; + + @override + String toString() => '[ALSEvent (degrees: $degrees)]'; +} diff --git a/packages/sensors_plus/sensors_plus_aurora/lib/events/compass_event.dart b/packages/sensors_plus/sensors_plus_aurora/lib/events/compass_event.dart new file mode 100644 index 0000000..9e42086 --- /dev/null +++ b/packages/sensors_plus/sensors_plus_aurora/lib/events/compass_event.dart @@ -0,0 +1,13 @@ +// SPDX-FileCopyrightText: Copyright 2023 Open Mobile Platform LLC +// SPDX-License-Identifier: BSD-3-Clause + +class CompassEvent { + CompassEvent(this.degrees, this.level); + + final int degrees; + + final int level; + + @override + String toString() => '[CompassEvent (degrees: $degrees, level: $level)]'; +} diff --git a/packages/sensors_plus/sensors_plus_aurora/lib/orientation_event.dart b/packages/sensors_plus/sensors_plus_aurora/lib/events/orientation_event.dart similarity index 98% rename from packages/sensors_plus/sensors_plus_aurora/lib/orientation_event.dart rename to packages/sensors_plus/sensors_plus_aurora/lib/events/orientation_event.dart index 8ba764f..3b743da 100644 --- a/packages/sensors_plus/sensors_plus_aurora/lib/orientation_event.dart +++ b/packages/sensors_plus/sensors_plus_aurora/lib/events/orientation_event.dart @@ -4,16 +4,22 @@ enum OrientationEvent { /// The orientation is unknown. undefined, + /// The Top edge of the device is pointing up. topUp, + /// The Top edge of the device is pointing down. topDown, + /// The Left edge of the device is pointing up. leftUp, + /// The Right edge of the device is pointing up. rightUp, + /// The Face of the device is pointing up. faceUp, + /// The Face of the device is pointing down. faceDown } diff --git a/packages/sensors_plus/sensors_plus_aurora/lib/events/proximity_event.dart b/packages/sensors_plus/sensors_plus_aurora/lib/events/proximity_event.dart new file mode 100644 index 0000000..ffda18c --- /dev/null +++ b/packages/sensors_plus/sensors_plus_aurora/lib/events/proximity_event.dart @@ -0,0 +1,11 @@ +// SPDX-FileCopyrightText: Copyright 2023 Open Mobile Platform LLC +// SPDX-License-Identifier: BSD-3-Clause + +class ProximityEvent { + ProximityEvent(this.withinProximity); + + final bool withinProximity; + + @override + String toString() => '[ProximityEvent (withinProximity: $withinProximity)]'; +} diff --git a/packages/sensors_plus/sensors_plus_aurora/lib/events/tap_event.dart b/packages/sensors_plus/sensors_plus_aurora/lib/events/tap_event.dart new file mode 100644 index 0000000..df4e031 --- /dev/null +++ b/packages/sensors_plus/sensors_plus_aurora/lib/events/tap_event.dart @@ -0,0 +1,53 @@ +// SPDX-FileCopyrightText: Copyright 2023 Open Mobile Platform LLC +// SPDX-License-Identifier: BSD-3-Clause + +/// Direction of tap. The last six directions may not be supported +/// depending on hardware. +enum TapDirection { + /// Left or right side tapped + x, + + /// Top or down side tapped + y, + + /// Face or bottom tapped + z, + + /// Tapped from left to right + leftRight, + + /// Tapped from right to left + rightLeft, + + /// Tapped from top to bottom + topBottom, + + /// Tapped from bottom to top + bottomTop, + + /// Tapped from face to back + faceBack, + + /// Tapped from back to face + backFace +} + +/// Type of tap. +enum TapType { + /// Double tap + doubleTap, + + /// Single tap. + singleTap +} + +class TapEvent { + TapEvent(this.direction, this.type); + + final TapDirection direction; + + final TapType type; + + @override + String toString() => '[TapEvent (direction: $direction, level: $type)]'; +} diff --git a/packages/sensors_plus/sensors_plus_aurora/lib/sensors_plus_aurora.dart b/packages/sensors_plus/sensors_plus_aurora/lib/sensors_plus_aurora.dart index 98dd33f..05776f3 100644 --- a/packages/sensors_plus/sensors_plus_aurora/lib/sensors_plus_aurora.dart +++ b/packages/sensors_plus/sensors_plus_aurora/lib/sensors_plus_aurora.dart @@ -2,7 +2,11 @@ // SPDX-License-Identifier: BSD-3-Clause import 'package:flutter/foundation.dart'; -import 'package:sensors_plus_aurora/orientation_event.dart'; +import 'package:sensors_plus_aurora/events/als_event.dart'; +import 'package:sensors_plus_aurora/events/compass_event.dart'; +import 'package:sensors_plus_aurora/events/orientation_event.dart'; +import 'package:sensors_plus_aurora/events/proximity_event.dart'; +import 'package:sensors_plus_aurora/events/tap_event.dart'; import 'package:sensors_plus_platform_interface/sensors_plus_platform_interface.dart'; import 'sensors_plus_aurora_platform_interface.dart'; @@ -15,15 +19,75 @@ Stream? get orientationEvents { return null; } +/// A broadcast stream of events from the Aurora OS device compass. +Stream? get compassEvents { + if (TargetPlatform.aurora == defaultTargetPlatform) { + return SensorsPlusAurora().onChangeCompass; + } + return null; +} + +/// A broadcast stream of events from the Aurora OS device tap. +Stream? get tapEvents { + if (TargetPlatform.aurora == defaultTargetPlatform) { + return SensorsPlusAurora().onChangeTap; + } + return null; +} + +/// A broadcast stream of events from the Aurora OS device ALS. +Stream? get alsEvents { + if (TargetPlatform.aurora == defaultTargetPlatform) { + return SensorsPlusAurora().onChangeALS; + } + return null; +} + +/// A broadcast stream of events from the Aurora OS device proximity. +Stream? get proximityEvents { + if (TargetPlatform.aurora == defaultTargetPlatform) { + return SensorsPlusAurora().onChangeProximity; + } + return null; +} + class SensorsPlusAurora extends SensorsPlatform { static void registerWith() { SensorsPlatform.instance = SensorsPlusAurora(); } + /// orientationsensor Stream get onChangeOrientation => SensorsPlusAuroraPlatform.instance.onChangeOrientation(); + /// accelerometersensor @override Stream get accelerometerEvents => SensorsPlusAuroraPlatform.instance.onChangeAccelerometer(); + + /// compasssensor + Stream get onChangeCompass => + SensorsPlusAuroraPlatform.instance.onChangeCompass(); + + /// tapsensor + Stream get onChangeTap => + SensorsPlusAuroraPlatform.instance.onChangeTap(); + + /// alssensor + Stream get onChangeALS => + SensorsPlusAuroraPlatform.instance.onChangeALS(); + + /// proximitysensor + Stream get onChangeProximity => + SensorsPlusAuroraPlatform.instance.onChangeProximity(); + + /// rotationsensor + @override + Stream get gyroscopeEvents => + SensorsPlusAuroraPlatform.instance.onChangeRotation(); + + /// magnetometersensor + @override + Stream get magnetometerEvents => + SensorsPlusAuroraPlatform.instance.onChangeMagnetometer(); } diff --git a/packages/sensors_plus/sensors_plus_aurora/lib/sensors_plus_aurora_method_channel.dart b/packages/sensors_plus/sensors_plus_aurora/lib/sensors_plus_aurora_method_channel.dart index c1cf24a..dae0a05 100644 --- a/packages/sensors_plus/sensors_plus_aurora/lib/sensors_plus_aurora_method_channel.dart +++ b/packages/sensors_plus/sensors_plus_aurora/lib/sensors_plus_aurora_method_channel.dart @@ -3,7 +3,11 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; -import 'package:sensors_plus_aurora/orientation_event.dart'; +import 'package:sensors_plus_aurora/events/als_event.dart'; +import 'package:sensors_plus_aurora/events/compass_event.dart'; +import 'package:sensors_plus_aurora/events/orientation_event.dart'; +import 'package:sensors_plus_aurora/events/proximity_event.dart'; +import 'package:sensors_plus_aurora/events/tap_event.dart'; import 'package:sensors_plus_platform_interface/sensors_plus_platform_interface.dart'; import 'sensors_plus_aurora_platform_interface.dart'; @@ -14,12 +18,20 @@ class MethodChannelSensorsPlusAurora extends SensorsPlusAuroraPlatform { @visibleForTesting final methodChannel = const MethodChannel('sensors_plus_aurora'); + List _loadData(dynamic data, String key) { + if (data == null) { + throw "Failed to load sensor '$key'"; + } + + return (data as List).map((e) => int.parse(e.toString())).toList(); + } + @override Stream onChangeOrientation() async* { - await for (final event in const EventChannel('sensors_aurora_orientation') - .receiveBroadcastStream()) { - int result = (event as int?) ?? 0; - switch (result) { + await for (final data + in const EventChannel('sensors_plus_aurora_orientationsensor') + .receiveBroadcastStream()) { + switch (_loadData(data, 'orientationsensor')[0]) { case 1: yield OrientationEvent.rightUp; break; @@ -46,13 +58,90 @@ class MethodChannelSensorsPlusAurora extends SensorsPlusAuroraPlatform { @override Stream onChangeAccelerometer() async* { - await for (final event in const EventChannel('sensors_aurora_accelerometer') - .receiveBroadcastStream()) { - final list = (event as List); + await for (final data + in const EventChannel('sensors_plus_aurora_accelerometersensor') + .receiveBroadcastStream()) { + final result = _loadData(data, 'accelerometersensor'); yield AccelerometerEvent( - (list[0] as int?)?.toDouble() ?? 0, - (list[1] as int?)?.toDouble() ?? 0, - (list[2] as int?)?.toDouble() ?? 0, + result[0].toDouble(), + result[1].toDouble(), + result[2].toDouble(), + ); + } + } + + @override + Stream onChangeCompass() async* { + await for (final data + in const EventChannel('sensors_plus_aurora_compasssensor') + .receiveBroadcastStream()) { + final result = _loadData(data, 'compasssensor'); + yield CompassEvent( + result[0], + result[1], + ); + } + } + + @override + Stream onChangeTap() async* { + await for (final data in const EventChannel('sensors_plus_aurora_tapsensor') + .receiveBroadcastStream()) { + final result = _loadData(data, 'tapsensor'); + yield TapEvent( + TapDirection.values[result[0]], + TapType.values[result[1]], + ); + } + } + + @override + Stream onChangeALS() async* { + await for (final data in const EventChannel('sensors_plus_aurora_alssensor') + .receiveBroadcastStream()) { + final result = _loadData(data, 'alssensor'); + yield ALSEvent( + result[0], + ); + } + } + + @override + Stream onChangeProximity() async* { + await for (final data + in const EventChannel('sensors_plus_aurora_proximitysensor') + .receiveBroadcastStream()) { + final result = _loadData(data, 'proximitysensor'); + yield ProximityEvent( + result[0] == 1, + ); + } + } + + @override + Stream onChangeRotation() async* { + await for (final data + in const EventChannel('sensors_plus_aurora_rotationsensor') + .receiveBroadcastStream()) { + final result = _loadData(data, 'rotationsensor'); + yield GyroscopeEvent( + result[0].toDouble(), + result[1].toDouble(), + result[2].toDouble(), + ); + } + } + + @override + Stream onChangeMagnetometer() async* { + await for (final data + in const EventChannel('sensors_plus_aurora_magnetometersensor') + .receiveBroadcastStream()) { + final result = _loadData(data, 'magnetometersensor'); + yield MagnetometerEvent( + result[0].toDouble(), + result[1].toDouble(), + result[2].toDouble(), ); } } diff --git a/packages/sensors_plus/sensors_plus_aurora/lib/sensors_plus_aurora_platform_interface.dart b/packages/sensors_plus/sensors_plus_aurora/lib/sensors_plus_aurora_platform_interface.dart index 9ccb897..859ed25 100644 --- a/packages/sensors_plus/sensors_plus_aurora/lib/sensors_plus_aurora_platform_interface.dart +++ b/packages/sensors_plus/sensors_plus_aurora/lib/sensors_plus_aurora_platform_interface.dart @@ -2,7 +2,11 @@ // SPDX-License-Identifier: BSD-3-Clause import 'package:plugin_platform_interface/plugin_platform_interface.dart'; -import 'package:sensors_plus_aurora/orientation_event.dart'; +import 'package:sensors_plus_aurora/events/als_event.dart'; +import 'package:sensors_plus_aurora/events/compass_event.dart'; +import 'package:sensors_plus_aurora/events/orientation_event.dart'; +import 'package:sensors_plus_aurora/events/proximity_event.dart'; +import 'package:sensors_plus_aurora/events/tap_event.dart'; import 'package:sensors_plus_platform_interface/sensors_plus_platform_interface.dart'; import 'sensors_plus_aurora_method_channel.dart'; @@ -35,4 +39,28 @@ abstract class SensorsPlusAuroraPlatform extends PlatformInterface { Stream onChangeAccelerometer() { throw UnimplementedError('onChangeAccelerometer() has not been implemented.'); } + + Stream onChangeCompass() { + throw UnimplementedError('onChangeCompass() has not been implemented.'); + } + + Stream onChangeTap() { + throw UnimplementedError('onChangeTap() has not been implemented.'); + } + + Stream onChangeALS() { + throw UnimplementedError('onChangeALS() has not been implemented.'); + } + + Stream onChangeProximity() { + throw UnimplementedError('onChangeProximity() has not been implemented.'); + } + + Stream onChangeRotation() { + throw UnimplementedError('onChangeRotation() has not been implemented.'); + } + + Stream onChangeMagnetometer() { + throw UnimplementedError('onChangeMagnetometer() has not been implemented.'); + } }