healthd: charger uses shared libraries.
With the change in [1], /sbin/charger always gets included into
system.img (as opposed to ramdisk) and started by second-stage-init. It
no longer needs to be statically linked. This CL switches it to use
shared libraries, and moves it to /system/bin/charger.
With this change, charger no longer gets installed into recovery image,
which will be handled by a follow-up CL.
[1] https://android-review.googlesource.com/c/platform/build/+/728287
Bug: 73660730
Test: Boot into charger mode on taimen. Check that charger UI works.
Test: Run charger_test on taimen.
Change-Id: Idff70cfad09c825cdba4d35a471ff7ecd5f8a8f7
diff --git a/CleanSpec.mk b/CleanSpec.mk
index 0e43dae..ebe5f4a 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -78,3 +78,5 @@
$(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)
diff --git a/healthd/Android.mk b/healthd/Android.mk
index 823ed06..42b1c23 100644
--- a/healthd/Android.mk
+++ b/healthd/Android.mk
@@ -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),)
@@ -28,6 +28,7 @@
include $(BUILD_STATIC_LIBRARY)
+### libhealthd_charger ###
include $(CLEAR_VARS)
LOCAL_CFLAGS := -Werror
@@ -49,24 +50,22 @@
$(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)
@@ -81,10 +80,6 @@
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
@@ -94,8 +89,6 @@
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 \
@@ -106,44 +99,43 @@
libhealthd_charger \
libhealthd_draw \
libbatterymonitor \
+
+CHARGER_SHARED_LIBRARIES := \
+ android.hardware.health@2.0 \
libbase \
- libutils \
libcutils \
libjsoncpp \
libprocessgroup \
liblog \
- libm \
- libc \
+ libpng \
+ libutils \
LOCAL_STATIC_LIBRARIES := $(CHARGER_STATIC_LIBRARIES)
+LOCAL_SHARED_LIBRARIES := $(CHARGER_SHARED_LIBRARIES)
ifneq ($(strip $(LOCAL_CHARGER_NO_UI)),true)
-LOCAL_STATIC_LIBRARIES += \
- libminui \
- libpng \
- libz \
-
+LOCAL_STATIC_LIBRARIES += libminui
endif
ifeq ($(strip $(BOARD_CHARGER_ENABLE_SUSPEND)),true)
-LOCAL_STATIC_LIBRARIES += libsuspend
+LOCAL_SHARED_LIBRARIES += libsuspend
endif
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_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_STATIC_LIBRARIES := $(CHARGER_STATIC_LIBRARIES)
+LOCAL_SHARED_LIBRARIES := $(CHARGER_SHARED_LIBRARIES)
LOCAL_SRC_FILES := \
charger.cpp \
charger_test.cpp \
@@ -151,7 +143,9 @@
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)