Skip to content

Commit

Permalink
Merge branch 'img_library'
Browse files Browse the repository at this point in the history
  • Loading branch information
13584452567 committed Sep 15, 2024
2 parents 8eabd81 + 10ff10a commit c573f92
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
7 changes: 4 additions & 3 deletions UotanToolbox/Common/Global.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal class Global
public static AvaloniaList<string> deviceslist;
public static string thisdevice = null;
public static ZipInfo Zipinfo = new ZipInfo("", "", "", "", "", false, PatchMode.None, "");
public static BootInfo Bootinfo = new BootInfo("", "", "", false, false, "", "", "", "", false, false, false, "", "");
public static BootInfo Bootinfo = new BootInfo("", "", "", false, false, "", "", "", "", false, false, false, "", "", "");
public static int mb_exitcode, cpio_exitcode, load_times;
//分区表储存
public static string sdatable = "";
Expand Down Expand Up @@ -44,7 +44,8 @@ public class BootInfo
public bool HaveDTB { get; set; }
public string DTBName { get; set; }
public string Arch { get; set; }
public BootInfo(string sha1, string path, string tempPath, bool isUseful, bool gki2, string version, string kmi, string osversion, string patchlevel, bool haveramdisk, bool havekernel, bool havedtb, string dtbname, string arch)
public string Compress { get; set; }
public BootInfo(string sha1, string path, string tempPath, bool isUseful, bool gki2, string version, string kmi, string osversion, string patchlevel, bool haveramdisk, bool havekernel, bool havedtb, string dtbname, string arch, string compress)
{
SHA1 = sha1;
Path = path;
Expand All @@ -60,7 +61,7 @@ public BootInfo(string sha1, string path, string tempPath, bool isUseful, bool g
HaveDTB = havedtb;
DTBName = dtbname;
Arch = arch;

Compress = compress;
}
}
public class ZipInfo
Expand Down
4 changes: 3 additions & 1 deletion UotanToolbox/Common/PatchHelper/BootDetect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal class BootDetect
private static string GetTranslation(string key) => FeaturesHelper.GetTranslation(key);
public static async Task<BootInfo> Boot_Detect(string path)
{
BootInfo bootinfo = new BootInfo("", "", "", false, false, "", "", "", "", false, false, false, "", "");
BootInfo bootinfo = new BootInfo("", "", "", false, false, "", "", "", "", false, false, false, "", "", "");
bootinfo.Path = path;
bootinfo.SHA1 = await FileHelper.SHA1HashAsync(bootinfo.Path);
bootinfo.TempPath = Path.Combine(Global.tmp_path, "Boot-" + StringHelper.RandomString(8));
Expand All @@ -22,13 +22,15 @@ public static async Task<BootInfo> Boot_Detect(string path)
}
string osVersionPattern = @"OS_VERSION\s+\[(.*?)\]";
string osPatchLevelPattern = @"OS_PATCH_LEVEL\s+\[(.*?)\]";
string osKernelFMTPattern = @"KERNEL_FMT\s*\[([^\]]*)\]";
(string mb_output, Global.mb_exitcode) = await CallExternalProgram.MagiskBoot($"unpack \"{path}\"", bootinfo.TempPath);
if (Global.mb_exitcode != 0)
{
throw new Exception(GetTranslation("Basicflash_SelectBoot") + mb_output);
}
bootinfo.OSVersion = Regex.Match(mb_output, osVersionPattern).Groups[1].Value;
bootinfo.PatchLevel = Regex.Match(mb_output, osPatchLevelPattern).Groups[1].Value;
bootinfo.Compress = Regex.Match(mb_output, osKernelFMTPattern).Groups[1].Value;
bootinfo.IsUseful = true;
(bootinfo.HaveDTB, bootinfo.DTBName) = await Task.Run(() => dtb_detect(bootinfo.TempPath));
(bootinfo.Version, bootinfo.KMI, bootinfo.HaveKernel, bootinfo.GKI2, bootinfo.Arch) = await kernel_detect(bootinfo.TempPath);
Expand Down
16 changes: 8 additions & 8 deletions UotanToolbox/Features/Basicflash/BasicflashView.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using Avalonia.Collections;
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Avalonia.Collections;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Platform.Storage;
using Avalonia.Threading;
using SukiUI.Controls;
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using UotanToolbox.Common;
using UotanToolbox.Common.PatchHelper;
using UotanToolbox.Features.Components;
Expand Down Expand Up @@ -391,7 +391,7 @@ private async void OpenBootFile(object sender, RoutedEventArgs args)
BootFile.Text = StringHelper.FilePath(files[0].Path.ToString());
Global.Bootinfo = await BootDetect.Boot_Detect(BootFile.Text);
ArchList.SelectedItem = Global.Bootinfo.Arch;
SukiHost.ShowDialog(new PureDialog($"{GetTranslation("Basicflash_DetectdBoot")}\nArch:{Global.Bootinfo.Arch}\nOS:{Global.Bootinfo.OSVersion}\nPatch_level:{Global.Bootinfo.PatchLevel}\nRamdisk:{Global.Bootinfo.HaveRamdisk}\nKMI:{Global.Bootinfo.KMI}"), allowBackgroundClose: true);
SukiHost.ShowDialog(new PureDialog($"{GetTranslation("Basicflash_DetectdBoot")}\nArch:{Global.Bootinfo.Arch}\nOS:{Global.Bootinfo.OSVersion}\nPatch_level:{Global.Bootinfo.PatchLevel}\nRamdisk:{Global.Bootinfo.HaveRamdisk}\nKMI:{Global.Bootinfo.KMI}\nKERNEL_FMT:{Global.Bootinfo.Compress}"), allowBackgroundClose: true);
}
catch (Exception ex)
{
Expand Down Expand Up @@ -443,7 +443,7 @@ private async void StartPatch(object sender, RoutedEventArgs args)
FileHelper.OpenFolder(Path.GetDirectoryName(Global.Bootinfo.Path));
}
Global.Zipinfo = new ZipInfo("", "", "", "", "", false, PatchMode.None, "");
Global.Bootinfo = new BootInfo("", "", "", false, false, "", "", "", "", false, false, false, "", "");
Global.Bootinfo = new BootInfo("", "", "", false, false, "", "", "", "", false, false, false, "", "", "");
SetDefaultMagisk();
BootFile.Text = null;
ArchList.SelectedItem = null;
Expand Down

0 comments on commit c573f92

Please sign in to comment.