您的位置:首页 > 移动开发 > Android开发

android 关机充电流程

2016-08-15 19:26 489 查看
点击打开链接

0.主要流程

usb插入通过传递cmdline给init解析从而启动充电进程

1. LK

lk\app\aboot\aboot.c

update_cmdline

----------

if (boot_into_ffbm)  // 工厂测试模式
{
cmdline_len += strlen(androidboot_mode);
cmdline_len += strlen(ffbm_mode_string);
/* reduce kernel console messages to speed-up boot */
cmdline_len += strlen(loglevel);
}
else if (target_pause_for_battery_charge())   // 判断是否关机充电
{
pause_at_bootup = 1;                    // charger flag
cmdline_len += strlen(battchg_pause);   //更新 cmd line 长度
}
----------

else if (pause_at_bootup)                    // charger flag
{
src = battchg_pause;         // static const char *battchg_pause = " androidboot.mode=charger";
if (have_cmdline) --dst;
while ((*dst++ = *src++));
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
[/code]

2.init

#init.c
if (!is_ffbm)
is_charger = !strcmp(bootmode, "charger");

----------
if (is_charger)
action_for_each_trigger("charger", action_add_queue_tail);
1
2
3
4
5
6
7
8
9
10
11
12
1
2
3
4
5
6
7
8
9
10
11
12
[/code]
# init.rc
on charger
class_start charger

----------

# init.qcom.rc
service charger /charger
class charger

----------

#system/core/healthd/Android.mk

LOCAL_MODULE := healthd
...
# Symlink /charger to /sbin/healthd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

[/code]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: