mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-08-19 13:09:30 +02:00
Root install
This commit is contained in:
@@ -33,6 +33,7 @@ import 'package:http/http.dart';
|
||||
import 'package:android_intent_plus/android_intent.dart';
|
||||
import 'package:flutter_archive/flutter_archive.dart';
|
||||
import 'package:shared_storage/shared_storage.dart' as saf;
|
||||
import 'installers_provider.dart';
|
||||
|
||||
final pm = AndroidPackageManager();
|
||||
|
||||
@@ -515,8 +516,14 @@ class AppsProvider with ChangeNotifier {
|
||||
await saveApps([apps[file.appId]!.app],
|
||||
attemptToCorrectInstallStatus: false);
|
||||
}
|
||||
int? code =
|
||||
await AndroidPackageInstaller.installApk(apkFilePath: file.file.path);
|
||||
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);
|
||||
}
|
||||
bool installed = false;
|
||||
if (code != null && code != 0 && code != 3) {
|
||||
throw InstallError(code);
|
||||
|
14
lib/providers/installers_provider.dart
Normal file
14
lib/providers/installers_provider.dart
Normal file
@@ -0,0 +1,14 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
class Installers {
|
||||
static const MethodChannel _channel = MethodChannel('installers');
|
||||
|
||||
static Future<int?> installWithShizuku({required String apkFilePath}) async {
|
||||
return await _channel.invokeMethod('installWithShizuku', {'apkFilePath': apkFilePath});
|
||||
}
|
||||
|
||||
static Future<int?> installWithRoot({required String apkFilePath}) async {
|
||||
return await _channel.invokeMethod('installWithRoot', {'apkFilePath': apkFilePath});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user