From aae1ce43a45f38b3b4c0fac90e208253fa02ffe6 Mon Sep 17 00:00:00 2001 From: Iliyan Malchev Date: Wed, 5 Dec 2012 15:19:07 -0800 Subject: [PATCH 1/3] libsuspend: compile as a static library Compile libsuspend as a static library as well, currently needed by the charger code in some cases. Related-to-bug: 7429504 Change-Id: I113017c2c855f915b77c76d8934b6e57c0bb532c Signed-off-by: Iliyan Malchev --- libsuspend/Android.mk | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libsuspend/Android.mk b/libsuspend/Android.mk index 45cb70116..a2fa3e0d8 100644 --- a/libsuspend/Android.mk +++ b/libsuspend/Android.mk @@ -12,7 +12,6 @@ libsuspend_libraries := \ liblog libcutils include $(CLEAR_VARS) - LOCAL_SRC_FILES := $(libsuspend_src_files) LOCAL_MODULE := libsuspend LOCAL_MODULE_TAGS := optional @@ -21,3 +20,12 @@ LOCAL_C_INCLUDES += $(LOCAL_PATH)/include LOCAL_SHARED_LIBRARIES := $(libsuspend_libraries) #LOCAL_CFLAGS += -DLOG_NDEBUG=0 include $(BUILD_SHARED_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_SRC_FILES := $(libsuspend_src_files) +LOCAL_MODULE := libsuspend +LOCAL_MODULE_TAGS := optional +LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include +LOCAL_C_INCLUDES += $(LOCAL_PATH)/include +#LOCAL_CFLAGS += -DLOG_NDEBUG=0 +include $(BUILD_STATIC_LIBRARY) From 3493f18985973e35f83b34b737c8fbcb179007c3 Mon Sep 17 00:00:00 2001 From: "choongryeol.lee" Date: Thu, 15 Nov 2012 17:03:03 -0800 Subject: [PATCH 2/3] 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 --- charger/Android.mk | 7 +++++++ charger/charger.c | 25 ++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) 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) LOCAL_CFLAGS := -DCHARGER_DISABLE_INIT_BLANK endif +ifeq ($(strip $(BOARD_CHARGER_ENABLE_SUSPEND)),true) +LOCAL_CFLAGS += -DCHARGER_ENABLE_SUSPEND +endif + LOCAL_MODULE := charger LOCAL_MODULE_TAGS := optional LOCAL_FORCE_STATIC_EXECUTABLE := true @@ -21,6 +25,9 @@ LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_UNSTRIPPED) LOCAL_C_INCLUDES := bootable/recovery LOCAL_STATIC_LIBRARIES := libminui libpixelflinger_static libpng +ifeq ($(strip $(BOARD_CHARGER_ENABLE_SUSPEND)),true) +LOCAL_STATIC_LIBRARIES += libsuspend +endif LOCAL_STATIC_LIBRARIES += libz libstdc++ libcutils libm libc include $(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 @@ #include #include +#ifdef CHARGER_ENABLE_SUSPEND +#include +#endif + #include "minui/minui.h" #ifndef max @@ -352,6 +356,21 @@ static void remove_supply(struct charger *charger, struct power_supply *supply) free(supply); } +#ifdef CHARGER_ENABLE_SUSPEND +static int request_suspend(bool enable) +{ + if (enable) + return autosuspend_enable(); + else + return autosuspend_disable(); +} +#else +static int request_suspend(bool enable) +{ + return 0; +} +#endif + static void parse_uevent(const char *msg, struct uevent *uevent) { uevent->action = ""; @@ -685,6 +704,7 @@ static void update_screen_state(struct charger *charger, int64_t now) charger->next_screen_transition = -1; gr_fb_blank(true); LOGV("[%lld] animation done\n", now); + request_suspend(true); return; } @@ -824,8 +844,10 @@ static void process_key(struct charger *charger, int code, int64_t now) } } else { /* if the power key got released, force screen state cycle */ - if (key->pending) + if (key->pending) { + request_suspend(false); kick_animation(charger->batt_anim); + } } } @@ -843,6 +865,7 @@ static void handle_input_state(struct charger *charger, int64_t now) static void handle_power_supply_state(struct charger *charger, int64_t now) { if (charger->num_supplies_online == 0) { + request_suspend(false); if (charger->next_pwr_check == -1) { charger->next_pwr_check = now + UNPLUGGED_SHUTDOWN_TIME; LOGI("[%lld] device unplugged: shutting down in %lld (@ %lld)\n", From 7d5f33ed55b9511a64d3e73b33366718972f74af Mon Sep 17 00:00:00 2001 From: Devin Kim Date: Fri, 7 Dec 2012 09:25:06 -0800 Subject: [PATCH 3/3] charger: Do not suspend when disconnecting from charger The device should be power off when disconnecting from charger. If the device enter to suspend, the device couldn't handle the power off process. So the device shouldn't suspend to handle the power off at that time Bug: 7429504 Change-Id: I9a0a60e53f315cd83550dc730a33bc7bd464ef67 --- charger/charger.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/charger/charger.c b/charger/charger.c index 25b3b1aaf..353bdf086 100644 --- a/charger/charger.c +++ b/charger/charger.c @@ -704,7 +704,8 @@ static void update_screen_state(struct charger *charger, int64_t now) charger->next_screen_transition = -1; gr_fb_blank(true); LOGV("[%lld] animation done\n", now); - request_suspend(true); + if (charger->num_supplies_online > 0) + request_suspend(true); return; }