berlna: lights: Restore QCOM notification LED behavior

Change-Id: Idb952c8b91caa03a07f1bac75a1f5126cd87f416
This commit is contained in:
dianlujitao 2022-02-16 13:54:12 +08:00 committed by Andrew Hexen
parent f364528ccf
commit 4ba4469097
No known key found for this signature in database
GPG key ID: 8A690B4B0CD461A2

View file

@ -67,17 +67,30 @@ inline bool IsLit(uint32_t color) {
} }
void ApplyNotificationState(const HwLightState& state) { void ApplyNotificationState(const HwLightState& state) {
auto brightness = RgbaToBrightness(state.color); bool blink = state.flashOnMs > 0 && state.flashOffMs > 0;
bool ok = false;
// Turn off the leds (initially) switch (state.flashMode) {
WriteToFile(CHARGING_ATTR(breath), 0); case FlashMode::HARDWARE:
if (state.flashMode == FlashMode::TIMED && state.flashOnMs > 0 && state.flashOffMs > 0) { ok = WriteToFile(CHARGING_ATTR(breath), blink);
WriteToFile(CHARGING_ATTR(delay_on), state.flashOnMs); // fallback to timed blinking if breath is not supported
WriteToFile(CHARGING_ATTR(delay_off), state.flashOffMs); if (ok) break;
WriteToFile(CHARGING_ATTR(breath), 1); FALLTHROUGH_INTENDED;
} else { case FlashMode::TIMED:
WriteToFile(CHARGING_ATTR(brightness), brightness); ok = WriteToFile(CHARGING_ATTR(delay_off), state.flashOffMs);
ok &= WriteToFile(CHARGING_ATTR(delay_on), state.flashOnMs);
// fallback to constant on if timed blinking is not supported
if (ok) break;
FALLTHROUGH_INTENDED;
case FlashMode::NONE:
default:
ok = WriteToFile(CHARGING_ATTR(brightness), RgbaToBrightness(state.color));
break;
} }
LOG(DEBUG) << __func__ << ": mode=" << toString(state.flashMode) << ", colorRGB=" << std::hex
<< state.color << std::dec << ", onMS=" << state.flashOnMs
<< ", offMS=" << state.flashOffMs << ", ok=" << ok;
} }
} // anonymous namespace } // anonymous namespace