Commit 64f5ff54 authored by topjohnwu's avatar topjohnwu

Use global A/B detection

parent 75877711
...@@ -2,6 +2,7 @@ package com.topjohnwu.magisk.ui.install ...@@ -2,6 +2,7 @@ package com.topjohnwu.magisk.ui.install
import android.net.Uri import android.net.Uri
import com.topjohnwu.magisk.R import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.core.Info
import com.topjohnwu.magisk.core.download.DownloadService import com.topjohnwu.magisk.core.download.DownloadService
import com.topjohnwu.magisk.core.download.RemoteFileService import com.topjohnwu.magisk.core.download.RemoteFileService
import com.topjohnwu.magisk.extensions.addOnPropertyChangedCallback import com.topjohnwu.magisk.extensions.addOnPropertyChangedCallback
...@@ -11,14 +12,13 @@ import com.topjohnwu.magisk.model.events.RequestFileEvent ...@@ -11,14 +12,13 @@ import com.topjohnwu.magisk.model.events.RequestFileEvent
import com.topjohnwu.magisk.ui.base.BaseViewModel import com.topjohnwu.magisk.ui.base.BaseViewModel
import com.topjohnwu.magisk.utils.KObservableField import com.topjohnwu.magisk.utils.KObservableField
import com.topjohnwu.superuser.Shell import com.topjohnwu.superuser.Shell
import com.topjohnwu.superuser.ShellUtils
import org.koin.core.get import org.koin.core.get
import kotlin.math.roundToInt import kotlin.math.roundToInt
class InstallViewModel : BaseViewModel(State.LOADED) { class InstallViewModel : BaseViewModel(State.LOADED) {
val isRooted = Shell.rootAccess() val isRooted get() = Shell.rootAccess()
val isAB = isABDevice() val isAB get() = Info.isAB
val step = KObservableField(0) val step = KObservableField(0)
val method = KObservableField(-1) val method = KObservableField(-1)
...@@ -64,9 +64,4 @@ class InstallViewModel : BaseViewModel(State.LOADED) { ...@@ -64,9 +64,4 @@ class InstallViewModel : BaseViewModel(State.LOADED) {
R.id.method_inactive_slot -> Configuration.Flash.Secondary R.id.method_inactive_slot -> Configuration.Flash.Secondary
else -> throw IllegalArgumentException("Unknown value") else -> throw IllegalArgumentException("Unknown value")
} }
private fun isABDevice() = ShellUtils
.fastCmd("grep_prop ro.build.ab_update")
.let { it.isNotEmpty() && it.toBoolean() }
} }
...@@ -206,7 +206,7 @@ ...@@ -206,7 +206,7 @@
<com.google.android.material.radiobutton.MaterialRadioButton <com.google.android.material.radiobutton.MaterialRadioButton
android:id="@+id/method_inactive_slot" android:id="@+id/method_inactive_slot"
style="@style/WidgetFoundation.RadioButton" style="@style/WidgetFoundation.RadioButton"
gone="@{!viewModel.rooted || !viewModel.aB}" gone="@{!viewModel.isRooted || !viewModel.isAB}"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/install_inactive_slot" /> android:text="@string/install_inactive_slot" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment