Install Magisk Manager APK with pm (Android O Compat.)

This commit is contained in:
topjohnwu 2017-05-09 01:16:58 +08:00
parent bb96477779
commit e603877a17
2 changed files with 21 additions and 0 deletions

View File

@ -727,6 +727,26 @@ void late_start(int client) {
LOGI("* Running module service scripts\n");
exec_module_script("service");
// Install Magisk Manager if exists
if (access(MANAGERAPK, F_OK) == 0) {
while(1) {
sleep(5);
char *const command[] = { "sh", "-c",
"CLASSPATH=/system/framework/pm.jar "
"/system/bin/app_process /system/bin "
"com.android.commands.pm.Pm install -r " MANAGERAPK, NULL };
int apk_res, pid;
pid = run_command(&apk_res, "/system/bin/sh", command);
waitpid(pid, NULL, 0);
fdgets(buf, PATH_MAX, apk_res);
close(apk_res);
// Keep trying until pm is started
if (strstr(buf, "Error:") == NULL)
break;
}
unlink(MANAGERAPK);
}
// All boot stage done, cleanup everything
free(buf);
free(buf2);

View File

@ -34,6 +34,7 @@
#define HOSTSFILE COREDIR "/hosts"
#define MAINIMG "/data/magisk.img"
#define DATABIN "/data/magisk"
#define MANAGERAPK DATABIN "/magisk.apk"
#define MAGISKTMP "/dev/magisk"
#define MIRRDIR MAGISKTMP "/mirror"
#define DUMMDIR MAGISKTMP "/dummy"