Skip to content

Commit d822c13

Browse files
ComputerEliteComputerElite
authored andcommitted
comitting
1 parent a5f0e2a commit d822c13

File tree

4 files changed

+48
-32
lines changed

4 files changed

+48
-32
lines changed

QuestAppVersionSwitcher/Assets/html/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ <h2>Downloads</h2>
215215
</div>
216216
<div class="buttonContainer">
217217
<div class="button" id="deleteAllMods">Delete all mods</div>
218-
<div class="buttonLabel">Disables and deletes all mods frome the currently selected game</div>
218+
<div class="buttonLabel">Disables and deletes all mods from the currently selected game</div>
219219
</div>
220220
<div id="updateTextBox" class="textBox"></div>
221221

@@ -515,7 +515,7 @@ <h2>Downloads</h2>
515515
<div class="contentHeader headerMargin">
516516
Access needed
517517
</div>
518-
To create backups, restore backups and manage mods, QuestAppVersionSwitcher needs access to Android data and obb folder. To grant access press the <code>Grant access</code> button below and press <code>Use this folder</code>
518+
To create backups, restore backups and manage mods, QuestAppVersionSwitcher needs access to Android data and obb folder. To grant access press <code>Grant access</code> below and press <code>Use this folder</code> on <b>both</b> prompts you'll get.
519519
<div id="step12box" class="textBox"></div>
520520
<div class="buttonSelectionContainer">
521521
<div class="buttonContainer">

