Skip to content

Commit

Permalink
调整功能,修复Bug
Browse files Browse the repository at this point in the history
  • Loading branch information
mujianwu committed Jul 23, 2024
1 parent e0c5c21 commit 2b2fec7
Show file tree
Hide file tree
Showing 11 changed files with 148 additions and 85 deletions.
4 changes: 2 additions & 2 deletions UotanToolbox/Assets/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions UotanToolbox/Assets/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@
<value>Boot:</value>
</data>
<data name="Basicflash_ChooseMagisk" xml:space="preserve">
<value>Magisk:</value>
<value>File:</value>
</data>
<data name="Basicflash_ChooseRecovery" xml:space="preserve">
<value>RecoveryFile:</value>
Expand Down Expand Up @@ -907,7 +907,7 @@
<value>The current device does not require this operation!</value>
</data>
<data name="Basicflash_PatchDone" xml:space="preserve">
<value>Magisk patch done</value>
<value>Boot patch done, is it flashing to the currently connected device?</value>
</data>
<data name="Basicflash_PreMagisk" xml:space="preserve">
<value>During pre-processing of Magisk components</value>
Expand Down
4 changes: 2 additions & 2 deletions UotanToolbox/Assets/Resources.zh-CN.resx
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@
<value>选择Boot:</value>
</data>
<data name="Basicflash_ChooseMagisk" xml:space="preserve">
<value>选择面具:</value>
<value>选择文件:</value>
</data>
<data name="Basicflash_ChooseRecovery" xml:space="preserve">
<value>选择Recovery:</value>
Expand Down Expand Up @@ -907,7 +907,7 @@
<value>当前设备无需进行此操作!</value>
</data>
<data name="Basicflash_PatchDone" xml:space="preserve">
<value>面具修补完成</value>
<value>Boot修补完成,是否刷入至当前连接设备?</value>
</data>
<data name="Basicflash_PreMagisk" xml:space="preserve">
<value>Magisk组件预处理时</value>
Expand Down
6 changes: 4 additions & 2 deletions UotanToolbox/Common/PatchHelper/KernelSUPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> KernelSU_Patch(ZipInfo zipInfo, BootInfo bootInfo)
{
if (bootInfo.HaveKernel == false)
{
Expand All @@ -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)
{
Expand Down
7 changes: 4 additions & 3 deletions UotanToolbox/Common/PatchHelper/MagiskPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> Magisk_Patch(ZipInfo zipInfo, BootInfo bootInfo)
{
if (bootInfo.HaveRamdisk == false)
{
Expand Down Expand Up @@ -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)
{
Expand Down
18 changes: 18 additions & 0 deletions UotanToolbox/Features/Customizedflash/CustomizedflashView.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,15 @@ 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";
string shell = String.Format($"-s {Global.thisdevice} flash system \"{SystemFile.Text}\"");
await Fastboot(shell);
OpenSystemFileBut.IsEnabled = true;
FlashSystemFileBut.IsEnabled = true;
Global.checkdevice = true;
}
else
{
Expand Down Expand Up @@ -127,13 +129,15 @@ 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";
string shell = String.Format($"-s {Global.thisdevice} flash product \"{ProductFile.Text}\"");
await Fastboot(shell);
OpenProductFileBut.IsEnabled = true;
FlashProductFileBut.IsEnabled = true;
Global.checkdevice = true;
}
else
{
Expand Down Expand Up @@ -172,13 +176,15 @@ 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";
string shell = String.Format($"-s {Global.thisdevice} flash vendor \"{VenderFile.Text}\"");
await Fastboot(shell);
OpenVenderFileBut.IsEnabled = true;
FlashVenderFileBut.IsEnabled = true;
Global.checkdevice = true;
}
else
{
Expand Down Expand Up @@ -217,13 +223,15 @@ 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";
string shell = String.Format($"-s {Global.thisdevice} flash boot \"{BootFile.Text}\"");
await Fastboot(shell);
OpenBootFileBut.IsEnabled = true;
FlashBootFileBut.IsEnabled = true;
Global.checkdevice = true;
}
else
{
Expand Down Expand Up @@ -262,13 +270,15 @@ 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";
string shell = String.Format($"-s {Global.thisdevice} flash system_ext \"{SystemextFile.Text}\"");
await Fastboot(shell);
OpenSystemextFileBut.IsEnabled = true;
FlashSystemextFileBut.IsEnabled = true;
Global.checkdevice = true;
}
else
{
Expand Down Expand Up @@ -307,13 +317,15 @@ 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";
string shell = String.Format($"-s {Global.thisdevice} flash odm \"{OdmFile.Text}\"");
await Fastboot(shell);
OpenOdmFileBut.IsEnabled = true;
FlashOdmFileBut.IsEnabled = true;
Global.checkdevice = true;
}
else
{
Expand Down Expand Up @@ -352,13 +364,15 @@ 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";
string shell = String.Format($"-s {Global.thisdevice} flash vendor_boot \"{VenderbootFile.Text}\"");
await Fastboot(shell);
OpenVenderbootFileBut.IsEnabled = true;
FlashVenderbootFileBut.IsEnabled = true;
Global.checkdevice = true;
}
else
{
Expand Down Expand Up @@ -397,13 +411,15 @@ 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";
string shell = String.Format($"-s {Global.thisdevice} flash init_boot \"{InitbootFile.Text}\"");
await Fastboot(shell);
OpenInitbootFileBut.IsEnabled = true;
FlashInitbootFileBut.IsEnabled = true;
Global.checkdevice = true;
}
else
{
Expand Down Expand Up @@ -442,13 +458,15 @@ 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";
string shell = String.Format($"-s {Global.thisdevice} flash {Part.Text} \"{ImageFile.Text}\"");
await Fastboot(shell);
OpenImageFileBut.IsEnabled = true;
FlashImageFileBut.IsEnabled = true;
Global.checkdevice = true;
}
else
{
Expand Down
7 changes: 2 additions & 5 deletions UotanToolbox/Features/Dashboard/DashboardView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,10 @@
<ComboBox Width="160" Name="ArchList"/>
</StackPanel>
</StackPanel>
<StackPanel Margin="100,0,0,0" Orientation="Horizontal" Spacing="20">
<Button Width="180" Margin="0,10,0,0" Click="StartPatch">
<StackPanel Spacing="15">
<Button Width="210" Margin="0,10,0,0" Click="StartPatch">
<TextBlock Text="{x:Static assets:Resources.Basicflash_Start}"/>
</Button>
<Button Width="180" Margin="0,10,0,0" Click="FlashBoot">
<TextBlock Text="{x:Static assets:Resources.Basicflash_FlashBoot}"/>
</Button>
</StackPanel>
</StackPanel>
</suki:BusyArea>
Expand Down
Loading

0 comments on commit 2b2fec7

Please sign in to comment.