Skip to content

Commit

Permalink
add support for system enviriment variables and update bloatware list
Browse files Browse the repository at this point in the history
  • Loading branch information
msartore committed May 31, 2024
1 parent b1296c7 commit 3194d3f
Show file tree
Hide file tree
Showing 20 changed files with 233 additions and 174 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.5.0</Version>
<AssemblyVersion>3.7.5.0</AssemblyVersion>
<FileVersion>3.7.5.0</FileVersion>
<Version>3.8.0.0</Version>
<AssemblyVersion>3.8.0.0</AssemblyVersion>
<FileVersion>3.8.0.0</FileVersion>

<!-- Publish settings -->
<PublishUrl>publish\</PublishUrl>
Expand Down
30 changes: 29 additions & 1 deletion ATA-GUI/Classes/ATA.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
using System.Windows.Forms;
Expand All @@ -10,24 +11,28 @@ namespace ATA_GUI.Classes
{
internal class ATA
{
public static readonly string CURRENTVERSION = "v3.7.5";
public static readonly string CURRENTVERSION = "v3.8.0";
public static readonly string IPFileName = "IPList.txt";

public HashSet<string> IPList { get; } = new HashSet<string>();
public List<DeviceData> Devices { get; } = new List<DeviceData>();
public string FILEADB { get; }
public string FILEFastboot { get; }
public bool TextboxClear { get; set; }
public bool IsConnected { get; set; }
public bool IsMaximize { get; set; }
public Tab CurrentTab { get; private set; }
public static DeviceData CurrentDeviceSelected { get; set; }
public static string FASTBOOTPath { get; set; }
public static string ADBPath { get; set; }
public Size windowSize;
public List<DataGridViewRow> selectedRows { get; set; }


public ATA()
{
FILEADB = "adb.exe";
FILEFastboot = "fastboot.exe";
IsConnected = true;
IsMaximize = false;
CurrentTab = Tab.SYSTEM;
Expand Down Expand Up @@ -64,6 +69,29 @@ public void setCurrentTab(string currentTab)
_ => Tab.UNKNOWN,
};
}

public static string FindExecutable(string executable)
{
string customPath = Directory.GetCurrentDirectory();
List<string> paths = new List<string> { customPath };

var envPaths = Environment.GetEnvironmentVariable("Path");
if (envPaths != null)
{
paths.AddRange(envPaths.Split(Path.PathSeparator));
}

foreach (var path in paths)
{
string fullPath = Path.Combine(path, executable);
if (File.Exists(fullPath))
{
return fullPath;
}
}

return null;
}
}

internal enum Tab
Expand Down
20 changes: 10 additions & 10 deletions ATA-GUI/Forms/AboutForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@ public AboutForm()

private void pictureRepo_Click(object sender, EventArgs e)
{
ConsoleProcess.openLink("https://github.com/MassimilianoSartore/ATA-GUI");
ConsoleProcess.OpenLink("https://github.com/MassimilianoSartore/ATA-GUI");
}

private void labelLicense_Click(object sender, EventArgs e)
{
ConsoleProcess.openLink("https://raw.githubusercontent.com/MassimilianoSartore/ATA-GUI/main/LICENSE");
ConsoleProcess.OpenLink("https://raw.githubusercontent.com/MassimilianoSartore/ATA-GUI/main/LICENSE");
}

private void linkLabelDNZ_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
ConsoleProcess.openLink("https://github.com/haf/DotNetZip.Semverd");
ConsoleProcess.OpenLink("https://github.com/haf/DotNetZip.Semverd");
}

private void linkLabelSDK_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
ConsoleProcess.openLink("https://developer.android.com/studio/releases/platform-tools");
ConsoleProcess.OpenLink("https://developer.android.com/studio/releases/platform-tools");
}

private void linkLabelRepo_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
ConsoleProcess.openLink("https://github.com/MassimilianoSartore/ATA-GUI");
ConsoleProcess.OpenLink("https://github.com/MassimilianoSartore/ATA-GUI");
}

private void buttonClose_Click(object sender, EventArgs e)
Expand All @@ -44,17 +44,17 @@ private void buttonClose_Click(object sender, EventArgs e)

private void linkLabelNewtonsoft_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
ConsoleProcess.openLink("https://www.newtonsoft.com/json");
ConsoleProcess.OpenLink("https://www.newtonsoft.com/json");
}

