Make commands data class
This commit is contained in:
@@ -28,7 +28,7 @@ fun ProcessBuilder.fixPath(redirect: Boolean = false) = apply {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Parcelize
|
@Parcelize
|
||||||
class Dump(val path: String, val cacheDir: File = app.deviceStorage.codeCacheDir) : RootCommandNoResult {
|
data class Dump(val path: String, val cacheDir: File = app.deviceStorage.codeCacheDir) : RootCommandNoResult {
|
||||||
@Suppress("BlockingMethodInNonBlockingContext")
|
@Suppress("BlockingMethodInNonBlockingContext")
|
||||||
override suspend fun execute() = withContext(Dispatchers.IO) {
|
override suspend fun execute() = withContext(Dispatchers.IO) {
|
||||||
FileOutputStream(path, true).use { out ->
|
FileOutputStream(path, true).use { out ->
|
||||||
@@ -128,7 +128,8 @@ class ReadArp : RootCommand<ParcelableString> {
|
|||||||
|
|
||||||
@Parcelize
|
@Parcelize
|
||||||
@RequiresApi(30)
|
@RequiresApi(30)
|
||||||
class StartTethering(private val type: Int, private val showProvisioningUi: Boolean) : RootCommand<ParcelableInt?> {
|
data class StartTethering(private val type: Int,
|
||||||
|
private val showProvisioningUi: Boolean) : RootCommand<ParcelableInt?> {
|
||||||
override suspend fun execute(): ParcelableInt? {
|
override suspend fun execute(): ParcelableInt? {
|
||||||
val future = CompletableDeferred<Int?>()
|
val future = CompletableDeferred<Int?>()
|
||||||
val callback = object : TetheringManager.StartTetheringCallback {
|
val callback = object : TetheringManager.StartTetheringCallback {
|
||||||
@@ -151,8 +152,8 @@ class StartTethering(private val type: Int, private val showProvisioningUi: Bool
|
|||||||
@Parcelize
|
@Parcelize
|
||||||
@RequiresApi(24)
|
@RequiresApi(24)
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
class StartTetheringLegacy(private val cacheDir: File, private val type: Int,
|
data class StartTetheringLegacy(private val cacheDir: File, private val type: Int,
|
||||||
private val showProvisioningUi: Boolean) : RootCommand<ParcelableBoolean> {
|
private val showProvisioningUi: Boolean) : RootCommand<ParcelableBoolean> {
|
||||||
override suspend fun execute(): ParcelableBoolean {
|
override suspend fun execute(): ParcelableBoolean {
|
||||||
val future = CompletableDeferred<Boolean>()
|
val future = CompletableDeferred<Boolean>()
|
||||||
val callback = object : TetheringManager.StartTetheringCallback {
|
val callback = object : TetheringManager.StartTetheringCallback {
|
||||||
@@ -172,7 +173,7 @@ class StartTetheringLegacy(private val cacheDir: File, private val type: Int,
|
|||||||
|
|
||||||
@Parcelize
|
@Parcelize
|
||||||
@RequiresApi(24)
|
@RequiresApi(24)
|
||||||
class StopTethering(private val type: Int) : RootCommandNoResult {
|
data class StopTethering(private val type: Int) : RootCommandNoResult {
|
||||||
override suspend fun execute(): Parcelable? {
|
override suspend fun execute(): Parcelable? {
|
||||||
TetheringManager.stopTethering(type)
|
TetheringManager.stopTethering(type)
|
||||||
return null
|
return null
|
||||||
@@ -180,7 +181,7 @@ class StopTethering(private val type: Int) : RootCommandNoResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Parcelize
|
@Parcelize
|
||||||
class SettingsGlobalPut(val name: String, val value: String) : RootCommandNoResult {
|
data class SettingsGlobalPut(val name: String, val value: String) : RootCommandNoResult {
|
||||||
companion object {
|
companion object {
|
||||||
suspend fun int(name: String, value: Int) {
|
suspend fun int(name: String, value: Int) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ object RepeaterCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Parcelize
|
@Parcelize
|
||||||
class SetChannel(private val oc: Int) : RootCommand<ParcelableInt?> {
|
data class SetChannel(private val oc: Int) : RootCommand<ParcelableInt?> {
|
||||||
override suspend fun execute() = Services.p2p!!.run {
|
override suspend fun execute() = Services.p2p!!.run {
|
||||||
setWifiP2pChannels(obtainChannel(), 0, oc)?.let { ParcelableInt(it) }
|
setWifiP2pChannels(obtainChannel(), 0, oc)?.let { ParcelableInt(it) }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ object RoutingCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Parcelize
|
@Parcelize
|
||||||
class Process(val command: List<String>, private val redirect: Boolean = false) : RootCommand<ProcessResult> {
|
data class Process(val command: List<String>, private val redirect: Boolean = false) : RootCommand<ProcessResult> {
|
||||||
@Suppress("BlockingMethodInNonBlockingContext")
|
@Suppress("BlockingMethodInNonBlockingContext")
|
||||||
override suspend fun execute() = withContext(Dispatchers.IO) {
|
override suspend fun execute() = withContext(Dispatchers.IO) {
|
||||||
val process = ProcessBuilder(command).fixPath(redirect).start()
|
val process = ProcessBuilder(command).fixPath(redirect).start()
|
||||||
|
|||||||
Reference in New Issue
Block a user