Compare commits

...

4 Commits
v0.6 ... v0.7

Author SHA1 Message Date
nerdunit
978dc671ef Add files via upload 2020-06-17 23:35:35 +03:00
nerdunit
bcd61f1596 Add files via upload 2020-06-17 23:34:33 +03:00
nerdunit
82f858b678 Update version 2020-06-16 11:08:06 +03:00
nerdunit
fa3b795695 Update README.md 2020-06-16 11:07:56 +03:00
4 changed files with 225 additions and 130 deletions

62
Form1.Designer.cs generated
View File

@@ -32,7 +32,6 @@
this.devicesbutton = new System.Windows.Forms.Button();
this.instructionsbutton = new System.Windows.Forms.Button();
this.obbcopybutton = new System.Windows.Forms.Button();
this.progressBar1 = new System.Windows.Forms.ProgressBar();
this.backupbutton = new System.Windows.Forms.Button();
this.debugbutton = new System.Windows.Forms.Button();
this.restorebutton = new System.Windows.Forms.Button();
@@ -42,6 +41,9 @@
this.getApkButton = new System.Windows.Forms.Button();
this.listApkPermsButton = new System.Windows.Forms.Button();
this.changePermsBtn = new System.Windows.Forms.Button();
this.launchPackageTextBox = new System.Windows.Forms.TextBox();
this.launchApkButton = new System.Windows.Forms.Button();
this.uninstallAppButton = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// startsideloadbutton
@@ -66,9 +68,9 @@
//
// instructionsbutton
//
this.instructionsbutton.Location = new System.Drawing.Point(281, 12);
this.instructionsbutton.Location = new System.Drawing.Point(282, 12);
this.instructionsbutton.Name = "instructionsbutton";
this.instructionsbutton.Size = new System.Drawing.Size(88, 34);
this.instructionsbutton.Size = new System.Drawing.Size(87, 34);
this.instructionsbutton.TabIndex = 4;
this.instructionsbutton.Text = "Instructions";
this.instructionsbutton.UseVisualStyleBackColor = true;
@@ -78,19 +80,12 @@
//
this.obbcopybutton.Location = new System.Drawing.Point(193, 12);
this.obbcopybutton.Name = "obbcopybutton";
this.obbcopybutton.Size = new System.Drawing.Size(82, 34);
this.obbcopybutton.Size = new System.Drawing.Size(87, 34);
this.obbcopybutton.TabIndex = 5;
this.obbcopybutton.Text = "Copy Obb";
this.obbcopybutton.UseVisualStyleBackColor = true;
this.obbcopybutton.Click += new System.EventHandler(this.obbcopybutton_Click);
//
// progressBar1
//
this.progressBar1.Location = new System.Drawing.Point(13, 161);
this.progressBar1.Name = "progressBar1";
this.progressBar1.Size = new System.Drawing.Size(426, 20);
this.progressBar1.TabIndex = 7;
//
// backupbutton
//
this.backupbutton.Location = new System.Drawing.Point(13, 52);
@@ -125,7 +120,7 @@
//
this.customadbcmdbutton.Location = new System.Drawing.Point(193, 52);
this.customadbcmdbutton.Name = "customadbcmdbutton";
this.customadbcmdbutton.Size = new System.Drawing.Size(82, 34);
this.customadbcmdbutton.Size = new System.Drawing.Size(87, 34);
this.customadbcmdbutton.TabIndex = 12;
this.customadbcmdbutton.Text = "Run Adb Command";
this.customadbcmdbutton.UseVisualStyleBackColor = true;
@@ -172,7 +167,7 @@
//
// changePermsBtn
//
this.changePermsBtn.Location = new System.Drawing.Point(286, 92);
this.changePermsBtn.Location = new System.Drawing.Point(282, 92);
this.changePermsBtn.Name = "changePermsBtn";
this.changePermsBtn.Size = new System.Drawing.Size(87, 34);
this.changePermsBtn.TabIndex = 17;
@@ -180,11 +175,42 @@
this.changePermsBtn.UseVisualStyleBackColor = true;
this.changePermsBtn.Click += new System.EventHandler(this.changePermsBtn_Click);
//
// launchPackageTextBox
//
this.launchPackageTextBox.Location = new System.Drawing.Point(446, 134);
this.launchPackageTextBox.Name = "launchPackageTextBox";
this.launchPackageTextBox.Size = new System.Drawing.Size(192, 20);
this.launchPackageTextBox.TabIndex = 18;
this.launchPackageTextBox.Text = "de.eye_interactive.atvl.settings";
//
// launchApkButton
//
this.launchApkButton.Location = new System.Drawing.Point(446, 161);
this.launchApkButton.Name = "launchApkButton";
this.launchApkButton.Size = new System.Drawing.Size(192, 20);
this.launchApkButton.TabIndex = 19;
this.launchApkButton.Text = "Launch Apk By Package Name";
this.launchApkButton.UseVisualStyleBackColor = true;
this.launchApkButton.Click += new System.EventHandler(this.launchApkButton_Click);
//
// uninstallAppButton
//
this.uninstallAppButton.Location = new System.Drawing.Point(375, 92);
this.uninstallAppButton.Name = "uninstallAppButton";
this.uninstallAppButton.Size = new System.Drawing.Size(64, 34);
this.uninstallAppButton.TabIndex = 20;
this.uninstallAppButton.Text = "Uninstall app";
this.uninstallAppButton.UseVisualStyleBackColor = true;
this.uninstallAppButton.Click += new System.EventHandler(this.uninstallAppButton_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(450, 411);
this.ClientSize = new System.Drawing.Size(650, 411);
this.Controls.Add(this.uninstallAppButton);
this.Controls.Add(this.launchApkButton);
this.Controls.Add(this.launchPackageTextBox);
this.Controls.Add(this.changePermsBtn);
this.Controls.Add(this.listApkPermsButton);
this.Controls.Add(this.getApkButton);
@@ -194,17 +220,17 @@
this.Controls.Add(this.restorebutton);
this.Controls.Add(this.debugbutton);
this.Controls.Add(this.backupbutton);
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(466, 1000);
this.MaximumSize = new System.Drawing.Size(666, 1000);
this.MinimumSize = new System.Drawing.Size(466, 450);
this.Name = "Form1";
this.Text = "Rookie SideLoader";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
@@ -213,7 +239,6 @@
private System.Windows.Forms.Button devicesbutton;
private System.Windows.Forms.Button instructionsbutton;
private System.Windows.Forms.Button obbcopybutton;
private System.Windows.Forms.ProgressBar progressBar1;
private System.Windows.Forms.Button backupbutton;
private System.Windows.Forms.Button debugbutton;
private System.Windows.Forms.Button restorebutton;
@@ -223,6 +248,9 @@
private System.Windows.Forms.Button getApkButton;
private System.Windows.Forms.Button listApkPermsButton;
private System.Windows.Forms.Button changePermsBtn;
private System.Windows.Forms.TextBox launchPackageTextBox;
private System.Windows.Forms.Button launchApkButton;
private System.Windows.Forms.Button uninstallAppButton;
}
}

