mirror of
https://github.com/team-infusion-developers/android_hardware_samsung.git
synced 2024-11-06 21:55:41 +00:00
Merge pull request #24 from LineageOS/lineage-16.0
hidl: Don't compile setNotificationLED if there is no blink node
This commit is contained in:
commit
39f820b7ff
2 changed files with 22 additions and 15 deletions
|
@ -55,12 +55,14 @@ Light::Light() {
|
||||||
std::bind(&Light::handleBacklight, this, std::placeholders::_1));
|
std::bind(&Light::handleBacklight, this, std::placeholders::_1));
|
||||||
#ifdef BUTTON_BRIGHTNESS_NODE
|
#ifdef BUTTON_BRIGHTNESS_NODE
|
||||||
mLights.emplace(Type::BUTTONS, std::bind(&Light::handleButtons, this, std::placeholders::_1));
|
mLights.emplace(Type::BUTTONS, std::bind(&Light::handleButtons, this, std::placeholders::_1));
|
||||||
#endif
|
#endif /* BUTTON_BRIGHTNESS_NODE */
|
||||||
|
#ifdef LED_BLINK_NODE
|
||||||
mLights.emplace(Type::BATTERY, std::bind(&Light::handleBattery, this, std::placeholders::_1));
|
mLights.emplace(Type::BATTERY, std::bind(&Light::handleBattery, this, std::placeholders::_1));
|
||||||
mLights.emplace(Type::NOTIFICATIONS,
|
mLights.emplace(Type::NOTIFICATIONS,
|
||||||
std::bind(&Light::handleNotifications, this, std::placeholders::_1));
|
std::bind(&Light::handleNotifications, this, std::placeholders::_1));
|
||||||
mLights.emplace(Type::ATTENTION,
|
mLights.emplace(Type::ATTENTION,
|
||||||
std::bind(&Light::handleAttention, this, std::placeholders::_1));
|
std::bind(&Light::handleAttention, this, std::placeholders::_1));
|
||||||
|
#endif /* LED_BLINK_NODE */
|
||||||
}
|
}
|
||||||
|
|
||||||
Return<Status> Light::setLight(Type type, const LightState& state) {
|
Return<Status> Light::setLight(Type type, const LightState& state) {
|
||||||
|
@ -103,6 +105,7 @@ void Light::handleButtons(const LightState& state) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef LED_BLINK_NODE
|
||||||
void Light::handleBattery(const LightState& state) {
|
void Light::handleBattery(const LightState& state) {
|
||||||
mBatteryState = state;
|
mBatteryState = state;
|
||||||
setNotificationLED();
|
setNotificationLED();
|
||||||
|
@ -123,14 +126,14 @@ void Light::setNotificationLED() {
|
||||||
LightState state;
|
LightState state;
|
||||||
#ifdef LED_BLN_NODE
|
#ifdef LED_BLN_NODE
|
||||||
bool bln = false;
|
bool bln = false;
|
||||||
#endif
|
#endif /* LED_BLN_NODE */
|
||||||
|
|
||||||
if (mNotificationState.color & COLOR_MASK) {
|
if (mNotificationState.color & COLOR_MASK) {
|
||||||
adjusted_brightness = LED_BRIGHTNESS_NOTIFICATION;
|
adjusted_brightness = LED_BRIGHTNESS_NOTIFICATION;
|
||||||
state = mNotificationState;
|
state = mNotificationState;
|
||||||
#ifdef LED_BLN_NODE
|
#ifdef LED_BLN_NODE
|
||||||
bln = true;
|
bln = true;
|
||||||
#endif
|
#endif /* LED_BLN_NODE */
|
||||||
} else if (mAttentionState.color & COLOR_MASK) {
|
} else if (mAttentionState.color & COLOR_MASK) {
|
||||||
adjusted_brightness = LED_BRIGHTNESS_ATTENTION;
|
adjusted_brightness = LED_BRIGHTNESS_ATTENTION;
|
||||||
state = mAttentionState;
|
state = mAttentionState;
|
||||||
|
@ -164,9 +167,19 @@ void Light::setNotificationLED() {
|
||||||
if (bln) {
|
if (bln) {
|
||||||
set(LED_BLN_NODE, (state.color & COLOR_MASK) ? 1 : 0);
|
set(LED_BLN_NODE, (state.color & COLOR_MASK) ? 1 : 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* LED_BLN_NODE */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t Light::calibrateColor(uint32_t color, int32_t brightness) {
|
||||||
|
uint32_t red = ((color >> 16) & 0xFF) * LED_ADJUSTMENT_R;
|
||||||
|
uint32_t green = ((color >> 8) & 0xFF) * LED_ADJUSTMENT_G;
|
||||||
|
uint32_t blue = (color & 0xFF) * LED_ADJUSTMENT_B;
|
||||||
|
|
||||||
|
return (((red * brightness) / 255) << 16) + (((green * brightness) / 255) << 8) +
|
||||||
|
((blue * brightness) / 255);
|
||||||
|
}
|
||||||
|
#endif /* LED_BLINK_NODE */
|
||||||
|
|
||||||
Return<void> Light::getSupportedTypes(getSupportedTypes_cb _hidl_cb) {
|
Return<void> Light::getSupportedTypes(getSupportedTypes_cb _hidl_cb) {
|
||||||
std::vector<Type> types;
|
std::vector<Type> types;
|
||||||
|
|
||||||
|
@ -186,15 +199,6 @@ uint32_t Light::rgbToBrightness(const LightState& state) {
|
||||||
8;
|
8;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Light::calibrateColor(uint32_t color, int32_t brightness) {
|
|
||||||
uint32_t red = ((color >> 16) & 0xFF) * LED_ADJUSTMENT_R;
|
|
||||||
uint32_t green = ((color >> 8) & 0xFF) * LED_ADJUSTMENT_G;
|
|
||||||
uint32_t blue = (color & 0xFF) * LED_ADJUSTMENT_B;
|
|
||||||
|
|
||||||
return (((red * brightness) / 255) << 16) + (((green * brightness) / 255) << 8) +
|
|
||||||
((blue * brightness) / 255);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace implementation
|
} // namespace implementation
|
||||||
} // namespace V2_0
|
} // namespace V2_0
|
||||||
} // namespace light
|
} // namespace light
|
||||||
|
|
|
@ -48,17 +48,20 @@ struct Light : public ILight {
|
||||||
void handleBacklight(const LightState& state);
|
void handleBacklight(const LightState& state);
|
||||||
#ifdef BUTTON_BRIGHTNESS_NODE
|
#ifdef BUTTON_BRIGHTNESS_NODE
|
||||||
void handleButtons(const LightState& state);
|
void handleButtons(const LightState& state);
|
||||||
#endif
|
#endif /* BUTTON_BRIGHTNESS_NODE */
|
||||||
|
#ifdef LED_BLINK_NODE
|
||||||
void handleBattery(const LightState& state);
|
void handleBattery(const LightState& state);
|
||||||
void handleNotifications(const LightState& state);
|
void handleNotifications(const LightState& state);
|
||||||
void handleAttention(const LightState& state);
|
void handleAttention(const LightState& state);
|
||||||
void setNotificationLED();
|
void setNotificationLED();
|
||||||
uint32_t rgbToBrightness(const LightState& state);
|
|
||||||
uint32_t calibrateColor(uint32_t color, int32_t brightness);
|
uint32_t calibrateColor(uint32_t color, int32_t brightness);
|
||||||
|
|
||||||
LightState mAttentionState;
|
LightState mAttentionState;
|
||||||
LightState mBatteryState;
|
LightState mBatteryState;
|
||||||
LightState mNotificationState;
|
LightState mNotificationState;
|
||||||
|
#endif /* LED_BLINK_NODE */
|
||||||
|
|
||||||
|
uint32_t rgbToBrightness(const LightState& state);
|
||||||
|
|
||||||
std::mutex mLock;
|
std::mutex mLock;
|
||||||
std::unordered_map<Type, std::function<void(const LightState&)>> mLights;
|
std::unordered_map<Type, std::function<void(const LightState&)>> mLights;
|
||||||
|
|
Loading…
Reference in a new issue