diff --git a/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/home/HomeScreen.kt b/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/home/HomeScreen.kt index 18d5247daac2e..d5e96857f10bd 100644 --- a/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/home/HomeScreen.kt +++ b/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/home/HomeScreen.kt @@ -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), diff --git a/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/install/InstallBottomSheet.kt b/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/install/InstallBottomSheet.kt index 5854df2730a59..eaf07a23c214c 100644 --- a/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/install/InstallBottomSheet.kt +++ b/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/install/InstallBottomSheet.kt @@ -129,7 +129,7 @@ fun InstallBottomSheet( }, ) - if (installVm.isRooted) { + if (installVm.isRooted && !installVm.isBootloaderLocked) { SettingsArrow( title = stringResource(CoreR.string.direct_install), onClick = { diff --git a/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/install/InstallViewModel.kt b/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/install/InstallViewModel.kt index 0605c90ef724e..7a32d3aa8fb89 100644 --- a/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/install/InstallViewModel.kt +++ b/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/install/InstallViewModel.kt @@ -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.asStateFlow() @@ -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, diff --git a/app/apk/src/main/java/com/topjohnwu/magisk/ui/install/InstallViewModel.kt b/app/apk/src/main/java/com/topjohnwu/magisk/ui/install/InstallViewModel.kt index b6a64dffd3470..53cf32f80784f 100644 --- a/app/apk/src/main/java/com/topjohnwu/magisk/ui/install/InstallViewModel.kt +++ b/app/apk/src/main/java/com/topjohnwu/magisk/ui/install/InstallViewModel.kt @@ -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 @@ -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) @@ -117,7 +121,9 @@ class InstallViewModel(svc: NetworkService, markwon: Markwon) : BaseViewModel() override fun onRestoreState(state: Bundle) { state.getParcelable(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 diff --git a/app/apk/src/main/res/layout/fragment_home_md2.xml b/app/apk/src/main/res/layout/fragment_home_md2.xml index a3d2c60cd5618..8ad19c65c74d0 100644 --- a/app/apk/src/main/res/layout/fragment_home_md2.xml +++ b/app/apk/src/main/res/layout/fragment_home_md2.xml @@ -108,13 +108,13 @@ app:layout_constraintTop_toBottomOf="@+id/home_magisk_wrapper" />