mirror of
https://github.com/revanced/revanced-manager
synced 2024-05-14 13:56:57 +02:00
feat: Hide "Install as Root" button if user does not have root access at all
This commit is contained in:
parent
c8c35ca801
commit
9561153bfb
@ -5,6 +5,15 @@ class RootAPI {
|
|||||||
final String _postFsDataDirPath = '/data/adb/post-fs-data.d';
|
final String _postFsDataDirPath = '/data/adb/post-fs-data.d';
|
||||||
final String _serviceDDirPath = '/data/adb/service.d';
|
final String _serviceDDirPath = '/data/adb/service.d';
|
||||||
|
|
||||||
|
Future<bool> isRooted() async {
|
||||||
|
try {
|
||||||
|
bool? isRooted = await Root.isRootAvailable();
|
||||||
|
return isRooted != null && isRooted;
|
||||||
|
} on Exception {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<bool> hasRootPermissions() async {
|
Future<bool> hasRootPermissions() async {
|
||||||
try {
|
try {
|
||||||
bool? isRooted = await Root.isRootAvailable();
|
bool? isRooted = await Root.isRootAvailable();
|
||||||
|
@ -106,7 +106,7 @@ class InstallerView extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Visibility(
|
Visibility(
|
||||||
visible: !model.isInstalled,
|
visible: !model.isInstalled && model.isRooted,
|
||||||
child: CustomMaterialButton(
|
child: CustomMaterialButton(
|
||||||
isFilled: false,
|
isFilled: false,
|
||||||
label:
|
label:
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// ignore_for_file: use_build_context_synchronously
|
||||||
import 'package:device_apps/device_apps.dart';
|
import 'package:device_apps/device_apps.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
@ -9,6 +10,7 @@ import 'package:revanced_manager/models/patch.dart';
|
|||||||
import 'package:revanced_manager/models/patched_application.dart';
|
import 'package:revanced_manager/models/patched_application.dart';
|
||||||
import 'package:revanced_manager/services/manager_api.dart';
|
import 'package:revanced_manager/services/manager_api.dart';
|
||||||
import 'package:revanced_manager/services/patcher_api.dart';
|
import 'package:revanced_manager/services/patcher_api.dart';
|
||||||
|
import 'package:revanced_manager/services/root_api.dart';
|
||||||
import 'package:revanced_manager/services/toast.dart';
|
import 'package:revanced_manager/services/toast.dart';
|
||||||
import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart';
|
import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart';
|
||||||
import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart';
|
import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart';
|
||||||
@ -18,6 +20,7 @@ import 'package:wakelock/wakelock.dart';
|
|||||||
class InstallerViewModel extends BaseViewModel {
|
class InstallerViewModel extends BaseViewModel {
|
||||||
final ManagerAPI _managerAPI = locator<ManagerAPI>();
|
final ManagerAPI _managerAPI = locator<ManagerAPI>();
|
||||||
final PatcherAPI _patcherAPI = locator<PatcherAPI>();
|
final PatcherAPI _patcherAPI = locator<PatcherAPI>();
|
||||||
|
final RootAPI _rootAPI = RootAPI();
|
||||||
final Toast _toast = locator<Toast>();
|
final Toast _toast = locator<Toast>();
|
||||||
final PatchedApplication _app = locator<PatcherViewModel>().selectedApp!;
|
final PatchedApplication _app = locator<PatcherViewModel>().selectedApp!;
|
||||||
final List<Patch> _patches = locator<PatcherViewModel>().selectedPatches;
|
final List<Patch> _patches = locator<PatcherViewModel>().selectedPatches;
|
||||||
@ -28,11 +31,13 @@ class InstallerViewModel extends BaseViewModel {
|
|||||||
double? progress = 0.0;
|
double? progress = 0.0;
|
||||||
String logs = '';
|
String logs = '';
|
||||||
String headerLogs = '';
|
String headerLogs = '';
|
||||||
|
bool isRooted = false;
|
||||||
bool isPatching = true;
|
bool isPatching = true;
|
||||||
bool isInstalled = false;
|
bool isInstalled = false;
|
||||||
bool hasErrors = false;
|
bool hasErrors = false;
|
||||||
|
|
||||||
Future<void> initialize(BuildContext context) async {
|
Future<void> initialize(BuildContext context) async {
|
||||||
|
isRooted = await _rootAPI.isRooted();
|
||||||
if (await Permission.ignoreBatteryOptimizations.isGranted) {
|
if (await Permission.ignoreBatteryOptimizations.isGranted) {
|
||||||
try {
|
try {
|
||||||
FlutterBackground.initialize(
|
FlutterBackground.initialize(
|
||||||
|
Loading…
Reference in New Issue
Block a user