mirror of
https://github.com/revanced/revanced-manager.git
synced 2025-04-29 21:44:26 +02:00
perf: Don't recalculate universal patches or compatible packages if not necessary
This commit is contained in:
parent
7b7d91d661
commit
7e3afe0cb2
@ -18,8 +18,7 @@ import 'package:share_plus/share_plus.dart';
|
|||||||
|
|
||||||
@lazySingleton
|
@lazySingleton
|
||||||
class PatcherAPI {
|
class PatcherAPI {
|
||||||
static const patcherChannel =
|
static const patcherChannel = MethodChannel('app.revanced.manager.flutter/patcher');
|
||||||
MethodChannel('app.revanced.manager.flutter/patcher');
|
|
||||||
final ManagerAPI _managerAPI = locator<ManagerAPI>();
|
final ManagerAPI _managerAPI = locator<ManagerAPI>();
|
||||||
final RootAPI _rootAPI = RootAPI();
|
final RootAPI _rootAPI = RootAPI();
|
||||||
late Directory _dataDir;
|
late Directory _dataDir;
|
||||||
@ -27,7 +26,7 @@ class PatcherAPI {
|
|||||||
late File _keyStoreFile;
|
late File _keyStoreFile;
|
||||||
List<Patch> _patches = [];
|
List<Patch> _patches = [];
|
||||||
List<Patch> _universalPatches = [];
|
List<Patch> _universalPatches = [];
|
||||||
List<String> _compatiblePackages = [];
|
Set<String> _compatiblePackages = {};
|
||||||
Map filteredPatches = <String, List<Patch>>{};
|
Map filteredPatches = <String, List<Patch>>{};
|
||||||
File? outFile;
|
File? outFile;
|
||||||
|
|
||||||
@ -46,8 +45,8 @@ class PatcherAPI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> getCompatiblePackages() {
|
Set<String> getCompatiblePackages() {
|
||||||
final List<String> compatiblePackages = [];
|
final Set<String> compatiblePackages = {};
|
||||||
for (final Patch patch in _patches) {
|
for (final Patch patch in _patches) {
|
||||||
for (final Package package in patch.compatiblePackages) {
|
for (final Package package in patch.compatiblePackages) {
|
||||||
if (!compatiblePackages.contains(package.name)) {
|
if (!compatiblePackages.contains(package.name)) {
|
||||||
@ -66,16 +65,16 @@ class PatcherAPI {
|
|||||||
try {
|
try {
|
||||||
if (_patches.isEmpty) {
|
if (_patches.isEmpty) {
|
||||||
_patches = await _managerAPI.getPatches();
|
_patches = await _managerAPI.getPatches();
|
||||||
|
_universalPatches = getUniversalPatches();
|
||||||
|
_compatiblePackages = getCompatiblePackages();
|
||||||
}
|
}
|
||||||
} on Exception catch (e) {
|
} on Exception catch (e) {
|
||||||
if (kDebugMode) {
|
if (kDebugMode) {
|
||||||
print(e);
|
print(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
_patches = List.empty();
|
_patches = List.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
_compatiblePackages = getCompatiblePackages();
|
|
||||||
_universalPatches = getUniversalPatches();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<ApplicationWithIcon>> getFilteredInstalledApps(
|
Future<List<ApplicationWithIcon>> getFilteredInstalledApps(
|
||||||
@ -84,6 +83,7 @@ class PatcherAPI {
|
|||||||
final List<ApplicationWithIcon> filteredApps = [];
|
final List<ApplicationWithIcon> filteredApps = [];
|
||||||
final bool allAppsIncluded =
|
final bool allAppsIncluded =
|
||||||
_universalPatches.isNotEmpty && showUniversalPatches;
|
_universalPatches.isNotEmpty && showUniversalPatches;
|
||||||
|
|
||||||
if (allAppsIncluded) {
|
if (allAppsIncluded) {
|
||||||
final appList = await DeviceApps.getInstalledApplications(
|
final appList = await DeviceApps.getInstalledApplications(
|
||||||
includeAppIcons: true,
|
includeAppIcons: true,
|
||||||
@ -94,6 +94,7 @@ class PatcherAPI {
|
|||||||
filteredApps.add(app as ApplicationWithIcon);
|
filteredApps.add(app as ApplicationWithIcon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final packageName in _compatiblePackages) {
|
for (final packageName in _compatiblePackages) {
|
||||||
try {
|
try {
|
||||||
if (!filteredApps.any((app) => app.packageName == packageName)) {
|
if (!filteredApps.any((app) => app.packageName == packageName)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user