From 2b2fec792299129ed0d8c30ff258604bc0c7c803 Mon Sep 17 00:00:00 2001 From: mujianwu Date: Tue, 23 Jul 2024 23:29:30 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=8A=9F=E8=83=BD=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E5=A4=8DBug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- UotanToolbox/Assets/Resources.Designer.cs | 4 +- UotanToolbox/Assets/Resources.resx | 4 +- UotanToolbox/Assets/Resources.zh-CN.resx | 4 +- .../Common/PatchHelper/KernelSUPatch.cs | 6 +- .../Common/PatchHelper/MagiskPatch.cs | 7 +- .../CustomizedflashView.axaml.cs | 18 +++ .../Features/Dashboard/DashboardView.axaml | 7 +- .../Features/Dashboard/DashboardView.axaml.cs | 145 +++++++++++------- .../FormatExtract/FormatExtractView.axaml.cs | 2 + UotanToolbox/Features/Home/HomeViewModel.cs | 2 +- .../Wiredflash/WiredflashView.axaml.cs | 34 ++-- 11 files changed, 148 insertions(+), 85 deletions(-) diff --git a/UotanToolbox/Assets/Resources.Designer.cs b/UotanToolbox/Assets/Resources.Designer.cs index 7fe2f9a2..0851f6be 100644 --- a/UotanToolbox/Assets/Resources.Designer.cs +++ b/UotanToolbox/Assets/Resources.Designer.cs @@ -421,7 +421,7 @@ public static string Basicflash_ChooseBoot { } /// - /// 查找类似 Magisk: 的本地化字符串。 + /// 查找类似 File: 的本地化字符串。 /// public static string Basicflash_ChooseMagisk { get { @@ -736,7 +736,7 @@ public static string Basicflash_PatchBoot { } /// - /// 查找类似 Magisk patch done 的本地化字符串。 + /// 查找类似 Boot patch done, is it flashing to the currently connected device? 的本地化字符串。 /// public static string Basicflash_PatchDone { get { diff --git a/UotanToolbox/Assets/Resources.resx b/UotanToolbox/Assets/Resources.resx index 32af1516..0109d6b1 100644 --- a/UotanToolbox/Assets/Resources.resx +++ b/UotanToolbox/Assets/Resources.resx @@ -475,7 +475,7 @@ Boot: - Magisk: + File: RecoveryFile: @@ -907,7 +907,7 @@ The current device does not require this operation! - Magisk patch done + Boot patch done, is it flashing to the currently connected device? During pre-processing of Magisk components diff --git a/UotanToolbox/Assets/Resources.zh-CN.resx b/UotanToolbox/Assets/Resources.zh-CN.resx index 24a0d880..1c6e8d65 100644 --- a/UotanToolbox/Assets/Resources.zh-CN.resx +++ b/UotanToolbox/Assets/Resources.zh-CN.resx @@ -448,7 +448,7 @@ 选择Boot: - 选择面具: + 选择文件: 选择Recovery: @@ -907,7 +907,7 @@ 当前设备无需进行此操作! - 面具修补完成 + Boot修补完成,是否刷入至当前连接设备? Magisk组件预处理时 diff --git a/UotanToolbox/Common/PatchHelper/KernelSUPatch.cs b/UotanToolbox/Common/PatchHelper/KernelSUPatch.cs index 3fc34f3f..609d232f 100644 --- a/UotanToolbox/Common/PatchHelper/KernelSUPatch.cs +++ b/UotanToolbox/Common/PatchHelper/KernelSUPatch.cs @@ -8,7 +8,7 @@ namespace UotanToolbox.Common.PatchHelper internal class KernelSUPatch { private static string GetTranslation(string key) => FeaturesHelper.GetTranslation(key); - public async static Task KernelSU_Patch(ZipInfo zipInfo, BootInfo bootInfo) + public async static Task KernelSU_Patch(ZipInfo zipInfo, BootInfo bootInfo) { if (bootInfo.HaveKernel == false) { @@ -25,7 +25,9 @@ public async static Task KernelSU_Patch(ZipInfo zipInfo, BootInfo bootInfo) Random random = new Random(); string randomStr = new string(Enumerable.Repeat(allowedChars, 16) .Select(s => s[random.Next(s.Length)]).ToArray()); - File.Copy(Path.Combine(bootInfo.TempPath, "new-boot.img"), Path.Combine(Path.GetDirectoryName(bootInfo.Path), "boot_patched_" + randomStr + ".img"), true); + string newboot = Path.Combine(Path.GetDirectoryName(bootInfo.Path), "boot_patched_" + randomStr + ".img"); + File.Copy(Path.Combine(bootInfo.TempPath, "new-boot.img"), newboot, true); + return newboot; } private static void CleanBoot(string path) { diff --git a/UotanToolbox/Common/PatchHelper/MagiskPatch.cs b/UotanToolbox/Common/PatchHelper/MagiskPatch.cs index 7f6beada..ed1b6117 100644 --- a/UotanToolbox/Common/PatchHelper/MagiskPatch.cs +++ b/UotanToolbox/Common/PatchHelper/MagiskPatch.cs @@ -10,7 +10,7 @@ namespace UotanToolbox.Common.PatchHelper internal class MagiskPatch { private static string GetTranslation(string key) => FeaturesHelper.GetTranslation(key); - public async static Task Magisk_Patch(ZipInfo zipInfo, BootInfo bootInfo) + public async static Task Magisk_Patch(ZipInfo zipInfo, BootInfo bootInfo) { if (bootInfo.HaveRamdisk == false) { @@ -49,8 +49,9 @@ public async static Task Magisk_Patch(ZipInfo zipInfo, BootInfo bootInfo) await kernel_patch(bootInfo, EnvironmentVariable.LEGACYSAR); CleanBoot(bootInfo.TempPath); (mb_output, exitcode) = await CallExternalProgram.MagiskBoot($"repack \"{bootInfo.Path}\"", bootInfo.TempPath); - File.Copy(Path.Combine(bootInfo.TempPath, "new-boot.img"), Path.Combine(Path.GetDirectoryName(bootInfo.Path), "boot_patched_" + randomStr + ".img"), true); - + string newboot = Path.Combine(Path.GetDirectoryName(bootInfo.Path), "boot_patched_" + randomStr + ".img"); + File.Copy(Path.Combine(bootInfo.TempPath, "new-boot.img"), newboot, true); + return newboot; } private static void boot_img_pre(BootInfo bootinfo) { diff --git a/UotanToolbox/Features/Customizedflash/CustomizedflashView.axaml.cs b/UotanToolbox/Features/Customizedflash/CustomizedflashView.axaml.cs index 8aec0a9b..17dc2179 100644 --- a/UotanToolbox/Features/Customizedflash/CustomizedflashView.axaml.cs +++ b/UotanToolbox/Features/Customizedflash/CustomizedflashView.axaml.cs @@ -81,6 +81,7 @@ private async void FlashSystemFile(object sender, RoutedEventArgs args) MainViewModel sukiViewModel = GlobalData.MainViewModelInstance; if (sukiViewModel.Status == GetTranslation("Home_Fastboot") || sukiViewModel.Status == GetTranslation("Home_Fastbootd")) { + Global.checkdevice = false; OpenSystemFileBut.IsEnabled = false; FlashSystemFileBut.IsEnabled = false; CustomizedflashLog.Text = GetTranslation("Customizedflash_Flashing") + "\n"; @@ -88,6 +89,7 @@ private async void FlashSystemFile(object sender, RoutedEventArgs args) await Fastboot(shell); OpenSystemFileBut.IsEnabled = true; FlashSystemFileBut.IsEnabled = true; + Global.checkdevice = true; } else { @@ -127,6 +129,7 @@ private async void FlashProductFile(object sender, RoutedEventArgs args) MainViewModel sukiViewModel = GlobalData.MainViewModelInstance; if (sukiViewModel.Status == GetTranslation("Home_Fastboot") || sukiViewModel.Status == GetTranslation("Home_Fastbootd")) { + Global.checkdevice = false; OpenProductFileBut.IsEnabled = false; FlashProductFileBut.IsEnabled = false; CustomizedflashLog.Text = GetTranslation("Customizedflash_Flashing") + "\n"; @@ -134,6 +137,7 @@ private async void FlashProductFile(object sender, RoutedEventArgs args) await Fastboot(shell); OpenProductFileBut.IsEnabled = true; FlashProductFileBut.IsEnabled = true; + Global.checkdevice = true; } else { @@ -172,6 +176,7 @@ private async void FlashVenderFile(object sender, RoutedEventArgs args) MainViewModel sukiViewModel = GlobalData.MainViewModelInstance; if (sukiViewModel.Status == GetTranslation("Home_Fastboot") || sukiViewModel.Status == GetTranslation("Home_Fastbootd")) { + Global.checkdevice = false; OpenVenderFileBut.IsEnabled = false; FlashVenderFileBut.IsEnabled = false; CustomizedflashLog.Text = GetTranslation("Customizedflash_Flashing") + "\n"; @@ -179,6 +184,7 @@ private async void FlashVenderFile(object sender, RoutedEventArgs args) await Fastboot(shell); OpenVenderFileBut.IsEnabled = true; FlashVenderFileBut.IsEnabled = true; + Global.checkdevice = true; } else { @@ -217,6 +223,7 @@ private async void FlashBootFile(object sender, RoutedEventArgs args) MainViewModel sukiViewModel = GlobalData.MainViewModelInstance; if (sukiViewModel.Status == GetTranslation("Home_Fastboot") || sukiViewModel.Status == GetTranslation("Home_Fastbootd")) { + Global.checkdevice = false; OpenBootFileBut.IsEnabled = false; FlashBootFileBut.IsEnabled = false; CustomizedflashLog.Text = GetTranslation("Customizedflash_Flashing") + "\n"; @@ -224,6 +231,7 @@ private async void FlashBootFile(object sender, RoutedEventArgs args) await Fastboot(shell); OpenBootFileBut.IsEnabled = true; FlashBootFileBut.IsEnabled = true; + Global.checkdevice = true; } else { @@ -262,6 +270,7 @@ private async void FlashSystemextFile(object sender, RoutedEventArgs args) MainViewModel sukiViewModel = GlobalData.MainViewModelInstance; if (sukiViewModel.Status == GetTranslation("Home_Fastboot") || sukiViewModel.Status == GetTranslation("Home_Fastbootd")) { + Global.checkdevice = false; OpenSystemextFileBut.IsEnabled = false; FlashSystemextFileBut.IsEnabled = false; CustomizedflashLog.Text = GetTranslation("Customizedflash_Flashing") + "\n"; @@ -269,6 +278,7 @@ private async void FlashSystemextFile(object sender, RoutedEventArgs args) await Fastboot(shell); OpenSystemextFileBut.IsEnabled = true; FlashSystemextFileBut.IsEnabled = true; + Global.checkdevice = true; } else { @@ -307,6 +317,7 @@ private async void FlashOdmFile(object sender, RoutedEventArgs args) MainViewModel sukiViewModel = GlobalData.MainViewModelInstance; if (sukiViewModel.Status == GetTranslation("Home_Fastboot") || sukiViewModel.Status == GetTranslation("Home_Fastbootd")) { + Global.checkdevice = false; OpenOdmFileBut.IsEnabled = false; FlashOdmFileBut.IsEnabled = false; CustomizedflashLog.Text = GetTranslation("Customizedflash_Flashing") + "\n"; @@ -314,6 +325,7 @@ private async void FlashOdmFile(object sender, RoutedEventArgs args) await Fastboot(shell); OpenOdmFileBut.IsEnabled = true; FlashOdmFileBut.IsEnabled = true; + Global.checkdevice = true; } else { @@ -352,6 +364,7 @@ private async void FlashVenderbootFile(object sender, RoutedEventArgs args) MainViewModel sukiViewModel = GlobalData.MainViewModelInstance; if (sukiViewModel.Status == GetTranslation("Home_Fastboot") || sukiViewModel.Status == GetTranslation("Home_Fastbootd")) { + Global.checkdevice = false; OpenVenderbootFileBut.IsEnabled = false; FlashVenderbootFileBut.IsEnabled = false; CustomizedflashLog.Text = GetTranslation("Customizedflash_Flashing") + "\n"; @@ -359,6 +372,7 @@ private async void FlashVenderbootFile(object sender, RoutedEventArgs args) await Fastboot(shell); OpenVenderbootFileBut.IsEnabled = true; FlashVenderbootFileBut.IsEnabled = true; + Global.checkdevice = true; } else { @@ -397,6 +411,7 @@ private async void FlashInitbootFile(object sender, RoutedEventArgs args) MainViewModel sukiViewModel = GlobalData.MainViewModelInstance; if (sukiViewModel.Status == GetTranslation("Home_Fastboot") || sukiViewModel.Status == GetTranslation("Home_Fastbootd")) { + Global.checkdevice = false; OpenInitbootFileBut.IsEnabled = false; FlashInitbootFileBut.IsEnabled = false; CustomizedflashLog.Text = GetTranslation("Customizedflash_Flashing") + "\n"; @@ -404,6 +419,7 @@ private async void FlashInitbootFile(object sender, RoutedEventArgs args) await Fastboot(shell); OpenInitbootFileBut.IsEnabled = true; FlashInitbootFileBut.IsEnabled = true; + Global.checkdevice = true; } else { @@ -442,6 +458,7 @@ private async void FlashImageFile(object sender, RoutedEventArgs args) MainViewModel sukiViewModel = GlobalData.MainViewModelInstance; if (sukiViewModel.Status == GetTranslation("Home_Fastboot") || sukiViewModel.Status == GetTranslation("Home_Fastbootd")) { + Global.checkdevice = false; OpenImageFileBut.IsEnabled = false; FlashImageFileBut.IsEnabled = false; CustomizedflashLog.Text = GetTranslation("Customizedflash_Flashing") + "\n"; @@ -449,6 +466,7 @@ private async void FlashImageFile(object sender, RoutedEventArgs args) await Fastboot(shell); OpenImageFileBut.IsEnabled = true; FlashImageFileBut.IsEnabled = true; + Global.checkdevice = true; } else { diff --git a/UotanToolbox/Features/Dashboard/DashboardView.axaml b/UotanToolbox/Features/Dashboard/DashboardView.axaml index 8e375659..bc4d07e2 100644 --- a/UotanToolbox/Features/Dashboard/DashboardView.axaml +++ b/UotanToolbox/Features/Dashboard/DashboardView.axaml @@ -197,13 +197,10 @@ - - - diff --git a/UotanToolbox/Features/Dashboard/DashboardView.axaml.cs b/UotanToolbox/Features/Dashboard/DashboardView.axaml.cs index 9ce81b05..3a7c2a76 100644 --- a/UotanToolbox/Features/Dashboard/DashboardView.axaml.cs +++ b/UotanToolbox/Features/Dashboard/DashboardView.axaml.cs @@ -77,6 +77,7 @@ private async void Unlock(object sender, RoutedEventArgs args) MainViewModel sukiViewModel = GlobalData.MainViewModelInstance; if (sukiViewModel.Status == GetTranslation("Home_Fastboot")) { + Global.checkdevice = false; BusyUnlock.IsBusy = true; UnlockPanel.IsEnabled = false; if (!string.IsNullOrEmpty(UnlockFile.Text) && !string.IsNullOrEmpty(UnlockCode.Text)) @@ -114,6 +115,7 @@ private async void Unlock(object sender, RoutedEventArgs args) } BusyUnlock.IsBusy = false; UnlockPanel.IsEnabled = true; + Global.checkdevice = true; } else { @@ -133,6 +135,7 @@ private async void Lock(object sender, RoutedEventArgs args) MainViewModel sukiViewModel = GlobalData.MainViewModelInstance; if (sukiViewModel.Status == GetTranslation("Home_Fastboot")) { + Global.checkdevice = false; BusyUnlock.IsBusy = true; UnlockPanel.IsEnabled = false; await CallExternalProgram.Fastboot($"-s {Global.thisdevice} oem lock-go"); @@ -147,6 +150,7 @@ private async void Lock(object sender, RoutedEventArgs args) } BusyUnlock.IsBusy = false; UnlockPanel.IsEnabled = true; + Global.checkdevice = true; } else { @@ -217,6 +221,7 @@ private async Task FlashRec(string shell) MainViewModel sukiViewModel = GlobalData.MainViewModelInstance; if (sukiViewModel.Status == GetTranslation("Home_Fastboot")) { + Global.checkdevice = false; BusyFlash.IsBusy = true; FlashRecovery.IsEnabled = false; if (!string.IsNullOrEmpty(RecFile.Text)) @@ -231,7 +236,7 @@ private async Task FlashRec(string shell) output = await CallExternalProgram.Fastboot($"-s {Global.thisdevice} oem reboot-recovery"); if (output.Contains("unknown command")) { - await CallExternalProgram.Fastboot($"-s {Global.thisdevice} flash misc bin/img/misc.img"); + await CallExternalProgram.Fastboot($"-s {Global.thisdevice} flash misc {Global.runpath}/Image/misc.img"); await CallExternalProgram.Fastboot($"-s {Global.thisdevice} reboot"); } } @@ -247,6 +252,7 @@ private async Task FlashRec(string shell) } BusyFlash.IsBusy = false; FlashRecovery.IsEnabled = true; + Global.checkdevice = true; } else { @@ -281,6 +287,7 @@ private async void BootRec(object sender, RoutedEventArgs args) MainViewModel sukiViewModel = GlobalData.MainViewModelInstance; if (sukiViewModel.Status == GetTranslation("Home_Fastboot")) { + Global.checkdevice = false; BusyFlash.IsBusy = true; FlashRecovery.IsEnabled = false; if (!string.IsNullOrEmpty(RecFile.Text)) @@ -301,6 +308,7 @@ private async void BootRec(object sender, RoutedEventArgs args) } BusyFlash.IsBusy = false; FlashRecovery.IsEnabled = true; + Global.checkdevice = true; } else { @@ -410,18 +418,27 @@ private async void StartPatch(object sender, RoutedEventArgs args) { Global.Zipinfo = await ZipDetect.Zip_Detect(MagiskFile.Text); } + string newboot = null; switch (Global.Zipinfo.Mode) { case PatchMode.Magisk: - await MagiskPatch.Magisk_Patch(Global.Zipinfo, Global.Bootinfo); + newboot = await MagiskPatch.Magisk_Patch(Global.Zipinfo, Global.Bootinfo); break; case PatchMode.KernelSU: - await KernelSUPatch.KernelSU_Patch(Global.Zipinfo, Global.Bootinfo); + newboot = await KernelSUPatch.KernelSU_Patch(Global.Zipinfo, Global.Bootinfo); break; //throw new Exception(GetTranslation("Basicflash_CantKSU")); } - SukiHost.ShowDialog(new PureDialog(GetTranslation("Basicflash_PatchDone")), allowBackgroundClose: true); - FileHelper.OpenFolder(Path.GetDirectoryName(Global.Bootinfo.Path)); + var newDialog = new ConnectionDialog(GetTranslation("Basicflash_PatchDone")); + await SukiHost.ShowDialogAsync(newDialog); + if (newDialog.Result == true) + { + await FlashBoot(newboot); + } + else + { + FileHelper.OpenFolder(Path.GetDirectoryName(Global.Bootinfo.Path)); + } Global.Zipinfo = new ZipInfo("", "", "", "", "", false, PatchMode.None, ""); Global.Bootinfo = new BootInfo("", "", "", false, false, "", "", "", "", false, false, false, "", ""); SetDefaultMagisk(); @@ -435,29 +452,24 @@ private async void StartPatch(object sender, RoutedEventArgs args) patch_busy(false); } - private async void FlashBoot(object sender, RoutedEventArgs args) + private async Task FlashBoot(string boot) { if (await GetDevicesInfo.SetDevicesInfoLittle()) { MainViewModel sukiViewModel = GlobalData.MainViewModelInstance; if (sukiViewModel.Status == GetTranslation("Home_Fastboot")) { - if (!string.IsNullOrEmpty(BootFile.Text)) + Global.checkdevice = false; + string output = await CallExternalProgram.Fastboot($"-s {Global.thisdevice} flash boot \"{boot}\""); + if (!output.Contains("FAILED") && !output.Contains("error")) { - string output = await CallExternalProgram.Fastboot($"-s {Global.thisdevice} flash boot \"{BootFile.Text}\""); - if (!output.Contains("FAILED") && !output.Contains("error")) - { - SukiHost.ShowDialog(new PureDialog(GetTranslation("Basicflash_FlashSucc")), allowBackgroundClose: true); - } - else - { - SukiHost.ShowDialog(new PureDialog(GetTranslation("Basicflash_RecoveryFailed")), allowBackgroundClose: true); - } + SukiHost.ShowDialog(new PureDialog(GetTranslation("Basicflash_FlashSucc")), allowBackgroundClose: true); } else { - SukiHost.ShowDialog(new PureDialog(GetTranslation("Basicflash_SelectBoot")), allowBackgroundClose: true); + SukiHost.ShowDialog(new PureDialog(GetTranslation("Basicflash_RecoveryFailed")), allowBackgroundClose: true); } + Global.checkdevice = true; } else { @@ -558,31 +570,42 @@ private async void FlashMagisk(object sender, RoutedEventArgs args) if (await GetDevicesInfo.SetDevicesInfoLittle()) { MainViewModel sukiViewModel = GlobalData.MainViewModelInstance; - if (sukiViewModel.Status == "Recovery") + if (MagiskFile.Text != null) { - if (MagiskFile.Text != null) + BusyInstall.IsBusy = true; + InstallZIP.IsEnabled = false; + if (TWRPInstall.IsChecked == true) { - BusyInstall.IsBusy = true; - InstallZIP.IsEnabled = false; - if (TWRPInstall.IsChecked == true) + if (sukiViewModel.Status == "Recovery") { await CallExternalProgram.ADB($"-s {Global.thisdevice} push {MagiskFile.Text} /tmp/magisk.apk"); await CallExternalProgram.ADB($"-s {Global.thisdevice} shell twrp install /tmp/magisk.apk"); } - else if (ADBSideload.IsChecked == true) + else { - await CallExternalProgram.ADB($"-s {Global.thisdevice} sideload \"{MagiskFile.Text}\""); + SukiHost.ShowDialog(new PureDialog(GetTranslation("Common_EnterRecovery")), allowBackgroundClose: true); } - SukiHost.ShowDialog(new PureDialog(GetTranslation("Common_Execution")), allowBackgroundClose: true); - BusyInstall.IsBusy = false; - InstallZIP.IsEnabled = true; } - else + else if (ADBSideload.IsChecked == true) { - SukiHost.ShowDialog(new PureDialog(GetTranslation("Basicflash_SelectMagiskRight")), allowBackgroundClose: true); + if (sukiViewModel.Status == "Sideload") + { + await CallExternalProgram.ADB($"-s {Global.thisdevice} sideload \"{MagiskFile.Text}\""); + } + else + { + SukiHost.ShowDialog(new PureDialog(GetTranslation("Common_EnterSideload")), allowBackgroundClose: true); + } } + SukiHost.ShowDialog(new PureDialog(GetTranslation("Common_Execution")), allowBackgroundClose: true); + BusyInstall.IsBusy = false; + InstallZIP.IsEnabled = true; + } + else + { + SukiHost.ShowDialog(new PureDialog(GetTranslation("Basicflash_SelectMagiskRight")), allowBackgroundClose: true); } - else if (sukiViewModel.Status == GetTranslation("Home_System")) + if (sukiViewModel.Status == GetTranslation("Home_System")) { if (MagiskFile.Text != null) { @@ -603,10 +626,6 @@ private async void FlashMagisk(object sender, RoutedEventArgs args) SukiHost.ShowDialog(new PureDialog(GetTranslation("Basicflash_SelectMagiskRight")), allowBackgroundClose: true); } } - else - { - SukiHost.ShowDialog(new PureDialog(GetTranslation("Common_EnterRecovery")), allowBackgroundClose: true); - } } else { @@ -619,27 +638,34 @@ private async void DisableOffRec(object sender, RoutedEventArgs args) if (await GetDevicesInfo.SetDevicesInfoLittle()) { MainViewModel sukiViewModel = GlobalData.MainViewModelInstance; - if (sukiViewModel.Status == "Recovery") + BusyInstall.IsBusy = true; + InstallZIP.IsEnabled = false; + if (TWRPInstall.IsChecked == true) { - BusyInstall.IsBusy = true; - InstallZIP.IsEnabled = false; - if (TWRPInstall.IsChecked == true) + if (sukiViewModel.Status == "Recovery") { await CallExternalProgram.ADB($"-s {Global.thisdevice} push {Global.runpath}/ZIP/DisableAutoRecovery.zip /tmp/"); await CallExternalProgram.ADB($"-s {Global.thisdevice} shell twrp install /tmp/DisableAutoRecovery.zip"); } - else if (ADBSideload.IsChecked == true) + else { - await CallExternalProgram.ADB($"-s {Global.thisdevice} sideload ZIP/DisableAutoRecovery.zip"); + SukiHost.ShowDialog(new PureDialog(GetTranslation("Common_EnterRecovery")), allowBackgroundClose: true); } - SukiHost.ShowDialog(new PureDialog(GetTranslation("Common_Execution")), allowBackgroundClose: true); - BusyInstall.IsBusy = false; - InstallZIP.IsEnabled = true; } - else + else if (ADBSideload.IsChecked == true) { - SukiHost.ShowDialog(new PureDialog(GetTranslation("Common_EnterRecovery")), allowBackgroundClose: true); + if (sukiViewModel.Status == "Sideload") + { + await CallExternalProgram.ADB($"-s {Global.thisdevice} sideload ZIP/DisableAutoRecovery.zip"); + } + else + { + SukiHost.ShowDialog(new PureDialog(GetTranslation("Common_EnterSideload")), allowBackgroundClose: true); + } } + SukiHost.ShowDialog(new PureDialog(GetTranslation("Common_Execution")), allowBackgroundClose: true); + BusyInstall.IsBusy = false; + InstallZIP.IsEnabled = true; } else { @@ -652,27 +678,34 @@ private async void SyncAB(object sender, RoutedEventArgs args) if (await GetDevicesInfo.SetDevicesInfoLittle()) { MainViewModel sukiViewModel = GlobalData.MainViewModelInstance; - if (sukiViewModel.Status == "Recovery") + BusyInstall.IsBusy = true; + InstallZIP.IsEnabled = false; + if (TWRPInstall.IsChecked == true) { - BusyInstall.IsBusy = true; - InstallZIP.IsEnabled = false; - if (TWRPInstall.IsChecked == true) + if (sukiViewModel.Status == "Recovery") { await CallExternalProgram.ADB($"-s {Global.thisdevice} push {Global.runpath}/ZIP/copy-partitions.zip /tmp/"); await CallExternalProgram.ADB($"-s {Global.thisdevice} shell twrp install /tmp/copy-partitions.zip"); } - else if (ADBSideload.IsChecked == true) + else { - await CallExternalProgram.ADB($"-s {Global.thisdevice} sideload ZIP/copy-partitions.zip"); + SukiHost.ShowDialog(new PureDialog(GetTranslation("Common_EnterRecovery")), allowBackgroundClose: true); } - SukiHost.ShowDialog(new PureDialog(GetTranslation("Common_Execution")), allowBackgroundClose: true); - BusyInstall.IsBusy = false; - InstallZIP.IsEnabled = true; } - else + else if (ADBSideload.IsChecked == true) { - SukiHost.ShowDialog(new PureDialog(GetTranslation("Common_EnterRecovery")), allowBackgroundClose: true); + if (sukiViewModel.Status == "Sideload") + { + await CallExternalProgram.ADB($"-s {Global.thisdevice} sideload ZIP/copy-partitions.zip"); + } + else + { + SukiHost.ShowDialog(new PureDialog(GetTranslation("Common_EnterSideload")), allowBackgroundClose: true); + } } + SukiHost.ShowDialog(new PureDialog(GetTranslation("Common_Execution")), allowBackgroundClose: true); + BusyInstall.IsBusy = false; + InstallZIP.IsEnabled = true; } else { diff --git a/UotanToolbox/Features/FormatExtract/FormatExtractView.axaml.cs b/UotanToolbox/Features/FormatExtract/FormatExtractView.axaml.cs index 1081d157..679109f5 100644 --- a/UotanToolbox/Features/FormatExtract/FormatExtractView.axaml.cs +++ b/UotanToolbox/Features/FormatExtract/FormatExtractView.axaml.cs @@ -368,6 +368,7 @@ private async void FlashSuperEmpty(object sender, RoutedEventArgs args) { if (!string.IsNullOrEmpty(SuperEmptyFile.Text)) { + Global.checkdevice = false; BusyFlash.IsBusy = true; SuperEmpty.IsEnabled = false; output = ""; @@ -383,6 +384,7 @@ private async void FlashSuperEmpty(object sender, RoutedEventArgs args) } BusyFlash.IsBusy = false; SuperEmpty.IsEnabled = true; + Global.checkdevice = true; } else { diff --git a/UotanToolbox/Features/Home/HomeViewModel.cs b/UotanToolbox/Features/Home/HomeViewModel.cs index 71aafd72..86c98f82 100644 --- a/UotanToolbox/Features/Home/HomeViewModel.cs +++ b/UotanToolbox/Features/Home/HomeViewModel.cs @@ -344,7 +344,7 @@ public async Task FRRec() string output = await CallExternalProgram.Fastboot($"-s {Global.thisdevice} oem reboot-recovery"); if (output.Contains("unknown command")) { - await CallExternalProgram.Fastboot($"-s {Global.thisdevice} flash misc bin/img/misc.img"); + await CallExternalProgram.Fastboot($"-s {Global.thisdevice} flash misc {Global.runpath}/Image/misc.img"); await CallExternalProgram.Fastboot($"-s {Global.thisdevice} reboot"); } else diff --git a/UotanToolbox/Features/Wiredflash/WiredflashView.axaml.cs b/UotanToolbox/Features/Wiredflash/WiredflashView.axaml.cs index 343c2759..f7538671 100644 --- a/UotanToolbox/Features/Wiredflash/WiredflashView.axaml.cs +++ b/UotanToolbox/Features/Wiredflash/WiredflashView.axaml.cs @@ -515,6 +515,22 @@ private async void SetToB(object sender, RoutedEventArgs args) } } + public void MoreFlashBusy(bool is_busy) + { + if (is_busy) + { + Global.checkdevice = false; + BusyFlash.IsBusy = true; + MoreWiredFlash.IsEnabled = false; + } + else + { + Global.checkdevice = true; + BusyFlash.IsBusy = false; + MoreWiredFlash.IsEnabled = true; + } + } + private async void StartFlash(object sender, RoutedEventArgs args) { if (await GetDevicesInfo.SetDevicesInfoLittle()) @@ -524,15 +540,13 @@ private async void StartFlash(object sender, RoutedEventArgs args) { if (sukiViewModel.Status == "Sideload") { - BusyFlash.IsBusy = true; - MoreWiredFlash.IsEnabled = false; + MoreFlashBusy(true); output = ""; WiredflashLog.Text = ""; string shell = String.Format($"-s {Global.thisdevice} sideload \"{AdbSideloadFile.Text}\""); await ADB(shell); SukiHost.ShowDialog(new PureDialog(GetTranslation("Common_Execution")), allowBackgroundClose: true); - BusyFlash.IsBusy = false; - MoreWiredFlash.IsEnabled = true; + MoreFlashBusy(false); } else { @@ -543,15 +557,13 @@ private async void StartFlash(object sender, RoutedEventArgs args) { if (sukiViewModel.Status == "Fastboot") { - BusyFlash.IsBusy = true; - MoreWiredFlash.IsEnabled = false; + MoreFlashBusy(true); output = ""; WiredflashLog.Text = ""; string shell = String.Format($"-s {Global.thisdevice} update \"{FastbootUpdatedFile.Text}\""); await Fastboot(shell); SukiHost.ShowDialog(new PureDialog(GetTranslation("Common_Execution")), allowBackgroundClose: true); - BusyFlash.IsBusy = false; - MoreWiredFlash.IsEnabled = true; + MoreFlashBusy(false); } else { @@ -562,8 +574,7 @@ private async void StartFlash(object sender, RoutedEventArgs args) { if (sukiViewModel.Status == "Fastboot") { - BusyFlash.IsBusy = true; - MoreWiredFlash.IsEnabled = false; + MoreFlashBusy(true); output = ""; WiredflashLog.Text = ""; if (Global.System == "Windows") @@ -575,8 +586,7 @@ private async void StartFlash(object sender, RoutedEventArgs args) await RunSH(BatFile.Text); } SukiHost.ShowDialog(new PureDialog(GetTranslation("Common_Execution")), allowBackgroundClose: true); - BusyFlash.IsBusy = false; - MoreWiredFlash.IsEnabled = true; + MoreFlashBusy(false); } else {