mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-08-15 03:18:09 +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;
|
return downloadedFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<File> handleAPKIDChange(App app, PackageInfo newInfo,
|
Future<File> handleAPKIDChange(App app, PackageInfo? newInfo,
|
||||||
File downloadedFile, String downloadUrl) async {
|
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
|
// 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
|
// 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);
|
var isTempId = SourceProvider().isTempId(app);
|
||||||
|
if (newInfo != null) {
|
||||||
|
if (app.id != newInfo.packageName) {
|
||||||
if (apps[app.id] != null && !isTempId && !app.allowIdChange) {
|
if (apps[app.id] != null && !isTempId && !app.allowIdChange) {
|
||||||
throw IDChangedError(newInfo.packageName!);
|
throw IDChangedError(newInfo.packageName!);
|
||||||
}
|
}
|
||||||
@@ -283,6 +284,9 @@ class AppsProvider with ChangeNotifier {
|
|||||||
await saveApps([app], onlyIfExists: !isTempId && !idChangeWasAllowed);
|
await saveApps([app], onlyIfExists: !isTempId && !idChangeWasAllowed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (isTempId) {
|
||||||
|
throw ObtainiumError('Could not get ID from APK');
|
||||||
|
}
|
||||||
return downloadedFile;
|
return downloadedFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -344,7 +348,7 @@ class AppsProvider with ChangeNotifier {
|
|||||||
await pm.getPackageArchiveInfo(archiveFilePath: apks.first.path);
|
await pm.getPackageArchiveInfo(archiveFilePath: apks.first.path);
|
||||||
}
|
}
|
||||||
downloadedFile =
|
downloadedFile =
|
||||||
await handleAPKIDChange(app, newInfo!, downloadedFile, downloadUrl);
|
await handleAPKIDChange(app, newInfo, downloadedFile, downloadUrl);
|
||||||
// Delete older versions of the file if any
|
// Delete older versions of the file if any
|
||||||
for (var file in downloadedFile.parent.listSync()) {
|
for (var file in downloadedFile.parent.listSync()) {
|
||||||
var fn = file.path.split('/').last;
|
var fn = file.path.split('/').last;
|
||||||
|
Reference in New Issue
Block a user