diff options
| author | Georg Veichtlbauer <georg@vware.at> | 2023-05-21 22:31:22 +0200 |
|---|---|---|
| committer | Nolen Johnson <johnsonnolen@gmail.com> | 2023-05-22 14:42:31 +0200 |
| commit | bba76f3d3405644ea2782e5e063542eaea82708f (patch) | |
| tree | a129c6ebb057d21002ce100ba7114ace6655f487 | |
| parent | ce157a48be95aab87841cc94f86e1d049865ff9f (diff) | |
msm8998-common: light: Move path access check out of constructor
Change-Id: I3d906005572cb870692e82acce64518a7c1596a8
| -rw-r--r-- | light/Light.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/light/Light.cpp b/light/Light.cpp index 85797978..c26a1649 100644 --- a/light/Light.cpp +++ b/light/Light.cpp @@ -57,7 +57,6 @@ static int32_t BRIGHTNESS_RAMP[RAMP_STEPS] = {0, 12, 25, 37, 50, 72, 85, 100}; /* * Each value represents a duty percent (0 - 100) for the led pwm. */ -std::string led_path = CHARGING_LED; /* @@ -107,6 +106,7 @@ static std::string getScaledRamp(uint32_t brightness) { static void handleNotification(const LightState& state) { uint32_t alpha, brightness; + std::string led_path = CHARGING_LED; /* * Extract brightness from AARRGGBB. @@ -119,7 +119,13 @@ static void handleNotification(const LightState& state) { */ if (alpha != 0xFF) brightness = (brightness * alpha) / 0xFF; - + + /* Check if path is accessible, if not, use alternative */ + std::ofstream file(led_path + BRIGHTNESS); + if (!file.is_open()) { + led_path = WHITE_LED; + } + /* Disable blinking. */ set(led_path + BLINK, 0); @@ -160,12 +166,6 @@ static std::map<Type, std::function<void(const LightState&)>> lights = { }; Light::Light() { - std::ofstream file(led_path + BRIGHTNESS); - - if (!file.is_open()) { - ALOGE("Switching to WHITE LED"); - led_path = WHITE_LED; - } } Return<Status> Light::setLight(Type type, const LightState& state) { |
