mirror of
https://github.com/revanced/revanced-manager
synced 2024-05-14 13:56:57 +02:00
fix: Fix apps reassess on root
This commit is contained in:
parent
257fd46e27
commit
ae801a2918
@ -182,23 +182,27 @@ class ManagerAPI {
|
|||||||
List<PatchedApplication> patchedApps,
|
List<PatchedApplication> patchedApps,
|
||||||
) async {
|
) async {
|
||||||
List<PatchedApplication> unsavedApps = [];
|
List<PatchedApplication> unsavedApps = [];
|
||||||
List<String> installedApps = await _rootAPI.getInstalledApps();
|
bool hasRootPermissions = await _rootAPI.hasRootPermissions();
|
||||||
for (String packageName in installedApps) {
|
if (hasRootPermissions) {
|
||||||
if (!patchedApps.any((app) => app.packageName == packageName)) {
|
List<String> installedApps = await _rootAPI.getInstalledApps();
|
||||||
ApplicationWithIcon? application =
|
for (String packageName in installedApps) {
|
||||||
await DeviceApps.getApp(packageName, true) as ApplicationWithIcon?;
|
if (!patchedApps.any((app) => app.packageName == packageName)) {
|
||||||
if (application != null) {
|
ApplicationWithIcon? application =
|
||||||
unsavedApps.add(
|
await DeviceApps.getApp(packageName, true)
|
||||||
PatchedApplication(
|
as ApplicationWithIcon?;
|
||||||
name: application.appName,
|
if (application != null) {
|
||||||
packageName: application.packageName,
|
unsavedApps.add(
|
||||||
version: application.versionName!,
|
PatchedApplication(
|
||||||
apkFilePath: application.apkFilePath,
|
name: application.appName,
|
||||||
icon: application.icon,
|
packageName: application.packageName,
|
||||||
patchDate: DateTime.now(),
|
version: application.versionName!,
|
||||||
isRooted: true,
|
apkFilePath: application.apkFilePath,
|
||||||
),
|
icon: application.icon,
|
||||||
);
|
patchDate: DateTime.now(),
|
||||||
|
isRooted: true,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -227,7 +231,6 @@ class ManagerAPI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return unsavedApps;
|
return unsavedApps;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,14 +263,15 @@ class ManagerAPI {
|
|||||||
|
|
||||||
Future<bool> isAppUninstalled(PatchedApplication app) async {
|
Future<bool> isAppUninstalled(PatchedApplication app) async {
|
||||||
bool existsRoot = false;
|
bool existsRoot = false;
|
||||||
|
bool existsNonRoot = await DeviceApps.isAppInstalled(app.packageName);
|
||||||
if (app.isRooted) {
|
if (app.isRooted) {
|
||||||
bool hasRootPermissions = await _rootAPI.hasRootPermissions();
|
bool hasRootPermissions = await _rootAPI.hasRootPermissions();
|
||||||
if (hasRootPermissions) {
|
if (hasRootPermissions) {
|
||||||
existsRoot = await _rootAPI.isAppInstalled(app.packageName);
|
existsRoot = await _rootAPI.isAppInstalled(app.packageName);
|
||||||
}
|
}
|
||||||
|
return !existsRoot || !existsNonRoot;
|
||||||
}
|
}
|
||||||
bool existsNonRoot = await DeviceApps.isAppInstalled(app.packageName);
|
return !existsNonRoot;
|
||||||
return !existsRoot && !existsNonRoot;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> hasAppUpdates(String packageName, DateTime patchDate) async {
|
Future<bool> hasAppUpdates(String packageName, DateTime patchDate) async {
|
||||||
|
@ -58,16 +58,7 @@ class RootAPI {
|
|||||||
cmd: 'ls "$_managerDirPath"',
|
cmd: 'ls "$_managerDirPath"',
|
||||||
);
|
);
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
List<String> apps = res.split('\n');
|
return res.split('\n').map((pack) => pack.trim()).toList();
|
||||||
List<String> toRemove = [];
|
|
||||||
for (String packageName in apps) {
|
|
||||||
bool isInstalled = await isAppInstalled(packageName);
|
|
||||||
if (!isInstalled) {
|
|
||||||
toRemove.add(packageName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
apps.removeWhere((a) => toRemove.contains(a));
|
|
||||||
return apps;
|
|
||||||
}
|
}
|
||||||
} on Exception {
|
} on Exception {
|
||||||
return List.empty();
|
return List.empty();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user