mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-01-11 22:53:37 +00:00
Also get default flags in non-root environment
This commit is contained in:
parent
1643638a78
commit
0c247110a0
@ -29,11 +29,11 @@ public class MagiskInstallDialog extends CustomAlertDialog {
|
|||||||
options.add(mm.getString(R.string.patch_boot_file));
|
options.add(mm.getString(R.string.patch_boot_file));
|
||||||
if (Shell.rootAccess()) {
|
if (Shell.rootAccess()) {
|
||||||
options.add(mm.getString(R.string.direct_install));
|
options.add(mm.getString(R.string.direct_install));
|
||||||
}
|
|
||||||
String s = ShellUtils.fastCmd("grep_prop ro.build.ab_update");
|
String s = ShellUtils.fastCmd("grep_prop ro.build.ab_update");
|
||||||
if (!s.isEmpty() && Boolean.parseBoolean(s)) {
|
if (!s.isEmpty() && Boolean.parseBoolean(s)) {
|
||||||
options.add(mm.getString(R.string.install_inactive_slot));
|
options.add(mm.getString(R.string.install_inactive_slot));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
new InstallMethodDialog(activity, options).show();
|
new InstallMethodDialog(activity, options).show();
|
||||||
});
|
});
|
||||||
setNegativeButton(R.string.no_thanks, null);
|
setNegativeButton(R.string.no_thanks, null);
|
||||||
|
@ -12,7 +12,6 @@ import com.topjohnwu.superuser.ShellUtils;
|
|||||||
import com.topjohnwu.superuser.io.SuFile;
|
import com.topjohnwu.superuser.io.SuFile;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
public class RootUtils extends Shell.Initializer {
|
public class RootUtils extends Shell.Initializer {
|
||||||
@ -27,17 +26,11 @@ public class RootUtils extends Shell.Initializer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onInit(Context context, @NonNull Shell shell) {
|
public boolean onInit(Context context, @NonNull Shell shell) {
|
||||||
|
Shell.Job job = shell.newJob();
|
||||||
if (shell.isRoot()) {
|
if (shell.isRoot()) {
|
||||||
try (InputStream magiskUtils = context.getResources().openRawResource(R.raw.util_functions);
|
InputStream magiskUtils = context.getResources().openRawResource(R.raw.util_functions);
|
||||||
InputStream managerUtils = context.getResources().openRawResource(R.raw.utils)
|
InputStream managerUtils = context.getResources().openRawResource(R.raw.utils);
|
||||||
) {
|
job.add(magiskUtils).add(managerUtils);
|
||||||
shell.newJob()
|
|
||||||
.add(magiskUtils).add(managerUtils)
|
|
||||||
.add("mount_partitions", "get_flags", "run_migrations")
|
|
||||||
.exec();
|
|
||||||
} catch (IOException e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Const.MAGISK_DISABLE_FILE = new SuFile("/cache/.disable_magisk");
|
Const.MAGISK_DISABLE_FILE = new SuFile("/cache/.disable_magisk");
|
||||||
SuFile file = new SuFile("/sbin/.core/img");
|
SuFile file = new SuFile("/sbin/.core/img");
|
||||||
@ -51,10 +44,15 @@ public class RootUtils extends Shell.Initializer {
|
|||||||
Const.MAGISK_HOST_FILE = new SuFile(Const.MAGISK_PATH + "/.core/hosts");
|
Const.MAGISK_HOST_FILE = new SuFile(Const.MAGISK_PATH + "/.core/hosts");
|
||||||
|
|
||||||
Data.loadMagiskInfo();
|
Data.loadMagiskInfo();
|
||||||
|
} else {
|
||||||
|
InputStream nonroot = context.getResources().openRawResource(R.raw.nonroot_utils);
|
||||||
|
job.add(nonroot);
|
||||||
|
}
|
||||||
|
|
||||||
|
job.add("mount_partitions", "get_flags", "run_migrations").exec();
|
||||||
|
|
||||||
Data.keepVerity = Boolean.parseBoolean(ShellUtils.fastCmd("echo $KEEPVERITY"));
|
Data.keepVerity = Boolean.parseBoolean(ShellUtils.fastCmd("echo $KEEPVERITY"));
|
||||||
Data.keepEnc = Boolean.parseBoolean(ShellUtils.fastCmd("echo $KEEPFORCEENCRYPT"));
|
Data.keepEnc = Boolean.parseBoolean(ShellUtils.fastCmd("echo $KEEPFORCEENCRYPT"));
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
13
app/src/full/res/raw/nonroot_utils.sh
Normal file
13
app/src/full/res/raw/nonroot_utils.sh
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
mount_partitions() {
|
||||||
|
[ "`getprop ro.build.ab_update`" = "true" ] && SLOT=`getprop ro.boot.slot_suffix` || SLOT=
|
||||||
|
[ "`getprop ro.build.system_root_image`" = "true" ] && SYSTEM_ROOT=true || SYSTEM_ROOT=false
|
||||||
|
}
|
||||||
|
|
||||||
|
get_flags() {
|
||||||
|
$SYSTEM_ROOT && KEEPVERITY=true || KEEPVERITY=false
|
||||||
|
[ "`getprop ro.crypto.state`" = "encrypted" ] && KEEPFORCEENCRYPT=true || KEEPFORCEENCRYPT=false
|
||||||
|
}
|
||||||
|
|
||||||
|
run_migrations() {
|
||||||
|
# NOP
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user