android开机充电logo的显示方法
1,以下代码在uboot中
bool firstBoot = (getenv("battery_updated")==NULL);
if ((DC_in == 1) && (INF_REG4_REG != 0xf)) {
setenv ("bootargs", "androidboot.mode=charger"); 开机执行这句android就会进入充电画面
printf("charger mode\n");
} else {
setenv ("bootargs", "");
if ((DC_in == 1) && (INF_REG4_REG != 0xf)) {
setenv ("bootargs", "androidboot.mode=charger need_update_battery=true");
printf("charger mode\n");
} else {
setenv ("bootargs", "need_update_battery=true");
}
setenv ("battery_updated","true");
2,以下代码在kernel
/* if first booting, update */
if(strstr(saved_command_line,"need_update_battery=true")!=NULL){
bq27410_upgrade(di);
}
3,以下代码在/system/core/init/init.c
property_init_action(int nargs, char **args)
{
bool load_defaults = true;
INFO("property init\n");
if (!strcmp(bootmode, "charger")) 在这里会读取uboot传递的androidboot.mode
load_defaults = false;
property_init(load_defaults);
return 0;
}
for(;;) {
int nr, i, timeout = -1;
int fd;
static int flag=0;
char *fdp;
if ((flag++)>150) {
if ((fd = open ("/dev/mem", O_RDWR | O_SYNC)) > 0) {
if ((fdp = (char *) mmap (0, 0x1000, PROT_READ | PROT_WRITE,
MAP_SHARED, fd, base_addr)) != MAP_FAILED) {
if (*(int *)(fdp+INFORM0)==warm_boot)
*(int *)(fdp+INFORM0)=0;
if (*(int *)(fdp+INFORM1)==warm_boot)
*(int *)(fdp+INFORM1)=0;
if (*(int *)(fdp+INFORM2)==warm_boot)
*(int *)(fdp+INFORM2)=0;
munmap (fdp, 0x1000);
}
close(fd);
}
}
}
在device/***/device.mk中增加
PRODUCT_PACKAGES +=
charger /
charger_res_images
在device/***/init*.rc中增加
service batteryserver charger
class charger
on charger
class_start charger