Skip to content

Commit

Permalink
Action.sh Suppport 9/13
Browse files Browse the repository at this point in the history
  • Loading branch information
1q23lyc45 committed Dec 20, 2024
1 parent da92fce commit bef8ee0
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ data class LocalModule(
val isRiru: Boolean get() = (id == "riru-core") || riruFolder.exists()
val isZygisk: Boolean get() = zygiskFolder.exists()
val zygiskUnloaded: Boolean get() = unloaded.exists()
val hasAction: Boolean;

var enable: Boolean
get() = !disableFile.exists()
Expand Down Expand Up @@ -100,6 +101,8 @@ data class LocalModule(
if (name.isEmpty()) {
name = id
}

hasAction = RootUtils.fs.getFile(path, "action.sh").exists()
}

suspend fun fetch(): Boolean {
Expand Down
42 changes: 42 additions & 0 deletions app/src/main/java/com/topjohnwu/magisk/core/tasks/RunAction.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.topjohnwu.magisk.core.tasks

import android.net.Uri
import androidx.core.net.toFile
import com.topjohnwu.magisk.core.AppContext
import com.topjohnwu.magisk.core.Const
import com.topjohnwu.magisk.core.ktx.writeTo
import com.topjohnwu.magisk.core.utils.MediaStoreUtils.displayName
import com.topjohnwu.magisk.core.utils.MediaStoreUtils.inputStream
import com.topjohnwu.magisk.core.utils.unzip
import com.topjohnwu.superuser.Shell
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import timber.log.Timber
import java.io.File
import java.io.FileNotFoundException
import java.io.IOException

open class RunAction(
private val module: String,
private val console: MutableList<String>,
private val logs: MutableList<String>
) {
@Throws(IOException::class)
private suspend fun run(): Boolean {
return Shell.cmd("run_action \'$module\'").to(console, logs).exec().isSuccess
}

open suspend fun exec() = withContext(Dispatchers.IO) {
try {
if (!run()) {
console.add("! Run action failed")
false
} else {
true
}
} catch (e: IOException) {
Timber.e(e)
false
}
}
}

0 comments on commit bef8ee0

Please sign in to comment.