Skip to content

Commit 327f73c

Browse files
committed
More changes for XAPK support (#682)
1 parent e82170f commit 327f73c

File tree

1 file changed

+35
-8
lines changed

1 file changed

+35
-8
lines changed

lib/providers/apps_provider.dart

+35-8
Original file line numberDiff line numberDiff line change
@@ -516,11 +516,29 @@ class AppsProvider with ChangeNotifier {
516516
.listSync()
517517
.where((e) => e.path.toLowerCase().endsWith('.apk'))
518518
.toList();
519+
520+
FileSystemEntity? temp;
521+
apks.removeWhere((element) {
522+
bool res = element.uri.pathSegments.last.startsWith(app.id);
523+
if (res) {
524+
temp = element;
525+
}
526+
return res;
527+
});
528+
if (temp != null) {
529+
apks = [
530+
temp!,
531+
...apks,
532+
];
533+
}
534+
519535
for (var i = 0; i < apks.length; i++) {
520536
try {
521-
newInfo = await pm.getPackageArchiveInfo(
522-
archiveFilePath: apks.first.path);
523-
break;
537+
newInfo =
538+
await pm.getPackageArchiveInfo(archiveFilePath: apks[i].path);
539+
if (newInfo != null) {
540+
break;
541+
}
524542
} catch (e) {
525543
if (i == apks.length - 1) {
526544
rethrow;
@@ -654,13 +672,22 @@ class AppsProvider with ChangeNotifier {
654672
await moveObbFile(file, dir.appId);
655673
}
656674
}
657-
APKFiles.sort((a, b) {
658-
if (a.uri.pathSegments.last.startsWith(dir.appId)) {
659-
return -1;
660-
} else {
661-
return 0;
675+
676+
File? temp;
677+
APKFiles.removeWhere((element) {
678+
bool res = element.uri.pathSegments.last.startsWith(dir.appId);
679+
if (res) {
680+
temp = element;
662681
}
682+
return res;
663683
});
684+
if (temp != null) {
685+
APKFiles = [
686+
temp!,
687+
...APKFiles,
688+
];
689+
}
690+
664691
try {
665692
await installApk(
666693
DownloadedApk(dir.appId, APKFiles[0]), firstTimeWithContext,

0 commit comments

Comments
 (0)