Add userspace reboot
This commit is contained in:
parent
3fa3426032
commit
2760f37e6b
app/src/main
@ -1,8 +1,11 @@
|
||||
package com.topjohnwu.magisk.events
|
||||
|
||||
import android.os.Build
|
||||
import android.os.PowerManager
|
||||
import android.view.ContextThemeWrapper
|
||||
import android.view.MenuItem
|
||||
import android.widget.PopupMenu
|
||||
import androidx.core.content.getSystemService
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.core.base.BaseActivity
|
||||
import com.topjohnwu.superuser.Shell
|
||||
@ -13,6 +16,7 @@ object RebootEvent {
|
||||
private fun reboot(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
R.id.action_reboot_normal -> systemReboot()
|
||||
R.id.action_reboot_userspace -> systemReboot("userspace")
|
||||
R.id.action_reboot_bootloader -> systemReboot("bootloader")
|
||||
R.id.action_reboot_download -> systemReboot("download")
|
||||
R.id.action_reboot_edl -> systemReboot("edl")
|
||||
@ -25,6 +29,9 @@ object RebootEvent {
|
||||
fun inflateMenu(activity: BaseActivity): PopupMenu {
|
||||
val themeWrapper = ContextThemeWrapper(activity, R.style.Foundation_PopupMenu)
|
||||
val menu = PopupMenu(themeWrapper, activity.findViewById(R.id.action_reboot))
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R &&
|
||||
activity.getSystemService<PowerManager>()?.isRebootingUserspaceSupported == true)
|
||||
menu.menu.getItem(R.id.action_reboot_userspace).isVisible = true
|
||||
activity.menuInflater.inflate(R.menu.menu_reboot, menu.menu)
|
||||
menu.setOnMenuItemClickListener(::reboot)
|
||||
return menu
|
||||
|
@ -5,6 +5,15 @@
|
||||
android:id="@+id/action_reboot_normal"
|
||||
android:title="@string/reboot" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_reboot_userspace"
|
||||
android:title="@string/reboot_userspace"
|
||||
android:visible="false" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_reboot_recovery"
|
||||
android:title="@string/reboot_recovery" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_reboot_bootloader"
|
||||
android:title="@string/reboot_bootloader" />
|
||||
@ -17,8 +26,4 @@
|
||||
android:id="@+id/action_reboot_edl"
|
||||
android:title="@string/reboot_edl" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_reboot_recovery"
|
||||
android:title="@string/reboot_recovery" />
|
||||
|
||||
</menu>
|
@ -109,6 +109,7 @@
|
||||
|
||||
<!--Module -->
|
||||
<string name="no_info_provided">(No info provided)</string>
|
||||
<string name="reboot_userspace">Soft reboot</string>
|
||||
<string name="reboot_recovery">Reboot to Recovery</string>
|
||||
<string name="reboot_bootloader">Reboot to Bootloader</string>
|
||||
<string name="reboot_download">Reboot to Download</string>
|
||||
|
Loading…
Reference in New Issue
Block a user