Compare commits

...

8 Commits
v0.3 ... v0.5

Author SHA1 Message Date
nerdunit
bfe2ad2aad Update README.md 2020-06-14 13:37:15 +03:00
nerdunit
cebd440de2 Add files via upload 2020-06-14 13:36:58 +03:00
nerdunit
86bbb2d929 Update README.md 2020-06-06 20:10:10 +03:00
nerdunit
684408e8f2 Quick BugFix 2020-06-06 20:07:31 +03:00
nerdunit
d6bb14e8a4 Update version 2020-06-06 20:00:11 +03:00
nerdunit
616deec235 Add files via upload 2020-06-06 20:00:03 +03:00
nerdunit
7f9efc49f8 Add files via upload 2020-06-06 19:53:41 +03:00
nerdunit
684a65f432 bugfix 2020-06-06 09:02:26 +03:00
8 changed files with 250 additions and 142 deletions

BIN
7z.dll Normal file

Binary file not shown.

BIN
7z.exe Normal file

Binary file not shown.

75
Form1.Designer.cs generated
View File

@@ -33,11 +33,13 @@
this.instructionsbutton = new System.Windows.Forms.Button();
this.obbcopybutton = new System.Windows.Forms.Button();
this.progressBar1 = new System.Windows.Forms.ProgressBar();
this.flashfirmwarebutton = new System.Windows.Forms.Button();
this.backupbutton = new System.Windows.Forms.Button();
this.debugbutton = new System.Windows.Forms.Button();
this.restorebutton = new System.Windows.Forms.Button();
this.customadbcmdbutton = new System.Windows.Forms.Button();
this.ListApps = new System.Windows.Forms.Button();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.getApkButton = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// startsideloadbutton
@@ -82,26 +84,16 @@
//
// progressBar1
//
this.progressBar1.Location = new System.Drawing.Point(13, 92);
this.progressBar1.Location = new System.Drawing.Point(13, 161);
this.progressBar1.Name = "progressBar1";
this.progressBar1.Size = new System.Drawing.Size(356, 20);
this.progressBar1.Size = new System.Drawing.Size(426, 20);
this.progressBar1.TabIndex = 7;
//
// flashfirmwarebutton
//
this.flashfirmwarebutton.Location = new System.Drawing.Point(13, 52);
this.flashfirmwarebutton.Name = "flashfirmwarebutton";
this.flashfirmwarebutton.Size = new System.Drawing.Size(82, 34);
this.flashfirmwarebutton.TabIndex = 8;
this.flashfirmwarebutton.Text = "Flash Firmware";
this.flashfirmwarebutton.UseVisualStyleBackColor = true;
this.flashfirmwarebutton.Click += new System.EventHandler(this.flashfirmwarebutton_Click);
//
// backupbutton
//
this.backupbutton.Location = new System.Drawing.Point(100, 52);
this.backupbutton.Location = new System.Drawing.Point(13, 52);
this.backupbutton.Name = "backupbutton";
this.backupbutton.Size = new System.Drawing.Size(87, 34);
this.backupbutton.Size = new System.Drawing.Size(81, 34);
this.backupbutton.TabIndex = 9;
this.backupbutton.Text = "Backup Gamedata";
this.backupbutton.UseVisualStyleBackColor = true;
@@ -109,7 +101,7 @@
//
// debugbutton
//
this.debugbutton.Location = new System.Drawing.Point(-4, 107);
this.debugbutton.Location = new System.Drawing.Point(1, 2);
this.debugbutton.Name = "debugbutton";
this.debugbutton.Size = new System.Drawing.Size(75, 23);
this.debugbutton.TabIndex = 10;
@@ -119,9 +111,9 @@
//
// restorebutton
//
this.restorebutton.Location = new System.Drawing.Point(193, 52);
this.restorebutton.Location = new System.Drawing.Point(100, 52);
this.restorebutton.Name = "restorebutton";
this.restorebutton.Size = new System.Drawing.Size(82, 34);
this.restorebutton.Size = new System.Drawing.Size(87, 34);
this.restorebutton.TabIndex = 11;
this.restorebutton.Text = "Restore Gamedata";
this.restorebutton.UseVisualStyleBackColor = true;
@@ -129,31 +121,62 @@
//
// customadbcmdbutton
//
this.customadbcmdbutton.Location = new System.Drawing.Point(281, 52);
this.customadbcmdbutton.Location = new System.Drawing.Point(193, 52);
this.customadbcmdbutton.Name = "customadbcmdbutton";
this.customadbcmdbutton.Size = new System.Drawing.Size(88, 34);
this.customadbcmdbutton.Size = new System.Drawing.Size(82, 34);
this.customadbcmdbutton.TabIndex = 12;
this.customadbcmdbutton.Text = "Run Adb Command";
this.customadbcmdbutton.UseVisualStyleBackColor = true;
this.customadbcmdbutton.Click += new System.EventHandler(this.customadbcmdbutton_Click);
//
// ListApps
//
this.ListApps.Location = new System.Drawing.Point(12, 92);
this.ListApps.Name = "ListApps";
this.ListApps.Size = new System.Drawing.Size(82, 34);
this.ListApps.TabIndex = 13;
this.ListApps.Text = "List Apps";
this.ListApps.UseVisualStyleBackColor = true;
this.ListApps.Click += new System.EventHandler(this.ListApps_Click);
//
// comboBox1
//
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Location = new System.Drawing.Point(13, 134);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(426, 21);
this.comboBox1.TabIndex = 14;
this.comboBox1.Text = "Please Press List Apps First";
//
// getApkButton
//
this.getApkButton.Location = new System.Drawing.Point(100, 92);
this.getApkButton.Name = "getApkButton";
this.getApkButton.Size = new System.Drawing.Size(87, 34);
this.getApkButton.TabIndex = 15;
this.getApkButton.Text = "Get Apk";
this.getApkButton.UseVisualStyleBackColor = true;
this.getApkButton.Click += new System.EventHandler(this.getApkButton_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(383, 127);
this.ClientSize = new System.Drawing.Size(447, 193);
this.Controls.Add(this.getApkButton);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.ListApps);
this.Controls.Add(this.customadbcmdbutton);
this.Controls.Add(this.restorebutton);
this.Controls.Add(this.debugbutton);
this.Controls.Add(this.backupbutton);
this.Controls.Add(this.flashfirmwarebutton);
this.Controls.Add(this.progressBar1);
this.Controls.Add(this.obbcopybutton);
this.Controls.Add(this.instructionsbutton);
this.Controls.Add(this.devicesbutton);
this.Controls.Add(this.startsideloadbutton);
this.MaximumSize = new System.Drawing.Size(399, 166);
this.MinimumSize = new System.Drawing.Size(399, 166);
this.MaximumSize = new System.Drawing.Size(463, 232);
this.MinimumSize = new System.Drawing.Size(463, 232);
this.Name = "Form1";
this.Text = "Rookie SideLoader";
this.Load += new System.EventHandler(this.Form1_Load);
@@ -167,11 +190,13 @@
private System.Windows.Forms.Button instructionsbutton;
private System.Windows.Forms.Button obbcopybutton;
private System.Windows.Forms.ProgressBar progressBar1;
private System.Windows.Forms.Button flashfirmwarebutton;
private System.Windows.Forms.Button backupbutton;
private System.Windows.Forms.Button debugbutton;
private System.Windows.Forms.Button restorebutton;
private System.Windows.Forms.Button customadbcmdbutton;
private System.Windows.Forms.Button ListApps;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.Button getApkButton;
}
}

