diff options
author | Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de> | 2016-12-12 15:16:39 +0100 |
---|---|---|
committer | Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de> | 2016-12-12 15:16:39 +0100 |
commit | bd9837c3559f8e545bdb6bd4010b0e2d6e6297c4 (patch) | |
tree | 4af1be2ac6814a892f91168089f6d3980bcf6931 /healthd/healthd_mode_charger.cpp | |
parent | 870d7cfb19f49ced89117b403972eef4a05faf08 (diff) | |
parent | 656154a5b4127370f7317852e224a9121c6beed3 (diff) | |
download | system_core-bd9837c3559f8e545bdb6bd4010b0e2d6e6297c4.zip system_core-bd9837c3559f8e545bdb6bd4010b0e2d6e6297c4.tar.gz system_core-bd9837c3559f8e545bdb6bd4010b0e2d6e6297c4.tar.bz2 |
Merge branch 'cm-13.0' of https://github.com/CyanogenMod/android_system_core into replicant-6.0
Diffstat (limited to 'healthd/healthd_mode_charger.cpp')
-rw-r--r-- | healthd/healthd_mode_charger.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/healthd/healthd_mode_charger.cpp b/healthd/healthd_mode_charger.cpp index eb93d6a..6df9f12 100644 --- a/healthd/healthd_mode_charger.cpp +++ b/healthd/healthd_mode_charger.cpp @@ -82,6 +82,10 @@ char *locale; #define BLUE_LED_PATH "/sys/class/leds/blue/brightness" #endif +#ifndef BLINK_PATH +#define BLINK_PATH "/sys/class/leds/red/device/blink" +#endif + #define LOGE(x...) do { KLOG_ERROR("charger", x); } while (0) #define LOGW(x...) do { KLOG_WARNING("charger", x); } while (0) #define LOGV(x...) do { KLOG_DEBUG("charger", x); } while (0) @@ -183,6 +187,7 @@ enum { BLUE_LED = 0x01 << 2, }; +#ifndef NO_CHARGER_LED struct led_ctl { int color; const char *path; @@ -203,6 +208,7 @@ struct soc_led_color_mapping soc_leds[3] = { {90, RED_LED | GREEN_LED}, {100, GREEN_LED}, }; +#endif static struct charger charger_state; static struct healthd_config *healthd_config; @@ -211,6 +217,27 @@ static int char_width; static int char_height; static bool minui_inited; +#ifndef NO_CHARGER_LED +static int set_blink(int val) +{ + int fd; + char buffer[10]; + + fd = open(BLINK_PATH, O_RDWR); + if (fd < 0) { + LOGE("Could not open blink file\n"); + return -1; + } + snprintf(buffer, sizeof(buffer), "%d\n", val); + if (write(fd, buffer, strlen(buffer)) < 0) { + LOGE("Could not write to blink file\n"); + close(fd); + return -1; + } + close(fd); + return 0; +} + static int set_tricolor_led(int on, int color) { int fd, i; @@ -255,8 +282,12 @@ static int set_battery_soc_leds(int soc) LOGV("soc = %d, set led color 0x%x\n", soc, soc_leds[i].color); } + /* This is required to commit the changes to hardware */ + set_blink(0); + return 0; } +#endif /* current time in milliseconds */ static int64_t curr_time_ms(void) @@ -667,14 +698,17 @@ static void handle_input_state(struct charger *charger, int64_t now) static void handle_power_supply_state(struct charger *charger, int64_t now) { +#ifndef NO_CHARGER_LED static int old_soc = 0; int soc = 0; +#endif if (!charger->have_battery_state) return; healthd_board_mode_charger_battery_update(batt_prop); +#ifndef NO_CHARGER_LED if (batt_prop && batt_prop->batteryLevel >= 0) { soc = batt_prop->batteryLevel; } @@ -683,6 +717,7 @@ static void handle_power_supply_state(struct charger *charger, int64_t now) old_soc = soc; set_battery_soc_leds(soc); } +#endif if (!charger->charger_connected) { |