mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-08-12 01:50:15 +02:00
Better error for some incompatible APK cases (#981)
This commit is contained in:
@@ -263,12 +263,13 @@ class AppsProvider with ChangeNotifier {
|
||||
return downloadedFile;
|
||||
}
|
||||
|
||||
Future<File> handleAPKIDChange(App app, PackageInfo newInfo,
|
||||
Future<File> handleAPKIDChange(App app, PackageInfo? newInfo,
|
||||
File downloadedFile, String downloadUrl) async {
|
||||
// If the APK package ID is different from the App ID, it is either new (using a placeholder ID) or the ID has changed
|
||||
// The former case should be handled (give the App its real ID), the latter is a security issue
|
||||
if (app.id != newInfo.packageName) {
|
||||
var isTempId = SourceProvider().isTempId(app);
|
||||
if (newInfo != null) {
|
||||
if (app.id != newInfo.packageName) {
|
||||
if (apps[app.id] != null && !isTempId && !app.allowIdChange) {
|
||||
throw IDChangedError(newInfo.packageName!);
|
||||
}
|
||||
@@ -283,6 +284,9 @@ class AppsProvider with ChangeNotifier {
|
||||
await saveApps([app], onlyIfExists: !isTempId && !idChangeWasAllowed);
|
||||
}
|
||||
}
|
||||
} else if (isTempId) {
|
||||
throw ObtainiumError('Could not get ID from APK');
|
||||
}
|
||||
return downloadedFile;
|
||||
}
|
||||
|
||||
@@ -344,7 +348,7 @@ class AppsProvider with ChangeNotifier {
|
||||
await pm.getPackageArchiveInfo(archiveFilePath: apks.first.path);
|
||||
}
|
||||
downloadedFile =
|
||||
await handleAPKIDChange(app, newInfo!, downloadedFile, downloadUrl);
|
||||
await handleAPKIDChange(app, newInfo, downloadedFile, downloadUrl);
|
||||
// Delete older versions of the file if any
|
||||
for (var file in downloadedFile.parent.listSync()) {
|
||||
var fn = file.path.split('/').last;
|
||||
|
Reference in New Issue
Block a user