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>
This commit is contained in:
parent
fdf2f33780
commit
dec27f6e11
2 changed files with 31 additions and 1 deletions
|
|
@ -12,6 +12,10 @@ ifeq ($(strip $(BOARD_CHARGER_DISABLE_INIT_BLANK)),true)
|
||||||
LOCAL_CFLAGS := -DCHARGER_DISABLE_INIT_BLANK
|
LOCAL_CFLAGS := -DCHARGER_DISABLE_INIT_BLANK
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(strip $(BOARD_CHARGER_ENABLE_SUSPEND)),true)
|
||||||
|
LOCAL_CFLAGS += -DCHARGER_ENABLE_SUSPEND
|
||||||
|
endif
|
||||||
|
|
||||||
LOCAL_MODULE := charger
|
LOCAL_MODULE := charger
|
||||||
LOCAL_MODULE_TAGS := optional
|
LOCAL_MODULE_TAGS := optional
|
||||||
LOCAL_FORCE_STATIC_EXECUTABLE := true
|
LOCAL_FORCE_STATIC_EXECUTABLE := true
|
||||||
|
|
@ -21,6 +25,9 @@ LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_UNSTRIPPED)
|
||||||
LOCAL_C_INCLUDES := bootable/recovery
|
LOCAL_C_INCLUDES := bootable/recovery
|
||||||
|
|
||||||
LOCAL_STATIC_LIBRARIES := libminui libpixelflinger_static libpng
|
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
|
LOCAL_STATIC_LIBRARIES += libz libstdc++ libcutils libm libc
|
||||||
|
|
||||||
include $(BUILD_EXECUTABLE)
|
include $(BUILD_EXECUTABLE)
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,10 @@
|
||||||
#include <cutils/misc.h>
|
#include <cutils/misc.h>
|
||||||
#include <cutils/uevent.h>
|
#include <cutils/uevent.h>
|
||||||
|
|
||||||
|
#ifdef CHARGER_ENABLE_SUSPEND
|
||||||
|
#include <suspend/autosuspend.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "minui/minui.h"
|
#include "minui/minui.h"
|
||||||
|
|
||||||
#ifndef max
|
#ifndef max
|
||||||
|
|
@ -352,6 +356,21 @@ static void remove_supply(struct charger *charger, struct power_supply *supply)
|
||||||
free(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)
|
static void parse_uevent(const char *msg, struct uevent *uevent)
|
||||||
{
|
{
|
||||||
uevent->action = "";
|
uevent->action = "";
|
||||||
|
|
@ -685,6 +704,7 @@ static void update_screen_state(struct charger *charger, int64_t now)
|
||||||
charger->next_screen_transition = -1;
|
charger->next_screen_transition = -1;
|
||||||
gr_fb_blank(true);
|
gr_fb_blank(true);
|
||||||
LOGV("[%lld] animation done\n", now);
|
LOGV("[%lld] animation done\n", now);
|
||||||
|
request_suspend(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -824,8 +844,10 @@ static void process_key(struct charger *charger, int code, int64_t now)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* if the power key got released, force screen state cycle */
|
/* if the power key got released, force screen state cycle */
|
||||||
if (key->pending)
|
if (key->pending) {
|
||||||
|
request_suspend(false);
|
||||||
kick_animation(charger->batt_anim);
|
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)
|
static void handle_power_supply_state(struct charger *charger, int64_t now)
|
||||||
{
|
{
|
||||||
if (charger->num_supplies_online == 0) {
|
if (charger->num_supplies_online == 0) {
|
||||||
|
request_suspend(false);
|
||||||
if (charger->next_pwr_check == -1) {
|
if (charger->next_pwr_check == -1) {
|
||||||
charger->next_pwr_check = now + UNPLUGGED_SHUTDOWN_TIME;
|
charger->next_pwr_check = now + UNPLUGGED_SHUTDOWN_TIME;
|
||||||
LOGI("[%lld] device unplugged: shutting down in %lld (@ %lld)\n",
|
LOGI("[%lld] device unplugged: shutting down in %lld (@ %lld)\n",
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue