healthd healthd是安卓4.4之后提出来的,监听来自kernel的电池事件,并向上传递电池数据给framework层的BatteryService。 healthd.cpp healthd_mode_android.cpp images BatteryMonitor.cpp BatteryPropertiesRegistrar.cpp healthd_board_default.cpp healthd.h healthd_mode_charger.cpp 下面一张图清晰的表示了Android电池系统框架 ? healthd服务入口:android/system/core/healthd/healthd.cpp 中main函数。 (&healthd_config); //根据系统所处的模式,有三种情况的init,开机充电,关机充电,recovery healthd_mode_ops->init(&healthd_config
主模块处理流程 Healthd模块代码是在system/core/healthd/,其模块入口在healthd的main函数,函数代码如下: 1 int main(int argc, char ** (&healthd_config); 20 21 healthd_mode_ops->init(&healthd_config); 22 23 wakealarm_init(); 24 android_ops的init函数指针指向healthd_mode_android_init函数 代码如下: 1 void healthd_mode_android_init(struct healthd_config Healthd_init走完之后,接着就是调用healthd_mainloop函数,该函数维持了一个死循环,代码如下: 1 static void healthd_mainloop(void) { 2 事件获取与处理 Healthd中维持了一个阻塞式的死循环healthd_mainloop,在该函数中提供阻塞式的监听已发送的事件函数epoll_wait(),healthd_mainloop中有如下代码
主模块处理流程 Healthd模块代码是在system/core/healthd/,其模块入口在healthd的main函数,函数代码如下: int main(int argc, char **argv (&healthd_config); healthd_mode_ops->init(&healthd_config); wakealarm_init(); uevent_init android_ops的init函数指针指向healthd_mode_android_init函数 代码如下: void healthd_mode_android_init(struct healthd_config Healthd_init走完之后,接着就是调用healthd_mainloop函数,该函数维持了一个死循环,代码如下: static void healthd_mainloop(void) { while 事件获取与处理 Healthd中维持了一个阻塞式的死循环healthd_mainloop,在该函数中提供阻塞式的监听已发送的事件函数epoll_wait(),healthd_mainloop中有如下代码
LOCAL_SRC_FILES := \ healthd.cpp \ healthd_mode_android.cpp \ healthd_mode_charger.cpp \ healthd_mode_ops->init(&healthd_config); //wakealarm定时器初始化 wakealarm_init(); //uevent事件初始化,用以监听电池的 android(healthd_mode_android.cpp) void healthd_mode_android_init(struct healthd_config* /*config*/) { ) 1105 void healthd_mode_charger_init(struct healthd_config* config) 1106 { 1118 ret = ev_init( healthd_config.periodic_chores_interval_fast : healthd_config.periodic_chores_interval_slow
四、healthd简介 由于uevent机制仅将一个简单的字符串传递给了用户空间,而安卓系统建立在kernel之上,需要思考如何将设备属性的变化值及时更新到用户空间,于是就有了healthd服务,healthd 相关的代码路径主要是在: /hardware/interfaces/health/; /system/core/healthd/; 从service.cpp开始理一下调用流程,可以整理出上述的调用流程 与底层节点交互的逻辑都在BatteryMonitor中,在初始化过程中会初始化healthd_config结构体,用于保存psy属性节点的路径。 Healthd是一个根植于powersupply子系统,并采用了epoll监听底层节点的uevent事件,之后轮询底层属性节点的守护进程。 psy和Healthd比较适合新手学习,能提供一个由外向内的视角去解读kernel,也能加深对设备驱动模型的理解。
healthd简介 由于uevent机制仅将一个简单的字符串传递给了用户空间,而安卓系统建立在kernel之上,需要思考如何将设备属性的变化值及时更新到用户空间,于是就有了healthd服务,healthd 具体的函数调用流程图如下: 相关的代码路径主要是在: /hardware/interfaces/health/; /system/core/healthd/; 从service.cpp开始理一下调用流程 与底层节点交互的逻辑都在BatteryMonitor中,在初始化过程中会初始化healthd_config结构体,用于保存psy属性节点的路径。 Healthd是一个根植于powersupply子系统,并采用了epoll监听底层节点的uevent事件,之后轮询底层属性节点的守护进程。 psy和Healthd比较适合新手学习,能提供一个由外向内的视角去解读kernel,也能加深对设备驱动模型的理解。
电源管理应用healthd healthd 是一个电源管理的应用,主要功能为:检测电池电量、设置充电电流、电量变低警报、电压过低关机、电池温度过高过度保护等等。 应用配置方法: ‑> System components ‑> aw components [*] healthd for axp 应用源码路径为: lichee/rtos/components/ aw/healthd/healthd.c healthd 用法 开启应用 应用在默认SDK 中并不会启动,在系统启动之后,需要手动输入: healthd 然后就开启了电池管理应用了。 获取电池电量 运行命令: healthd_get_capacity 设置充电电流 运行命令: healthd_set_chgcur 1500 命令的后缀为充电电流大小,单位为mA,范围为0~3072mA
NSLocalizedDescription=无法连接到 iTunes Store, SSErrorHTTPStatusCodeKey=503} Aug 18 16:29:31 YDZdeMacBook-Pro healthd PairedSync, Debugging at level 0 for console and level 0 for log files Aug 18 16:29:31 YDZdeMacBook-Pro healthd iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PairedSyncServices/com.apple.pairedsync.healthd.plist Returning nil PSYSyncCoordinator for service name com.apple.pairedsync.healthd. Aug 18 16:29:31 YDZdeMacBook-Pro healthd[19174]: Error: failed to load bundle "/Applications/Xcode.app
logd logd 6 group root system 7 writepid /dev/cpuset/system-background/tasks 8 9service healthd /sbin/healthd 10 class core 11 critical 12 seclabel u:r:healthd:s0 13 14# Actions 15# on <trigger
2 irq/322-HPH_R O u:r:logd:s0 logd 259 1 /system/bin/logd u:r:healthd :s0 root 260 1 /sbin/healthd u:r:lmkd:s0 root 261
restorecon /postinstall start ueventd start healthd on init export ANDROID_ROOT /system
servicemanager 603 class core 604 user system 605 group system 606 critical 607 onrestart restart healthd
1. frameworks 仓库:openvela 服务框架核心 该仓库是 openvela 服务框架的核心载体,涵盖蓝牙、电话、图形、多媒体、应用框架、安全等关键模块,还包含 KVDB、OTA、healthd
init进程会孵化出ueventd、logd、healthd、installd、adbd、lmkd等用户守护进程; init进程还启动servicemanager、bootanim、mediaserver
hw/android.hardware.configstore@1.0-service 267 13464K 4504K 993K 860K /system/bin/healthd android.hardware.configstore@1.0-service (pid 257) 1,005K: android.hardware.cas@1.0-service (pid 256) 985K: healthd 1.0-service (pid 257) 1,005K: android.hardware.cas@1.0-service (pid 256) 985K: healthd
pstore/pmsg-ramoops-0 # enable armv8_deprecated instruction hooks write /proc/sys/abi/swp 1 # Healthd bin/logd --reinit oneshot writepid /dev/cpuset/system-background/tasks disabled service healthd /sbin/healthd class core critical seclabel u:r:healthd:s0 group root system service bin/servicemanager class core user system group system critical onrestart restart healthd
S 7 16540K 1272K fg /sbin/adbd 327 root 20 0 0% S 1 3404K 852K fg /sbin/healthd
lichee/rtos/components/ ├──aw │├──blkpart │├──bluetooth │├──csi │├──devfs │├──healthd │├──......
1175/kworker/0:1H: 0% user + 0% kernel 0% 1186/logd: 0% user + 0% kernel / faults: 3 minor 0% 1200/healthd
bin/servicemanager class core user system group system critical onrestart restart healthd