Shizuku logic 2: Determination of installation

This commit is contained in:
Gregory Velichko
2024-04-18 20:01:40 +03:00
parent 29e13efd66
commit a311894b9f
4 changed files with 32 additions and 9 deletions

View File

@@ -143,8 +143,10 @@
"noNewUpdates": "No new updates.", "noNewUpdates": "No new updates.",
"xHasAnUpdate": "{} has an update.", "xHasAnUpdate": "{} has an update.",
"appsUpdated": "Apps Updated", "appsUpdated": "Apps Updated",
"appsNotUpdated": "Failed to update applications",
"appsUpdatedNotifDescription": "Notifies the user that updates to one or more Apps were applied in the background", "appsUpdatedNotifDescription": "Notifies the user that updates to one or more Apps were applied in the background",
"xWasUpdatedToY": "{} was updated to {}.", "xWasUpdatedToY": "{} was updated to {}.",
"xWasNotUpdatedToY": "Failed to update {} to {}.",
"errorCheckingUpdates": "Error Checking for Updates", "errorCheckingUpdates": "Error Checking for Updates",
"errorCheckingUpdatesNotifDescription": "A notification that shows when background update checking fails", "errorCheckingUpdatesNotifDescription": "A notification that shows when background update checking fails",
"appsRemoved": "Apps Removed", "appsRemoved": "Apps Removed",
@@ -352,6 +354,10 @@
"one": "{} and 1 more app was updated.", "one": "{} and 1 more app was updated.",
"other": "{} and {} more apps were updated." "other": "{} and {} more apps were updated."
}, },
"xAndNMoreUpdatesFailed": {
"one": "Failed to update {} and 1 more app.",
"other": "Failed to update {} and {} more apps."
},
"xAndNMoreUpdatesPossiblyInstalled": { "xAndNMoreUpdatesPossiblyInstalled": {
"one": "{} and 1 more app may have been updated.", "one": "{} and 1 more app may have been updated.",
"other": "{} and {} more apps may have been updated." "other": "{} and {} more apps may have been updated."

View File

@@ -143,8 +143,10 @@
"noNewUpdates": "Нет новых обновлений", "noNewUpdates": "Нет новых обновлений",
"xHasAnUpdate": "{} есть обновление", "xHasAnUpdate": "{} есть обновление",
"appsUpdated": "Приложения обновлены", "appsUpdated": "Приложения обновлены",
"appsNotUpdated": "Не удалось обновить приложения",
"appsUpdatedNotifDescription": "Уведомляет об обновлении одного или нескольких приложений в фоновом режиме", "appsUpdatedNotifDescription": "Уведомляет об обновлении одного или нескольких приложений в фоновом режиме",
"xWasUpdatedToY": "{} была обновлена до версии {}", "xWasUpdatedToY": "{} была обновлена до версии {}",
"xWasNotUpdatedToY": "Не удалось обновить {} до версии {}",
"errorCheckingUpdates": "Ошибка при проверке обновлений", "errorCheckingUpdates": "Ошибка при проверке обновлений",
"errorCheckingUpdatesNotifDescription": "Уведомление о завершении проверки обновлений в фоновом режиме с ошибкой", "errorCheckingUpdatesNotifDescription": "Уведомление о завершении проверки обновлений в фоновом режиме с ошибкой",
"appsRemoved": "Приложение удалено", "appsRemoved": "Приложение удалено",
@@ -352,6 +354,10 @@
"one": "{} и ещё 1 приложение были обновлены", "one": "{} и ещё 1 приложение были обновлены",
"other": "{} и ещё {} приложений были обновлены" "other": "{} и ещё {} приложений были обновлены"
}, },
"xAndNMoreUpdatesFailed": {
"one": "Не удалось обновить {} и ещё 1 приложение",
"other": "Не удалось обновить {} и ещё {} приложений"
},
"xAndNMoreUpdatesPossiblyInstalled": { "xAndNMoreUpdatesPossiblyInstalled": {
"one": "{} и ещё 1 приложение могли быть обновлены", "one": "{} и ещё 1 приложение могли быть обновлены",
"other": "{} и ещё {} приложений могли быть обновлены" "other": "{} и ещё {} приложений могли быть обновлены"

View File

@@ -854,7 +854,7 @@ class AppsProvider with ChangeNotifier {
var contextIfNewInstall = var contextIfNewInstall =
apps[id]?.installedInfo == null ? context : null; apps[id]?.installedInfo == null ? context : null;
if (downloadedFile != null) { if (downloadedFile != null) {
if (willBeSilent && context == null) { if (willBeSilent && context == null && !settingsProvider.useShizuku) {
installApk(downloadedFile, contextIfNewInstall, installApk(downloadedFile, contextIfNewInstall,
needsBGWorkaround: true); needsBGWorkaround: true);
} else { } else {
@@ -862,7 +862,7 @@ class AppsProvider with ChangeNotifier {
await installApk(downloadedFile, contextIfNewInstall); await installApk(downloadedFile, contextIfNewInstall);
} }
} else { } else {
if (willBeSilent && context == null) { if (willBeSilent && context == null && !settingsProvider.useShizuku) {
installXApkDir(downloadedDir!, contextIfNewInstall, installXApkDir(downloadedDir!, contextIfNewInstall,
needsBGWorkaround: true); needsBGWorkaround: true);
} else { } else {
@@ -870,7 +870,12 @@ class AppsProvider with ChangeNotifier {
await installXApkDir(downloadedDir!, contextIfNewInstall); await installXApkDir(downloadedDir!, contextIfNewInstall);
} }
} }
if (willBeSilent && context == null) { if (willBeSilent && settingsProvider.useShizuku) {
notificationsProvider?.notify(SilentUpdateNotification(
[apps[id]!.app],
sayInstalled,
id: id.hashCode));
} else if (willBeSilent && context == null) {
notificationsProvider?.notify(SilentUpdateAttemptNotification( notificationsProvider?.notify(SilentUpdateAttemptNotification(
[apps[id]!.app], [apps[id]!.app],
id: id.hashCode)); id: id.hashCode));

View File

@@ -41,20 +41,26 @@ class UpdateNotification extends ObtainiumNotification {
} }
class SilentUpdateNotification extends ObtainiumNotification { class SilentUpdateNotification extends ObtainiumNotification {
SilentUpdateNotification(List<App> updates, {int? id}) SilentUpdateNotification(List<App> updates, bool succeeded, {int? id})
: super( : super(
id ?? 3, id ?? 3,
tr('appsUpdated'), succeeded
? tr('appsUpdated')
: tr('appsNotUpdated'),
'', '',
'APPS_UPDATED', 'APPS_UPDATED',
tr('appsUpdatedNotifChannel'), tr('appsUpdatedNotifChannel'),
tr('appsUpdatedNotifDescription'), tr('appsUpdatedNotifDescription'),
Importance.defaultImportance) { Importance.defaultImportance) {
message = updates.length == 1 message = updates.length == 1
? tr('xWasUpdatedToY', ? tr(succeeded
args: [updates[0].finalName, updates[0].latestVersion]) ? 'xWasUpdatedToY'
: plural('xAndNMoreUpdatesInstalled', updates.length - 1, : 'xWasNotUpdatedToY',
args: [updates[0].finalName, (updates.length - 1).toString()]); args: [updates[0].finalName, updates[0].latestVersion])
: plural(succeeded
? 'xAndNMoreUpdatesInstalled'
: "xAndNMoreUpdatesFailed",
updates.length - 1, args: [updates[0].finalName, (updates.length - 1).toString()]);
} }
} }