private void linkLabelScrcpy_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
ConsoleProcess.openLink("https://github.com/Genymobile/scrcpy");
ConsoleProcess.OpenLink("https://github.com/Genymobile/scrcpy");
}

private void linkLabelIcons_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
ConsoleProcess.openLink("https://icons8.com");
ConsoleProcess.OpenLink("https://icons8.com");
}

private void About_Load(object sender, EventArgs e)
Expand All @@ -64,12 +64,12 @@ private void About_Load(object sender, EventArgs e)

private void linkLabelGithub_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
ConsoleProcess.openLink("https://github.com/msartore");
ConsoleProcess.OpenLink("https://github.com/msartore");
}

private void linkLabelWebsite_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
ConsoleProcess.openLink("https://msartore.dev");
ConsoleProcess.OpenLink("https://msartore.dev");
}
}
}
4 changes: 2 additions & 2 deletions ATA-GUI/Forms/BloatwareRemoverForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private void buttonAction_Click(object sender, EventArgs e)

if (nonSystemApp.Any(it => it.Equals(app)) || comboBoxActionMode.SelectedIndex == 1)
{
if (ConsoleProcess.adbFastbootCommandR(MainForm.commandAssemblerF("shell pm uninstall -k --user " + ATA.CurrentDeviceSelected.User + " " + item), 0).Contains("Success"))
if (ConsoleProcess.AdbFastbootCommandR(MainForm.commandAssemblerF("shell pm uninstall -k --user " + ATA.CurrentDeviceSelected.User + " " + item), 0).Contains("Success"))
{
listSuccess.Add(app);
}
Expand All @@ -106,7 +106,7 @@ private void buttonAction_Click(object sender, EventArgs e)
}
else
{
if (ConsoleProcess.adbFastbootCommandR(MainForm.commandAssemblerF("shell pm disable-user --user " + ATA.CurrentDeviceSelected.User + " " + item), 0).Contains(item + " new state: disabled-user"))
if (ConsoleProcess.AdbFastbootCommandR(MainForm.commandAssemblerF("shell pm disable-user --user " + ATA.CurrentDeviceSelected.User + " " + item), 0).Contains(item + " new state: disabled-user"))
{
listSuccess.Add(app);
}
Expand Down
16 changes: 8 additions & 8 deletions ATA-GUI/Forms/BootloaderMenuForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,42 +13,42 @@ public BootloaderMenuForm()

private void buttonUB2014_Click(object sender, EventArgs e)
{
richTextBoxLog.Text += ConsoleProcess.adbFastbootCommandR(new[] { MainForm.commandAssemblerF("oem device-info"), MainForm.commandAssemblerF("oem unlock"), MainForm.commandAssemblerF("getvar unlocked") }, 1) + "\n";
richTextBoxLog.Text += ConsoleProcess.AdbFastbootCommandR(new[] { MainForm.commandAssemblerF("oem device-info"), MainForm.commandAssemblerF("oem unlock"), MainForm.commandAssemblerF("getvar unlocked") }, 1) + "\n";
}

private void buttonLB2014_Click(object sender, EventArgs e)
{
richTextBoxLog.Text += ConsoleProcess.adbFastbootCommandR(new[] { MainForm.commandAssemblerF("oem device-info"), MainForm.commandAssemblerF("oem lock"), MainForm.commandAssemblerF("getvar unlocked") }, 1) + "\n";
richTextBoxLog.Text += ConsoleProcess.AdbFastbootCommandR(new[] { MainForm.commandAssemblerF("oem device-info"), MainForm.commandAssemblerF("oem lock"), MainForm.commandAssemblerF("getvar unlocked") }, 1) + "\n";
}

private void buttonUB2015_Click(object sender, EventArgs e)
{
richTextBoxLog.Text += ConsoleProcess.adbFastbootCommandR(new[] { MainForm.commandAssemblerF("oem device-info"), MainForm.commandAssemblerF("flashing unlock"), MainForm.commandAssemblerF("getvar unlocked") }, 1) + "\n";
richTextBoxLog.Text += ConsoleProcess.AdbFastbootCommandR(new[] { MainForm.commandAssemblerF("oem device-info"), MainForm.commandAssemblerF("flashing unlock"), MainForm.commandAssemblerF("getvar unlocked") }, 1) + "\n";
}

private void buttonLB2015_Click(object sender, EventArgs e)
{
richTextBoxLog.Text += ConsoleProcess.adbFastbootCommandR(new[] { MainForm.commandAssemblerF("oem device-info"), MainForm.commandAssemblerF("flashing lock"), MainForm.commandAssemblerF("getvar unlocked") }, 1) + "\n";
richTextBoxLog.Text += ConsoleProcess.AdbFastbootCommandR(new[] { MainForm.commandAssemblerF("oem device-info"), MainForm.commandAssemblerF("flashing lock"), MainForm.commandAssemblerF("getvar unlocked") }, 1) + "\n";
}

private void buttonVivoUnlock_Click(object sender, EventArgs e)
{
richTextBoxLog.Text += ConsoleProcess.adbFastbootCommandR(new[] { MainForm.commandAssemblerF("bbk unlock_vivo") }, 1) + "\n";
richTextBoxLog.Text += ConsoleProcess.AdbFastbootCommandR(new[] { MainForm.commandAssemblerF("bbk unlock_vivo") }, 1) + "\n";
}

private void buttonVivoLock_Click(object sender, EventArgs e)
{
richTextBoxLog.Text += ConsoleProcess.adbFastbootCommandR(new[] { MainForm.commandAssemblerF("bbk lock_vivo") }, 1) + "\n";
richTextBoxLog.Text += ConsoleProcess.AdbFastbootCommandR(new[] { MainForm.commandAssemblerF("bbk lock_vivo") }, 1) + "\n";
}

private void buttonDI_Click(object sender, EventArgs e)
{
richTextBoxLog.Text += ConsoleProcess.adbFastbootCommandR(new[] { MainForm.commandAssemblerF("getvar all") }, 1) + "\n";
richTextBoxLog.Text += ConsoleProcess.AdbFastbootCommandR(new[] { MainForm.commandAssemblerF("getvar all") }, 1) + "\n";
}

private void buttonDID_Click(object sender, EventArgs e)
{
richTextBoxLog.Text += ConsoleProcess.adbFastbootCommandR(new[] { MainForm.commandAssemblerF("oem device-id") }, 1) + "\n";
richTextBoxLog.Text += ConsoleProcess.AdbFastbootCommandR(new[] { MainForm.commandAssemblerF("oem device-id") }, 1) + "\n";
}
}
}
5 changes: 1 addition & 4 deletions ATA-GUI/Forms/DefaultAppForm.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Windows.Forms;
using ATA_GUI.Classes;
using ATA_GUI.Utils;

namespace ATA_GUI
Expand Down Expand Up @@ -28,9 +27,7 @@ private void buttonClose_Click(object sender, EventArgs e)

private void buttonSetDefault_Click(object sender, EventArgs e)
{
Clipboard.SetText("-s " + ATA.CurrentDeviceSelected.ID + " shell cmd role add-role-holder android.app.role." + comboBoxType.Text + " " + apk);

_ = ConsoleProcess.systemCommand("adb -s " + ATA.CurrentDeviceSelected.ID + " shell cmd role add-role-holder android.app.role." + comboBoxType.Text + " " + apk);
_ = ConsoleProcess.AdbProcess(MainForm.commandAssemblerF("shell cmd role add-role-holder android.app.role." + comboBoxType.Text + " " + apk));

MainForm.MessageShowBox("Command injected", 2);
}
Expand Down
2 changes: 1 addition & 1 deletion ATA-GUI/Forms/DeviceLogsForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ private void buttonLogcatClear_Click(object sender, EventArgs e)
{
checkAndStop();
buttonLogcat.Text = "Start";
_ = ConsoleProcess.adbFastbootCommandR("-s " + ATA.CurrentDeviceSelected.ID + " logcat -c", 0);
_ = ConsoleProcess.AdbFastbootCommandR("-s " + ATA.CurrentDeviceSelected.ID + " logcat -c", 0);
}

private void richTextBoxLog_LinkClicked(object sender, LinkClickedEventArgs e)
Expand Down
10 changes: 5 additions & 5 deletions ATA-GUI/Forms/FeedbackForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,27 +46,27 @@ public static bool changeFeedbackFile(bool popUp)

private void buttonSendFeedback_Click(object sender, EventArgs e)
{
ConsoleProcess.openLink("https://github.com/MassimilianoSartore/ATA-GUI/issues/new/choose");
ConsoleProcess.OpenLink("https://github.com/MassimilianoSartore/ATA-GUI/issues/new/choose");
}

