mirror of
https://github.com/revanced/revanced-manager
synced 2024-05-14 13:56:57 +02:00
feat: Retrieve unsaved apps from manager's root folder and known packages from user's apps list
This commit is contained in:
parent
bb4b59eee6
commit
5fbc8ff7a0
@ -165,14 +165,79 @@ class ManagerAPI {
|
|||||||
return packageInfo.version;
|
return packageInfo.version;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> reAssessSavedApps() async {
|
Future<List<PatchedApplication>> getAppsToRemove(
|
||||||
List<PatchedApplication> patchedApps = getPatchedApps();
|
List<PatchedApplication> patchedApps,
|
||||||
|
) async {
|
||||||
List<PatchedApplication> toRemove = [];
|
List<PatchedApplication> toRemove = [];
|
||||||
for (PatchedApplication app in patchedApps) {
|
for (PatchedApplication app in patchedApps) {
|
||||||
bool isRemove = await isAppUninstalled(app);
|
bool isRemove = await isAppUninstalled(app);
|
||||||
if (isRemove) {
|
if (isRemove) {
|
||||||
toRemove.add(app);
|
toRemove.add(app);
|
||||||
} else {
|
}
|
||||||
|
}
|
||||||
|
return toRemove;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<List<PatchedApplication>> getUnsavedApps(
|
||||||
|
List<PatchedApplication> patchedApps,
|
||||||
|
) async {
|
||||||
|
List<PatchedApplication> unsavedApps = [];
|
||||||
|
List<String> installedApps = await _rootAPI.getInstalledApps();
|
||||||
|
for (String packageName in installedApps) {
|
||||||
|
if (!patchedApps.any((app) => app.packageName == packageName)) {
|
||||||
|
ApplicationWithIcon? application =
|
||||||
|
await DeviceApps.getApp(packageName, true) as ApplicationWithIcon?;
|
||||||
|
if (application != null) {
|
||||||
|
unsavedApps.add(
|
||||||
|
PatchedApplication(
|
||||||
|
name: application.appName,
|
||||||
|
packageName: application.packageName,
|
||||||
|
version: application.versionName!,
|
||||||
|
apkFilePath: application.apkFilePath,
|
||||||
|
icon: application.icon,
|
||||||
|
patchDate: DateTime.now(),
|
||||||
|
isRooted: true,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<Application> userApps = await DeviceApps.getInstalledApplications(
|
||||||
|
includeSystemApps: false,
|
||||||
|
includeAppIcons: false,
|
||||||
|
);
|
||||||
|
for (Application app in userApps) {
|
||||||
|
if (app.packageName.startsWith('app.revanced') &&
|
||||||
|
!app.packageName.startsWith('app.revanced.manager.')) {
|
||||||
|
ApplicationWithIcon? application =
|
||||||
|
await DeviceApps.getApp(app.packageName, true)
|
||||||
|
as ApplicationWithIcon?;
|
||||||
|
if (application != null) {
|
||||||
|
unsavedApps.add(
|
||||||
|
PatchedApplication(
|
||||||
|
name: application.appName,
|
||||||
|
packageName: application.packageName,
|
||||||
|
version: application.versionName!,
|
||||||
|
apkFilePath: application.apkFilePath,
|
||||||
|
icon: application.icon,
|
||||||
|
patchDate: DateTime.now(),
|
||||||
|
isRooted: false,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return unsavedApps;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> reAssessSavedApps() async {
|
||||||
|
List<PatchedApplication> patchedApps = getPatchedApps();
|
||||||
|
List<PatchedApplication> unsavedApps = await getUnsavedApps(patchedApps);
|
||||||
|
patchedApps.addAll(unsavedApps);
|
||||||
|
List<PatchedApplication> toRemove = await getAppsToRemove(patchedApps);
|
||||||
|
patchedApps.removeWhere((a) => toRemove.contains(a));
|
||||||
|
for (PatchedApplication app in patchedApps) {
|
||||||
app.hasUpdates = await hasAppUpdates(app.packageName, app.patchDate);
|
app.hasUpdates = await hasAppUpdates(app.packageName, app.patchDate);
|
||||||
app.changelog = await getAppChangelog(app.packageName, app.patchDate);
|
app.changelog = await getAppChangelog(app.packageName, app.patchDate);
|
||||||
if (!app.hasUpdates) {
|
if (!app.hasUpdates) {
|
||||||
@ -190,8 +255,6 @@ class ManagerAPI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
patchedApps.removeWhere((a) => toRemove.contains(a));
|
|
||||||
await setPatchedApps(patchedApps);
|
await setPatchedApps(patchedApps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user