Now it looks good

This commit is contained in:
Gregory
2023-12-24 18:26:11 +03:00
parent 375b9bce30
commit b291c800f1
5 changed files with 161 additions and 136 deletions

View File

@@ -505,7 +505,8 @@ class AppsProvider with ChangeNotifier {
!(await canDowngradeApps())) {
throw DowngradeError();
}
if (needsBGWorkaround) {
if (needsBGWorkaround &&
settingsProvider.installMethod == InstallMethodSettings.normal) {
// The below 'await' will never return if we are in a background process
// To work around this, we should assume the install will be successful
// So we update the app's installed version first as we will never get to the later code
@@ -517,12 +518,13 @@ class AppsProvider with ChangeNotifier {
attemptToCorrectInstallStatus: false);
}
int? code;
if (settingsProvider.installMethod == InstallMethodSettings.normal) {
code = await AndroidPackageInstaller.installApk(apkFilePath: file.file.path);
} else if (settingsProvider.installMethod == InstallMethodSettings.shizuku) {
code = await Installers.installWithShizuku(apkFilePath: file.file.path);
} else if (settingsProvider.installMethod == InstallMethodSettings.root) {
code = await Installers.installWithRoot(apkFilePath: file.file.path);
switch (settingsProvider.installMethod) {
case InstallMethodSettings.normal:
code = await AndroidPackageInstaller.installApk(apkFilePath: file.file.path);
case InstallMethodSettings.shizuku:
code = (await Installers.installWithShizuku(apkFileUri: file.file.uri.toString())) ? 0 : 1;
case InstallMethodSettings.root:
code = (await Installers.installWithRoot(apkFilePath: file.file.path)) ? 0 : 1;
}
bool installed = false;
if (code != null && code != 0 && code != 3) {
@@ -679,8 +681,22 @@ class AppsProvider with ChangeNotifier {
}
var appId = downloadedFile?.appId ?? downloadedDir!.appId;
bool willBeSilent = await canInstallSilently(apps[appId]!.app);
if (!(await settingsProvider.getInstallPermission(enforce: false))) {
throw ObtainiumError(tr('cancelled'));
switch (settingsProvider.installMethod) {
case InstallMethodSettings.normal:
if (!(await settingsProvider.getInstallPermission(enforce: false))) {
throw ObtainiumError(tr('cancelled'));
}
case InstallMethodSettings.shizuku:
int code = await Installers.checkPermissionShizuku();
if (code == -1) {
throw ObtainiumError(tr('shizukuBinderNotFound'));
} else if (code == 0) {
throw ObtainiumError(tr('cancelled'));
}
case InstallMethodSettings.root:
if (!(await Installers.checkPermissionRoot())) {
throw ObtainiumError(tr('cancelled'));
}
}
if (!willBeSilent && context != null) {
// ignore: use_build_context_synchronously