mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-04-16 08:41:25 +00:00
Support patching second slot
This commit is contained in:
parent
b80ba13cb4
commit
4c9f5f4655
@ -229,6 +229,7 @@ public class MagiskManager extends Application {
|
||||
"export PATH=" + BUSYBOXPATH + ":$PATH",
|
||||
". " + utils,
|
||||
"mount_partitions",
|
||||
"BOOTIMAGE=",
|
||||
"find_boot_image",
|
||||
"migrate_boot_backup"
|
||||
);
|
||||
|
@ -342,11 +342,17 @@ public class Utils {
|
||||
if (Shell.rootAccess()) {
|
||||
options.add(mm.getString(R.string.direct_install));
|
||||
}
|
||||
List<String> res = Shell.getShell(mm).su("echo $SLOT");
|
||||
if (isValidShellResponse(res)) {
|
||||
options.add(mm.getString(R.string.install_second_slot));
|
||||
}
|
||||
char[] slot = isValidShellResponse(res) ? res.get(0).toCharArray() : null;
|
||||
new AlertDialog.Builder(fragment.getActivity())
|
||||
.setTitle(R.string.select_method)
|
||||
.setItems(
|
||||
options.toArray(new String [0]),
|
||||
(dialog, idx) -> {
|
||||
String boot;
|
||||
DownloadReceiver receiver = null;
|
||||
switch (idx) {
|
||||
case 1:
|
||||
@ -391,7 +397,7 @@ public class Utils {
|
||||
};
|
||||
break;
|
||||
case 2:
|
||||
final String boot = fragment.getSelectedBootImage();
|
||||
boot = fragment.getSelectedBootImage();
|
||||
if (boot == null)
|
||||
return;
|
||||
receiver = new DownloadReceiver() {
|
||||
@ -408,6 +414,36 @@ public class Utils {
|
||||
}
|
||||
};
|
||||
break;
|
||||
case 3:
|
||||
assert (slot != null);
|
||||
// Choose the other slot
|
||||
if (slot[1] == 'a') slot[1] = 'b';
|
||||
else slot[1] = 'a';
|
||||
// Then find the boot image again
|
||||
List<String> ret = Shell.getShell(mm).su(
|
||||
"BOOTIMAGE=",
|
||||
"SLOT=" + String.valueOf(slot),
|
||||
"find_boot_image",
|
||||
"echo \"$BOOTIMAGE\""
|
||||
);
|
||||
boot = isValidShellResponse(ret) ? ret.get(ret.size() - 1) : null;
|
||||
Shell.getShell(mm).su_raw("mount_partitions");
|
||||
if (boot == null)
|
||||
return;
|
||||
receiver = new DownloadReceiver() {
|
||||
@Override
|
||||
public void onDownloadDone(Uri uri) {
|
||||
Intent intent = new Intent(mm, FlashActivity.class);
|
||||
intent.setData(uri)
|
||||
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
.putExtra(FlashActivity.SET_BOOT, boot)
|
||||
.putExtra(FlashActivity.SET_ENC, enc)
|
||||
.putExtra(FlashActivity.SET_VERITY, verity)
|
||||
.putExtra(FlashActivity.SET_ACTION, FlashActivity.FLASH_MAGISK);
|
||||
mm.startActivity(intent);
|
||||
}
|
||||
};
|
||||
default:
|
||||
}
|
||||
Utils.dlAndReceive(
|
||||
mm,
|
||||
|
@ -114,6 +114,7 @@
|
||||
<string name="download_zip_only">Download Zip Only</string>
|
||||
<string name="patch_boot_file">Patch Boot Image File</string>
|
||||
<string name="direct_install">Direct Install (Recommend)</string>
|
||||
<string name="install_second_slot">Install to Second Slot (After OTA)</string>
|
||||
<string name="select_method">Select Method</string>
|
||||
<string name="no_boot_file_patch_support">Target Magisk version doesn\'t support boot image file patching</string>
|
||||
<string name="boot_file_patch_msg">Select stock boot image dump in .img or .img.tar format</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user