QuestAppVersionSwitcher/Assets/html/script.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ setInterval(() => {
578578
</div>
579579
${!d.done ? `<input type="button" class="DownloadText" value="Cancel" onclick="StopGameDownload('${d.id}')">` : ``}
580580
<div class="DownloadText" style="color: ${d.textColor};">
581-
${d.canceled ? "Canceled " : ""}${d.status} ${d.progressString} ${d.filesDownloaded} / ${d.filesToDownload} files downloaded
581+
${d.canceled ? "Canceled " : ""}${d.status}<br>${d.filesDownloaded} / ${d.filesToDownload} files downloaded
582582
</div>
583583
</div>`
584584
}
@@ -780,7 +780,7 @@ document.getElementById("uninstall2").onclick = () => {
780780
document.getElementById("confirm1").onclick = () => {
781781
fetch("/api/android/ispackageinstalled?package=" + config.currentApp).then(res => {
782782
res.json().then(j => {
783-
if (j.isAppInstalled) GotoStep(3)
783+
if (!j.isAppInstalled) GotoStep(3)
784784
else {
785785
TextBoxError("step1box", config.currentApp + " is still installed. Please uninstall it.")
786786
GotoStep(1)
@@ -883,6 +883,7 @@ document.getElementById("grantAccess").onclick = () => {
883883
}
884884

885885
document.getElementById("deleteAllMods").onclick = () => {
886+
TextBoxText("updateTextBox", "Deleting all mods...")
886887
fetch("/api/mods/deleteallmods", {
887888
method: "POST"
888889
}).then(res => {
@@ -1056,7 +1057,7 @@ document.getElementById("abortPassword").onclick = () => {
10561057
CloseGetPasswordPopup()
10571058
}
10581059
document.getElementById("confirmPassword").onclick = () => {
1059-
TextBoxText("step7box", "Waiting for response")
1060+
TextBoxText("step7box", "Waiting for response and requesting obbs to download from Oculus...")
10601061
options.password = encodeURIComponent(document.getElementById("passwordConfirm").value)
10611062
options.app = options.parentName
10621063
fetch("/api/download", {

QuestAppVersionSwitcher/GameDownloadManager.cs

Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22
using System.Collections.Generic;
33
using System.IO;
44
using System.Threading;
5+
using ComputerUtils.Android.Encryption;
56
using ComputerUtils.Android.FileManaging;
67
using ComputerUtils.Android.Logging;
8+
using OculusGraphQLApiLib;
9+
using OculusGraphQLApiLib.Results;
710
using Org.BouncyCastle.Bcpg.OpenPgp;
811
using QuestAppVersionSwitcher.ClientModels;
912
using QuestAppVersionSwitcher.Core;
@@ -27,7 +30,7 @@ public class GameDownloadManager
2730
public List<DownloadManager> downloadManagers { get; set; } = new List<DownloadManager>();
2831
public List<ObbEntry> obbsToDo { get; set; } = new List<ObbEntry>();
2932

30-
public DownloadRequest request { get; set; } = null;
33+
public DownloadRequest request = null;
3134
public Thread updateThread = null;
3235
public bool canceled { get; set; } = false;
3336
public bool done { get; set; } = false;
@@ -49,12 +52,38 @@ public void StartDownload()
4952
m.DownloadFinishedEvent += DownloadCompleted;
5053
m.isCancelable = false;
5154

55+
//Get OBBs via Oculus api
56+
try
57+
{
58+
GraphQLClient.oculusStoreToken = PasswordEncryption.Decrypt(CoreService.coreVars.token, request.password);
59+
AndroidBinary b = GraphQLClient.GetBinaryDetails(request.binaryId).data.node;
60+
if (b.obb_binary != null)
61+
{
62+
obbsToDo.Add(new ObbEntry
63+
{
64+
id = b.obb_binary.id,
65+
name = b.obb_binary.file_name
66+
});
67+
}
68+
foreach (AssetFile assetFile in b.asset_files.nodes)
69+
{
70+
obbsToDo.Add(new ObbEntry
71+
{
72+
id = assetFile.id,
73+
name = assetFile.file_name
74+
});
75+
}
76+
}
77+
catch (Exception e)
78+
{
79+
obbsToDo = request.obbList;
80+
}
81+
5282
this.backupName = gameName + " " + version + " Downgraded";
5383
status = gameName + " " + version;
5484
downloadManagers.Add(m);
5585
QAVSWebserver.managers.Add(m);
56-
obbsToDo = request.obbList;
57-
filesToDownload = 1 + request.obbList.Count;
86+
filesToDownload = 1 + obbsToDo.Count;
5887
updateThread = new Thread(() =>
5988
{
6089
while (filesDownloaded < filesToDownload)
@@ -79,27 +108,16 @@ public void Done()
79108

80109
public void UpdateManagersAndProgress()
81110
{
82-
for(int i = 0; i < downloadManagers.Count; i++)
83-
{
84-
DownloadManager m = downloadManagers[i];
85-
if(m.canceled)
86-
{
87-
downloadManagers.RemoveAt(i);
88-
QAVSWebserver.managers.Remove(m);
89-
i--;
90-
}
91-
}
92-
93111
progress = filesDownloaded / (double)filesToDownload;
94112
progressString = (progress * 100).ToString("F") + "%";
95113

96114
for (int i = 0; i < 10 - downloadManagers.Count; i++)
97115
{
98116
if (obbsToDo.Count <= 0) return;
99117
DownloadManager m = new DownloadManager();
100-
m.StartDownload(obbsToDo[0].id, request.password, request.version, request.app, request.parentId, true, request.packageName, obbsToDo[0].name);
101118
m.DownloadFinishedEvent += DownloadCompleted;
102119
m.isCancelable = false;
120+
m.StartDownload(obbsToDo[0].id, request.password, request.version, request.app, request.parentId, true, request.packageName, obbsToDo[0].name);
103121
downloadManagers.Add(m);
104122
QAVSWebserver.managers.Add(m);
105123
obbsToDo.RemoveAt(0);
@@ -116,27 +134,29 @@ public void Cancel()
116134
d.StopDownload();
117135
QAVSWebserver.managers.Remove(d);
118136
}
137+
downloadManagers.Clear();
119138
}
120139

121140
public void DownloadCompleted(DownloadManager m)
122141
{
123142
filesDownloaded++;
124143
QAVSWebserver.managers.Remove(m);
125144
downloadManagers.Remove(m);
145+
string backupDir = CoreService.coreVars.QAVSBackupDir + m.packageName + "/" + m.backupName + "/";
126146
if(m.isObb)
127147
{
128-
string bbackupDir = CoreService.coreVars.QAVSBackupDir + m.packageName + "/" + m.backupName + "/obb/";
129-
FileManager.CreateDirectoryIfNotExisting(bbackupDir);
130-
FileManager.DeleteFileIfExisting(bbackupDir + m.obbFileName);
131-
File.Move(m.tmpPath, bbackupDir + m.obbFileName);
148+
string obbDir = backupDir + "obb/" + m.packageName + "/";
149+
FileManager.CreateDirectoryIfNotExisting(obbDir);
150+
FileManager.DeleteFileIfExisting(obbDir + m.obbFileName);
151+
File.Move(m.tmpPath, obbDir + m.obbFileName);
132152
Logger.Log("Moved obb");
133153
return;
134154
}
135155
// Is apk
136-
string packageName = QAVSWebserver.GetAPKPackageName(m.tmpPath);
137-
string backupDir = CoreService.coreVars.QAVSBackupDir + packageName + "/" + m.backupName + "/";
138-
FileManager.RecreateDirectoryIfExisting(backupDir);
156+
FileManager.CreateDirectoryIfNotExisting(backupDir);
157+
FileManager.DeleteFileIfExisting(backupDir + "app.apk");
139158
File.Move(m.tmpPath, backupDir + "app.apk");
159+
Logger.Log("Moved apk");
140160
}
141161
}
142162
}

QuestAppVersionSwitcher/WebServer.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,11 +1151,6 @@ private void ChangeApp(string packageName)
11511151
QAVSModManager.Update();
11521152
}
11531153

1154-
public void ShowWebsite()
1155-
{
1156-
throw new NotImplementedException();
1157-
}
1158-
11591154
public string GetSHA256OfString(string input)
11601155
{
11611156
return BitConverter.ToString(hasher.ComputeHash(Encoding.UTF8.GetBytes(input))).Replace("-", "");

0 commit comments

Comments
 (0)