Skip to content

Commit 18a60bd

Browse files
committed
Add corrupted apk detection
1 parent 3ac5d4b commit 18a60bd

File tree

5 files changed

+14
-7
lines changed

5 files changed

+14
-7
lines changed

QuestAppVersionSwitcher/Assets/html/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ <h2>You can download mods and cosmetics from the following sites. Only QMods are
259259
<label><input type="checkbox" id="appdata" value="only backup app data" style="width: auto;">Only backup app data</label>
260260
<div id="backupTextBox" class="textBox"></div>
261261
</div>
262-
</div>
262+
</div>y
263263
<div class="contentItem hidden" style="padding: 0px; position: relative" id="downgrade" style="padding: 0px;">
264264
<h2>Available downgrades</h2>
265265
<div class="infiniteList" id="downgradeList"></div>

QuestAppVersionSwitcher/Assets/html/script.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ function UpdateUI(closeLists = false) {
814814
}
815815
// Also show mod this version button if backup is not modded and has an apk
816816
document.getElementById("backupList").innerHTML +=
817-
`<div class="listItem${backup.backupName == selectedBackup ? " listItemSelected" : ""}" value="${backup.backupName}">${backup.backupName} (${backup.backupSizeString}) ${extra}</div>`
817+
`<div class="listItem${backup.backupName == selectedBackup ? " listItemSelected" : ""}" value="${backup.backupName}">${backup.isCorrupted ? `<b style="color: #FF0000">CORRUPTED </b>` : ``} ${backup.backupName} (${backup.backupSizeString}) ${extra}</div>`
818818
})
819819
}
820820
if (document.getElementById("backupList").innerHTML == "") document.getElementById("backupList").innerHTML = `<div class="listItem" value="">No Backups</div>`

QuestAppVersionSwitcher/BackupManager.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using ComputerUtils.Android.VarUtils;
1111
using QuestAppVersionSwitcher.ClientModels;
1212
using QuestAppVersionSwitcher.Core;
13+
using Exception = Java.Lang.Exception;
1314

1415
namespace QuestAppVersionSwitcher
1516
{
@@ -38,13 +39,18 @@ public static BackupInfo GetBackupInfo(string path, bool loadAnyway = false)
3839
info.containsApk = File.Exists(pathWithoutSlash + "/app.apk");
3940
if (info.containsApk)
4041
{
41-
42-
using (ZipArchive apk = ZipFile.OpenRead(pathWithoutSlash + "/app.apk"))
42+
try
4343
{
44+
ZipArchive apk = ZipFile.OpenRead(pathWithoutSlash + "/app.apk");
4445
PatchingStatus s = PatchingManager.GetPatchingStatus(apk);
4546
info.gameVersion = s.version;
4647
info.isPatchedApk = s.isPatched;
4748
info.moddedJson = PatchingManager.GetModdedJson(apk);
49+
apk.Dispose();
50+
}
51+
catch (InvalidDataException e)
52+
{
53+
info.isCorrupted = true;
4854
}
4955
// Calculate SHA 256 of apk file
5056
/*
@@ -86,6 +92,7 @@ public static string GetPathWithoutSlash(string path)
8692

8793
public class BackupInfo
8894
{
95+
public bool isCorrupted { get; set; } = false;
8996
public BackupInfoVersion BackupInfoVersion { get; set; } = BackupInfoVersion.V6;
9097
public string backupName { get; set; } = "";
9198
public string backupLocation { get; set; } = "";

QuestAppVersionSwitcher/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.15.1" package="com.ComputerElite.questappversionswitcher" android:installLocation="preferExternal" android:versionCode="122">
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.15.2" package="com.ComputerElite.questappversionswitcher" android:installLocation="preferExternal" android:versionCode="123">
33
<uses-sdk android:minSdkVersion="28" android:targetSdkVersion="32" />
44
<uses-permission android:name="oculus.permission.handtracking" />
55
<uses-permission android:name="com.oculus.permission.HAND_TRACKING" />

QuestAppVersionSwitcher/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.15.1.0")]
26-
[assembly: AssemblyFileVersion("1.15.1.0")]
25+
[assembly: AssemblyVersion("1.15.2.0")]
26+
[assembly: AssemblyFileVersion("1.15.2.0")]

0 commit comments

Comments
 (0)