Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,12 @@ fun HomeScreen(viewModel: HomeViewModel, installVm: InstallViewModel) {
onHideRestorePressed = viewModel::onHideRestorePressed,
)

UninstallButton(
onClick = { viewModel.onDeletePressed() },
enabled = Info.env.isActive
)
if (!Info.isBootloaderLocked) {
UninstallButton(
onClick = { viewModel.onDeletePressed() },
enabled = Info.env.isActive
)
}

Text(
text = stringResource(CoreR.string.home_support_title),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ fun InstallBottomSheet(
},
)

if (installVm.isRooted) {
if (installVm.isRooted && !installVm.isBootloaderLocked) {
SettingsArrow(
title = stringResource(CoreR.string.direct_install),
onClick = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ class InstallViewModel(svc: NetworkService) : BaseViewModel() {
)

val isRooted get() = Info.isRooted
val isBootloaderLocked get() = Info.isBootloaderLocked
val skipOptions = Info.isEmulator || (Info.isSAR && !Info.isFDE && Info.ramdisk)
val noSecondSlot = !isRooted || !Info.isAB || Info.isEmulator
val noSecondSlot = !isRooted || !Info.isAB || Info.isEmulator || isBootloaderLocked

private val _uiState = MutableStateFlow(UiState(step = if (skipOptions) 1 else 0))
val uiState: StateFlow<UiState> = _uiState.asStateFlow()
Expand Down Expand Up @@ -114,6 +115,9 @@ class InstallViewModel(svc: NetworkService) : BaseViewModel() {
}

fun install() {
if (isBootloaderLocked &&
(_uiState.value.method == Method.DIRECT || _uiState.value.method == Method.INACTIVE_SLOT)
) return
when (_uiState.value.method) {
Method.PATCH -> navigateTo(Route.Flash(
action = Const.Value.PATCH_FILE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ import com.topjohnwu.magisk.core.R as CoreR
class InstallViewModel(svc: NetworkService, markwon: Markwon) : BaseViewModel() {

val isRooted get() = Info.isRooted
val isBootloaderLocked get() = Info.isBootloaderLocked
val skipOptions = Info.isEmulator || (Info.isSAR && !Info.isFDE && Info.ramdisk)
val noSecondSlot = !isRooted || !Info.isAB || Info.isEmulator
val noSecondSlot = !isRooted || !Info.isAB || Info.isEmulator || isBootloaderLocked

@get:Bindable
var step = if (skipOptions) 1 else 0
Expand Down Expand Up @@ -94,6 +95,9 @@ class InstallViewModel(svc: NetworkService, markwon: Markwon) : BaseViewModel()
}

fun install() {
if (Info.isBootloaderLocked &&
(method == R.id.method_direct || method == R.id.method_inactive_slot)
) return
when (method) {
R.id.method_patch -> FlashFragment.patch(data.value!!).navigate(true)
R.id.method_download -> FlashFragment.download(data.value!!).navigate(true)
Expand All @@ -117,7 +121,9 @@ class InstallViewModel(svc: NetworkService, markwon: Markwon) : BaseViewModel()

override fun onRestoreState(state: Bundle) {
state.getParcelable<InstallState>(INSTALL_STATE_KEY)?.let {
methodId = it.method
methodId = if (Info.isBootloaderLocked &&
(it.method == R.id.method_direct || it.method == R.id.method_inactive_slot)
) -1 else it.method
step = it.step
Config.keepVerity = it.keepVerity
Config.keepEnc = it.keepEnc
Expand Down
4 changes: 2 additions & 2 deletions app/apk/src/main/res/layout/fragment_home_md2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@
app:layout_constraintTop_toBottomOf="@+id/home_magisk_wrapper" />

<Space
goneUnless="@{Info.env.isActive}"
gone="@{!Info.env.isActive || Info.isBootloaderLocked}"
android:layout_width="match_parent"
android:layout_height="@dimen/l1" />

<Button
style="@style/WidgetFoundation.Button.Outlined.Error"
goneUnless="@{Info.env.isActive}"
gone="@{!Info.env.isActive || Info.isBootloaderLocked}"
Comment thread
pixincreate marked this conversation as resolved.
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/l1"
Expand Down
2 changes: 1 addition & 1 deletion app/apk/src/main/res/layout/fragment_install_md2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
<RadioButton
android:id="@+id/method_direct"
style="@style/WidgetFoundation.RadioButton"
gone="@{!viewModel.rooted}"
gone="@{!viewModel.rooted || Info.isBootloaderLocked}"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/direct_install" />
Comment thread
pixincreate marked this conversation as resolved.
Expand Down
6 changes: 6 additions & 0 deletions app/core/src/main/java/com/topjohnwu/magisk/core/Info.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ object Info {
|| getProperty("ro.kernel.qemu", "0") == "1"
|| getProperty("ro.boot.qemu", "0") == "1"

@JvmStatic val isBootloaderLocked: Boolean =
getProperty("ro.boot.vbmeta.device_state", "").let { state ->
if (state.isNotEmpty()) state.equals("locked", ignoreCase = true)
else getProperty("ro.boot.flash.locked", "0") == "1"
}

val isConnected = MutableLiveData(false)

val showSuperUser: Boolean get() {
Expand Down
Loading