Fix DT2S (Root) using keyevent (#3799)

* Add alternative root execution for dt2s

* Fix styling

* Use Shell instead
This commit is contained in:
John Andrew Camu
2023-12-02 04:03:22 +08:00
committed by GitHub
parent 4402ef1bf3
commit e79278e2db

View File

@@ -37,12 +37,12 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import app.lawnchair.LawnchairLauncher
import app.lawnchair.lawnchairApp
import app.lawnchair.root.RootHelperManager
import app.lawnchair.ui.AlertBottomSheetContent
import app.lawnchair.util.requireSystemService
import app.lawnchair.views.ComposeBottomSheet
import com.android.launcher3.R
import com.android.launcher3.Utilities
import com.topjohnwu.superuser.Shell
class SleepGestureHandler(context: Context) : GestureHandler(context) {
@@ -63,12 +63,11 @@ class SleepGestureHandler(context: Context) : GestureHandler(context) {
}
class SleepMethodRoot(context: Context) : SleepGestureHandler.SleepMethod(context) {
private val rootHelperManager = RootHelperManager.INSTANCE.get(context)
override suspend fun isSupported() = rootHelperManager.isAvailable()
override suspend fun isSupported() = Shell.getShell().isRoot
override suspend fun sleep(launcher: LawnchairLauncher) {
rootHelperManager.getService().goToSleep()
Shell.su("input keyevent 26").exec()
}
}