285
Form1.cs
View File

@@ -4,6 +4,7 @@ using System.Windows.Forms;
using System.IO;
using System.Threading;
using System.Windows;
using System.Threading.Tasks;
using System.Net.Http;
using System.Reflection;
using System.Net;
@@ -35,8 +36,8 @@ namespace AndroidSideloader
}
public void runAdbCommand(string command)
{
progressBar1.Value = 0;
{
exit = false;
Process cmd = new Process();
@@ -64,25 +65,18 @@ namespace AndroidSideloader
exit = true;
}
void runLoadingBar(string filePath)
private void sideload(string path)
{
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)
Thread t1 = new Thread(() =>
{
bytes += disk.NextValue();
try { progressBar1.Value = (int)(bytes); } catch { progressBar1.Maximum *= 2; }
Thread.Sleep(1000);
}
progressBar1.Value = progressBar1.Maximum;
runAdbCommand("install -r " + '"' + path + '"');
});
t1.IsBackground = true;
t1.Start();
t1.Join();
}
private void startsideloadbutton_Click(object sender, EventArgs e)
private async void startsideloadbutton_Click(object sender, EventArgs e)
{
using (OpenFileDialog openFileDialog = new OpenFileDialog())
@@ -101,15 +95,8 @@ namespace AndroidSideloader
MessageBox.Show("You must select an apk");
else
{
MessageBox.Show("Action Started, may take some time...");
Thread t1 = new Thread(() =>
{
runAdbCommand("install -r " + '"' + path + '"');
});
t1.IsBackground = true;
t1.Start();
runLoadingBar(path);
await Task.Run(() => sideload(path));
MessageBox.Show(allText);
}
@@ -145,7 +132,18 @@ namespace AndroidSideloader
x.WaitForExit();
}
private void obbcopybutton_Click(object sender, EventArgs e)
private void obbcopy(string obbPath)
{
Thread t1 = new Thread(() =>
{
runAdbCommand("push " + '"' + obbPath + '"' + " /sdcard/Android/obb");
});
t1.IsBackground = true;
t1.Start();
t1.Join();
}
private async void obbcopybutton_Click(object sender, EventArgs e)
{
using (var fbd = new FolderBrowserDialog())
{
@@ -163,16 +161,8 @@ namespace AndroidSideloader
if (obbPath.Length>0)
{
MessageBox.Show("Action Started, may take some time...");
Thread t1 = new Thread(() =>
{
runAdbCommand("push " + '"' + obbPath + '"' + " /sdcard/Android/obb");
});
t1.IsBackground = true;
t1.Start();
runLoadingBar(obbFile);
await Task.Run(() => obbcopy(obbPath));
MessageBox.Show(allText);
}
else
@@ -198,7 +188,7 @@ namespace AndroidSideloader
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");
client.DownloadFile("https://github.com/nerdunit/androidsideloader/raw/master/adb.7z", "adb.7z");
}
ExtractFile(Environment.CurrentDirectory + "\\adb.7z", Environment.CurrentDirectory);
File.Delete("adb.7z");
@@ -230,7 +220,7 @@ namespace AndroidSideloader
{
try
{
string localVersion = "0.6";
string localVersion = "0.7";
HttpClient client = new HttpClient();
string currentVersion = client.GetStringAsync("https://raw.githubusercontent.com/nerdunit/androidsideloader/master/version").Result;
currentVersion = currentVersion.Remove(currentVersion.Length - 1);
@@ -243,8 +233,7 @@ namespace AndroidSideloader
}
}
private void backupbutton_Click(object sender, EventArgs e)
private async void backup()
{
MessageBox.Show("Action Started, may take some time...");
Thread t1 = new Thread(() =>
@@ -253,11 +242,27 @@ namespace AndroidSideloader
});
t1.IsBackground = true;
t1.Start();
t1.Join();
}
while (exit == false)
Thread.Sleep(1000);
private async void backupbutton_Click(object sender, EventArgs e)
{
if (exit==false)
{
MessageBox.Show("Finish Previous action first!");
return;
}
Directory.Move(adbPath + "data", Environment.CurrentDirectory + "\\data");
await Task.Run(() => backup()); //we use async and await to not freeze the ui
try
{
Directory.Move(adbPath + "data", Environment.CurrentDirectory + "\\data");
}
catch (Exception ex)
{
File.AppendAllText(debugPath, ex.ToString());
}
MessageBox.Show(allText);
}
@@ -267,8 +272,25 @@ namespace AndroidSideloader
}
private void restorebutton_Click(object sender, EventArgs e)
private async void restore()
{
Thread t1 = new Thread(() =>
{
runAdbCommand("push " + '"' + obbPath + '"' + " /sdcard/Android/");
});
t1.IsBackground = true;
t1.Start();
t1.Join();
}
private async void restorebutton_Click(object sender, EventArgs e)
{
if (exit == false)
{
MessageBox.Show("Finish Previous action first!");
return;
}
using (var fbd = new FolderBrowserDialog())
{
DialogResult result = fbd.ShowDialog();
@@ -280,16 +302,7 @@ namespace AndroidSideloader
}
else return;
}
MessageBox.Show("Action Started, may take some time...");
Thread t1 = new Thread(() =>
{
runAdbCommand("push " + '"' + obbPath + '"' + " /sdcard/Android/");
});
t1.IsBackground = true;
t1.Start();
while (exit == false)
Thread.Sleep(1000);
await Task.Run(() => restore());
MessageBox.Show(allText);
}
@@ -300,22 +313,26 @@ namespace AndroidSideloader
adbCommandForm.Show();
}
private void ListApps_Click(object sender, EventArgs e)
private async void listapps()
{
allText = "";
comboBox1.Items.Clear();
Thread t1 = new Thread(() =>
{
runAdbCommand("shell pm list packages");
});
t1.IsBackground = true;
t1.Start();
t1.Join();
}
while (exit == false)
Thread.Sleep(1000);
private async void ListApps_Click(object sender, EventArgs e)
{
allText = "";
foreach (string obj in line)
comboBox1.Items.Clear();
await Task.Run(() => listapps());
foreach(string obj in line)
{
comboBox1.Items.Add(obj);
}
@@ -324,7 +341,28 @@ namespace AndroidSideloader
MessageBox.Show("Fetched apks with success");
}
private void getApkButton_Click(object sender, EventArgs e)
private async void getapk(string package)
{
Thread t1 = new Thread(() =>
{
runAdbCommand("shell pm path " + package);
});
t1.IsBackground = true;
t1.Start();
t1.Join();
}
private async void pullapk(string apkPath)
{
Thread t2 = new Thread(() =>
{
runAdbCommand("pull " + apkPath);
});
t2.IsBackground = true;
t2.Start();
}
private async void getApkButton_Click(object sender, EventArgs e)
{
string package;
allText = "";
@@ -336,15 +374,10 @@ namespace AndroidSideloader
//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);
await Task.Run(() => getapk(package));
allText = allText.Remove(allText.Length - 1);
//MessageBox.Show(allText);
@@ -352,15 +385,8 @@ namespace AndroidSideloader
apkPath = apkPath.Remove(apkPath.Length - 1);
//MessageBox.Show(adbPath);
exit = false;
Thread t2 = new Thread(() =>
{
runAdbCommand("pull " + apkPath);
});
t2.IsBackground = true;
t2.Start();
while (exit == false)
Thread.Sleep(1000);
await Task.Run(() => pullapk(apkPath));
string currApkPath = apkPath;
while (currApkPath.Contains("/"))
@@ -369,15 +395,26 @@ namespace AndroidSideloader
if (File.Exists(Environment.CurrentDirectory + "\\" + package + ".apk"))
File.Delete(Environment.CurrentDirectory + "\\" + package + ".apk");
File.Copy(Environment.CurrentDirectory + "\\adb\\" + currApkPath, Environment.CurrentDirectory + "\\" + package + ".apk");
File.Move(Environment.CurrentDirectory + "\\adb\\" + currApkPath, Environment.CurrentDirectory + "\\" + package + ".apk");
File.Delete(Environment.CurrentDirectory + "\\adb\\" + currApkPath);
//File.Delete(Environment.CurrentDirectory + "\\adb\\" + currApkPath);
MessageBox.Show("Done");
}
private void listApkPermsButton_Click(object sender, EventArgs e)
private async void listappperms(string package)
{
Thread t1 = new Thread(() =>
{
runAdbCommand("shell dumpsys package " + package);
});
t1.IsBackground = true;
t1.Start();
t1.Join();
}
private async void listApkPermsButton_Click(object sender, EventArgs e)
{
string package;
allText = "";
@@ -389,15 +426,8 @@ namespace AndroidSideloader
catch { MessageBox.Show("You must first run list items"); return; }
exit = false;
Thread t1 = new Thread(() =>
{
runAdbCommand("shell dumpsys package " + package);
});
t1.IsBackground = true;
t1.Start();
while (exit == false)
Thread.Sleep(1000);
await Task.Run(() => listappperms(package));
var grantedPerms = allText.Substring(allText.LastIndexOf("install permissions:") + 22);
grantedPerms.Substring(0, grantedPerms.IndexOf("User 0:"));
@@ -440,7 +470,7 @@ namespace AndroidSideloader
}
private void changePermsBtn_Click(object sender, EventArgs e)
private async void changePermsBtn_Click(object sender, EventArgs e)
{
string package;
allText = "";
@@ -455,33 +485,14 @@ namespace AndroidSideloader
{
if ((c is CheckBox))
{
exit = false;
if (((CheckBox)c).Checked==true)
{
exit = false;
Thread t1 = new Thread(() =>
{
File.AppendAllText("output.txt", "shell pm grant " + package + " " + c.Text);
runAdbCommand("shell pm grant " + package + " " + c.Text);
});
t1.IsBackground = true;
t1.Start();
while (exit == false)
Thread.Sleep(10);
await Task.Run(() => changePerms(c, package, "grant"));
}
else
{
exit = false;
//MessageBox.Show("Checkbox " + c.Text + " is not checked");
Thread t1 = new Thread(() =>
{
File.AppendAllText("output.txt", "shell pm grant " + package + " " + c.Text);
//MessageBox.Show("shell pm revoke " + package + " " + c.Text);
runAdbCommand("shell pm revoke " + package + " " + c.Text);
});
t1.IsBackground = true;
t1.Start();
while (exit == false)
Thread.Sleep(10);
await Task.Run(() => changePerms(c, package, "revoke"));
}
}
@@ -490,6 +501,56 @@ namespace AndroidSideloader
MessageBox.Show("Done!");
}
private async void changePerms(Control c, string package, string grant)
{
Thread t1 = new Thread(() =>
{
runAdbCommand("shell pm " + grant + " " + package + " " + c.Text);
});
t1.IsBackground = true;
t1.Start();
t1.Join();
}
private void launchApkButton_Click(object sender, EventArgs e)
{
exit = false;
Thread t1 = new Thread(() =>
{
runAdbCommand("shell am start -n " + launchPackageTextBox.Text);
});
t1.IsBackground = true;
t1.Start();
}
private void uninstallAppButton_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; }
DialogResult dialogResult = MessageBox.Show("Are you sure you want to uninstall " + package + " this CANNOT be undone!", "WARNING!", MessageBoxButtons.YesNo);
if (dialogResult != DialogResult.Yes)
return;
exit = false;
Thread t1 = new Thread(() =>
{
runAdbCommand("shell pm uninstall -k --user 0 " + package);
});
t1.IsBackground = true;
t1.Start();
MessageBox.Show(allText);
}
}
}

View File

@@ -2,6 +2,12 @@
Changelog
0.6
- Added List Apk Perms button
- Added Change Permissions button
- Added dinamically added checkbox for permisssions
- The software now downloads adb from master instead of v0.3 release
0.5
- Removed Flash Firmware
- Redesigned UI

View File

@@ -1 +1 @@
0.5
0.6