From 64f5ff54758be7844f23618685c7f3c4338bc995 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Fri, 28 Feb 2020 10:30:53 -0800 Subject: [PATCH] Use global A/B detection --- .../topjohnwu/magisk/ui/install/InstallViewModel.kt | 11 +++-------- app/src/main/res/layout/fragment_install_md2.xml | 2 +- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/install/InstallViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/ui/install/InstallViewModel.kt index aec2bafdd..1f84e1ca6 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/install/InstallViewModel.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/install/InstallViewModel.kt @@ -2,6 +2,7 @@ package com.topjohnwu.magisk.ui.install import android.net.Uri import com.topjohnwu.magisk.R +import com.topjohnwu.magisk.core.Info import com.topjohnwu.magisk.core.download.DownloadService import com.topjohnwu.magisk.core.download.RemoteFileService import com.topjohnwu.magisk.extensions.addOnPropertyChangedCallback @@ -11,14 +12,13 @@ import com.topjohnwu.magisk.model.events.RequestFileEvent import com.topjohnwu.magisk.ui.base.BaseViewModel import com.topjohnwu.magisk.utils.KObservableField import com.topjohnwu.superuser.Shell -import com.topjohnwu.superuser.ShellUtils import org.koin.core.get import kotlin.math.roundToInt class InstallViewModel : BaseViewModel(State.LOADED) { - val isRooted = Shell.rootAccess() - val isAB = isABDevice() + val isRooted get() = Shell.rootAccess() + val isAB get() = Info.isAB val step = KObservableField(0) val method = KObservableField(-1) @@ -64,9 +64,4 @@ class InstallViewModel : BaseViewModel(State.LOADED) { R.id.method_inactive_slot -> Configuration.Flash.Secondary else -> throw IllegalArgumentException("Unknown value") } - - private fun isABDevice() = ShellUtils - .fastCmd("grep_prop ro.build.ab_update") - .let { it.isNotEmpty() && it.toBoolean() } - } diff --git a/app/src/main/res/layout/fragment_install_md2.xml b/app/src/main/res/layout/fragment_install_md2.xml index 9282b3111..c295b9018 100644 --- a/app/src/main/res/layout/fragment_install_md2.xml +++ b/app/src/main/res/layout/fragment_install_md2.xml @@ -206,7 +206,7 @@