235
Form1.cs
View File

@@ -6,6 +6,7 @@ using System.Threading;
using System.Windows;
using System.Net.Http;
using System.Reflection;
using System.Net;
@@ -14,16 +15,16 @@ namespace AndroidSideloader
public partial class Form1 : Form
{
#if DEBUG
#if DEBUG
bool debugMode = true;
#else
bool debugMode = false;
#endif
#else
bool debugMode = false;
#endif
string path;
string obbPath = "";
string obbFile;
string allText;
bool exit = false;
string debugPath = "debug.log";
public string adbPath = Environment.CurrentDirectory + "\\adb\\";
@@ -37,9 +38,10 @@ namespace AndroidSideloader
{
progressBar1.Value = 0;
exit = false;
MessageBox.Show("Action Started, may take some time...");
Process cmd = new Process();
cmd.StartInfo.FileName = "cmd.exe";
cmd.StartInfo.FileName = Environment.CurrentDirectory + "\\adb\\adb.exe";
cmd.StartInfo.Arguments = command;
cmd.StartInfo.RedirectStandardInput = true;
cmd.StartInfo.RedirectStandardOutput = true;
cmd.StartInfo.CreateNoWindow = true;
@@ -49,9 +51,11 @@ namespace AndroidSideloader
cmd.StandardInput.WriteLine(command);
cmd.StandardInput.Flush();
cmd.StandardInput.Close();
cmd.WaitForExit();
allText = cmd.StandardOutput.ReadToEnd();
cmd.WaitForExit();
StreamWriter sw = File.AppendText(debugPath);
sw.Write("Action name = " + command + '\n');
sw.Write(allText);
sw.Write("\n--------------------------------------------------------------------\n");
sw.Flush();
@@ -66,20 +70,21 @@ namespace AndroidSideloader
FileInfo fi = new FileInfo(filePath);
//fi.Length file size in bytes
PerformanceCounter disk = new PerformanceCounter("PhysicalDisk", "Disk Write Bytes/sec", "_total");
var bytes = 0f;
progressBar1.Maximum = (int)(fi.Length/128);
while (exit==false)
{
bytes += disk.NextValue();
try { progressBar1.Value = (int)(bytes); } catch { progressBar1.Maximum *= 2; }
Thread.Sleep(1000);
}
progressBar1.Maximum = (int)(fi.Length / 128);
while (exit == false)
{
bytes += disk.NextValue();
try { progressBar1.Value = (int)(bytes); } catch { progressBar1.Maximum *= 2; }
Thread.Sleep(1000);
}
progressBar1.Value = progressBar1.Maximum;
}
private void startsideloadbutton_Click(object sender, EventArgs e)
{
using (OpenFileDialog openFileDialog = new OpenFileDialog())
{
openFileDialog.Filter = "Android apps (*.apk)|*.apk";
@@ -92,37 +97,30 @@ namespace AndroidSideloader
return;
}
if (path=="" || path.EndsWith(".apk")==false)
if (path == "" || path.EndsWith(".apk") == false)
MessageBox.Show("You must select an apk");
else
{
MessageBox.Show("Action Started, may take some time...");
Thread t1 = new Thread(() =>
{
runAdbCommand("adb.exe install -r " + '"' + path + '"');
runAdbCommand("install -r " + '"' + path + '"');
});
t1.IsBackground = true;
t1.Start();
runLoadingBar(path);
if (line[line.Length - 3].Contains("Success")==false)
{
MessageBox.Show("An error has occured, send the debug.log to rookie.lol");
}
else
MessageBox.Show(line[line.Length - 3]);
MessageBox.Show(allText);
}
}
private void devicesbutton_Click(object sender, EventArgs e)
{
runAdbCommand("adb.exe devices");
if (line[line.Length - 4].Contains("List of devices attached") == false)
MessageBox.Show(line[line.Length - 4]);
else
MessageBox.Show("No android device attached");
MessageBox.Show("Action Started, may take some time...");
runAdbCommand("devices");
MessageBox.Show(allText);
}
private void instructionsbutton_Click(object sender, EventArgs e)
@@ -136,6 +134,17 @@ namespace AndroidSideloader
MessageBox.Show(instructions);
}
public void ExtractFile(string sourceArchive, string destination)
{
string zPath = "7z.exe"; //add to proj and set CopyToOuputDir
ProcessStartInfo pro = new ProcessStartInfo();
pro.WindowStyle = ProcessWindowStyle.Hidden;
pro.FileName = zPath;
pro.Arguments = string.Format("x \"{0}\" -y -o\"{1}\"", sourceArchive, destination);
Process x = Process.Start(pro);
x.WaitForExit();
}
private void obbcopybutton_Click(object sender, EventArgs e)
{
using (var fbd = new FolderBrowserDialog())
@@ -154,17 +163,17 @@ namespace AndroidSideloader
if (obbPath.Length>0)
{
MessageBox.Show("Action Started, may take some time...");
Thread t1 = new Thread(() =>
{
runAdbCommand("adb push " + '"' + obbPath + '"' + " /sdcard/Android/obb");
runAdbCommand("push " + '"' + obbPath + '"' + " /sdcard/Android/obb");
});
t1.IsBackground = true;
t1.Start();
runLoadingBar(obbFile);
MessageBox.Show(line[line.Length - 3]);
MessageBox.Show(allText);
}
else
{
@@ -178,8 +187,33 @@ namespace AndroidSideloader
debugbutton.Visible = false;
if (Directory.Exists(adbPath)==false)
{
MessageBox.Show("You need to have the adb folder in the same folder as this software");
Environment.Exit(600);
MessageBox.Show("Please wait for the software to download and install the adb");
try
{
using (var client = new WebClient())
{
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
client.DownloadFile("https://github.com/nerdunit/androidsideloader/raw/master/7z.exe", "7z.exe");
client.DownloadFile("https://github.com/nerdunit/androidsideloader/raw/master/7z.dll", "7z.dll");
client.DownloadFile("http://github.com/nerdunit/androidsideloader/releases/download/v0.3/adb.7z", "adb.7z");
}
ExtractFile(Environment.CurrentDirectory + "\\adb.7z", Environment.CurrentDirectory);
File.Delete("adb.7z");
File.Delete("7z.dll");
File.Delete("7z.exe");
}
catch (Exception ex)
{
MessageBox.Show("Cannot download adb because you are not connected to the internet!");
StreamWriter sw = File.AppendText(debugPath);
sw.Write("\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
sw.Write(ex.ToString() + "\n");
sw.Flush();
sw.Close();
Environment.Exit(600);
}
}
if (debugMode==false)
checkForUpdate();
@@ -187,14 +221,14 @@ namespace AndroidSideloader
}
void intToolTips()
{
ToolTip FlashFirmwareToolTip = new ToolTip();
FlashFirmwareToolTip.SetToolTip(this.flashfirmwarebutton, "Make sure to put the firmware with the name UPDATE.zip in the software directory");
ToolTip ListAppsToolTip = new ToolTip();
ListAppsToolTip.SetToolTip(this.ListApps, "Press this to show what packages you have installed");
}
void checkForUpdate()
{
try
{
string localVersion = "0.2";
string localVersion = "0.5";
HttpClient client = new HttpClient();
string currentVersion = client.GetStringAsync("https://raw.githubusercontent.com/nerdunit/androidsideloader/master/version").Result;
currentVersion = currentVersion.Remove(currentVersion.Length - 1);
@@ -207,56 +241,13 @@ namespace AndroidSideloader
}
}
private void flashfirmwarebutton_Click(object sender, EventArgs e)
{
const string message =
"This is a dangerous action, be sure you know what you are doing! This feature is not tested and the loading bar may bug out Do NOT disconnect the quest, wait for the messagebox to show up first Press yes to continue";
const string caption = "WARNING";
var result = MessageBox.Show(message, caption,
MessageBoxButtons.YesNo,
MessageBoxIcon.Warning);
if (result == DialogResult.No)
return;
using (OpenFileDialog openFileDialog = new OpenFileDialog())
{
openFileDialog.Filter = "Android Firmware (*.zip)|*.zip";
openFileDialog.FilterIndex = 2;
openFileDialog.RestoreDirectory = true;
if (openFileDialog.ShowDialog() == DialogResult.OK)
path = openFileDialog.FileName;
else
return;
}
File.Copy(path, Environment.CurrentDirectory + "\\UPDATE.zip");
Thread t1 = new Thread(() =>
{
runAdbCommand("adb reboot bootloader");
Thread.Sleep(1000 * 15);
runAdbCommand("fastboot oem reboot-sideload");
Thread.Sleep(1000 * 15);
runAdbCommand("adb sideload UPDATE.zip");
});
t1.IsBackground = true;
t1.Start();
Thread.Sleep(1000 * 30);
runLoadingBar(path);
MessageBox.Show("Let the Quest sit for a bit, it will fully reboot back into Quest Home, then put it on and reboot, (hold power button a bit and select reboot)");
MessageBox.Show(allText);
}
private void backupbutton_Click(object sender, EventArgs e)
{
MessageBox.Show("Action Started, may take some time...");
Thread t1 = new Thread(() =>
{
runAdbCommand("adb pull " + '"' + "/sdcard/Android/data" + '"');
runAdbCommand("pull " + '"' + "/sdcard/Android/data" + '"');
});
t1.IsBackground = true;
t1.Start();
@@ -266,7 +257,7 @@ namespace AndroidSideloader
Directory.Move(adbPath + "data", Environment.CurrentDirectory + "\\data");
MessageBox.Show(line[line.Length - 3]);
MessageBox.Show(allText);
}
private void debugbutton_Click(object sender, EventArgs e)
@@ -287,10 +278,10 @@ namespace AndroidSideloader
}
else return;
}
MessageBox.Show("Action Started, may take some time...");
Thread t1 = new Thread(() =>
{
runAdbCommand("adb push " + '"' + obbPath + '"' + " /sdcard/Android/");
runAdbCommand("push " + '"' + obbPath + '"' + " /sdcard/Android/");
});
t1.IsBackground = true;
t1.Start();
@@ -298,7 +289,7 @@ namespace AndroidSideloader
while (exit == false)
Thread.Sleep(1000);
MessageBox.Show(line[line.Length - 3]);
MessageBox.Show(allText);
}
private void customadbcmdbutton_Click(object sender, EventArgs e)
@@ -306,5 +297,75 @@ namespace AndroidSideloader
customAdbCommandForm adbCommandForm = new customAdbCommandForm();
adbCommandForm.Show();
}
private void ListApps_Click(object sender, EventArgs e)
{
allText = "";
comboBox1.Items.Clear();
Thread t1 = new Thread(() =>
{
runAdbCommand("shell pm list packages");
});
t1.IsBackground = true;
t1.Start();
while (exit == false)
Thread.Sleep(1000);
foreach (string obj in line)
{
comboBox1.Items.Add(obj);
}
if (allText.Length > 0)
MessageBox.Show("Fetched apks with success");
}
private void getApkButton_Click(object sender, EventArgs e)
{
string package;
allText = "";
try
{
package = comboBox1.SelectedItem.ToString().Remove(0,8); //remove package:
package = package.Remove(package.Length - 1);
} catch { MessageBox.Show("You must first run list items"); return; }
//MessageBox.Show(package);
exit = false;
Thread t1 = new Thread(() =>
{
runAdbCommand("shell pm path " + package);
});
t1.IsBackground = true;
t1.Start();
while (exit == false)
Thread.Sleep(1000);
allText = allText.Remove(allText.Length - 1);
//MessageBox.Show(allText);
string apkPath = allText.Remove(0, 8); //remove package:
apkPath = apkPath.Remove(apkPath.Length - 1);
//MessageBox.Show(adbPath);
Thread t2 = new Thread(() =>
{
runAdbCommand("pull " + apkPath);
});
t2.IsBackground = true;
t2.Start();
while (exit == false)
Thread.Sleep(1000);
string currApkPath = apkPath;
while (currApkPath.Contains("/"))
currApkPath = currApkPath.Substring(currApkPath.IndexOf("/") + 1);
Thread.Sleep(1000);
File.Copy(Environment.CurrentDirectory + "\\adb\\" + currApkPath, Environment.CurrentDirectory + "\\" + package + ".apk");
File.Delete(Environment.CurrentDirectory + "\\adb\\" + currApkPath);
}
}
}

