More changes for XAPK support (#682)

This commit is contained in:
Imran Remtulla
2024-11-23 16:26:11 -05:00
parent e82170fec6
commit 327f73cc9e

View File

@@ -516,11 +516,29 @@ class AppsProvider with ChangeNotifier {
.listSync() .listSync()
.where((e) => e.path.toLowerCase().endsWith('.apk')) .where((e) => e.path.toLowerCase().endsWith('.apk'))
.toList(); .toList();
FileSystemEntity? temp;
apks.removeWhere((element) {
bool res = element.uri.pathSegments.last.startsWith(app.id);
if (res) {
temp = element;
}
return res;
});
if (temp != null) {
apks = [
temp!,
...apks,
];
}
for (var i = 0; i < apks.length; i++) { for (var i = 0; i < apks.length; i++) {
try { try {
newInfo = await pm.getPackageArchiveInfo( newInfo =
archiveFilePath: apks.first.path); await pm.getPackageArchiveInfo(archiveFilePath: apks[i].path);
break; if (newInfo != null) {
break;
}
} catch (e) { } catch (e) {
if (i == apks.length - 1) { if (i == apks.length - 1) {
rethrow; rethrow;
@@ -654,13 +672,22 @@ class AppsProvider with ChangeNotifier {
await moveObbFile(file, dir.appId); await moveObbFile(file, dir.appId);
} }
} }
APKFiles.sort((a, b) {
if (a.uri.pathSegments.last.startsWith(dir.appId)) { File? temp;
return -1; APKFiles.removeWhere((element) {
} else { bool res = element.uri.pathSegments.last.startsWith(dir.appId);
return 0; if (res) {
temp = element;
} }
return res;
}); });
if (temp != null) {
APKFiles = [
temp!,
...APKFiles,
];
}
try { try {
await installApk( await installApk(
DownloadedApk(dir.appId, APKFiles[0]), firstTimeWithContext, DownloadedApk(dir.appId, APKFiles[0]), firstTimeWithContext,