Skip to content

Commit 9d9b940

Browse files
committed
Enable Both slot Flash options : Try 2
1 parent 5b9ec5c commit 9d9b940

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

app/src/main/assets/flash_ak3.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ TMP=$F/tmp;
1313

1414
$F/busybox rm -rf $TMP 2>/dev/null;
1515
$F/busybox mkdir -p $TMP;
16-
$F/busybox sed -i "/export ZIPFILE=\"\$3\";/a export STATE=\"\$4\";\nexport SLOT=\"\$5\";" $F/update-binary;
16+
## $F/busybox sed -i "/export ZIPFILE=\"\$3\";/a export STATE=\"\$4\";\nexport SLOT=\"\$5\";" $F/update-binary;
1717
## $F/busybox sed -i 's/\[ -e \/dev\/block\/$byname\/system \] || slot=\$(find_slot);/[ -e \/dev\/block\/$byname\/system ] || slot=$SLOT;/' $F/update-binary;
18-
$F/busybox sed -i '/setup_env;/i sed -i "/is_slot_device=auto/i slot_select=$4" anykernel.sh' $F/update-binary;
19-
$F/busybox sed -i '/setup_env;/i sed -i '\''s/is_slot_device=auto/is_slot_device=1/'\'' anykernel.sh' $F/update-binary;
18+
## $F/busybox sed -i '/setup_env;/i sed -i "/is_slot_device=auto/i slot_select=$4" anykernel.sh' $F/update-binary;
19+
## $F/busybox sed -i '/setup_env;/i sed -i '\''s/is_slot_device=auto/is_slot_device=1/'\'' anykernel.sh' $F/update-binary;
2020

2121
# update-binary <RECOVERY_API_VERSION> <OUTFD> <ZIPFILE>
2222
AKHOME=$TMP/anykernel $F/busybox ash $F/update-binary 3 1 "$Z" "$S" "$P";

app/src/main/java/com/github/capntrips/kernelflasher/ui/screens/slot/SlotViewModel.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -429,10 +429,10 @@ class SlotViewModel(
429429
}
430430

431431
private fun resetSlot() {
432-
// val activeSlotSuffix = Shell.cmd("getprop ro.boot.slot_suffix").exec().out[0]
433-
// val newSlot = if (activeSlotSuffix == "_a") "_b" else "_a"
434-
// Shell.cmd("magisk resetprop -n ro.boot.slot_suffix $newSlot").exec()
435-
// wasSlotReset = !wasSlotReset
432+
val activeSlotSuffix = Shell.cmd("getprop ro.boot.slot_suffix").exec().out[0]
433+
val newSlot = if (activeSlotSuffix == "_a") "_b" else "_a"
434+
Shell.cmd("magisk resetprop -n ro.boot.slot_suffix $newSlot").exec()
435+
wasSlotReset = !wasSlotReset
436436
}
437437

438438
@Suppress("FunctionName")
@@ -496,7 +496,7 @@ class SlotViewModel(
496496
}
497497

498498
@Suppress("FunctionName")
499-
private suspend fun _flashAk3(context: Context, slotSuffix: String) {
499+
private suspend fun _flashAk3(context: Context) {
500500
if (!isActive) {
501501
resetSlot()
502502
}
@@ -508,7 +508,7 @@ class SlotViewModel(
508508
val files = File(context.filesDir.canonicalPath)
509509
val flashScript = File(files, "flash_ak3.sh")
510510
val slot_inactive_state = if(isActive) "active" else "inactive"
511-
val result = Shell.Builder.create().setFlags(Shell.FLAG_MOUNT_MASTER or Shell.FLAG_REDIRECT_STDERR).build().newJob().add("F=$files Z=\"$zip\" S=\"$slot_inactive_state\" P=\"$slotSuffix\" /system/bin/sh $flashScript").to(flashOutput).exec()
511+
val result = Shell.Builder.create().setFlags(Shell.FLAG_MOUNT_MASTER or Shell.FLAG_REDIRECT_STDERR).build().newJob().add("F=$files Z=\"$zip\" /system/bin/sh $flashScript").to(flashOutput).exec()
512512
if (result.isSuccess) {
513513
log(context, "Kernel flashed successfully")
514514
_wasFlashSuccess.value = true
@@ -534,15 +534,15 @@ class SlotViewModel(
534534
launch {
535535
_clearFlash()
536536
_copyFile(context, currentBackup, filename)
537-
_flashAk3(context,slotSuffix)
537+
_flashAk3(context)
538538
}
539539
}
540540

541541
fun flashAk3(context: Context, uri: Uri) {
542542
launch {
543543
_clearFlash()
544544
_copyFile(context, uri)
545-
_flashAk3(context, slotSuffix)
545+
_flashAk3(context)
546546
}
547547
}
548548

0 commit comments

Comments
 (0)