File tree 1 file changed +35
-8
lines changed
1 file changed +35
-8
lines changed Original file line number Diff line number Diff line change @@ -516,11 +516,29 @@ class AppsProvider with ChangeNotifier {
516
516
.listSync ()
517
517
.where ((e) => e.path.toLowerCase ().endsWith ('.apk' ))
518
518
.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
+
519
535
for (var i = 0 ; i < apks.length; i++ ) {
520
536
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
+ }
524
542
} catch (e) {
525
543
if (i == apks.length - 1 ) {
526
544
rethrow ;
@@ -654,13 +672,22 @@ class AppsProvider with ChangeNotifier {
654
672
await moveObbFile (file, dir.appId);
655
673
}
656
674
}
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;
662
681
}
682
+ return res;
663
683
});
684
+ if (temp != null ) {
685
+ APKFiles = [
686
+ temp! ,
687
+ ...APKFiles ,
688
+ ];
689
+ }
690
+
664
691
try {
665
692
await installApk (
666
693
DownloadedApk (dir.appId, APKFiles [0 ]), firstTimeWithContext,
You can’t perform that action at this time.
0 commit comments