View File

@@ -2,6 +2,20 @@
Changelog
0.5
- Removed Flash Firmware
- Redesigned UI
- Reworked RunAdbCommand function (now it will be possible to do stuff I wasnt able to do before)
- Replaced Ui Buttons, still needs work
- Added List apk button
- Added List apk combo box
- Added get apk function
- Cleaned a bit of code
0.4
- Added auto download of adb archive
- Added auto extraction of adb archive
0.3
- Added new form, you can run custom adb commands now
- Added recover and backup app data

View File

@@ -48,6 +48,7 @@
this.richTextBox1.Size = new System.Drawing.Size(775, 365);
this.richTextBox1.TabIndex = 1;
this.richTextBox1.Text = "";
this.richTextBox1.TextChanged += new System.EventHandler(this.richTextBox1_TextChanged);
//
// runcustomadbcmdbutton
//
@@ -69,6 +70,7 @@
this.Controls.Add(this.textBox1);
this.Name = "customAdbCommandForm";
this.Text = "customAdbCommandForm";
this.Load += new System.EventHandler(this.customAdbCommandForm_Load);
this.ResumeLayout(false);
this.PerformLayout();

View File

@@ -18,43 +18,49 @@ namespace AndroidSideloader
string output;
private void runcustomadbcmdbutton_Click(object sender, EventArgs e)
{
var command = textBox1.Text;
if (command.StartsWith("adb "))
command = command.Remove(0, 4);
runAdbCommand(command);
}
public void runAdbCommand(string command)
{
Thread t1 = new Thread(() =>
{
Process cmd = new Process();
cmd.StartInfo.FileName = "cmd.exe";
cmd.StartInfo.RedirectStandardInput = true;
cmd.StartInfo.RedirectStandardOutput = true;
cmd.StartInfo.CreateNoWindow = true;
cmd.StartInfo.UseShellExecute = false;
cmd.StartInfo.WorkingDirectory = Environment.CurrentDirectory + "\\adb\\";
cmd.Start();
cmd.StandardInput.WriteLine(command);
cmd.StandardInput.Flush();
cmd.StandardInput.Close();
cmd.WaitForExit();
output = cmd.StandardOutput.ReadToEnd();
StreamWriter sw = File.AppendText("debugC.log");
sw.Write(output);
sw.Write("\n--------------------------------------------------------------------\n");
sw.Flush();
sw.Close();
});
t1.IsBackground = true;
t1.Start();
Process cmd = new Process();
cmd.StartInfo.FileName = Environment.CurrentDirectory + "\\adb\\adb.exe";
cmd.StartInfo.Arguments = command;
cmd.StartInfo.RedirectStandardInput = true;
cmd.StartInfo.RedirectStandardOutput = true;
cmd.StartInfo.CreateNoWindow = true;
cmd.StartInfo.UseShellExecute = false;
cmd.StartInfo.WorkingDirectory = Environment.CurrentDirectory + "\\adb\\";
cmd.Start();
cmd.StandardInput.WriteLine(command);
cmd.StandardInput.Flush();
cmd.StandardInput.Close();
output = cmd.StandardOutput.ReadToEnd();
cmd.WaitForExit();
t1.Join();
StreamWriter sw = File.AppendText("debugC.log");
sw.Write("Action name = " + command + '\n');
sw.Write(output);
sw.Write("\n--------------------------------------------------------------------\n");
sw.Flush();
sw.Close();
richTextBox1.Text = output;
}
private void runcustomadbcmdbutton_Click(object sender, EventArgs e)
private void customAdbCommandForm_Load(object sender, EventArgs e)
{
if (textBox1.Text.Split(' ').Length>1)
runAdbCommand(textBox1.Text);
else
MessageBox.Show("You must enter at least 1 argument");
}
private void richTextBox1_TextChanged(object sender, EventArgs e)
{
}
}
}

View File

@@ -1 +1 @@
0.3
0.4