healthd: charger use runtime sysprops instead.
Bug: 124118169 Test: run off-mode charging Change-Id: Ib71f84f1c93d1566f4e3101920d98b1d39184390
This commit is contained in:
parent
dcbaeef6e3
commit
97eecdc875
12 changed files with 97 additions and 26 deletions
|
|
@ -110,3 +110,10 @@ cc_library_static {
|
||||||
"libutils",
|
"libutils",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sysprop_library {
|
||||||
|
name: "charger_sysprop",
|
||||||
|
srcs: ["charger.sysprop"],
|
||||||
|
property_owner: "Platform",
|
||||||
|
api_packages: ["android.sysprop"],
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ include $(CLEAR_VARS)
|
||||||
LOCAL_MODULE := libhealthd_draw
|
LOCAL_MODULE := libhealthd_draw
|
||||||
|
|
||||||
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
|
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
|
||||||
LOCAL_STATIC_LIBRARIES := libminui
|
LOCAL_STATIC_LIBRARIES := libcharger_sysprop libminui
|
||||||
LOCAL_SHARED_LIBRARIES := libbase
|
LOCAL_SHARED_LIBRARIES := libbase
|
||||||
LOCAL_SRC_FILES := healthd_draw.cpp
|
LOCAL_SRC_FILES := healthd_draw.cpp
|
||||||
|
|
||||||
|
|
@ -52,6 +52,7 @@ LOCAL_EXPORT_C_INCLUDE_DIRS := \
|
||||||
LOCAL_STATIC_LIBRARIES := \
|
LOCAL_STATIC_LIBRARIES := \
|
||||||
android.hardware.health@2.0-impl \
|
android.hardware.health@2.0-impl \
|
||||||
android.hardware.health@1.0-convert \
|
android.hardware.health@1.0-convert \
|
||||||
|
libcharger_sysprop \
|
||||||
libhealthstoragedefault \
|
libhealthstoragedefault \
|
||||||
libhealthd_draw \
|
libhealthd_draw \
|
||||||
libminui \
|
libminui \
|
||||||
|
|
@ -83,14 +84,12 @@ LOCAL_MODULE := charger
|
||||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
|
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
|
||||||
|
|
||||||
LOCAL_CFLAGS := -Werror
|
LOCAL_CFLAGS := -Werror
|
||||||
ifeq ($(strip $(LOCAL_CHARGER_NO_UI)),true)
|
|
||||||
LOCAL_CFLAGS += -DCHARGER_NO_UI
|
|
||||||
endif
|
|
||||||
|
|
||||||
CHARGER_STATIC_LIBRARIES := \
|
CHARGER_STATIC_LIBRARIES := \
|
||||||
android.hardware.health@2.0-impl \
|
android.hardware.health@2.0-impl \
|
||||||
android.hardware.health@1.0-convert \
|
android.hardware.health@1.0-convert \
|
||||||
libbinderthreadstate \
|
libbinderthreadstate \
|
||||||
|
libcharger_sysprop \
|
||||||
libhidltransport \
|
libhidltransport \
|
||||||
libhidlbase \
|
libhidlbase \
|
||||||
libhwbinder_noltopgo \
|
libhwbinder_noltopgo \
|
||||||
|
|
@ -141,8 +140,7 @@ LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/bin
|
||||||
LOCAL_MODULE_STEM := charger
|
LOCAL_MODULE_STEM := charger
|
||||||
|
|
||||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
|
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
|
||||||
LOCAL_CFLAGS := -Wall -Werror
|
LOCAL_CFLAGS := -Wall -Werror -DCHARGER_FORCE_NO_UI=1
|
||||||
LOCAL_CFLAGS += -DCHARGER_NO_UI
|
|
||||||
|
|
||||||
# charger.recovery doesn't link against libhealthd_{charger,draw} or libminui, since it doesn't need
|
# charger.recovery doesn't link against libhealthd_{charger,draw} or libminui, since it doesn't need
|
||||||
# any UI support.
|
# any UI support.
|
||||||
|
|
@ -150,6 +148,7 @@ LOCAL_STATIC_LIBRARIES := \
|
||||||
android.hardware.health@2.0-impl \
|
android.hardware.health@2.0-impl \
|
||||||
android.hardware.health@1.0-convert \
|
android.hardware.health@1.0-convert \
|
||||||
libbinderthreadstate \
|
libbinderthreadstate \
|
||||||
|
libcharger_sysprop \
|
||||||
libhidltransport \
|
libhidltransport \
|
||||||
libhidlbase \
|
libhidlbase \
|
||||||
libhwbinder_noltopgo \
|
libhwbinder_noltopgo \
|
||||||
|
|
@ -176,7 +175,7 @@ include $(BUILD_EXECUTABLE)
|
||||||
include $(CLEAR_VARS)
|
include $(CLEAR_VARS)
|
||||||
LOCAL_MODULE := charger_test
|
LOCAL_MODULE := charger_test
|
||||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
|
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
|
||||||
LOCAL_CFLAGS := -Wall -Werror -DCHARGER_NO_UI
|
LOCAL_CFLAGS := -Wall -Werror
|
||||||
LOCAL_STATIC_LIBRARIES := $(CHARGER_STATIC_LIBRARIES)
|
LOCAL_STATIC_LIBRARIES := $(CHARGER_STATIC_LIBRARIES)
|
||||||
LOCAL_SHARED_LIBRARIES := $(CHARGER_SHARED_LIBRARIES)
|
LOCAL_SHARED_LIBRARIES := $(CHARGER_SHARED_LIBRARIES)
|
||||||
LOCAL_SRC_FILES := \
|
LOCAL_SRC_FILES := \
|
||||||
|
|
|
||||||
1
healthd/api/current.txt
Normal file
1
healthd/api/current.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
// Signature format: 2.0
|
||||||
1
healthd/api/removed.txt
Normal file
1
healthd/api/removed.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
// Signature format: 2.0
|
||||||
1
healthd/api/system-current.txt
Normal file
1
healthd/api/system-current.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
// Signature format: 2.0
|
||||||
1
healthd/api/system-removed.txt
Normal file
1
healthd/api/system-removed.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
// Signature format: 2.0
|
||||||
1
healthd/api/test-current.txt
Normal file
1
healthd/api/test-current.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
// Signature format: 2.0
|
||||||
1
healthd/api/test-removed.txt
Normal file
1
healthd/api/test-removed.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
// Signature format: 2.0
|
||||||
|
|
@ -14,13 +14,18 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "charger.sysprop.h"
|
||||||
#include "healthd_mode_charger.h"
|
#include "healthd_mode_charger.h"
|
||||||
#include "healthd_mode_charger_nops.h"
|
#include "healthd_mode_charger_nops.h"
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
#ifndef CHARGER_FORCE_NO_UI
|
||||||
#ifdef CHARGER_NO_UI
|
#define CHARGER_FORCE_NO_UI 0
|
||||||
return healthd_charger_nops(argc, argv);
|
|
||||||
#else
|
|
||||||
return healthd_charger_main(argc, argv);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int main(int argc, char** argv) {
|
||||||
|
if (CHARGER_FORCE_NO_UI || android::sysprop::ChargerProperties::no_ui().value_or(false)) {
|
||||||
|
return healthd_charger_nops(argc, argv);
|
||||||
|
} else {
|
||||||
|
return healthd_charger_main(argc, argv);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
38
healthd/charger.sysprop
Normal file
38
healthd/charger.sysprop
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
owner: Platform
|
||||||
|
module: "android.sysprop.ChargerProperties"
|
||||||
|
|
||||||
|
prop {
|
||||||
|
api_name: "draw_split_screen"
|
||||||
|
type: Boolean
|
||||||
|
prop_name: "ro.charger.draw_split_screen"
|
||||||
|
scope: Internal
|
||||||
|
access: Readonly
|
||||||
|
}
|
||||||
|
prop {
|
||||||
|
api_name: "draw_split_offset"
|
||||||
|
type: Long
|
||||||
|
prop_name: "ro.charger.draw_split_offset"
|
||||||
|
scope: Internal
|
||||||
|
access: Readonly
|
||||||
|
}
|
||||||
|
prop {
|
||||||
|
api_name: "disable_init_blank"
|
||||||
|
type: Boolean
|
||||||
|
prop_name: "ro.charger.disable_init_blank"
|
||||||
|
scope: Internal
|
||||||
|
access: Readonly
|
||||||
|
}
|
||||||
|
prop {
|
||||||
|
api_name: "enable_suspend"
|
||||||
|
type: Boolean
|
||||||
|
prop_name: "ro.charger.enable_suspend"
|
||||||
|
scope: Internal
|
||||||
|
access: Readonly
|
||||||
|
}
|
||||||
|
prop {
|
||||||
|
api_name: "no_ui"
|
||||||
|
type: Boolean
|
||||||
|
prop_name: "ro.charger.no_ui"
|
||||||
|
scope: Internal
|
||||||
|
access: Readonly
|
||||||
|
}
|
||||||
|
|
@ -18,15 +18,34 @@
|
||||||
#include <batteryservice/BatteryService.h>
|
#include <batteryservice/BatteryService.h>
|
||||||
#include <cutils/klog.h>
|
#include <cutils/klog.h>
|
||||||
|
|
||||||
|
#include "charger.sysprop.h"
|
||||||
#include "healthd_draw.h"
|
#include "healthd_draw.h"
|
||||||
|
|
||||||
#define LOGE(x...) KLOG_ERROR("charger", x);
|
#define LOGE(x...) KLOG_ERROR("charger", x);
|
||||||
#define LOGW(x...) KLOG_WARNING("charger", x);
|
#define LOGW(x...) KLOG_WARNING("charger", x);
|
||||||
#define LOGV(x...) KLOG_DEBUG("charger", x);
|
#define LOGV(x...) KLOG_DEBUG("charger", x);
|
||||||
|
|
||||||
|
static bool get_split_screen() {
|
||||||
|
return android::sysprop::ChargerProperties::draw_split_screen().value_or(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int get_split_offset() {
|
||||||
|
int64_t value = android::sysprop::ChargerProperties::draw_split_offset().value_or(0);
|
||||||
|
if (value < static_cast<int64_t>(std::numeric_limits<int>::min())) {
|
||||||
|
LOGW("draw_split_offset = %" PRId64 " overflow for an int; resetting to %d.\n", value,
|
||||||
|
std::numeric_limits<int>::min());
|
||||||
|
value = std::numeric_limits<int>::min();
|
||||||
|
}
|
||||||
|
if (value > static_cast<int64_t>(std::numeric_limits<int>::max())) {
|
||||||
|
LOGW("draw_split_offset = %" PRId64 " overflow for an int; resetting to %d.\n", value,
|
||||||
|
std::numeric_limits<int>::max());
|
||||||
|
value = std::numeric_limits<int>::max();
|
||||||
|
}
|
||||||
|
return static_cast<int>(value);
|
||||||
|
}
|
||||||
|
|
||||||
HealthdDraw::HealthdDraw(animation* anim)
|
HealthdDraw::HealthdDraw(animation* anim)
|
||||||
: kSplitScreen(HEALTHD_DRAW_SPLIT_SCREEN),
|
: kSplitScreen(get_split_screen()), kSplitOffset(get_split_offset()) {
|
||||||
kSplitOffset(HEALTHD_DRAW_SPLIT_OFFSET) {
|
|
||||||
int ret = gr_init();
|
int ret = gr_init();
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
|
|
||||||
|
|
@ -43,11 +43,10 @@
|
||||||
#include <cutils/uevent.h>
|
#include <cutils/uevent.h>
|
||||||
#include <sys/reboot.h>
|
#include <sys/reboot.h>
|
||||||
|
|
||||||
#ifdef CHARGER_ENABLE_SUSPEND
|
|
||||||
#include <suspend/autosuspend.h>
|
#include <suspend/autosuspend.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "AnimationParser.h"
|
#include "AnimationParser.h"
|
||||||
|
#include "charger.sysprop.h"
|
||||||
#include "healthd_draw.h"
|
#include "healthd_draw.h"
|
||||||
|
|
||||||
#include <health2/Health.h>
|
#include <health2/Health.h>
|
||||||
|
|
@ -264,18 +263,16 @@ out:
|
||||||
LOGW("\n");
|
LOGW("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CHARGER_ENABLE_SUSPEND
|
|
||||||
static int request_suspend(bool enable) {
|
static int request_suspend(bool enable) {
|
||||||
|
if (!android::sysprop::ChargerProperties::enable_suspend().value_or(false)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (enable)
|
if (enable)
|
||||||
return autosuspend_enable();
|
return autosuspend_enable();
|
||||||
else
|
else
|
||||||
return autosuspend_disable();
|
return autosuspend_disable();
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
static int request_suspend(bool /*enable*/) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void kick_animation(animation* anim) {
|
static void kick_animation(animation* anim) {
|
||||||
anim->run = true;
|
anim->run = true;
|
||||||
|
|
@ -321,10 +318,10 @@ static void update_screen_state(charger* charger, int64_t now) {
|
||||||
|
|
||||||
healthd_draw.reset(new HealthdDraw(batt_anim));
|
healthd_draw.reset(new HealthdDraw(batt_anim));
|
||||||
|
|
||||||
#ifndef CHARGER_DISABLE_INIT_BLANK
|
if (android::sysprop::ChargerProperties::disable_init_blank().value_or(false)) {
|
||||||
healthd_draw->blank_screen(true);
|
healthd_draw->blank_screen(true);
|
||||||
charger->screen_blanked = true;
|
charger->screen_blanked = true;
|
||||||
#endif
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* animation is over, blank screen and leave */
|
/* animation is over, blank screen and leave */
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue