diff --git a/ADBForwarder.csproj b/ADBForwarder.csproj
index 4a57efe..0b7b19f 100644
--- a/ADBForwarder.csproj
+++ b/ADBForwarder.csproj
@@ -3,17 +3,10 @@
Exe
net6.0
- true
- true
- true
- win-x64
- false
- true
- link
- link
+
diff --git a/Program.cs b/Program.cs
index e745938..0a71d6d 100644
--- a/Program.cs
+++ b/Program.cs
@@ -1,34 +1,38 @@
using System;
using SharpAdbClient;
using System.Net;
+using System.IO;
+using Ionic.Zip;
namespace ADBForwarder
{
class Program
{
- const string sidequest = "\\Programs\\SideQuest\\resources\\app.asar.unpacked\\build\\platform-tools\\adb.exe";
- static string localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
- static string adbPath = localAppData + sidequest; //i fucking hate this but path.combine was not having it
+ //const string sidequest = "\\Programs\\SideQuest\\resources\\app.asar.unpacked\\build\\platform-tools\\adb.exe";
+ //static string localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
+ static string adbPath = Path.GetTempPath() + "\\adb\\platform-tools\\adb.exe";
+ static Uri uri = new Uri("https://dl.google.com/android/repository/platform-tools-latest-windows.zip");
+
static void Main(string[] args)
{
- Console.WriteLine("starting");
-
var endPoint = new IPEndPoint(IPAddress.Loopback, AdbClient.AdbServerPort);
AdbServer server = new AdbServer();
- try
+
+ if(!File.Exists(adbPath))
{
+ Console.WriteLine("ADB not found, downloading in the background...");
+ DownloadADB();
+ Console.WriteLine("Download Successful, starting ADB Daemon...");
var result = server.StartServer(adbPath, restartServerIfNewer: false);
- Console.WriteLine("ADB Daemon Started");
+
}
- catch
+ else
{
- Console.WriteLine("SideQuest not installed.");
- Console.ReadKey();
- return;
+ var result = server.StartServer(adbPath, restartServerIfNewer: false);
+ Console.WriteLine("Starting ADB Daemon...");
}
-
var client = new AdbClient();
client.Connect(endPoint);
@@ -57,6 +61,20 @@ static void Main(string[] args)
}
}
}
+
+ static void DownloadADB()
+ {
+ using (var client = new WebClient())
+ {
+ client.DownloadFile(uri, "adb.zip");
+
+ using (ZipFile zip = ZipFile.Read("adb.zip"))
+ {
+ zip.ExtractAll(Path.GetTempPath() + "\\adb",
+ ExtractExistingFileAction.DoNotOverwrite);
+ }
+ }
+ }
}
}