Fixed all issues.

This commit is contained in:
Harry Fn Potter
2021-06-19 20:00:18 -04:00
parent 5e30e3a22c
commit b9e98894e9
3 changed files with 59 additions and 63 deletions

40
ADB.cs
View File

@@ -12,8 +12,8 @@ namespace AndroidSideloader
class ADB
{
static Process adb = new Process();
public static string adbFolderPath = Properties.Settings.Default.ADBPath;
public static string adbFilePath = Properties.Settings.Default.ADBPath + "\\adb.exe";
public static string adbFolderPath = Environment.CurrentDirectory + "\\adb";
public static string adbFilePath = adbFolderPath + "\\adb.exe";
public static string DeviceID = "";
public static ProcessOutput RunAdbCommandToString(string command)
@@ -34,31 +34,19 @@ namespace AndroidSideloader
adb.Start();
adb.StandardInput.WriteLine(command);
adb.StandardInput.Flush();
adb.StandardInput.Close();
string output = "";
string error = "";
try
{
{
output = adb.StandardOutput.ReadToEnd();
error = adb.StandardError.ReadToEnd();
}
catch { }
if (command.Contains("connect"))
{
bool graceful = adb.WaitForExit(5000); //Wait 7 secs.
if (!graceful)
{
adb.Kill();
}
}
else
adb.WaitForExit();
if (error.Contains("ADB_VENDOR_KEYS"))
MessageBox.Show("Please check inside your headset for ADB DEBUGGING prompt, check box to \"Always allow from this computer.\" and hit OK.");
Logger.Log(output);
Logger.Log(error);
return new ProcessOutput(output, error);
@@ -86,19 +74,29 @@ namespace AndroidSideloader
try
{
output += adb.StandardOutput.ReadToEnd();
error += adb.StandardError.ReadToEnd();
output += adb.StandardOutput.ReadToEnd();
error += adb.StandardError.ReadToEnd();
}
catch { }
adb.WaitForExit();
if (command.Contains("connect"))
{
bool graceful = adb.WaitForExit(3000);
if (!graceful)
{
adb.Kill();
}
}
else
adb.WaitForExit();
if (error.Contains("ADB_VENDOR_KEYS"))
MessageBox.Show("Please check inside your headset for ADB DEBUGGING prompt, check box to \"Always allow from this computer.\" and hit OK.");
Logger.Log(output);
Logger.Log(error);
return new ProcessOutput(output, error);
}
public static ProcessOutput UninstallPackage(string package)
public static ProcessOutput UninstallPackage(string package)
{
WakeDevice();
ProcessOutput output = new ProcessOutput("", "");
@@ -114,7 +112,7 @@ namespace AndroidSideloader
long usedSize = 0;
long freeSize = 0;
WakeDevice();
var output = RunAdbCommandToString("shell df").Output.Split('\n');
foreach (string currLine in output)

View File

@@ -194,29 +194,28 @@ namespace AndroidSideloader
public void ChangeTitlebarToDevice()
{
if (Devices[0].Length > 1 && Devices.Contains("unauthorized") || Devices.Contains("ADB_VENDOR_KEYS"))
{
DeviceConnected = false;
this.Invoke(() =>
{
this.Text = "Device Not Authorized";
DialogResult dialogResult = MessageBox.Show("Device not authorized, check device screen for ALLOW USB DEBUGGING prompt, check \"Always allow\" box and hit OK.", "Not Authorized", MessageBoxButtons.RetryCancel);
if (dialogResult == DialogResult.Retry)
{
devicesbutton.PerformClick();
}
else
{
return;
}
});
}
if (!Devices.Contains("unauthorized"))
{
{
if (Devices[0].Length > 1 && Devices[0].Contains("unauthorized"))
{
DeviceConnected = false;
this.Invoke(() =>
{
this.Text = "Device Not Authorized";
DialogResult dialogResult = MessageBox.Show("Device not authorized, be sure to authorize computer on device.", "Not Authorized", MessageBoxButtons.RetryCancel);
if (dialogResult == DialogResult.Retry)
{
devicesbutton.PerformClick();
;
}
else
{
return;
}
if (Devices[0].Length > 1)
});
}
else if (Devices[0].Length > 1)
{
this.Invoke(() => { this.Text = "Device Connected with ID | " + Devices[0].Replace("device", ""); });
DeviceConnected = true;
@@ -240,7 +239,6 @@ namespace AndroidSideloader
});
}
}
public async void showAvailableSpace()
@@ -291,13 +289,12 @@ namespace AndroidSideloader
private async void Form1_Load(object sender, EventArgs e)
{
if (Directory.Exists($"{Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)}\\SideQuest\\platform-tools"))
Properties.Settings.Default.ADBPath = $"{Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)}\\SideQuest\\platform-tools";
else
Properties.Settings.Default.ADBPath = Environment.CurrentDirectory + "\\adb";
Properties.Settings.Default.MainDir = Environment.CurrentDirectory;
Properties.Settings.Default.ADBPath = $"{Properties.Settings.Default.MainDir}\\adb\\adb.exe";
Properties.Settings.Default.Save();
ADB.RunAdbCommandToString("kill-server");
if (File.Exists(Sideloader.CrashLogPath))
{
DialogResult dialogResult = FlexibleMessageBox.Show(this, $@"Looks like sideloader crashed last time, please make an issue at https://github.com/nerdunit/androidsideloader/issues
@@ -353,7 +350,6 @@ Do you want to delete the {Sideloader.CrashLogPath} (if you press yes, this mess
ADB.WakeDevice();
await CheckForDevice();
ChangeTitlebarToDevice();
ADB.RunAdbCommandToString("shell svc usb setFunctions mtp true");
}
catch { }
}
@@ -432,10 +428,7 @@ Do you want to delete the {Sideloader.CrashLogPath} (if you press yes, this mess
string path = dialog.FileName;
Thread t1 = new Thread(() =>
{
if (path.Contains("com."))
output += ADB.RunAdbCommandToString($"push \"{path}\" /sdcard/Android/data/");
if (path.Contains("data"))
output += ADB.RunAdbCommandToString($"push \"{path}\" /sdcard/Android/");
output += ADB.RunAdbCommandToString($"push \"{path}\" /sdcard/Android/");
});
t1.IsBackground = true;
t1.Start();
@@ -524,7 +517,7 @@ Do you want to delete the {Sideloader.CrashLogPath} (if you press yes, this mess
ADB.WakeDevice();
if (m_combo.SelectedIndex == -1)
{
FlexibleMessageBox.Show("Please select an app first ");
FlexibleMessageBox.Show("Please select an app first");
return;
}
string date_str = DateTime.Today.ToString("yyyy.MM.dd");
@@ -533,10 +526,12 @@ Do you want to delete the {Sideloader.CrashLogPath} (if you press yes, this mess
string GameName = m_combo.SelectedItem.ToString();
string packagename = Sideloader.gameNameToPackageName(GameName);
MessageBox.Show($"If savedata is found it will be saved to Documents\\Rookie Backups\\{date_str}(year.month.date)\\{packagename}", "Attempting Backup...", MessageBoxButtons.OK);
MessageBox.Show($"If savedata is found it will be saved to Documents\\Rookie Backups\\{date_str}(year.month.date)\\{packagename}\\data", "Attempting Backup...", MessageBoxButtons.OK);
Directory.CreateDirectory(CurrBackups);
ADB.RunAdbCommandToString($"pull \"/sdcard/Android/data/{packagename}\" \"{CurrBackups}\"");
String CurrbackupPaths = CurrBackups + "\\" + packagename + "\\data";
Directory.CreateDirectory(CurrbackupPaths);
ADB.RunAdbCommandToString($"pull \"/sdcard/Android/data/{packagename}\" \"{CurrbackupPaths}\"");
DialogResult dialogResult = MessageBox.Show($"Please check to see if we automatically found savedata in Documents\\Rookie Backups.\nIf there are no new files there is recommended that you do a full backup via Backup Gamedata before continuing.\nNOTE: Some games do not allow backup of savedata.\nContinue with the uninstall?", "Check for backup.", MessageBoxButtons.OKCancel);
if (dialogResult == DialogResult.Cancel)
{
@@ -1325,7 +1320,6 @@ without him none of this would be possible
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
RCLONE.killRclone();
ADB.RunAdbCommandToString("kill-server");
}
private void ADBWirelessDisable_Click(object sender, EventArgs e)
@@ -1523,12 +1517,15 @@ without him none of this would be possible
{
ADB.WakeDevice();
if (ADB.DeviceID.Contains(":5555")) {
MessageBox.Show("Mounting does not work with Wireless ADB, you must plug Quest into PC to mount.");
if (DeviceConnected)
{
if (ADB.DeviceID.Contains(":5555"))
MessageBox.Show("Mounting does not work with Wireless ADB, you must plug Quest into PC to mount.");
ADB.RunAdbCommandToString("shell svc usb setFunctions mtp true");
}
ADB.RunAdbCommandToString("shell svc usb setFunctions mtp true");
else
FlexibleMessageBox.Show("You must connect a device before mounting!");
}
private void freeDisclaimer_Click(object sender, EventArgs e)

View File

@@ -17,7 +17,7 @@ namespace AndroidSideloader
private static string RawGitHubUrl;
private static string GitHubUrl;
static readonly public string LocalVersion = "2.1.2";
static readonly public string LocalVersion = "2.1HF2";
public static string currentVersion = string.Empty;
public static string changelog = string.Empty;
@@ -30,6 +30,7 @@ namespace AndroidSideloader
currentVersion = client.GetStringAsync($"{RawGitHubUrl}/master/version").Result;
if (currentVersion.Length > LocalVersion.Length)
currentVersion = currentVersion.Remove(currentVersion.Length - 1);
currentVersion = currentVersion.Replace("\n", "");
changelog = client.GetStringAsync($"{RawGitHubUrl}/master/changelog.txt").Result;
client.Dispose();
}