From e278c9fb5a15248b1ab73a441f82fca91826cd4a Mon Sep 17 00:00:00 2001 From: Imran Remtulla Date: Thu, 1 Feb 2024 19:26:36 -0500 Subject: [PATCH 1/2] Correctly report and auto-delete bad APKs (#1251) --- assets/translations/bs.json | 1 + assets/translations/cs.json | 1 + assets/translations/de.json | 1 + assets/translations/en.json | 1 + assets/translations/es.json | 1 + assets/translations/fa.json | 1 + assets/translations/fr.json | 1 + assets/translations/hu.json | 1 + assets/translations/it.json | 1 + assets/translations/ja.json | 1 + assets/translations/nl.json | 1 + assets/translations/pl.json | 1 + assets/translations/pt.json | 1 + assets/translations/ru.json | 1 + assets/translations/sv.json | 1 + assets/translations/tr.json | 1 + assets/translations/vi.json | 1 + assets/translations/zh.json | 1 + lib/providers/apps_provider.dart | 11 ++++++++++- 19 files changed, 28 insertions(+), 1 deletion(-) diff --git a/assets/translations/bs.json b/assets/translations/bs.json index 3c86b69..12f5336 100644 --- a/assets/translations/bs.json +++ b/assets/translations/bs.json @@ -300,6 +300,7 @@ "invertRegEx": "Obrni regularni izraz", "note": "Note", "selfHostedNote": "The \"{}\" dropdown can be used to reach self-hosted/custom instances of any source.", + "badDownload": "The APK could not be parsed (incompatible or partial download)", "removeAppQuestion": { "one": "Želite li ukloniti aplikaciju?", "other": "Želite li ukloniti aplikacije?" diff --git a/assets/translations/cs.json b/assets/translations/cs.json index 5c65281..16bc773 100644 --- a/assets/translations/cs.json +++ b/assets/translations/cs.json @@ -300,6 +300,7 @@ "invertRegEx": "Invertovat regulární výraz", "note": "Note", "selfHostedNote": "The \"{}\" dropdown can be used to reach self-hosted/custom instances of any source.", + "badDownload": "The APK could not be parsed (incompatible or partial download)", "removeAppQuestion": { "one": "Odstranit Apku?", "other": "Odstranit Apky?" diff --git a/assets/translations/de.json b/assets/translations/de.json index 2c976dc..f515d2a 100644 --- a/assets/translations/de.json +++ b/assets/translations/de.json @@ -300,6 +300,7 @@ "invertRegEx": "Regulären Ausdruck invertieren", "note": "Note", "selfHostedNote": "The \"{}\" dropdown can be used to reach self-hosted/custom instances of any source.", + "badDownload": "The APK could not be parsed (incompatible or partial download)", "removeAppQuestion": { "one": "App entfernen?", "other": "Apps entfernen?" diff --git a/assets/translations/en.json b/assets/translations/en.json index d37888f..cecb9c4 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -300,6 +300,7 @@ "invertRegEx": "Invert regular expression", "note": "Note", "selfHostedNote": "The \"{}\" dropdown can be used to reach self-hosted/custom instances of any source.", + "badDownload": "The APK could not be parsed (incompatible or partial download)", "removeAppQuestion": { "one": "Remove App?", "other": "Remove Apps?" diff --git a/assets/translations/es.json b/assets/translations/es.json index c9da393..3af0908 100644 --- a/assets/translations/es.json +++ b/assets/translations/es.json @@ -300,6 +300,7 @@ "invertRegEx": "Invertir expresión regular", "note": "Note", "selfHostedNote": "The \"{}\" dropdown can be used to reach self-hosted/custom instances of any source.", + "badDownload": "The APK could not be parsed (incompatible or partial download)", "removeAppQuestion": { "one": "¿Eliminar Aplicación?", "other": "¿Eliminar Aplicaciones?" diff --git a/assets/translations/fa.json b/assets/translations/fa.json index 756e320..4635928 100644 --- a/assets/translations/fa.json +++ b/assets/translations/fa.json @@ -300,6 +300,7 @@ "invertRegEx": "معکوس کردن عبارت منظم", "note": "Note", "selfHostedNote": "The \"{}\" dropdown can be used to reach self-hosted/custom instances of any source.", + "badDownload": "The APK could not be parsed (incompatible or partial download)", "removeAppQuestion": { "one": "برنامه حذف شود؟", "other": "برنامه ها حذف شوند؟" diff --git a/assets/translations/fr.json b/assets/translations/fr.json index 41649ea..0b6e94d 100644 --- a/assets/translations/fr.json +++ b/assets/translations/fr.json @@ -300,6 +300,7 @@ "invertRegEx": "Inverser l'expression régulière", "note": "Note", "selfHostedNote": "The \"{}\" dropdown can be used to reach self-hosted/custom instances of any source.", + "badDownload": "The APK could not be parsed (incompatible or partial download)", "removeAppQuestion": { "one": "Supprimer l'application ?", "other": "Supprimer les applications ?" diff --git a/assets/translations/hu.json b/assets/translations/hu.json index 173dab8..0bc6eb6 100644 --- a/assets/translations/hu.json +++ b/assets/translations/hu.json @@ -300,6 +300,7 @@ "invertRegEx": "Invertált reguláris kifejezés", "note": "Note", "selfHostedNote": "The \"{}\" dropdown can be used to reach self-hosted/custom instances of any source.", + "badDownload": "The APK could not be parsed (incompatible or partial download)", "removeAppQuestion": { "one": "Eltávolítja az alkalmazást?", "other": "Eltávolítja az alkalmazást?" diff --git a/assets/translations/it.json b/assets/translations/it.json index ddbe043..050707a 100644 --- a/assets/translations/it.json +++ b/assets/translations/it.json @@ -300,6 +300,7 @@ "invertRegEx": "Inverti espressione regolare", "note": "Note", "selfHostedNote": "The \"{}\" dropdown can be used to reach self-hosted/custom instances of any source.", + "badDownload": "The APK could not be parsed (incompatible or partial download)", "removeAppQuestion": { "one": "Rimuovere l'app?", "other": "Rimuovere le app?" diff --git a/assets/translations/ja.json b/assets/translations/ja.json index ae470568..dae398f 100644 --- a/assets/translations/ja.json +++ b/assets/translations/ja.json @@ -300,6 +300,7 @@ "invertRegEx": "正規表現を反転", "note": "Note", "selfHostedNote": "The \"{}\" dropdown can be used to reach self-hosted/custom instances of any source.", + "badDownload": "The APK could not be parsed (incompatible or partial download)", "removeAppQuestion": { "one": "アプリを削除しますか?", "other": "アプリを削除しますか?" diff --git a/assets/translations/nl.json b/assets/translations/nl.json index 372760e..9d53109 100644 --- a/assets/translations/nl.json +++ b/assets/translations/nl.json @@ -300,6 +300,7 @@ "invertRegEx": "Reguliere expressie omkeren", "note": "Note", "selfHostedNote": "The \"{}\" dropdown can be used to reach self-hosted/custom instances of any source.", + "badDownload": "The APK could not be parsed (incompatible or partial download)", "removeAppQuestion": { "one": "App verwijderen?", "other": "Apps verwijderen?" diff --git a/assets/translations/pl.json b/assets/translations/pl.json index f92a37b..5620552 100644 --- a/assets/translations/pl.json +++ b/assets/translations/pl.json @@ -300,6 +300,7 @@ "invertRegEx": "Odwróć wyrażenie regularne", "note": "Note", "selfHostedNote": "The \"{}\" dropdown can be used to reach self-hosted/custom instances of any source.", + "badDownload": "The APK could not be parsed (incompatible or partial download)", "removeAppQuestion": { "one": "Usunąć aplikację?", "few": "Usunąć aplikacje?", diff --git a/assets/translations/pt.json b/assets/translations/pt.json index 675d352..e9ff3c6 100644 --- a/assets/translations/pt.json +++ b/assets/translations/pt.json @@ -300,6 +300,7 @@ "invertRegEx": "Inverter expressão regular", "note": "Note", "selfHostedNote": "The \"{}\" dropdown can be used to reach self-hosted/custom instances of any source.", + "badDownload": "The APK could not be parsed (incompatible or partial download)", "removeAppQuestion": { "one": "Remover aplicativo?", "other": "Remover aplicativos?" diff --git a/assets/translations/ru.json b/assets/translations/ru.json index 062e5b4..019707b 100644 --- a/assets/translations/ru.json +++ b/assets/translations/ru.json @@ -300,6 +300,7 @@ "invertRegEx": "Инвертировать регулярное выражение", "note": "Note", "selfHostedNote": "The \"{}\" dropdown can be used to reach self-hosted/custom instances of any source.", + "badDownload": "The APK could not be parsed (incompatible or partial download)", "removeAppQuestion": { "one": "Удалить приложение?", "other": "Удалить приложения?" diff --git a/assets/translations/sv.json b/assets/translations/sv.json index b61e3b2..18c806f 100644 --- a/assets/translations/sv.json +++ b/assets/translations/sv.json @@ -300,6 +300,7 @@ "invertRegEx": "Invertera reguljärt uttryck", "note": "Note", "selfHostedNote": "The \"{}\" dropdown can be used to reach self-hosted/custom instances of any source.", + "badDownload": "The APK could not be parsed (incompatible or partial download)", "removeAppQuestion": { "one": "Ta Bort App?", "other": "Ta Bort Appar?" diff --git a/assets/translations/tr.json b/assets/translations/tr.json index e3bc3a3..e374d00 100644 --- a/assets/translations/tr.json +++ b/assets/translations/tr.json @@ -300,6 +300,7 @@ "invertRegEx": "Normal ifadeyi ters çevir", "note": "Note", "selfHostedNote": "The \"{}\" dropdown can be used to reach self-hosted/custom instances of any source.", + "badDownload": "The APK could not be parsed (incompatible or partial download)", "removeAppQuestion": { "one": "Uygulamayı Kaldır?", "other": "Uygulamaları Kaldır?" diff --git a/assets/translations/vi.json b/assets/translations/vi.json index abe297f..2dcde6d 100644 --- a/assets/translations/vi.json +++ b/assets/translations/vi.json @@ -300,6 +300,7 @@ "invertRegEx": "Đảo ngược biểu thức chính quy", "note": "Note", "selfHostedNote": "The \"{}\" dropdown can be used to reach self-hosted/custom instances of any source.", + "badDownload": "The APK could not be parsed (incompatible or partial download)", "removeAppQuestion": { "one": "Gỡ ứng dụng?", "other": "Gỡ ứng dụng?" diff --git a/assets/translations/zh.json b/assets/translations/zh.json index d5be7db..b00e819 100644 --- a/assets/translations/zh.json +++ b/assets/translations/zh.json @@ -300,6 +300,7 @@ "invertRegEx": "反转正则表达式", "note": "Note", "selfHostedNote": "The \"{}\" dropdown can be used to reach self-hosted/custom instances of any source.", + "badDownload": "The APK could not be parsed (incompatible or partial download)", "removeAppQuestion": { "one": "是否删除应用?", "other": "是否删除应用?" diff --git a/lib/providers/apps_provider.dart b/lib/providers/apps_provider.dart index 95f6f09..f6c2881 100644 --- a/lib/providers/apps_provider.dart +++ b/lib/providers/apps_provider.dart @@ -532,9 +532,18 @@ class AppsProvider with ChangeNotifier { {bool needsBGWorkaround = false}) async { var newInfo = await pm.getPackageArchiveInfo(archiveFilePath: file.file.path); + if (newInfo == null) { + try { + file.file.deleteSync(recursive: true); + } catch (e) { + // + } finally { + throw ObtainiumError(tr('badDownload')); + } + } PackageInfo? appInfo = await getInstalledInfo(apps[file.appId]!.app.id); if (appInfo != null && - newInfo!.versionCode! < appInfo.versionCode! && + newInfo.versionCode! < appInfo.versionCode! && !(await canDowngradeApps())) { throw DowngradeError(); } From 3842c1e2dfb284f45eaccaa2d3ab0f1878b95fea Mon Sep 17 00:00:00 2001 From: Imran Remtulla Date: Thu, 1 Feb 2024 19:31:32 -0500 Subject: [PATCH 2/2] Update packages, increment version --- pubspec.lock | 16 ++++++++-------- pubspec.yaml | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pubspec.lock b/pubspec.lock index 6216029..b2bc2cc 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -190,10 +190,10 @@ packages: dependency: "direct main" description: name: device_info_plus - sha256: "0042cb3b2a76413ea5f8a2b40cec2a33e01d0c937e91f0f7c211fde4f7739ba6" + sha256: "77f757b789ff68e4eaf9c56d1752309bd9f7ad557cb105b938a7f8eb89e59110" url: "https://pub.dev" source: hosted - version: "9.1.1" + version: "9.1.2" device_info_plus_platform_interface: dependency: transitive description: @@ -410,10 +410,10 @@ packages: dependency: transitive description: name: image - sha256: "004a2e90ce080f8627b5a04aecb4cdfac87d2c3f3b520aa291260be5a32c033d" + sha256: "49a0d4b0c12402853d3f227fe7c315601b238d126aa4caa5dbb2dcf99421aa4a" url: "https://pub.dev" source: hosted - version: "4.1.4" + version: "4.1.6" intl: dependency: transitive description: @@ -650,10 +650,10 @@ packages: dependency: "direct main" description: name: share_plus - sha256: f74fc3f1cbd99f39760182e176802f693fa0ec9625c045561cfad54681ea93dd + sha256: "3ef39599b00059db0990ca2e30fca0a29d8b37aae924d60063f8e0184cf20900" url: "https://pub.dev" source: hosted - version: "7.2.1" + version: "7.2.2" share_plus_platform_interface: dependency: transitive description: @@ -919,10 +919,10 @@ packages: dependency: "direct main" description: name: webview_flutter - sha256: "71e1bfaef41016c8d5954291df5e9f8c6172f1f6ff3af01b5656456ddb11f94c" + sha256: d81b68e88cc353e546afb93fb38958e3717282c5ac6e5d3be4a4aef9fc3c1413 url: "https://pub.dev" source: hosted - version: "4.4.4" + version: "4.5.0" webview_flutter_android: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 50c4d68..908e34b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,7 +17,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 1.0.1+251 # When changing this, update the tag in main() accordingly +version: 1.0.2+252 # When changing this, update the tag in main() accordingly environment: sdk: '>=3.0.0 <4.0.0'