mirror of
https://github.com/revanced/revanced-manager
synced 2024-05-14 13:56:57 +02:00
fix: improve get compatible packages and patches
This commit is contained in:
parent
cc47584643
commit
cfad7222ab
@ -39,18 +39,21 @@ class PatcherAPI {
|
||||
|
||||
Future<List<AppInfo>> getFilteredInstalledApps() async {
|
||||
if (_patchBundleFile != null && _filteredPackages.isEmpty) {
|
||||
List<AppInfo> all = await InstalledApps.getInstalledApps(false, true);
|
||||
try {
|
||||
List<String>? patchesPackages =
|
||||
await platform.invokeListMethod<String>('getCompatiblePackages');
|
||||
if (patchesPackages != null) {
|
||||
for (AppInfo app in all) {
|
||||
if (patchesPackages.contains(app.packageName)) {
|
||||
for (String package in patchesPackages) {
|
||||
try {
|
||||
AppInfo app = await InstalledApps.getAppInfo(package);
|
||||
_filteredPackages.add(app);
|
||||
} catch (e) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
} on Exception {
|
||||
} on PlatformException {
|
||||
_filteredPackages.clear();
|
||||
return List.empty();
|
||||
}
|
||||
}
|
||||
@ -73,21 +76,25 @@ class PatcherAPI {
|
||||
);
|
||||
if (patches != null) {
|
||||
for (var patch in patches) {
|
||||
_filteredPatches[targetApp.packageName]!.add(
|
||||
Patch(
|
||||
name: patch['name'],
|
||||
simpleName: (patch['name'] as String)
|
||||
.replaceAll('-', ' ')
|
||||
.split('-')
|
||||
.join(' ')
|
||||
.toTitleCase(),
|
||||
version: patch['version'] ?? 'unknown',
|
||||
description: patch['description'] ?? 'unknown',
|
||||
),
|
||||
);
|
||||
if (!_filteredPatches[targetApp.packageName]!
|
||||
.any((element) => element.name == patch['name'])) {
|
||||
_filteredPatches[targetApp.packageName]!.add(
|
||||
Patch(
|
||||
name: patch['name'],
|
||||
simpleName: (patch['name'] as String)
|
||||
.replaceAll('-', ' ')
|
||||
.split('-')
|
||||
.join(' ')
|
||||
.toTitleCase(),
|
||||
version: patch['version'] ?? '?.?.?',
|
||||
description: patch['description'] ?? 'N/A',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
} on Exception {
|
||||
} on PlatformException {
|
||||
_filteredPatches[targetApp.packageName]!.clear();
|
||||
return List.empty();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user