Skip to content

Commit

Permalink
update the SDK Platform Tools downloader and remover
Browse files Browse the repository at this point in the history
  • Loading branch information
msartore committed Feb 5, 2024
1 parent 4be24ad commit cfc7a17
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 70 deletions.
6 changes: 3 additions & 3 deletions ATA-GUI/ATA-GUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<ApplicationIcon>ATALogoGUI.ico</ApplicationIcon>

<!-- Versioning -->
<Version>3.4.3.0</Version>
<FileVersion>3.4.3.0</FileVersion>
<AssemblyVersion>3.4.3.0</AssemblyVersion>
<Version>3.4.4.0</Version>
<FileVersion>3.4.4.0</FileVersion>
<AssemblyVersion>3.4.4.0</AssemblyVersion>
<Copyright>© 2021-2024 Massimiliano Sartore</Copyright>

<!-- Publish settings -->
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 @@ -9,7 +9,7 @@ namespace ATA_GUI.Classes
{
internal class ATA
{
public static readonly string CURRENTVERSION = "v3.4.3";
public static readonly string CURRENTVERSION = "v3.4.4";
public static readonly string IPFileName = "IPList.txt";

public HashSet<string> IPList { get; } = new HashSet<string>();
Expand Down
32 changes: 16 additions & 16 deletions ATA-GUI/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -988,14 +988,14 @@ private void backgroundWorkerFlashImg_DoWork(object sender, System.ComponentMode
private async Task<bool> checkAdbFastboot(bool isAdb)
{
string exeTmp = isAdb ? "adb.exe" : "fastboot.exe";
bool exist = File.Exists(exeTmp) && File.Exists("AdbWinUsbApi.dll") && File.Exists("AdbWinApi.dll");
bool exist = File.Exists(exeTmp) && File.Exists("AdbWinUsbApi.dll") && File.Exists("AdbWinApi.dll") && File.Exists("etc1tool.exe");

if (!exist)
{
LogWriteLine("adb not found", LogType.ERROR);
LogWriteLine("platform tools not found", LogType.ERROR);
}

return exist || await ADBDownload();
return exist || await ADBDownload(false);
}

private void buttonRebootToSystem_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -1247,11 +1247,11 @@ private void tabControl1_Selected(object sender, TabControlEventArgs e)
panelFastboot.Enabled = false;
}

private async Task<bool> ADBDownload()
public async Task<bool> ADBDownload(bool isUpdate)
{
if (!ata.IsConnected)
{
MessageShowBox("You are offline, ATA can not download ADB", 0);
MessageShowBox("You are offline, ATA can not download SDK Platform Tools", 0);
return false;
}
Invoke(delegate
Expand All @@ -1260,7 +1260,9 @@ private async Task<bool> ADBDownload()
buttonDisconnectIP.Enabled = false;
});

ExeMissingForm adbError = new("adb.exe not found\n\nDo you want to download sdk platform tool?\n\n[By pressing YES you agree sdk platform tool terms and conditions]\nfor more info press info button", "Error, ADB Missing!");
string message = isUpdate ? "" : "SDK Platform Tools not found\n\n";

ExeMissingForm adbError = new(message + "Do you want to download them?\n\n[By pressing 'YES' you agree SDK Platform Tools terms and conditions]\nfor more info press info button", "Error, SDK Platform Tools Missing!");
_ = adbError.ShowDialog();

switch (adbError.DialogResult)
Expand Down Expand Up @@ -1293,14 +1295,7 @@ private async Task<bool> ADBDownload()
LogWriteLine("getting things ready...", LogType.INFO);
_ = ConsoleProcess.systemCommand("taskkill /f /im adb.exe");
_ = ConsoleProcess.systemCommand("taskkill /f /im fastboot.exe");
_ = ConsoleProcess.systemCommand("del adb.exe");
_ = ConsoleProcess.systemCommand("del AdbWinUsbApi.dll");
_ = ConsoleProcess.systemCommand("del AdbWinApi.dll");
_ = ConsoleProcess.systemCommand("del fastboot.exe");
_ = ConsoleProcess.systemCommand("move platform-tools\\adb.exe \"%cd%\"");
_ = ConsoleProcess.systemCommand("move platform-tools\\AdbWinUsbApi.dll \"%cd%\"");
_ = ConsoleProcess.systemCommand("move platform-tools\\AdbWinApi.dll \"%cd%\"");
_ = ConsoleProcess.systemCommand("move platform-tools\\fastboot.exe \"%cd%\"");
_ = ConsoleProcess.systemCommand("move /Y platform-tools\\* \"%cd%\"");
Directory.Delete("platform-tools", true);
File.Delete("sdkplatformtool.zip");

Expand Down Expand Up @@ -1479,10 +1474,15 @@ private void labelSettings_MouseLeave(object sender, EventArgs e)
labelSettings.BackColor = Color.Black;
}

private void labelSettings_Click(object sender, EventArgs e)
private async void labelSettings_Click(object sender, EventArgs e)
{
Settings settings = new();
_ = settings.ShowDialog();
DialogResult dialogResult = settings.ShowDialog();

if (dialogResult == DialogResult.Yes)
{
_ = await ADBDownload(true);
}
}

private void labelHelp_Click(object sender, EventArgs e)
Expand Down
32 changes: 17 additions & 15 deletions ATA-GUI/Forms/Settings.Designer.cs

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

35 changes: 3 additions & 32 deletions ATA-GUI/Forms/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,39 +125,10 @@ private void checkBoxInitPopUp_CheckedChanged(object sender, EventArgs e)
_ = Feedback.changeFeedbackFile(true);
}

private void buttonRemoveLocalSDK_Click(object sender, EventArgs e)
private void buttonUpdateLocalSDK_Click(object sender, EventArgs e)
{
string[] programs = { "adb.exe", "fastboot.exe", "AdbWinUsbApi.dll", "AdbWinApi.dll" };
bool nFound = false;

_ = ConsoleProcess.systemCommand("taskkill /f /im " + programs[0]);

foreach (string program in programs)
{
if (!deleter(program))
{
nFound = true;
}
}

if (nFound)
{
MainForm.MessageShowBox("SDK not found", 1);
}
else
{
MainForm.MessageShowBox("SDK deleted", 2);
}
}

private bool deleter(string programName)
{
if (File.Exists(programName))
{
File.Delete(programName);
return true;
}
return false;
DialogResult = DialogResult.Yes;
Close();
}

private void buttonDeleteIPHistory_Click(object sender, EventArgs e)
Expand Down
4 changes: 1 addition & 3 deletions ATA-GUI/Forms/WaitingForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,14 @@ public WaitingForm()
InitializeComponent();
}



private void backgroundWorkerMessages_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
{
int counter = 0;

while (!backgroundWorkerMessages.CancellationPending)
{
backgroundWorkerMessages.ReportProgress(counter++);
Thread.Sleep(1000);
Thread.Sleep(2000);
}
}

Expand Down

0 comments on commit cfc7a17

Please sign in to comment.