Skip to content

Commit

Permalink
- Fixed installer by using session installer
Browse files Browse the repository at this point in the history
- Added support for multi-installer
  • Loading branch information
AyraHikari committed Jan 28, 2022
1 parent 982456a commit f13984e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 19 deletions.
5 changes: 4 additions & 1 deletion HikariToolkit/Forms/Home.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 23 additions & 18 deletions HikariToolkit/Forms/Home.cs
Original file line number Diff line number Diff line change
Expand Up @@ -375,39 +375,34 @@ private void btn_DualAppsUninstall_Click(object sender, EventArgs e)
string output = cmdProcess.StartProcessingInThread("adb shell pm path " + s, formMethods.SelectedDevice());
if (!String.IsNullOrEmpty(output))
{
// creating installation session
string installSession = cmdProcess.StartProcessingInThread("adb shell pm install-create --user 95", formMethods.SelectedDevice());
Debug.WriteLine(installSession);
string sesId = installSession.Split('[')[1].Split(']')[0];
Debug.WriteLine(sesId);

foreach (var item in output.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries))
{
counts += 1;
var splitter = item.Remove(0, 8);
// Copying apks to temp data
// If multiple packages detected, pull into PC
if (counts >= 2)
if (counts >= 1)
{
print("Failed: Splitted apk is not supported, please install SAI to dual apps\n and install in your device instead");
break;
// print("Pulling " + counts + ".apk");
// string no1 = cmdProcess.StartProcessingInThread("adb pull " + splitter + " " + counts + ".apk", formMethods.SelectedDevice());
// multiPacks += counts + ".apk ";
}
else // Dangerous step was disabled
{
// This may dangerous, perhaps there's better method than this?
// Also above code is disable because install-multiple with --user args does not work
string no1 = cmdProcess.StartProcessingInThread("adb shell cp " + splitter + " /data/local/tmp/" + counts + ".apk", formMethods.SelectedDevice());
multiPacks += "/data/local/tmp/" + counts + ".apk ";
string no2 = cmdProcess.StartProcessingInThread("adb shell pm install-write " + sesId + " " + counts + ".apk /data/local/tmp/" + counts + ".apk", formMethods.SelectedDevice());
}
}
}
if (counts == 1)
{
print("Installing packages...");
cmdProcess.StartProcessing("adb install --user " + DualApps + " " + multiPacks, formMethods.SelectedDevice());
print("Installing packages, please wait...");
//cmdProcess.StartProcessing("adb install --user " + DualApps + " " + multiPacks, formMethods.SelectedDevice());
string commit = cmdProcess.StartProcessingInThread("adb shell pm install-commit " + sesId, formMethods.SelectedDevice());
RefreshInstalledApps();
print("Installed!");

//string no3 = cmdProcess.StartProcessingInThread("del " + multiPacks, formMethods.SelectedDevice());
string no3 = cmdProcess.StartProcessingInThread("adb shell rm " + multiPacks, formMethods.SelectedDevice());
}
//string no3 = cmdProcess.StartProcessingInThread("del " + multiPacks, formMethods.SelectedDevice());
string no3 = cmdProcess.StartProcessingInThread("adb shell rm " + multiPacks, formMethods.SelectedDevice());
}
else
{
Expand Down Expand Up @@ -469,5 +464,15 @@ public void clear()
{
rtb_console.Text = "";
}

private void button5_Click(object sender, EventArgs e)
{
Process.Start("https://github.com/AyraHikari/AyraDualApps");
}

private void button4_Click(object sender, EventArgs e)
{
Process.Start("https://github.com/AyraHikari/AyraDualApps/releases");
}
}
}

0 comments on commit f13984e

Please # to comment.