20 #include "LegacyLights.h" 21 #include <QtCore/QDebug> 24 #include "android-hardware.h" 28 LegacyLights::~LegacyLights()
31 hw_device_t* device = (hw_device_t*) m_lightDevice;
32 device->close(device);
36 bool LegacyLights::init()
45 err = hw_get_module(LIGHTS_HARDWARE_MODULE_ID, (hw_module_t
const**)&module);
48 err = module->methods->open(module, LIGHT_ID_NOTIFICATIONS, &device);
50 m_lightDevice = (light_device_t*)device;
54 qWarning() <<
"Failed to access notification lights";
57 qWarning() <<
"Failed to initialize lights hardware.";
62 void LegacyLights::turnOn()
66 memset(&state, 0,
sizeof(light_state_t));
67 state.color = m_color.rgba();
68 state.flashMode = LIGHT_FLASH_TIMED;
69 state.flashOnMS = m_onMs;
70 state.flashOffMS = m_offMs;
71 state.brightnessMode = BRIGHTNESS_MODE_USER;
73 if (m_lightDevice->set_light(m_lightDevice, &state) != 0) {
74 qWarning() <<
"Failed to turn the light off";
78 void LegacyLights::turnOff()
81 memset(&state, 0,
sizeof(light_state_t));
82 state.color = 0x00000000;
83 state.flashMode = LIGHT_FLASH_NONE;
86 state.brightnessMode = 0;
88 if (m_lightDevice->set_light(m_lightDevice, &state) != 0) {
89 qWarning() <<
"Failed to turn the light off";