You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
Add recommended KEEPVERITY and KEEPFORCEENCRYPT flags
This commit is contained in:
@@ -109,19 +109,16 @@ public class FlashActivity extends Activity {
|
||||
Intent intent = getIntent();
|
||||
Uri uri = intent.getData();
|
||||
|
||||
boolean keepEnc = intent.getBooleanExtra(Const.Key.FLASH_SET_ENC, false);
|
||||
boolean keepVerity = intent.getBooleanExtra(Const.Key.FLASH_SET_VERITY, false);
|
||||
|
||||
switch (intent.getStringExtra(Const.Key.FLASH_ACTION)) {
|
||||
case Const.Value.FLASH_ZIP:
|
||||
new FlashZip(this, uri, console, logs).exec();
|
||||
break;
|
||||
case Const.Value.PATCH_BOOT:
|
||||
new InstallMagisk(this, console, logs, uri, keepEnc, keepVerity, (Uri) intent.getParcelableExtra(Const.Key.FLASH_SET_BOOT))
|
||||
new InstallMagisk(this, console, logs, uri, (Uri) intent.getParcelableExtra(Const.Key.FLASH_SET_BOOT))
|
||||
.exec();
|
||||
break;
|
||||
case Const.Value.FLASH_MAGISK:
|
||||
new InstallMagisk(this, console, logs, uri, keepEnc, keepVerity, intent.getStringExtra(Const.Key.FLASH_SET_BOOT))
|
||||
new InstallMagisk(this, console, logs, uri, intent.getStringExtra(Const.Key.FLASH_SET_BOOT))
|
||||
.exec();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -117,8 +117,7 @@ public class MagiskFragment extends Fragment
|
||||
}
|
||||
|
||||
((NotificationManager) mm.getSystemService(Context.NOTIFICATION_SERVICE)).cancelAll();
|
||||
ShowUI.magiskInstallDialog(getActivity(),
|
||||
keepEncChkbox.isChecked(), keepVerityChkbox.isChecked());
|
||||
ShowUI.magiskInstallDialog(getActivity());
|
||||
}
|
||||
|
||||
@OnClick(R.id.uninstall_button)
|
||||
@@ -139,7 +138,13 @@ public class MagiskFragment extends Fragment
|
||||
setupExpandable();
|
||||
|
||||
keepVerityChkbox.setChecked(mm.keepVerity);
|
||||
keepVerityChkbox.setOnCheckedChangeListener((view, isChecked) -> {
|
||||
mm.keepVerity = isChecked;
|
||||
});
|
||||
keepEncChkbox.setChecked(mm.keepEnc);
|
||||
keepEncChkbox.setOnCheckedChangeListener((view, isChecked) -> {
|
||||
mm.keepEnc = isChecked;
|
||||
});
|
||||
|
||||
mSwipeRefreshLayout.setOnRefreshListener(this);
|
||||
updateUI();
|
||||
|
||||
@@ -50,8 +50,8 @@ public class MagiskManager extends Application {
|
||||
public String managerLink;
|
||||
public String bootBlock = null;
|
||||
public int snetVersion;
|
||||
public boolean keepVerity;
|
||||
public boolean keepEnc;
|
||||
public boolean keepVerity = false;
|
||||
public boolean keepEnc = false;
|
||||
|
||||
// Data
|
||||
public Map<String, Module> moduleMap;
|
||||
@@ -186,22 +186,33 @@ public class MagiskManager extends Application {
|
||||
magiskHide = true;
|
||||
}
|
||||
|
||||
ret = Shell.su("echo \"$BOOTIMAGE\"");
|
||||
if (Utils.isValidShellResponse(ret))
|
||||
bootBlock = ret.get(0);
|
||||
|
||||
ret = Shell.su("echo \"$DTBOIMAGE\"");
|
||||
if (Utils.isValidShellResponse(ret))
|
||||
keepVerity = true;
|
||||
|
||||
ret = Shell.su(
|
||||
"getvar KEEPVERITY",
|
||||
"echo $KEEPVERITY");
|
||||
try {
|
||||
keepVerity = Utils.isValidShellResponse(ret) && Boolean.parseBoolean(ret.get(0));
|
||||
} catch (NumberFormatException e) {
|
||||
keepVerity = false;
|
||||
}
|
||||
if (Utils.isValidShellResponse(ret))
|
||||
keepVerity = Boolean.parseBoolean(ret.get(0));
|
||||
} catch (NumberFormatException ignored) {}
|
||||
|
||||
ret = Shell.sh("getprop ro.crypto.state");
|
||||
if (Utils.isValidShellResponse(ret) && ret.get(0).equals("encrypted"))
|
||||
keepEnc = true;
|
||||
|
||||
ret = Shell.su(
|
||||
"getvar KEEPFORCEENCRYPT",
|
||||
"echo $KEEPFORCEENCRYPT");
|
||||
try {
|
||||
keepEnc = Utils.isValidShellResponse(ret) && Boolean.parseBoolean(ret.get(0));
|
||||
} catch (NumberFormatException e) {
|
||||
keepEnc = false;
|
||||
}
|
||||
if (Utils.isValidShellResponse(ret))
|
||||
keepEnc = Boolean.parseBoolean(ret.get(0));
|
||||
} catch (NumberFormatException ignored) {}
|
||||
|
||||
if (suDB != null && !SuDatabaseHelper.verified) {
|
||||
suDB.close();
|
||||
|
||||
@@ -62,11 +62,6 @@ public class SplashActivity extends Activity {
|
||||
// Magisk working as expected
|
||||
if (Shell.rootAccess() && mm.magiskVersionCode > 0) {
|
||||
|
||||
List<String> ret = Shell.su("echo \"$BOOTIMAGE\"");
|
||||
if (Utils.isValidShellResponse(ret)) {
|
||||
mm.bootBlock = ret.get(0);
|
||||
}
|
||||
|
||||
// Add update checking service
|
||||
if (Const.Value.UPDATE_SERVICE_VER > mm.prefs.getInt(Const.Key.UPDATE_SERVICE_VER, -1)) {
|
||||
ComponentName service = new ComponentName(this, UpdateCheckService.class);
|
||||
|
||||
@@ -40,26 +40,23 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
|
||||
private Uri mBootImg, mZip;
|
||||
private List<String> console, logs;
|
||||
private String mBootLocation;
|
||||
private boolean mKeepEnc, mKeepVerity;
|
||||
private int mode;
|
||||
|
||||
private InstallMagisk(Activity context, List<String> console, List<String> logs, Uri zip, boolean enc, boolean verity) {
|
||||
private InstallMagisk(Activity context, List<String> console, List<String> logs, Uri zip) {
|
||||
super(context);
|
||||
this.console = console;
|
||||
this.logs = logs;
|
||||
mZip = zip;
|
||||
mKeepEnc = enc;
|
||||
mKeepVerity = verity;
|
||||
}
|
||||
|
||||
public InstallMagisk(Activity context, List<String> console, List<String> logs, Uri zip, boolean enc, boolean verity, Uri boot) {
|
||||
this(context, console, logs, zip, enc, verity);
|
||||
public InstallMagisk(Activity context, List<String> console, List<String> logs, Uri zip, Uri boot) {
|
||||
this(context, console, logs, zip);
|
||||
mBootImg = boot;
|
||||
mode = PATCH_MODE;
|
||||
}
|
||||
|
||||
public InstallMagisk(Activity context, List<String> console, List<String> logs, Uri zip, boolean enc, boolean verity, String boot) {
|
||||
this(context, console, logs, zip, enc, verity);
|
||||
public InstallMagisk(Activity context, List<String> console, List<String> logs, Uri zip, String boot) {
|
||||
this(context, console, logs, zip);
|
||||
mBootLocation = boot;
|
||||
mode = DIRECT_MODE;
|
||||
}
|
||||
@@ -190,7 +187,7 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
|
||||
"cd " + install,
|
||||
Utils.fmt("KEEPFORCEENCRYPT=%b KEEPVERITY=%b HIGHCOMP=%b " +
|
||||
"sh update-binary indep boot_patch.sh %s || echo 'Failed!'",
|
||||
mKeepEnc, mKeepVerity, highCompression, boot));
|
||||
mm.keepEnc, mm.keepVerity, highCompression, boot));
|
||||
|
||||
if (TextUtils.equals(console.get(console.size() - 1), "Failed!"))
|
||||
return false;
|
||||
@@ -250,7 +247,7 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
|
||||
Utils.fmt("cp -af %s/* %s; rm -rf %s", install, binPath, install),
|
||||
Utils.fmt("flash_boot_image %s %s", patched_boot, mBootLocation),
|
||||
mm.remoteMagiskVersionCode >= 1464 ? "[ -L /data/magisk.img ] || cp /data/magisk.img /data/adb/magisk.img" : "",
|
||||
"patch_dtbo_image");
|
||||
mm.keepVerity ? "" : "patch_dtbo_image");
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
|
||||
@@ -112,9 +112,6 @@ public class Const {
|
||||
public static final String INTENT_PERM = "perm_dialog";
|
||||
public static final String FLASH_ACTION = "action";
|
||||
public static final String FLASH_SET_BOOT = "boot";
|
||||
public static final String FLASH_SET_ENC = "enc";
|
||||
public static final String FLASH_SET_VERITY = "verity";
|
||||
|
||||
|
||||
// others
|
||||
public static final String UPDATE_NOTIFICATION = "notification";
|
||||
|
||||
@@ -94,6 +94,7 @@ public class Shell {
|
||||
"export PATH=" + bbpath + ":$PATH",
|
||||
"mount_partitions",
|
||||
"find_boot_image",
|
||||
"find_dtbo_image",
|
||||
"migrate_boot_backup");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ public class ShowUI {
|
||||
notificationManager.notify(Const.ID.DTBO_NOTIFICATION_ID, builder.build());
|
||||
}
|
||||
|
||||
public static void magiskInstallDialog(Activity activity, boolean enc, boolean verity) {
|
||||
public static void magiskInstallDialog(Activity activity) {
|
||||
MagiskManager mm = Utils.getMagiskManager(activity);
|
||||
String filename = Utils.fmt("Magisk-v%s.zip", mm.remoteMagiskVersionString);
|
||||
new AlertDialogBuilder(activity)
|
||||
@@ -145,8 +145,6 @@ public class ShowUI {
|
||||
intent.setData(uri)
|
||||
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
.putExtra(Const.Key.FLASH_SET_BOOT, data.getData())
|
||||
.putExtra(Const.Key.FLASH_SET_ENC, enc)
|
||||
.putExtra(Const.Key.FLASH_SET_VERITY, verity)
|
||||
.putExtra(Const.Key.FLASH_ACTION, Const.Value.PATCH_BOOT);
|
||||
mm.startActivity(intent);
|
||||
}
|
||||
@@ -175,8 +173,6 @@ public class ShowUI {
|
||||
Intent intent = new Intent(mm, FlashActivity.class);
|
||||
intent.setData(uri)
|
||||
.putExtra(Const.Key.FLASH_SET_BOOT, boot)
|
||||
.putExtra(Const.Key.FLASH_SET_ENC, enc)
|
||||
.putExtra(Const.Key.FLASH_SET_VERITY, verity)
|
||||
.putExtra(Const.Key.FLASH_ACTION, Const.Value.FLASH_MAGISK);
|
||||
activity.startActivity(intent);
|
||||
}
|
||||
@@ -203,8 +199,6 @@ public class ShowUI {
|
||||
Intent intent = new Intent(mm, FlashActivity.class);
|
||||
intent.setData(uri)
|
||||
.putExtra(Const.Key.FLASH_SET_BOOT, boot)
|
||||
.putExtra(Const.Key.FLASH_SET_ENC, enc)
|
||||
.putExtra(Const.Key.FLASH_SET_VERITY, verity)
|
||||
.putExtra(Const.Key.FLASH_ACTION, Const.Value.FLASH_MAGISK);
|
||||
activity.startActivity(intent);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user