summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchoongryeol.lee2012-11-15 19:03:03 -0600
committerThe Android Automerger2013-01-22 23:14:31 -0600
commit3493f18985973e35f83b34b737c8fbcb179007c3 (patch)
tree15bf6956a80149297a12c06e004c50070839d6ae
parentaae1ce43a45f38b3b4c0fac90e208253fa02ffe6 (diff)
downloadplatform-system-core-3493f18985973e35f83b34b737c8fbcb179007c3.tar.gz
platform-system-core-3493f18985973e35f83b34b737c8fbcb179007c3.tar.xz
platform-system-core-3493f18985973e35f83b34b737c8fbcb179007c3.zip
charger: suspend enable in charger mode
To reduce power consumption after charging completion, enable suspend when LCD is turned off. Bug: 7429504 Change-Id: I34731dc392661c9051a20cea74f70d94a8aaeb42 Signed-off-by: Iliyan Malchev <malchev@google.com>
-rw-r--r--charger/Android.mk7
-rw-r--r--charger/charger.c25
2 files changed, 31 insertions, 1 deletions
diff --git a/charger/Android.mk b/charger/Android.mk
index fe0c91d93..02586042f 100644
--- a/charger/Android.mk
+++ b/charger/Android.mk
@@ -12,6 +12,10 @@ ifeq ($(strip $(BOARD_CHARGER_DISABLE_INIT_BLANK)),true)
12LOCAL_CFLAGS := -DCHARGER_DISABLE_INIT_BLANK 12LOCAL_CFLAGS := -DCHARGER_DISABLE_INIT_BLANK
13endif 13endif
14 14
15ifeq ($(strip $(BOARD_CHARGER_ENABLE_SUSPEND)),true)
16LOCAL_CFLAGS += -DCHARGER_ENABLE_SUSPEND
17endif
18
15LOCAL_MODULE := charger 19LOCAL_MODULE := charger
16LOCAL_MODULE_TAGS := optional 20LOCAL_MODULE_TAGS := optional
17LOCAL_FORCE_STATIC_EXECUTABLE := true 21LOCAL_FORCE_STATIC_EXECUTABLE := true
@@ -21,6 +25,9 @@ LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_UNSTRIPPED)
21LOCAL_C_INCLUDES := bootable/recovery 25LOCAL_C_INCLUDES := bootable/recovery
22 26
23LOCAL_STATIC_LIBRARIES := libminui libpixelflinger_static libpng 27LOCAL_STATIC_LIBRARIES := libminui libpixelflinger_static libpng
28ifeq ($(strip $(BOARD_CHARGER_ENABLE_SUSPEND)),true)
29LOCAL_STATIC_LIBRARIES += libsuspend
30endif
24LOCAL_STATIC_LIBRARIES += libz libstdc++ libcutils libm libc 31LOCAL_STATIC_LIBRARIES += libz libstdc++ libcutils libm libc
25 32
26include $(BUILD_EXECUTABLE) 33include $(BUILD_EXECUTABLE)
diff --git a/charger/charger.c b/charger/charger.c
index c5e4ec276..25b3b1aaf 100644
--- a/charger/charger.c
+++ b/charger/charger.c
@@ -41,6 +41,10 @@
41#include <cutils/misc.h> 41#include <cutils/misc.h>
42#include <cutils/uevent.h> 42#include <cutils/uevent.h>
43 43
44#ifdef CHARGER_ENABLE_SUSPEND
45#include <suspend/autosuspend.h>
46#endif
47
44#include "minui/minui.h" 48#include "minui/minui.h"
45 49
46#ifndef max 50#ifndef max
@@ -352,6 +356,21 @@ static void remove_supply(struct charger *charger, struct power_supply *supply)
352 free(supply); 356 free(supply);
353} 357}
354 358
359#ifdef CHARGER_ENABLE_SUSPEND
360static int request_suspend(bool enable)
361{
362 if (enable)
363 return autosuspend_enable();
364 else
365 return autosuspend_disable();
366}
367#else
368static int request_suspend(bool enable)
369{
370 return 0;
371}
372#endif
373
355static void parse_uevent(const char *msg, struct uevent *uevent) 374static void parse_uevent(const char *msg, struct uevent *uevent)
356{ 375{
357 uevent->action = ""; 376 uevent->action = "";
@@ -685,6 +704,7 @@ static void update_screen_state(struct charger *charger, int64_t now)
685 charger->next_screen_transition = -1; 704 charger->next_screen_transition = -1;
686 gr_fb_blank(true); 705 gr_fb_blank(true);
687 LOGV("[%lld] animation done\n", now); 706 LOGV("[%lld] animation done\n", now);
707 request_suspend(true);
688 return; 708 return;
689 } 709 }
690 710
@@ -824,8 +844,10 @@ static void process_key(struct charger *charger, int code, int64_t now)
824 } 844 }
825 } else { 845 } else {
826 /* if the power key got released, force screen state cycle */ 846 /* if the power key got released, force screen state cycle */
827 if (key->pending) 847 if (key->pending) {
848 request_suspend(false);
828 kick_animation(charger->batt_anim); 849 kick_animation(charger->batt_anim);
850 }
829 } 851 }
830 } 852 }
831 853
@@ -843,6 +865,7 @@ static void handle_input_state(struct charger *charger, int64_t now)
843static void handle_power_supply_state(struct charger *charger, int64_t now) 865static void handle_power_supply_state(struct charger *charger, int64_t now)
844{ 866{
845 if (charger->num_supplies_online == 0) { 867 if (charger->num_supplies_online == 0) {
868 request_suspend(false);
846 if (charger->next_pwr_check == -1) { 869 if (charger->next_pwr_check == -1) {
847 charger->next_pwr_check = now + UNPLUGGED_SHUTDOWN_TIME; 870 charger->next_pwr_check = now + UNPLUGGED_SHUTDOWN_TIME;
848 LOGI("[%lld] device unplugged: shutting down in %lld (@ %lld)\n", 871 LOGI("[%lld] device unplugged: shutting down in %lld (@ %lld)\n",