summaryrefslogtreecommitdiffstats
path: root/healthd
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2018-09-11 10:46:35 -0700
committerTao Bao <tbao@google.com>2019-03-06 14:41:47 -0800
commit5747e228f729c6012bdce7003dcc99c99515dc92 (patch)
treed999799ca2db2130763e4ac690488420b7b0d35b /healthd
parentf2455d8068ccf2b412cdea25fb665c3896b00562 (diff)
downloadsystem_core-5747e228f729c6012bdce7003dcc99c99515dc92.tar.gz
system_core-5747e228f729c6012bdce7003dcc99c99515dc92.tar.bz2
system_core-5747e228f729c6012bdce7003dcc99c99515dc92.zip
healthd: Add charger.recovery module.
This CL splits out healthd_mode_charger_nops for building charger.recovery. It doesn't change the functionality of the charger module under recovery, i.e. a) it still doesn't do much work other than reporting the battery status periodically; b) it keeps calling device-specific healthd functions (healthd_board_init and healthd_board_battery_update) via the statically linked HAL. Previously `charger -r` was used to indicate starting charger under recovery mode. This CL makes it a noop since we've changed the caller in recovery. Bug: 73660730 Bug: 114042635 Test: Boot into charger mode on walleye. Check that charger UI works. Test: Boot into recovery mode on walleye. Check that /system/bin/charger keeps working. Test: Run charger_test on walleye. Change-Id: Id91acfcc77ec315c2382392dc54e36c3e85de2eb
Diffstat (limited to 'healthd')
-rw-r--r--healthd/Android.bp26
-rw-r--r--healthd/Android.mk58
-rw-r--r--healthd/charger.cpp95
-rw-r--r--healthd/healthd_mode_charger.cpp33
-rw-r--r--healthd/healthd_mode_charger.h19
-rw-r--r--healthd/healthd_mode_charger_nops.cpp60
-rw-r--r--healthd/healthd_mode_charger_nops.h19
7 files changed, 212 insertions, 98 deletions
diff --git a/healthd/Android.bp b/healthd/Android.bp
index 6b00f81f1..2cf6be96d 100644
--- a/healthd/Android.bp
+++ b/healthd/Android.bp
@@ -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",
+ ],
+}
diff --git a/healthd/Android.mk b/healthd/Android.mk
index 42b1c2320..d18f15a0c 100644
--- a/healthd/Android.mk
+++ b/healthd/Android.mk
@@ -97,6 +97,7 @@ CHARGER_STATIC_LIBRARIES := \
libhealthstoragedefault \
libvndksupport \
libhealthd_charger \
+ libhealthd_charger_nops \
libhealthd_draw \
libbatterymonitor \
@@ -107,20 +108,20 @@ CHARGER_SHARED_LIBRARIES := \
libjsoncpp \
libprocessgroup \
liblog \
- 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
+CHARGER_STATIC_LIBRARIES += libminui
+CHARGER_SHARED_LIBRARIES += libpng
endif
ifeq ($(strip $(BOARD_CHARGER_ENABLE_SUSPEND)),true)
-LOCAL_SHARED_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 /system/bin/charger
@@ -129,15 +130,56 @@ LOCAL_POST_INSTALL_CMD := $(hide) mkdir -p $(TARGET_ROOT_OUT) \
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_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)
diff --git a/healthd/charger.cpp b/healthd/charger.cpp
index 43e7fd5b8..085ccebca 100644
--- a/healthd/charger.cpp
+++ b/healthd/charger.cpp
@@ -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
+}
diff --git a/healthd/healthd_mode_charger.cpp b/healthd/healthd_mode_charger.cpp
index 8f2f7274f..5fe58ac5a 100644
--- a/healthd/healthd_mode_charger.cpp
+++ b/healthd/healthd_mode_charger.cpp
@@ -54,6 +54,9 @@
using namespace android;
+// main healthd loop
+extern int healthd_main(void);
+
char* locale;
#ifndef max
@@ -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();
+}
diff --git a/healthd/healthd_mode_charger.h b/healthd/healthd_mode_charger.h
new file mode 100644
index 000000000..2f0c9f289
--- /dev/null
+++ b/healthd/healthd_mode_charger.h
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+int healthd_charger_main(int argc, char** argv);
diff --git a/healthd/healthd_mode_charger_nops.cpp b/healthd/healthd_mode_charger_nops.cpp
new file mode 100644
index 000000000..bcc04d5ae
--- /dev/null
+++ b/healthd/healthd_mode_charger_nops.cpp
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "healthd_mode_charger_nops.h"
+
+#include <health2/Health.h>
+#include <healthd/healthd.h>
+
+#include <stdlib.h>
+#include <string.h>
+
+using namespace android;
+
+// main healthd loop
+extern int healthd_main(void);
+
+// 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,
+};
+
+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_nops(int /* argc */, char** /* argv */) {
+ healthd_mode_ops = &healthd_nops;
+ return healthd_main();
+}
diff --git a/healthd/healthd_mode_charger_nops.h b/healthd/healthd_mode_charger_nops.h
new file mode 100644
index 000000000..a37b247ee
--- /dev/null
+++ b/healthd/healthd_mode_charger_nops.h
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+int healthd_charger_nops(int argc, char** argv);