Skip to content

Commit 59f44eb

Browse files
author
ComputerElite
committed
Add only app data backup
1 parent 8c683f6 commit 59f44eb

5 files changed

Lines changed: 86 additions & 16 deletions

File tree

Assets/html/index.html

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
<div class="button" id="createBackup">Create Backup</div>
5656
<div class="buttonLabel">Creates a backup of <div class="inline packageName">some game</div></div>
5757
</div>
58+
<label><input type="checkbox" id="appdata" value="only backup app data" style="width: auto;">Only backup app data</label>
5859
<div id="backupTextBox" class="textBox"></div>
5960
</div>
6061
</div>
@@ -402,9 +403,10 @@
402403
TextBoxError("backupTextBox", "A Backup is being created right now. Please wait until it has finished")
403404
return
404405
}
406+
var onlyAppData = document.getElementById("appdata").checked
405407
backupInProgress = true
406408
TextBoxText("backupTextBox", "Please wait while the Backup is being created. This can take a few minutes")
407-
fetch("backup?package=" + config.currentApp + "&backupname=" + document.getElementById("backupname").value, {
409+
fetch("backup?package=" + config.currentApp + "&backupname=" + document.getElementById("backupname").value + (onlyAppData ? "&onlyappdata=true" : "") , {
408410
method: "POST"
409411
}).then(res => {
410412
res.text().then(text => {
@@ -469,12 +471,21 @@
469471
}
470472

471473
document.getElementById("uninstall2").onclick = () => {
472-
fetch(`android/uninstallpackage?package=${config.currentApp}`, {
473-
method: "POST"
474-
}).then(res => {
475-
if (res.status == 230) GotoStep(3)
476-
else GotoStep(2)
474+
fetch(`isonlyappdata?package=${config.currentApp}&backupname=${selectedBackup}`).then(res => {
475+
res.text().then(text => {
476+
if(text == "true") {
477+
GotoStep(4)
478+
} else {
479+
fetch(`android/uninstallpackage?package=${config.currentApp}`, {
480+
method: "POST"
481+
}).then(res => {
482+
if (res.status == 230) GotoStep(3)
483+
else GotoStep(2)
484+
})
485+
}
486+
})
477487
})
488+
478489
}
479490

480491
document.getElementById("confirm1").onclick = () => {

Properties/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.1.4" package="com.ComputerElite.questappversionswitcher" android:installLocation="preferExternal" android:versionCode="8">
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.1.5" package="com.ComputerElite.questappversionswitcher" android:installLocation="preferExternal" android:versionCode="9">
33
<uses-sdk android:minSdkVersion="28" android:targetSdkVersion="29" />
44
<uses-permission android:name="oculus.permission.handtracking" />
55
<uses-permission android:name="com.oculus.permission.HAND_TRACKING" />

Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@
2222
// Minor Version
2323
// Build Number
2424
// Revision
25-
[assembly: AssemblyVersion("1.1.4.0")]
26-
[assembly: AssemblyFileVersion("1.1.4.0")]
25+
[assembly: AssemblyVersion("1.1.5.0")]
26+
[assembly: AssemblyFileVersion("1.1.5.0")]

QuestAppVersionSwitcher.csproj.user

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
4-
<SelectedDevice>pixel_5_q_10_0_-_api_29</SelectedDevice>
5-
<ActiveDebugProfile>pixel_5_q_10_0_-_api_29</ActiveDebugProfile>
4+
<SelectedDevice>Samsung SM-A202F %28192.168.178.63:5555%29</SelectedDevice>
5+
<ActiveDebugProfile>Samsung SM-A202F %28192.168.178.63:5555%29</ActiveDebugProfile>
66
<DefaultDevice>pixel_5_q_10_0_-_api_29</DefaultDevice>
77
<AndroidDesignerPreferredTheme>AppTheme</AndroidDesignerPreferredTheme>
88
<AndroidDesignerPreferredDevice>Nexus 4</AndroidDesignerPreferredDevice>

WebServer.cs

Lines changed: 64 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
using System.Security.Cryptography;
1818
using System.Text;
1919
using System.Linq;
20-
using OculusGraphQLApiLib;
2120

2221
namespace QuestAppVersionSwitcher
2322
{
@@ -206,11 +205,19 @@ public void Start()
206205
}
207206
string apkDir = AndroidService.FindAPKLocation(package);
208207
string gameDataDir = CoreService.coreVars.AndroidAppLocation + package;
208+
209+
209210
try
210211
{
211-
text = "Copying APK. Please wait until it has finished. This can take up to 2 minutes";
212-
code = 202;
213-
File.Copy(apkDir, backupDir + "app.apk");
212+
if (serverRequest.queryString.Get("onlyappdata") == null)
213+
{
214+
text = "Copying APK. Please wait until it has finished. This can take up to 2 minutes";
215+
code = 202;
216+
File.Copy(apkDir, backupDir + "app.apk");
217+
} else
218+
{
219+
File.WriteAllText(backupDir + "onlyappdata.txt", "This backup only contains app data.");
220+
}
214221
text = "Copying App Data. Please wait until it has finished. This can take up to 2 minutes";
215222
code = 202;
216223
FileManager.DirectoryCopy(gameDataDir, backupDir + package, true);
@@ -234,6 +241,44 @@ public void Start()
234241
code = 200;
235242
return true;
236243
}));
244+
server.AddRoute("GET", "/isonlyappdata", new Func<ServerRequest, bool>(serverRequest =>
245+
{
246+
if (serverRequest.queryString.Get("package") == null)
247+
{
248+
serverRequest.SendString("package key needed", "text/plain", 400);
249+
return true;
250+
}
251+
if (serverRequest.queryString.Get("backupname") == null)
252+
{
253+
serverRequest.SendString("backupname key needed", "text/plain", 400);
254+
return true;
255+
}
256+
string package = serverRequest.queryString.Get("package");
257+
string backupname = serverRequest.queryString.Get("backupname");
258+
if (!IsNameFileNameSafe(backupname))
259+
{
260+
serverRequest.SendString("Your Backup name contains a forbidden character. Please remove them. Forbidden characters are: " + String.Join(' ', ReservedChars) + "and space. Tip: replace spaces with _", "text/plain", 400);
261+
return true;
262+
}
263+
if (!IsNameFileNameSafe(package))
264+
{
265+
serverRequest.SendString("Your package contains a forbidden character. Forbidden characters are: " + String.Join(' ', ReservedChars) + "and space. Tip: replace spaces with _", "text/plain", 400);
266+
return true;
267+
}
268+
if (backupname == "")
269+
{
270+
serverRequest.SendString("The backup has to have a name. Please add one.", "text/plain", 400);
271+
return true;
272+
}
273+
string backupDir = CoreService.coreVars.QAVSBackupDir + package + "/" + backupname + "/";
274+
if (!Directory.Exists(backupDir))
275+
{
276+
serverRequest.SendString("This backup doesn't exist", "text/plain", 400);
277+
return true;
278+
}
279+
serverRequest.SendString(File.Exists(backupDir + "onlyappdata.txt").ToString().ToLower());
280+
return true;
281+
}));
237282
server.AddRoute("GET", "/backup", new Func<ServerRequest, bool>(serverRequest =>
238283
{
239284
serverRequest.SendString(text, "text/plain", code);
@@ -402,7 +447,21 @@ public void Start()
402447
server.AddRoute("POST", "/token", new Func<ServerRequest, bool>(serverRequest =>
403448
{
404449
TokenRequest r = JsonSerializer.Deserialize<TokenRequest>(serverRequest.bodyString);
405-
string error = TokenTools
450+
if (r.token.Contains("%"))
451+
{
452+
serverRequest.SendString("You got your token from the wrong place. Go to the payload tab. Don't get it from the url.", "text/plain", 400);
453+
return true;
454+
}
455+
if (!r.token.StartsWith("OC"))
456+
{
457+
serverRequest.SendString("Tokens must start with 'OC'. Please get a new one", "text/plain", 400);
458+
return true;
459+
}
460+
if (r.token.Contains("|"))
461+
{
462+
serverRequest.SendString("You seem to have entered a token of an application. Please get YOUR token. Usually this can be done by using another request in the network tab.", "text/plain", 400);
463+
return true;
464+
}
406465
CoreService.coreVars.token = PasswordEncryption.Encrypt(r.token, r.password);
407466
SHA256 s = SHA256.Create();
408467
CoreService.coreVars.password = GetSHA256OfString(r.password);

0 commit comments

Comments
 (0)