mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-07-31 21:00:15 +02:00
Probably fixed
This commit is contained in:
@@ -547,8 +547,7 @@ class AppsProvider with ChangeNotifier {
|
||||
!(await canDowngradeApps())) {
|
||||
throw DowngradeError();
|
||||
}
|
||||
if (needsBGWorkaround &&
|
||||
settingsProvider.installMethod == InstallMethodSettings.normal) {
|
||||
if (needsBGWorkaround) {
|
||||
// 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
|
||||
@@ -560,20 +559,14 @@ class AppsProvider with ChangeNotifier {
|
||||
attemptToCorrectInstallStatus: false);
|
||||
}
|
||||
int? code;
|
||||
switch (settingsProvider.installMethod) {
|
||||
case InstallMethodSettings.normal:
|
||||
code = await AndroidPackageInstaller.installApk(
|
||||
apkFilePath: file.file.path);
|
||||
case InstallMethodSettings.shizuku:
|
||||
code = (await NativeFeatures.installWithShizuku(
|
||||
apkFileUri: file.file.uri.toString()))
|
||||
? 0
|
||||
: 1;
|
||||
case InstallMethodSettings.root:
|
||||
code =
|
||||
(await NativeFeatures.installWithRoot(apkFilePath: file.file.path))
|
||||
? 0
|
||||
: 1;
|
||||
if (!settingsProvider.useShizuku) {
|
||||
code = await AndroidPackageInstaller.installApk(
|
||||
apkFilePath: file.file.path);
|
||||
} else {
|
||||
code = (await NativeFeatures.installWithShizuku(
|
||||
apkFileUri: file.file.uri.toString()))
|
||||
? 0
|
||||
: 1;
|
||||
}
|
||||
bool installed = false;
|
||||
if (code != null && code != 0 && code != 3) {
|
||||
@@ -732,25 +725,19 @@ class AppsProvider with ChangeNotifier {
|
||||
}
|
||||
var appId = downloadedFile?.appId ?? downloadedDir!.appId;
|
||||
bool willBeSilent = await canInstallSilently(apps[appId]!.app);
|
||||
switch (settingsProvider.installMethod) {
|
||||
case InstallMethodSettings.normal:
|
||||
if (!(await settingsProvider.getInstallPermission(
|
||||
enforce: false))) {
|
||||
throw ObtainiumError(tr('cancelled'));
|
||||
}
|
||||
case InstallMethodSettings.shizuku:
|
||||
int code = await NativeFeatures.checkPermissionShizuku();
|
||||
if (code == -1) {
|
||||
throw ObtainiumError(tr('shizukuBinderNotFound'));
|
||||
} else if (code == 0) {
|
||||
throw ObtainiumError(tr('cancelled'));
|
||||
}
|
||||
case InstallMethodSettings.root:
|
||||
if (!(await NativeFeatures.checkPermissionRoot())) {
|
||||
throw ObtainiumError(tr('cancelled'));
|
||||
}
|
||||
if (!settingsProvider.useShizuku) {
|
||||
if (!(await settingsProvider.getInstallPermission(enforce: false))) {
|
||||
throw ObtainiumError(tr('cancelled'));
|
||||
}
|
||||
} else {
|
||||
int code = await NativeFeatures.checkPermissionShizuku();
|
||||
if (code == 0) {
|
||||
throw ObtainiumError(tr('cancelled'));
|
||||
} else if (code == -1) {
|
||||
throw ObtainiumError(tr('shizukuBinderNotFound'));
|
||||
}
|
||||
}
|
||||
if (!willBeSilent && context != null) {
|
||||
if (!willBeSilent && context != null && !settingsProvider.useShizuku) {
|
||||
// ignore: use_build_context_synchronously
|
||||
await waitForUserToReturnToForeground(context);
|
||||
}
|
||||
|
@@ -59,17 +59,8 @@ class NativeFeatures {
|
||||
return res;
|
||||
}
|
||||
|
||||
static Future<bool> checkPermissionRoot() async {
|
||||
return await _channel.invokeMethod('checkPermissionRoot');
|
||||
}
|
||||
|
||||
static Future<bool> installWithShizuku({required String apkFileUri}) async {
|
||||
return await _channel.invokeMethod(
|
||||
'installWithShizuku', {'apkFileUri': apkFileUri});
|
||||
}
|
||||
|
||||
static Future<bool> installWithRoot({required String apkFilePath}) async {
|
||||
return await _channel.invokeMethod(
|
||||
'installWithRoot', {'apkFilePath': apkFilePath});
|
||||
}
|
||||
}
|
||||
|
@@ -18,8 +18,6 @@ String obtainiumTempId = 'imranr98_obtainium_${GitHub().hosts[0]}';
|
||||
String obtainiumId = 'dev.imranr.obtainium';
|
||||
String obtainiumUrl = 'https://github.com/ImranR98/Obtainium';
|
||||
|
||||
enum InstallMethodSettings { normal, shizuku, root }
|
||||
|
||||
enum ThemeSettings { system, light, dark }
|
||||
|
||||
enum ColourSettings { basic, materialYou }
|
||||
@@ -61,13 +59,12 @@ class SettingsProvider with ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
InstallMethodSettings get installMethod {
|
||||
return InstallMethodSettings.values[
|
||||
prefs?.getInt('installMethod') ?? InstallMethodSettings.normal.index];
|
||||
bool get useShizuku{
|
||||
return prefs?.getBool('useShizuku') ?? false;
|
||||
}
|
||||
|
||||
set installMethod(InstallMethodSettings t) {
|
||||
prefs?.setInt('installMethod', t.index);
|
||||
set useShizuku(bool useShizuku) {
|
||||
prefs?.setBool('useShizuku', useShizuku);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user