Skip to content

Commit

Permalink
fix fastboot info extraction and add more fastboot info
Browse files Browse the repository at this point in the history
  • Loading branch information
msartore committed May 14, 2024
1 parent 8f66a46 commit 5433ae6
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 114 deletions.
6 changes: 3 additions & 3 deletions ATA-GUI/ATA-GUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
<Copyright>© 2021-2024 Massimiliano Sartore</Copyright>

<!-- Versioning -->
<Version>3.7.0.0</Version>
<AssemblyVersion>3.7.0.0</AssemblyVersion>
<FileVersion>3.7.0.0</FileVersion>
<Version>3.7.1.0</Version>
<AssemblyVersion>3.7.1.0</AssemblyVersion>
<FileVersion>3.7.1.0</FileVersion>

<!-- Publish settings -->
<PublishUrl>publish\</PublishUrl>
Expand Down
2 changes: 1 addition & 1 deletion ATA-GUI/Classes/ATA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace ATA_GUI.Classes
{
internal class ATA
{
public static readonly string CURRENTVERSION = "v3.7.0";
public static readonly string CURRENTVERSION = "v3.7.1";
public static readonly string IPFileName = "IPList.txt";

public HashSet<string> IPList { get; } = new HashSet<string>();
Expand Down
48 changes: 47 additions & 1 deletion ATA-GUI/Classes/DeviceData.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace ATA_GUI.Classes
{
Expand Down Expand Up @@ -34,6 +37,49 @@ public bool sameMode(Tab tab)
{
return (Mode == DeviceMode.RECOVERY && tab == Tab.RECOVERY) || (Mode == DeviceMode.FASTBOOT && tab == Tab.FASTBOOT) || (Mode == DeviceMode.SYSTEM && tab == Tab.SYSTEM) || (Mode == DeviceMode.SIDELOAD && tab == Tab.RECOVERY);
}

public static string ExtractBootloaderInfo(string input)
{
StringBuilder sb = new StringBuilder();
string[] lines = input.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);


var usefulKeys = new HashSet<string>
{
"DP",
"token",
"crc",
"parallel-download-flash",
"anti",
"cpuid",
"board_version",
"hw-revision",
"unlocked",
"off-mode-charge",
"charger-screen-enabled",
"battery-soc-ok",
"battery-voltage",
"erase-block-size",
"logical-block-size",
"variant",
"secure",
"serialno",
"product",
"max-download-size",
"kernel"
};

foreach (var line in lines)
{
var match = Regex.Match(line, @"\(bootloader\) (?<key>[^:]+):(?<value>.+)");
if (match.Success && usefulKeys.Contains(match.Groups["key"].Value))
{
sb.AppendLine($"{match.Groups["key"].Value}: {match.Groups["value"].Value.Trim()}");
}
}

return sb.ToString().Trim();
}
}

internal enum DeviceMode
Expand Down
121 changes: 29 additions & 92 deletions ATA-GUI/Forms/MainForm.Designer.cs

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

17 changes: 1 addition & 16 deletions ATA-GUI/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,7 @@ private async void buttonSyncApp_Click(object sender, EventArgs e)
SyncDevice();
break;
case Tab.FASTBOOT:
string[] log = ConsoleProcess.fastbootProcess(commandAssemblerF("getvar all")).Split(' ', '\n');
for (int a = 0; a < log.Count(); a++)
{
if (log[a].Contains("partition-type:userdata:"))
{
labelUDT.Text = log[a]["partition-type:userdata:".Length..];
}
else if (log[a].Contains("partition-type:cache:"))
{
labelCDT.Text = log[a]["partition-type:cache:".Length..];
}
else if (log[a].Contains("unlocked:"))
{
labelBootloaderStatus.Text = log[a].Contains("yes") ? "Yes" : "No";
}
}
richTextBoxFastbootInfo.Text = DeviceData.ExtractBootloaderInfo(ConsoleProcess.fastbootProcess(commandAssemblerF("getvar all")));
panelFastboot.Enabled = true;
LogWriteLine("info extracted", LogType.OK);
break;
Expand Down
2 changes: 1 addition & 1 deletion ATA-GUI/Utils/ConsoleProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public static string adbFastbootCommandR(string[] args, int type)
using Process process = new() { StartInfo = startInfo };
process.Start();

string output = process.StandardOutput.ReadToEnd();
string error = process.StandardError.ReadToEnd();
string output = process.StandardOutput.ReadToEnd();

if (!string.IsNullOrEmpty(output))
{
Expand Down

0 comments on commit 5433ae6

Please sign in to comment.