Compare commits

...

7 Commits
v0.5 ... 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
nerdunit
6a34deeede Add files via upload 2020-06-16 11:05:49 +03:00
nerdunit
266c242199 Bugfix 2020-06-14 13:47:35 +03:00
nerdunit
366627085f Update version 2020-06-14 13:38:51 +03:00
5 changed files with 345 additions and 100 deletions

88
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();
@@ -40,6 +39,11 @@
this.ListApps = new System.Windows.Forms.Button();
this.comboBox1 = new System.Windows.Forms.ComboBox();
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
@@ -64,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;
@@ -76,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);
@@ -123,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;
@@ -158,11 +155,64 @@
this.getApkButton.UseVisualStyleBackColor = true;
this.getApkButton.Click += new System.EventHandler(this.getApkButton_Click);
//
// listApkPermsButton
//
this.listApkPermsButton.Location = new System.Drawing.Point(193, 92);
this.listApkPermsButton.Name = "listApkPermsButton";
this.listApkPermsButton.Size = new System.Drawing.Size(87, 34);
this.listApkPermsButton.TabIndex = 16;
this.listApkPermsButton.Text = "List Apk Perms";
this.listApkPermsButton.UseVisualStyleBackColor = true;
this.listApkPermsButton.Click += new System.EventHandler(this.listApkPermsButton_Click);
//
// changePermsBtn
//
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;
this.changePermsBtn.Text = "Change Permissions";
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(447, 193);
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);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.ListApps);
@@ -170,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(463, 232);
this.MinimumSize = new System.Drawing.Size(463, 232);
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();
}
@@ -189,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;
@@ -197,6 +246,11 @@
private System.Windows.Forms.Button ListApps;
private System.Windows.Forms.ComboBox comboBox1;
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;
}
}

349
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
@@ -183,6 +173,8 @@ namespace AndroidSideloader
private void Form1_Load(object sender, EventArgs e)
{
if (File.Exists(debugPath))
File.Delete(debugPath);
if (debugMode == false)
debugbutton.Visible = false;
if (Directory.Exists(adbPath)==false)
@@ -196,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");
@@ -228,7 +220,7 @@ namespace AndroidSideloader
{
try
{
string localVersion = "0.5";
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);
@@ -241,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(() =>
@@ -251,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);
}
@@ -265,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();
@@ -278,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);
}
@@ -298,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);
}
@@ -322,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 = "";
@@ -334,38 +374,183 @@ 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);
string apkPath = allText.Remove(0, 8); //remove package:
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("/"))
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);
if (File.Exists(Environment.CurrentDirectory + "\\" + package + ".apk"))
File.Delete(Environment.CurrentDirectory + "\\" + package + ".apk");
File.Move(Environment.CurrentDirectory + "\\adb\\" + currApkPath, Environment.CurrentDirectory + "\\" + package + ".apk");
//File.Delete(Environment.CurrentDirectory + "\\adb\\" + currApkPath);
MessageBox.Show("Done");
}
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 = "";
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; }
exit = false;
await Task.Run(() => listappperms(package));
var grantedPerms = allText.Substring(allText.LastIndexOf("install permissions:") + 22);
grantedPerms.Substring(0, grantedPerms.IndexOf("User 0:"));
line = grantedPerms.Split('\n');
int pos1 = 12;
int pos2 = 187;
for (int i=0; i< line.Length; i++)
{
if (line[i].Contains("android.permission."))
{
CheckBox chk = new CheckBox();
if (line[i].Contains("true"))
chk.Checked = true;
else
chk.Checked = false;
line[i] = line[i].Substring(0, line[i].IndexOf(": granted"));
line[i] = line[i].Substring(line[i].LastIndexOf(" "));
chk.Location = new System.Drawing.Point(pos1, pos2);
chk.Width = 420;
chk.Height = 17;
chk.Text = line[i];
chk.CheckedChanged += new EventHandler(CheckBox_Checked);
Controls.Add(chk);
pos2 += 20;
}
}
}
private void CheckBox_Checked(object sender, EventArgs e)
{
}
private async void changePermsBtn_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; }
foreach (Control c in Controls)
{
if ((c is CheckBox))
{
exit = false;
if (((CheckBox)c).Checked==true)
{
await Task.Run(() => changePerms(c, package, "grant"));
}
else
{
await Task.Run(() => changePerms(c, package, "revoke"));
}
}
}
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

BIN
adb.7z Normal file

Binary file not shown.

View File

@@ -1 +1 @@
0.4
0.6