Loading CleanSpec.mk +2 −0 Original line number Diff line number Diff line Loading @@ -78,3 +78,5 @@ $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/ld.config.txt) $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/llndk.libraries.txt) $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/vndksp.libraries.txt) $(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/) $(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/sbin/charger) $(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/sbin/charger) healthd/Android.bp +26 −0 Original line number Diff line number Diff line Loading @@ -84,3 +84,29 @@ cc_binary { "manifest_healthd.xml" ], } cc_library_static { name: "libhealthd_charger_nops", srcs: [ "healthd_mode_charger_nops.cpp", ], cflags: [ "-Wall", "-Werror", ], header_libs: [ "libhealthd_headers", ], static_libs: [ "android.hardware.health@2.0-impl", ], shared_libs: [ "android.hardware.health@2.0", "libutils", ], } healthd/Android.mk +71 −35 Original line number Diff line number Diff line Loading @@ -2,14 +2,14 @@ LOCAL_PATH := $(call my-dir) ### libhealthd_draw ### include $(CLEAR_VARS) LOCAL_MODULE := libhealthd_draw LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) LOCAL_STATIC_LIBRARIES := \ libminui \ libbase LOCAL_STATIC_LIBRARIES := libminui LOCAL_SHARED_LIBRARIES := libbase LOCAL_SRC_FILES := healthd_draw.cpp ifneq ($(TARGET_HEALTHD_DRAW_SPLIT_SCREEN),) Loading @@ -28,6 +28,7 @@ LOCAL_HEADER_LIBRARIES := libbatteryservice_headers include $(BUILD_STATIC_LIBRARY) ### libhealthd_charger ### include $(CLEAR_VARS) LOCAL_CFLAGS := -Werror Loading @@ -49,24 +50,22 @@ LOCAL_EXPORT_C_INCLUDE_DIRS := \ $(LOCAL_PATH)/include LOCAL_STATIC_LIBRARIES := \ android.hardware.health@2.0 \ android.hardware.health@2.0-impl \ android.hardware.health@1.0 \ android.hardware.health@1.0-convert \ libhealthstoragedefault \ libhealthd_draw \ libminui \ libpng \ libz \ libutils \ LOCAL_SHARED_LIBRARIES := \ android.hardware.health@2.0 \ libbase \ libcutils \ libhealthd_draw \ liblog \ libm \ libc \ libpng \ libutils \ ifeq ($(strip $(BOARD_CHARGER_ENABLE_SUSPEND)),true) LOCAL_STATIC_LIBRARIES += libsuspend LOCAL_SHARED_LIBRARIES += libsuspend endif include $(BUILD_STATIC_LIBRARY) Loading @@ -81,10 +80,6 @@ LOCAL_SRC_FILES := \ charger.cpp \ LOCAL_MODULE := charger LOCAL_MODULE_TAGS := optional LOCAL_FORCE_STATIC_EXECUTABLE := true LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT_SBIN) LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_SBIN_UNSTRIPPED) LOCAL_C_INCLUDES := $(LOCAL_PATH)/include LOCAL_CFLAGS := -Werror Loading @@ -94,8 +89,6 @@ endif CHARGER_STATIC_LIBRARIES := \ android.hardware.health@2.0-impl \ android.hardware.health@2.0 \ android.hardware.health@1.0 \ android.hardware.health@1.0-convert \ libbinderthreadstate \ libhidltransport \ Loading @@ -104,54 +97,97 @@ CHARGER_STATIC_LIBRARIES := \ libhealthstoragedefault \ libvndksupport \ libhealthd_charger \ libhealthd_charger_nops \ libhealthd_draw \ libbatterymonitor \ CHARGER_SHARED_LIBRARIES := \ android.hardware.health@2.0 \ libbase \ libutils \ libcutils \ libjsoncpp \ libprocessgroup \ liblog \ libm \ libc \ LOCAL_STATIC_LIBRARIES := $(CHARGER_STATIC_LIBRARIES) libutils \ ifneq ($(strip $(LOCAL_CHARGER_NO_UI)),true) LOCAL_STATIC_LIBRARIES += \ libminui \ libpng \ libz \ CHARGER_STATIC_LIBRARIES += libminui CHARGER_SHARED_LIBRARIES += libpng endif ifeq ($(strip $(BOARD_CHARGER_ENABLE_SUSPEND)),true) LOCAL_STATIC_LIBRARIES += libsuspend CHARGER_SHARED_LIBRARIES += libsuspend endif LOCAL_STATIC_LIBRARIES := $(CHARGER_STATIC_LIBRARIES) LOCAL_SHARED_LIBRARIES := $(CHARGER_SHARED_LIBRARIES) LOCAL_HAL_STATIC_LIBRARIES := libhealthd # Symlink /charger to /sbin/charger # Symlink /charger to /system/bin/charger LOCAL_POST_INSTALL_CMD := $(hide) mkdir -p $(TARGET_ROOT_OUT) \ && ln -sf /sbin/charger $(TARGET_ROOT_OUT)/charger && ln -sf /system/bin/charger $(TARGET_ROOT_OUT)/charger include $(BUILD_EXECUTABLE) ### charger.recovery ### include $(CLEAR_VARS) LOCAL_SRC_FILES := \ charger.cpp \ LOCAL_MODULE := charger.recovery LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/bin LOCAL_MODULE_STEM := charger LOCAL_C_INCLUDES := $(LOCAL_PATH)/include LOCAL_CFLAGS := -Wall -Werror LOCAL_CFLAGS += -DCHARGER_NO_UI # charger.recovery doesn't link against libhealthd_{charger,draw} or libminui, since it doesn't need # any UI support. LOCAL_STATIC_LIBRARIES := \ android.hardware.health@2.0-impl \ android.hardware.health@1.0-convert \ libbinderthreadstate \ libhidltransport \ libhidlbase \ libhwbinder_noltopgo \ libhealthstoragedefault \ libvndksupport \ libhealthd_charger_nops \ libbatterymonitor \ # These shared libs will be installed to recovery image because of the dependency in `recovery` # module. LOCAL_SHARED_LIBRARIES := \ android.hardware.health@2.0 \ libbase \ libcutils \ liblog \ libutils \ # The use of LOCAL_HAL_STATIC_LIBRARIES prevents from building this module with Android.bp. LOCAL_HAL_STATIC_LIBRARIES := libhealthd include $(BUILD_EXECUTABLE) ### charger_test ### include $(CLEAR_VARS) LOCAL_MODULE := charger_test LOCAL_MODULE_TAGS := optional LOCAL_FORCE_STATIC_EXECUTABLE := true LOCAL_C_INCLUDES := $(LOCAL_PATH)/include LOCAL_CFLAGS := -Wall -Werror -DCHARGER_TEST -DCHARGER_NO_UI LOCAL_CFLAGS := -Wall -Werror -DCHARGER_NO_UI LOCAL_STATIC_LIBRARIES := $(CHARGER_STATIC_LIBRARIES) LOCAL_SHARED_LIBRARIES := $(CHARGER_SHARED_LIBRARIES) LOCAL_SRC_FILES := \ charger.cpp \ charger_test.cpp \ include $(BUILD_EXECUTABLE) CHARGER_STATIC_LIBRARIES := CHARGER_SHARED_LIBRARIES := ### charger_res_images ### ifneq ($(strip $(LOCAL_CHARGER_NO_UI)),true) define _add-charger-image include $$(CLEAR_VARS) Loading healthd/charger.cpp +5 −90 Original line number Diff line number Diff line Loading @@ -14,98 +14,13 @@ * limitations under the License. */ #define LOG_TAG "charger" #define KLOG_LEVEL 6 #include <health2/Health.h> #include <healthd/healthd.h> #include <stdlib.h> #include <string.h> #include <cutils/klog.h> using namespace android; // main healthd loop extern int healthd_main(void); // Charger mode extern void healthd_mode_charger_init(struct healthd_config *config); extern int healthd_mode_charger_preparetowait(void); extern void healthd_mode_charger_heartbeat(void); extern void healthd_mode_charger_battery_update( struct android::BatteryProperties *props); // NOPs for modes that need no special action static void healthd_mode_nop_init(struct healthd_config *config); static int healthd_mode_nop_preparetowait(void); static void healthd_mode_nop_heartbeat(void); static void healthd_mode_nop_battery_update( struct android::BatteryProperties *props); static struct healthd_mode_ops healthd_nops = { .init = healthd_mode_nop_init, .preparetowait = healthd_mode_nop_preparetowait, .heartbeat = healthd_mode_nop_heartbeat, .battery_update = healthd_mode_nop_battery_update, }; #include "healthd_mode_charger.h" #include "healthd_mode_charger_nops.h" int main(int argc, char** argv) { #ifdef CHARGER_NO_UI static struct healthd_mode_ops charger_ops = healthd_nops; return healthd_charger_nops(argc, argv); #else static struct healthd_mode_ops charger_ops = { .init = healthd_mode_charger_init, .preparetowait = healthd_mode_charger_preparetowait, .heartbeat = healthd_mode_charger_heartbeat, .battery_update = healthd_mode_charger_battery_update, }; #endif static void healthd_mode_nop_init(struct healthd_config* config) { using android::hardware::health::V2_0::implementation::Health; Health::initInstance(config); } static int healthd_mode_nop_preparetowait(void) { return -1; } static void healthd_mode_nop_heartbeat(void) { } static void healthd_mode_nop_battery_update( struct android::BatteryProperties* /*props*/) { } int healthd_charger_main(int argc, char** argv) { int ch; healthd_mode_ops = &charger_ops; while ((ch = getopt(argc, argv, "cr")) != -1) { switch (ch) { case 'c': // -c is now a noop break; case 'r': // force nops for recovery healthd_mode_ops = &healthd_nops; break; case '?': default: KLOG_ERROR(LOG_TAG, "Unrecognized charger option: %c\n", optopt); exit(1); } } return healthd_main(); } #ifndef CHARGER_TEST int main(int argc, char** argv) { return healthd_charger_main(argc, argv); } #endif } healthd/healthd_mode_charger.cpp +33 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,9 @@ using namespace android; // main healthd loop extern int healthd_main(void); char* locale; #ifndef max Loading Loading @@ -711,3 +714,33 @@ void healthd_mode_charger_init(struct healthd_config* config) { healthd_config = config; charger->boot_min_cap = config->boot_min_cap; } static struct healthd_mode_ops charger_ops = { .init = healthd_mode_charger_init, .preparetowait = healthd_mode_charger_preparetowait, .heartbeat = healthd_mode_charger_heartbeat, .battery_update = healthd_mode_charger_battery_update, }; int healthd_charger_main(int argc, char** argv) { int ch; healthd_mode_ops = &charger_ops; while ((ch = getopt(argc, argv, "cr")) != -1) { switch (ch) { case 'c': // -c is now a noop break; case 'r': // -r is now a noop break; case '?': default: LOGE("Unrecognized charger option: %c\n", optopt); exit(1); } } return healthd_main(); } Loading
CleanSpec.mk +2 −0 Original line number Diff line number Diff line Loading @@ -78,3 +78,5 @@ $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/ld.config.txt) $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/llndk.libraries.txt) $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/vndksp.libraries.txt) $(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/) $(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/sbin/charger) $(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/sbin/charger)
healthd/Android.bp +26 −0 Original line number Diff line number Diff line Loading @@ -84,3 +84,29 @@ cc_binary { "manifest_healthd.xml" ], } cc_library_static { name: "libhealthd_charger_nops", srcs: [ "healthd_mode_charger_nops.cpp", ], cflags: [ "-Wall", "-Werror", ], header_libs: [ "libhealthd_headers", ], static_libs: [ "android.hardware.health@2.0-impl", ], shared_libs: [ "android.hardware.health@2.0", "libutils", ], }
healthd/Android.mk +71 −35 Original line number Diff line number Diff line Loading @@ -2,14 +2,14 @@ LOCAL_PATH := $(call my-dir) ### libhealthd_draw ### include $(CLEAR_VARS) LOCAL_MODULE := libhealthd_draw LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) LOCAL_STATIC_LIBRARIES := \ libminui \ libbase LOCAL_STATIC_LIBRARIES := libminui LOCAL_SHARED_LIBRARIES := libbase LOCAL_SRC_FILES := healthd_draw.cpp ifneq ($(TARGET_HEALTHD_DRAW_SPLIT_SCREEN),) Loading @@ -28,6 +28,7 @@ LOCAL_HEADER_LIBRARIES := libbatteryservice_headers include $(BUILD_STATIC_LIBRARY) ### libhealthd_charger ### include $(CLEAR_VARS) LOCAL_CFLAGS := -Werror Loading @@ -49,24 +50,22 @@ LOCAL_EXPORT_C_INCLUDE_DIRS := \ $(LOCAL_PATH)/include LOCAL_STATIC_LIBRARIES := \ android.hardware.health@2.0 \ android.hardware.health@2.0-impl \ android.hardware.health@1.0 \ android.hardware.health@1.0-convert \ libhealthstoragedefault \ libhealthd_draw \ libminui \ libpng \ libz \ libutils \ LOCAL_SHARED_LIBRARIES := \ android.hardware.health@2.0 \ libbase \ libcutils \ libhealthd_draw \ liblog \ libm \ libc \ libpng \ libutils \ ifeq ($(strip $(BOARD_CHARGER_ENABLE_SUSPEND)),true) LOCAL_STATIC_LIBRARIES += libsuspend LOCAL_SHARED_LIBRARIES += libsuspend endif include $(BUILD_STATIC_LIBRARY) Loading @@ -81,10 +80,6 @@ LOCAL_SRC_FILES := \ charger.cpp \ LOCAL_MODULE := charger LOCAL_MODULE_TAGS := optional LOCAL_FORCE_STATIC_EXECUTABLE := true LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT_SBIN) LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_SBIN_UNSTRIPPED) LOCAL_C_INCLUDES := $(LOCAL_PATH)/include LOCAL_CFLAGS := -Werror Loading @@ -94,8 +89,6 @@ endif CHARGER_STATIC_LIBRARIES := \ android.hardware.health@2.0-impl \ android.hardware.health@2.0 \ android.hardware.health@1.0 \ android.hardware.health@1.0-convert \ libbinderthreadstate \ libhidltransport \ Loading @@ -104,54 +97,97 @@ CHARGER_STATIC_LIBRARIES := \ libhealthstoragedefault \ libvndksupport \ libhealthd_charger \ libhealthd_charger_nops \ libhealthd_draw \ libbatterymonitor \ CHARGER_SHARED_LIBRARIES := \ android.hardware.health@2.0 \ libbase \ libutils \ libcutils \ libjsoncpp \ libprocessgroup \ liblog \ libm \ libc \ LOCAL_STATIC_LIBRARIES := $(CHARGER_STATIC_LIBRARIES) libutils \ ifneq ($(strip $(LOCAL_CHARGER_NO_UI)),true) LOCAL_STATIC_LIBRARIES += \ libminui \ libpng \ libz \ CHARGER_STATIC_LIBRARIES += libminui CHARGER_SHARED_LIBRARIES += libpng endif ifeq ($(strip $(BOARD_CHARGER_ENABLE_SUSPEND)),true) LOCAL_STATIC_LIBRARIES += libsuspend CHARGER_SHARED_LIBRARIES += libsuspend endif LOCAL_STATIC_LIBRARIES := $(CHARGER_STATIC_LIBRARIES) LOCAL_SHARED_LIBRARIES := $(CHARGER_SHARED_LIBRARIES) LOCAL_HAL_STATIC_LIBRARIES := libhealthd # Symlink /charger to /sbin/charger # Symlink /charger to /system/bin/charger LOCAL_POST_INSTALL_CMD := $(hide) mkdir -p $(TARGET_ROOT_OUT) \ && ln -sf /sbin/charger $(TARGET_ROOT_OUT)/charger && ln -sf /system/bin/charger $(TARGET_ROOT_OUT)/charger include $(BUILD_EXECUTABLE) ### charger.recovery ### include $(CLEAR_VARS) LOCAL_SRC_FILES := \ charger.cpp \ LOCAL_MODULE := charger.recovery LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/bin LOCAL_MODULE_STEM := charger LOCAL_C_INCLUDES := $(LOCAL_PATH)/include LOCAL_CFLAGS := -Wall -Werror LOCAL_CFLAGS += -DCHARGER_NO_UI # charger.recovery doesn't link against libhealthd_{charger,draw} or libminui, since it doesn't need # any UI support. LOCAL_STATIC_LIBRARIES := \ android.hardware.health@2.0-impl \ android.hardware.health@1.0-convert \ libbinderthreadstate \ libhidltransport \ libhidlbase \ libhwbinder_noltopgo \ libhealthstoragedefault \ libvndksupport \ libhealthd_charger_nops \ libbatterymonitor \ # These shared libs will be installed to recovery image because of the dependency in `recovery` # module. LOCAL_SHARED_LIBRARIES := \ android.hardware.health@2.0 \ libbase \ libcutils \ liblog \ libutils \ # The use of LOCAL_HAL_STATIC_LIBRARIES prevents from building this module with Android.bp. LOCAL_HAL_STATIC_LIBRARIES := libhealthd include $(BUILD_EXECUTABLE) ### charger_test ### include $(CLEAR_VARS) LOCAL_MODULE := charger_test LOCAL_MODULE_TAGS := optional LOCAL_FORCE_STATIC_EXECUTABLE := true LOCAL_C_INCLUDES := $(LOCAL_PATH)/include LOCAL_CFLAGS := -Wall -Werror -DCHARGER_TEST -DCHARGER_NO_UI LOCAL_CFLAGS := -Wall -Werror -DCHARGER_NO_UI LOCAL_STATIC_LIBRARIES := $(CHARGER_STATIC_LIBRARIES) LOCAL_SHARED_LIBRARIES := $(CHARGER_SHARED_LIBRARIES) LOCAL_SRC_FILES := \ charger.cpp \ charger_test.cpp \ include $(BUILD_EXECUTABLE) CHARGER_STATIC_LIBRARIES := CHARGER_SHARED_LIBRARIES := ### charger_res_images ### ifneq ($(strip $(LOCAL_CHARGER_NO_UI)),true) define _add-charger-image include $$(CLEAR_VARS) Loading
healthd/charger.cpp +5 −90 Original line number Diff line number Diff line Loading @@ -14,98 +14,13 @@ * limitations under the License. */ #define LOG_TAG "charger" #define KLOG_LEVEL 6 #include <health2/Health.h> #include <healthd/healthd.h> #include <stdlib.h> #include <string.h> #include <cutils/klog.h> using namespace android; // main healthd loop extern int healthd_main(void); // Charger mode extern void healthd_mode_charger_init(struct healthd_config *config); extern int healthd_mode_charger_preparetowait(void); extern void healthd_mode_charger_heartbeat(void); extern void healthd_mode_charger_battery_update( struct android::BatteryProperties *props); // NOPs for modes that need no special action static void healthd_mode_nop_init(struct healthd_config *config); static int healthd_mode_nop_preparetowait(void); static void healthd_mode_nop_heartbeat(void); static void healthd_mode_nop_battery_update( struct android::BatteryProperties *props); static struct healthd_mode_ops healthd_nops = { .init = healthd_mode_nop_init, .preparetowait = healthd_mode_nop_preparetowait, .heartbeat = healthd_mode_nop_heartbeat, .battery_update = healthd_mode_nop_battery_update, }; #include "healthd_mode_charger.h" #include "healthd_mode_charger_nops.h" int main(int argc, char** argv) { #ifdef CHARGER_NO_UI static struct healthd_mode_ops charger_ops = healthd_nops; return healthd_charger_nops(argc, argv); #else static struct healthd_mode_ops charger_ops = { .init = healthd_mode_charger_init, .preparetowait = healthd_mode_charger_preparetowait, .heartbeat = healthd_mode_charger_heartbeat, .battery_update = healthd_mode_charger_battery_update, }; #endif static void healthd_mode_nop_init(struct healthd_config* config) { using android::hardware::health::V2_0::implementation::Health; Health::initInstance(config); } static int healthd_mode_nop_preparetowait(void) { return -1; } static void healthd_mode_nop_heartbeat(void) { } static void healthd_mode_nop_battery_update( struct android::BatteryProperties* /*props*/) { } int healthd_charger_main(int argc, char** argv) { int ch; healthd_mode_ops = &charger_ops; while ((ch = getopt(argc, argv, "cr")) != -1) { switch (ch) { case 'c': // -c is now a noop break; case 'r': // force nops for recovery healthd_mode_ops = &healthd_nops; break; case '?': default: KLOG_ERROR(LOG_TAG, "Unrecognized charger option: %c\n", optopt); exit(1); } } return healthd_main(); } #ifndef CHARGER_TEST int main(int argc, char** argv) { return healthd_charger_main(argc, argv); } #endif }
healthd/healthd_mode_charger.cpp +33 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,9 @@ using namespace android; // main healthd loop extern int healthd_main(void); char* locale; #ifndef max Loading Loading @@ -711,3 +714,33 @@ void healthd_mode_charger_init(struct healthd_config* config) { healthd_config = config; charger->boot_min_cap = config->boot_min_cap; } static struct healthd_mode_ops charger_ops = { .init = healthd_mode_charger_init, .preparetowait = healthd_mode_charger_preparetowait, .heartbeat = healthd_mode_charger_heartbeat, .battery_update = healthd_mode_charger_battery_update, }; int healthd_charger_main(int argc, char** argv) { int ch; healthd_mode_ops = &charger_ops; while ((ch = getopt(argc, argv, "cr")) != -1) { switch (ch) { case 'c': // -c is now a noop break; case 'r': // -r is now a noop break; case '?': default: LOGE("Unrecognized charger option: %c\n", optopt); exit(1); } } return healthd_main(); }