summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2020-03-13 20:26:02 +0100
committerJan Altensen <info@stricted.net>2020-03-20 15:39:10 +0100
commiteeb666cf009bb24951ff321aa64ff4938c716ac4 (patch)
tree7134b28bd83d7281b46c3ba3338aad53cd2c8bc0
parentebe41450ebd315a4650d056177d7b87a2ad63c02 (diff)
downloadandroid_hardware_samsung-eeb666cf009bb24951ff321aa64ff4938c716ac4.tar.gz
android_hardware_samsung-eeb666cf009bb24951ff321aa64ff4938c716ac4.tar.bz2
android_hardware_samsung-eeb666cf009bb24951ff321aa64ff4938c716ac4.zip
hidl: Don't compile setNotificationLED if there is no blink node
For example exynos9820 doesn't provide a LED. Change-Id: I745f179fae52816c915833321123c8f49ba0a7d2
-rw-r--r--hidl/light/Light.cpp30
-rw-r--r--hidl/light/Light.h7
2 files changed, 22 insertions, 15 deletions
diff --git a/hidl/light/Light.cpp b/hidl/light/Light.cpp
index 6516dd4..6a105da 100644
--- a/hidl/light/Light.cpp
+++ b/hidl/light/Light.cpp
@@ -56,12 +56,14 @@ Light::Light() {
std::bind(&Light::handleBacklight, this, std::placeholders::_1));
#ifdef BUTTON_BRIGHTNESS_NODE
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::NOTIFICATIONS,
std::bind(&Light::handleNotifications, this, std::placeholders::_1));
mLights.emplace(Type::ATTENTION,
std::bind(&Light::handleAttention, this, std::placeholders::_1));
+#endif /* LED_BLINK_NODE */
}
Return<Status> Light::setLight(Type type, const LightState& state) {
@@ -104,6 +106,7 @@ void Light::handleButtons(const LightState& state) {
}
#endif
+#ifdef LED_BLINK_NODE
void Light::handleBattery(const LightState& state) {
mBatteryState = state;
setNotificationLED();
@@ -124,14 +127,14 @@ void Light::setNotificationLED() {
LightState state;
#ifdef LED_BLN_NODE
bool bln = false;
-#endif
+#endif /* LED_BLN_NODE */
if (mNotificationState.color & COLOR_MASK) {
adjusted_brightness = LED_BRIGHTNESS_NOTIFICATION;
state = mNotificationState;
#ifdef LED_BLN_NODE
bln = true;
-#endif
+#endif /* LED_BLN_NODE */
} else if (mAttentionState.color & COLOR_MASK) {
adjusted_brightness = LED_BRIGHTNESS_ATTENTION;
state = mAttentionState;
@@ -163,8 +166,18 @@ void Light::setNotificationLED() {
if (bln) {
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) {
std::vector<Type> types;
@@ -185,15 +198,6 @@ uint32_t Light::rgbToBrightness(const LightState& state) {
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 V2_0
} // namespace light
diff --git a/hidl/light/Light.h b/hidl/light/Light.h
index b256cc9..a318e15 100644
--- a/hidl/light/Light.h
+++ b/hidl/light/Light.h
@@ -48,17 +48,20 @@ struct Light : public ILight {
void handleBacklight(const LightState& state);
#ifdef BUTTON_BRIGHTNESS_NODE
void handleButtons(const LightState& state);
-#endif
+#endif /* BUTTON_BRIGHTNESS_NODE */
+#ifdef LED_BLINK_NODE
void handleBattery(const LightState& state);
void handleNotifications(const LightState& state);
void handleAttention(const LightState& state);
void setNotificationLED();
- uint32_t rgbToBrightness(const LightState& state);
uint32_t calibrateColor(uint32_t color, int32_t brightness);
LightState mAttentionState;
LightState mBatteryState;
LightState mNotificationState;
+#endif /* LED_BLINK_NODE */
+
+ uint32_t rgbToBrightness(const LightState& state);
std::mutex mLock;
std::unordered_map<Type, std::function<void(const LightState&)>> mLights;