Improvements to the installation UI
- No longer show irrelevant options to the user - No longer require an additional button press to start installation
This commit is contained in:
parent
ccde8b73a2
commit
e437ffdbae
@ -106,6 +106,10 @@ object Config : PreferenceModel, DBConfig {
|
||||
else
|
||||
Value.DEFAULT_CHANNEL
|
||||
|
||||
@JvmStatic var keepVerity = false
|
||||
@JvmStatic var keepEnc = false
|
||||
@JvmStatic var recovery = false
|
||||
|
||||
var bootId by preference(Key.BOOT_ID, "")
|
||||
var askedHome by preference(Key.ASKED_HOME, false)
|
||||
|
||||
|
@ -26,14 +26,10 @@ object Info {
|
||||
|
||||
var remote = UpdateInfo()
|
||||
|
||||
// Toggle-able options
|
||||
@JvmStatic var keepVerity = false
|
||||
@JvmStatic var keepEnc = false
|
||||
@JvmStatic var recovery = false
|
||||
|
||||
// Immutable device state
|
||||
// Device state
|
||||
@JvmStatic var isSAR = false
|
||||
@JvmStatic var isAB = false
|
||||
@JvmStatic var isFBE = false
|
||||
@JvmStatic var ramdisk = false
|
||||
@JvmStatic var hasGMS = true
|
||||
|
||||
|
@ -9,15 +9,15 @@ import androidx.annotation.WorkerThread
|
||||
import androidx.core.os.postDelayed
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.core.Info
|
||||
import com.topjohnwu.magisk.core.Config
|
||||
import com.topjohnwu.magisk.core.utils.MediaStoreUtils
|
||||
import com.topjohnwu.magisk.core.utils.MediaStoreUtils.inputStream
|
||||
import com.topjohnwu.magisk.core.utils.MediaStoreUtils.outputStream
|
||||
import com.topjohnwu.magisk.data.network.GithubRawServices
|
||||
import com.topjohnwu.magisk.di.Protected
|
||||
import com.topjohnwu.magisk.events.dialog.EnvFixDialog
|
||||
import com.topjohnwu.magisk.ktx.reboot
|
||||
import com.topjohnwu.magisk.ktx.withStreams
|
||||
import com.topjohnwu.magisk.core.utils.MediaStoreUtils
|
||||
import com.topjohnwu.magisk.core.utils.MediaStoreUtils.inputStream
|
||||
import com.topjohnwu.magisk.core.utils.MediaStoreUtils.outputStream
|
||||
import com.topjohnwu.magisk.utils.Utils
|
||||
import com.topjohnwu.signing.SignBoot
|
||||
import com.topjohnwu.superuser.Shell
|
||||
@ -272,8 +272,8 @@ abstract class MagiskInstallImpl : KoinComponent {
|
||||
return false
|
||||
}
|
||||
|
||||
if (!("KEEPFORCEENCRYPT=${Info.keepEnc} KEEPVERITY=${Info.keepVerity} " +
|
||||
"RECOVERYMODE=${Info.recovery} sh update-binary " +
|
||||
if (!("KEEPFORCEENCRYPT=${Config.keepEnc} KEEPVERITY=${Config.keepVerity} " +
|
||||
"RECOVERYMODE=${Config.recovery} sh update-binary " +
|
||||
"sh boot_patch.sh $srcBoot").sh().isSuccess) {
|
||||
return false
|
||||
}
|
||||
|
@ -1,13 +1,16 @@
|
||||
package com.topjohnwu.magisk.core.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.core.Config
|
||||
import com.topjohnwu.magisk.core.Const
|
||||
import com.topjohnwu.magisk.core.Info
|
||||
import com.topjohnwu.magisk.core.wrap
|
||||
import com.topjohnwu.magisk.ktx.rawResource
|
||||
import com.topjohnwu.superuser.Shell
|
||||
import com.topjohnwu.superuser.ShellUtils
|
||||
import com.topjohnwu.superuser.io.SuFile
|
||||
|
||||
class RootInit : Shell.Initializer() {
|
||||
|
||||
@ -39,13 +42,19 @@ class RootInit : Shell.Initializer() {
|
||||
fun getBool(name: String) = getvar(name).toBoolean()
|
||||
|
||||
Const.MAGISKTMP = getvar("MAGISKTMP")
|
||||
Info.keepVerity = getBool("KEEPVERITY")
|
||||
Info.keepEnc = getBool("KEEPFORCEENCRYPT")
|
||||
Info.isSAR = getBool("SYSTEM_ROOT")
|
||||
Info.ramdisk = getBool("RAMDISKEXIST")
|
||||
Info.recovery = getBool("RECOVERYMODE")
|
||||
Info.isAB = getBool("ISAB")
|
||||
|
||||
// FBE does not exist pre 7.0
|
||||
if (Build.VERSION.SDK_INT >= 24)
|
||||
Info.isFBE = SuFile("/data/unencrypted").exists()
|
||||
|
||||
// Default presets
|
||||
Config.recovery = getBool("RECOVERYMODE")
|
||||
Config.keepVerity = getBool("KEEPVERITY")
|
||||
Config.keepEnc = getBool("KEEPFORCEENCRYPT")
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
package com.topjohnwu.magisk.ktx
|
||||
|
||||
import android.content.Context
|
||||
import com.topjohnwu.magisk.core.Config
|
||||
import com.topjohnwu.magisk.core.Const
|
||||
import com.topjohnwu.magisk.core.Info
|
||||
import com.topjohnwu.superuser.Shell
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
fun reboot(reason: String = if (Info.recovery) "recovery" else "") {
|
||||
fun reboot(reason: String = if (Config.recovery) "recovery" else "") {
|
||||
Shell.su("/system/bin/svc power reboot $reason || /system/bin/reboot $reason").submit()
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ import com.topjohnwu.magisk.arch.BaseUIFragment
|
||||
import com.topjohnwu.magisk.core.download.BaseDownloadService
|
||||
import com.topjohnwu.magisk.databinding.FragmentInstallMd2Binding
|
||||
import com.topjohnwu.magisk.events.RequestFileEvent
|
||||
import com.topjohnwu.magisk.ktx.coroutineScope
|
||||
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||
|
||||
class InstallFragment : BaseUIFragment<InstallViewModel, FragmentInstallMd2Binding>() {
|
||||
@ -24,7 +25,7 @@ class InstallFragment : BaseUIFragment<InstallViewModel, FragmentInstallMd2Bindi
|
||||
requireActivity().setTitle(R.string.install)
|
||||
|
||||
// Allow markwon to run in viewmodel scope
|
||||
binding.releaseNotes.tag = viewModel.viewModelScope
|
||||
binding.releaseNotes.coroutineScope = viewModel.viewModelScope
|
||||
BaseDownloadService.observeProgress(this, viewModel::onProgressUpdate)
|
||||
}
|
||||
|
||||
|
@ -25,11 +25,11 @@ class InstallViewModel(
|
||||
stringRepo: StringRepository
|
||||
) : BaseViewModel(State.LOADED) {
|
||||
|
||||
val isRooted get() = Shell.rootAccess()
|
||||
val isAB get() = Info.isAB
|
||||
val isRooted = Shell.rootAccess()
|
||||
val skipOptions = Info.ramdisk && Info.isFBE && Info.isSAR
|
||||
|
||||
@get:Bindable
|
||||
var step = 0
|
||||
var step = if (skipOptions) 1 else 0
|
||||
set(value) = set(value, field, { field = it }, BR.step)
|
||||
|
||||
@get:Bindable
|
||||
|
@ -6,6 +6,7 @@
|
||||
<data>
|
||||
|
||||
<import type="com.topjohnwu.magisk.core.Info" />
|
||||
<import type="com.topjohnwu.magisk.core.Config" />
|
||||
|
||||
<variable
|
||||
name="viewModel"
|
||||
@ -35,6 +36,7 @@
|
||||
android:paddingTop="@dimen/l1">
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
gone="@{viewModel.skipOptions}"
|
||||
style="@style/WidgetFoundation.Card.Variant"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@ -92,31 +94,34 @@
|
||||
tools:layout_gravity="center">
|
||||
|
||||
<CheckBox
|
||||
gone="@{Info.isSAR}"
|
||||
style="@style/WidgetFoundation.Checkbox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="start|center_vertical"
|
||||
android:checked="@={Info.keepVerity}"
|
||||
android:checked="@={Config.keepVerity}"
|
||||
android:gravity="center"
|
||||
android:text="@string/keep_dm_verity"
|
||||
tools:checked="true" />
|
||||
|
||||
<CheckBox
|
||||
gone="@{Info.isFBE}"
|
||||
style="@style/WidgetFoundation.Checkbox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="start|center_vertical"
|
||||
android:checked="@={Info.keepEnc}"
|
||||
android:checked="@={Config.keepEnc}"
|
||||
android:gravity="center"
|
||||
android:text="@string/keep_force_encryption"
|
||||
app:tint="?colorPrimary" />
|
||||
|
||||
<CheckBox
|
||||
gone="@{Info.ramdisk}"
|
||||
style="@style/WidgetFoundation.Checkbox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="start|center_vertical"
|
||||
android:checked="@={Info.recovery}"
|
||||
android:checked="@={Config.recovery}"
|
||||
android:gravity="center"
|
||||
android:text="@string/recovery_mode"
|
||||
app:tint="?colorPrimary" />
|
||||
@ -168,8 +173,10 @@
|
||||
isEnabled="@{viewModel.method == @id/method_patch ? viewModel.data != null : viewModel.method != -1}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:onClick="@{() -> viewModel.step(2)}"
|
||||
android:text="@string/install_next" />
|
||||
android:onClick="@{() -> viewModel.install()}"
|
||||
android:text="@string/install_start"
|
||||
app:icon="@drawable/ic_forth_md2"
|
||||
app:iconGravity="textEnd"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@ -211,7 +218,7 @@
|
||||
<RadioButton
|
||||
android:id="@+id/method_inactive_slot"
|
||||
style="@style/WidgetFoundation.RadioButton"
|
||||
gone="@{!viewModel.isRooted || !viewModel.isAB}"
|
||||
gone="@{!viewModel.isRooted || !Info.isAB}"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/install_inactive_slot" />
|
||||
@ -224,7 +231,6 @@
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
style="@style/WidgetFoundation.Card.Variant"
|
||||
gone="@{viewModel.step != 0}"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/l1"
|
||||
@ -243,18 +249,6 @@
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
<Button
|
||||
style="@style/WidgetFoundation.Button.Text"
|
||||
gone="@{viewModel.step != 2}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:layout_margin="@dimen/l1"
|
||||
android:onClick="@{() -> viewModel.install()}"
|
||||
android:text="@string/install_start"
|
||||
app:icon="@drawable/ic_forth_md2"
|
||||
app:iconGravity="textEnd" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
Loading…
Reference in New Issue
Block a user