Add new boot service: boot-complete

This commit is contained in:
topjohnwu
2018-08-09 14:52:44 +08:00
parent bdff9769be
commit d3858b81e2
5 changed files with 46 additions and 28 deletions

View File

@ -872,15 +872,13 @@ core_only:
// All boot stage done, cleanup
vec_deep_destroy(&module_list);
// Wait for boot complete, and clear boot count
while (1) {
char *prop = getprop("sys.boot_completed");
if (prop != NULL && strcmp(prop, "1") == 0) {
free(prop);
unlink(BOOTCOUNT);
break;
}
sleep(2);
}
}
void boot_complete(int client) {
LOGI("** boot_complete triggered\n");
// ack
write_int(client, 0);
close(client);
unlink(BOOTCOUNT);
}

View File

@ -40,6 +40,7 @@ static void *request_handler(void *args) {
case LS_HIDELIST:
case POST_FS_DATA:
case LATE_START:
case BOOT_COMPLETE:
if (credential.uid != 0) {
write_int(client, ROOT_REQUIRED);
close(client);
@ -82,6 +83,9 @@ static void *request_handler(void *args) {
case LATE_START:
late_start(client);
break;
case BOOT_COMPLETE:
boot_complete(client);
break;
case HANDSHAKE:
/* Do NOT close the client, make it hold */
break;

View File

@ -50,7 +50,7 @@ static void usage() {
" --clone-attr SRC DEST clone permission, owner, and selinux context\n"
"\n"
"Supported init triggers:\n"
" startup, post-fs-data, service\n"
" startup, post-fs-data, service, boot-complete\n"
"\n"
"Supported applets:\n");
@ -111,6 +111,10 @@ int magisk_main(int argc, char *argv[]) {
int fd = connect_daemon();
write_int(fd, LATE_START);
return read_int(fd);
} else if (strcmp(argv[1], "--boot-complete") == 0) {
int fd = connect_daemon();
write_int(fd, BOOT_COMPLETE);
return read_int(fd);
}
// Applets