private void buttonShareTwitter_Click(object sender, EventArgs e)
{
ConsoleProcess.openLink("https://twitter.com/intent/tweet?text=Check+out+this+cool+Android™+tool+that+I+found!+https://github.com/MassimilianoSartore/ATA-GUI");
ConsoleProcess.OpenLink("https://twitter.com/intent/tweet?text=Check+out+this+cool+Android™+tool+that+I+found!+https://github.com/MassimilianoSartore/ATA-GUI");
}

private void buttonSGF_Click(object sender, EventArgs e)
{
ConsoleProcess.openLink("https://github.com/MassimilianoSartore/ATA-GUI/issues/new?assignees=&labels=enhancement&template=feature_request.md&title=%5BFEATURE%5D");
ConsoleProcess.OpenLink("https://github.com/MassimilianoSartore/ATA-GUI/issues/new?assignees=&labels=enhancement&template=feature_request.md&title=%5BFEATURE%5D");
}

private void buttonSGI_Click(object sender, EventArgs e)
{
ConsoleProcess.openLink("https://github.com/MassimilianoSartore/ATA-GUI/issues/new?assignees=&labels=bug&template=bug_report.md&title=%5BBUG%5D");
ConsoleProcess.OpenLink("https://github.com/MassimilianoSartore/ATA-GUI/issues/new?assignees=&labels=bug&template=bug_report.md&title=%5BBUG%5D");
}

private void buttonDonate_Click(object sender, EventArgs e)
{
ConsoleProcess.openLink("https://msartore.dev/donation/");
ConsoleProcess.OpenLink("https://msartore.dev/donation/");
}
}
}
12 changes: 6 additions & 6 deletions ATA-GUI/Forms/LoadingForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
{
labelFileName.Text = x;
Refresh();
string result = ConsoleProcess.adbProcess(command + x).ToLowerInvariant();
string result = ConsoleProcess.AdbProcess(command + x).ToLowerInvariant();
if (result.Contains("not found") || result.Contains("fail") || result.Trim().Length == 0 || result.Contains("doesn't exist"))
{
failedApps.Add(x);
Expand All @@ -100,15 +100,15 @@ private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)

break;
case OperationType.Transfer:
_ = ConsoleProcess.adbProcess("-s " + deviceSerial + " shell mkdir sdcard/ATA");
_ = ConsoleProcess.AdbProcess("-s " + deviceSerial + " shell mkdir sdcard/ATA");

array.ForEach(file =>
{
if (File.Exists(file))
{
labelFileName.Text = file[(file.LastIndexOf('\\') + 1)..];
Refresh();
if (ConsoleProcess.adbProcess("-s " + deviceSerial + " push " + file + " sdcard/ATA ") == null)
if (ConsoleProcess.AdbProcess("-s " + deviceSerial + " push " + file + " sdcard/ATA ") == null)
{
failedApps.Add(file);
}
Expand All @@ -121,17 +121,17 @@ private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)

if (!Directory.Exists("APKS"))
{
_ = ConsoleProcess.systemCommand("mkdir APKS");
_ = ConsoleProcess.SystemCommand("mkdir APKS");
}

array.ForEach(x =>
{
labelFileName.Text = x;
Refresh();
string[] pathList = ConsoleProcess.adbProcess("-s " + deviceSerial + " shell pm path " + x).Split('\n').Where(it => it.Contains("package")).ToArray();
string[] pathList = ConsoleProcess.AdbProcess("-s " + deviceSerial + " shell pm path " + x).Split('\n').Where(it => it.Contains("package")).ToArray();
foreach (string path in pathList)
{
string result = ConsoleProcess.adbProcess(("-s " + deviceSerial + " pull " + path.Replace("package:", "").Trim() + " " + Application.StartupPath + "APKS\\" + x + "_" + path[(path.LastIndexOf('/') + 1)..]).Trim());
string result = ConsoleProcess.AdbProcess(("-s " + deviceSerial + " pull " + path.Replace("package:", "").Trim() + " " + Application.StartupPath + "APKS\\" + x + "_" + path[(path.LastIndexOf('/') + 1)..]).Trim());
if (!result.Contains("file pulled"))
{
failedApps.Add(result);
Expand Down
2 changes: 1 addition & 1 deletion ATA-GUI/Forms/MainForm.Designer.cs

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

Loading

0 comments on commit 3194d3f

Please sign in to comment.