Skip to content

Commit

Permalink
More changes for XAPK support (#682)
Browse files Browse the repository at this point in the history
  • Loading branch information
ImranR98 committed Nov 23, 2024
1 parent e82170f commit 327f73c
Showing 1 changed file with 35 additions and 8 deletions.
43 changes: 35 additions & 8 deletions lib/providers/apps_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -516,11 +516,29 @@ class AppsProvider with ChangeNotifier {
.listSync()
.where((e) => e.path.toLowerCase().endsWith('.apk'))
.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++) {
try {
newInfo = await pm.getPackageArchiveInfo(
archiveFilePath: apks.first.path);
break;
newInfo =
await pm.getPackageArchiveInfo(archiveFilePath: apks[i].path);
if (newInfo != null) {
break;
}
} catch (e) {
if (i == apks.length - 1) {
rethrow;
Expand Down Expand Up @@ -654,13 +672,22 @@ class AppsProvider with ChangeNotifier {
await moveObbFile(file, dir.appId);
}
}
APKFiles.sort((a, b) {
if (a.uri.pathSegments.last.startsWith(dir.appId)) {
return -1;
} else {
return 0;

File? temp;
APKFiles.removeWhere((element) {
bool res = element.uri.pathSegments.last.startsWith(dir.appId);
if (res) {
temp = element;
}
return res;
});
if (temp != null) {
APKFiles = [
temp!,
...APKFiles,
];
}

try {
await installApk(
DownloadedApk(dir.appId, APKFiles[0]), firstTimeWithContext,
Expand Down

0 comments on commit 327f73c

Please sign in to comment.