mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-01-02 05:47:38 +00:00
Add new boot service: boot-complete
This commit is contained in:
parent
bdff9769be
commit
d3858b81e2
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -19,6 +19,7 @@ enum {
|
||||
CHECK_VERSION_CODE,
|
||||
POST_FS_DATA,
|
||||
LATE_START,
|
||||
BOOT_COMPLETE,
|
||||
LAUNCH_MAGISKHIDE,
|
||||
STOP_MAGISKHIDE,
|
||||
ADD_HIDELIST,
|
||||
@ -73,6 +74,7 @@ void write_string(int fd, const char* val);
|
||||
void startup();
|
||||
void post_fs_data(int client);
|
||||
void late_start(int client);
|
||||
void boot_complete(int client);
|
||||
|
||||
/**************
|
||||
* MagiskHide *
|
||||
|
@ -6,31 +6,41 @@ const char magiskrc[] =
|
||||
// Triggers
|
||||
|
||||
"on post-fs-data\n"
|
||||
" start logd\n"
|
||||
" load_persist_props\n"
|
||||
" rm "UNBLOCKFILE"\n"
|
||||
" start magisk_startup\n"
|
||||
" wait "UNBLOCKFILE" 10\n"
|
||||
" rm "UNBLOCKFILE"\n"
|
||||
" start logd\n"
|
||||
" load_persist_props\n"
|
||||
" rm "UNBLOCKFILE"\n"
|
||||
" start magisk_startup\n"
|
||||
" wait "UNBLOCKFILE" 10\n"
|
||||
" rm "UNBLOCKFILE"\n"
|
||||
"\n"
|
||||
|
||||
"on property:sys.boot_completed=1\n"
|
||||
" start magisk_bc\n"
|
||||
"\n"
|
||||
|
||||
// Services
|
||||
|
||||
"service magisk_daemon /sbin/magisk --daemon\n"
|
||||
" user root\n"
|
||||
" seclabel u:r:"SEPOL_PROC_DOMAIN":s0\n"
|
||||
" oneshot\n"
|
||||
" user root\n"
|
||||
" seclabel u:r:"SEPOL_PROC_DOMAIN":s0\n"
|
||||
" oneshot\n"
|
||||
"\n"
|
||||
|
||||
"service magisk_startup /sbin/magisk --startup\n"
|
||||
" user root\n"
|
||||
" seclabel u:r:"SEPOL_PROC_DOMAIN":s0\n"
|
||||
" oneshot\n"
|
||||
" user root\n"
|
||||
" seclabel u:r:"SEPOL_PROC_DOMAIN":s0\n"
|
||||
" oneshot\n"
|
||||
"\n"
|
||||
|
||||
"service magisk_service /sbin/magisk --service\n"
|
||||
" class late_start\n"
|
||||
" user root\n"
|
||||
" seclabel u:r:"SEPOL_PROC_DOMAIN":s0\n"
|
||||
" oneshot\n"
|
||||
" class late_start\n"
|
||||
" user root\n"
|
||||
" seclabel u:r:"SEPOL_PROC_DOMAIN":s0\n"
|
||||
" oneshot\n"
|
||||
"\n"
|
||||
|
||||
"service magisk_bc /sbin/magisk --boot-complete\n"
|
||||
" user root\n"
|
||||
" seclabel u:r:"SEPOL_PROC_DOMAIN":s0\n"
|
||||
" oneshot\n"
|
||||
;
|
||||
|
Loading…
x
Reference in New Issue
Block a user