3217c5c7d9
In readFromFile() when a newline is not found in the data, we reset the initial character of the buffer to \0, but leave the count as is (something >0 in this case). Later in getBooleanField() we could erroneously treat a response as "true" because count would be >0 and the initial value of buf would be != '0' (set to \0 in this case). To fixup error paths such as this, we can simplify readFromFile by using android::base functions: ReadFromFileString() and Trim(). NOTES: - Converted char * buffers used with readFromFile to std::string - Removed unused variable btech from BatteryMonitor::update Testing Done: - Build healthd and recovery for angler device - Confirm that known values are being read correctly from kernel sysfs. Change-Id: I238bbff097543767f352aa084bf0acbc1324baca Signed-off-by: Michael Scott <michael.scott@linaro.org>
110 lines
2.9 KiB
Makefile
110 lines
2.9 KiB
Makefile
# Copyright 2013 The Android Open Source Project
|
|
|
|
LOCAL_PATH := $(call my-dir)
|
|
|
|
include $(CLEAR_VARS)
|
|
LOCAL_SRC_FILES := healthd_board_default.cpp
|
|
LOCAL_MODULE := libhealthd.default
|
|
LOCAL_CFLAGS := -Werror
|
|
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
|
|
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
|
|
LOCAL_STATIC_LIBRARIES := libbinder
|
|
LOCAL_EXPORT_STATIC_LIBRARY_HEADERS := libbinder
|
|
include $(BUILD_STATIC_LIBRARY)
|
|
|
|
include $(CLEAR_VARS)
|
|
LOCAL_SRC_FILES := BatteryMonitor.cpp
|
|
LOCAL_MODULE := libbatterymonitor
|
|
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
|
|
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
|
|
LOCAL_STATIC_LIBRARIES := libutils libbase libbinder
|
|
include $(BUILD_STATIC_LIBRARY)
|
|
|
|
include $(CLEAR_VARS)
|
|
|
|
ifeq ($(strip $(BOARD_CHARGER_NO_UI)),true)
|
|
LOCAL_CHARGER_NO_UI := true
|
|
endif
|
|
ifdef BRILLO
|
|
LOCAL_CHARGER_NO_UI := true
|
|
endif
|
|
|
|
LOCAL_SRC_FILES := \
|
|
healthd.cpp \
|
|
healthd_mode_android.cpp \
|
|
BatteryPropertiesRegistrar.cpp
|
|
|
|
ifneq ($(strip $(LOCAL_CHARGER_NO_UI)),true)
|
|
LOCAL_SRC_FILES += healthd_mode_charger.cpp
|
|
endif
|
|
|
|
LOCAL_MODULE := healthd
|
|
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_CFLAGS := -D__STDC_LIMIT_MACROS -Werror
|
|
|
|
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
|
|
|
|
ifeq ($(strip $(LOCAL_CHARGER_NO_UI)),true)
|
|
LOCAL_CFLAGS += -DCHARGER_NO_UI
|
|
endif
|
|
|
|
LOCAL_C_INCLUDES := bootable/recovery $(LOCAL_PATH)/include
|
|
|
|
LOCAL_STATIC_LIBRARIES := libbatterymonitor libbatteryservice libbinder libbase
|
|
|
|
ifneq ($(strip $(LOCAL_CHARGER_NO_UI)),true)
|
|
LOCAL_STATIC_LIBRARIES += libminui libpng libz
|
|
endif
|
|
|
|
LOCAL_STATIC_LIBRARIES += libutils libcutils liblog libm libc
|
|
|
|
ifeq ($(strip $(BOARD_CHARGER_ENABLE_SUSPEND)),true)
|
|
LOCAL_STATIC_LIBRARIES += libsuspend
|
|
endif
|
|
|
|
LOCAL_HAL_STATIC_LIBRARIES := libhealthd
|
|
|
|
# Symlink /charger to /sbin/healthd
|
|
LOCAL_POST_INSTALL_CMD := $(hide) mkdir -p $(TARGET_ROOT_OUT) \
|
|
&& ln -sf /sbin/healthd $(TARGET_ROOT_OUT)/charger
|
|
|
|
include $(BUILD_EXECUTABLE)
|
|
|
|
|
|
ifneq ($(strip $(LOCAL_CHARGER_NO_UI)),true)
|
|
define _add-charger-image
|
|
include $$(CLEAR_VARS)
|
|
LOCAL_MODULE := system_core_charger_$(notdir $(1))
|
|
LOCAL_MODULE_STEM := $(notdir $(1))
|
|
_img_modules += $$(LOCAL_MODULE)
|
|
LOCAL_SRC_FILES := $1
|
|
LOCAL_MODULE_TAGS := optional
|
|
LOCAL_MODULE_CLASS := ETC
|
|
LOCAL_MODULE_PATH := $$(TARGET_ROOT_OUT)/res/images/charger
|
|
include $$(BUILD_PREBUILT)
|
|
endef
|
|
|
|
_img_modules :=
|
|
_images :=
|
|
$(foreach _img, $(call find-subdir-subdir-files, "images", "*.png"), \
|
|
$(eval $(call _add-charger-image,$(_img))))
|
|
|
|
include $(CLEAR_VARS)
|
|
LOCAL_MODULE := charger_res_images
|
|
LOCAL_MODULE_TAGS := optional
|
|
LOCAL_REQUIRED_MODULES := $(_img_modules)
|
|
include $(BUILD_PHONY_PACKAGE)
|
|
|
|
_add-charger-image :=
|
|
_img_modules :=
|
|
endif # LOCAL_CHARGER_NO_UI
|