|
|
@@ -28,7 +28,9 @@ import io.ktor.client.call.body
|
|
|
import io.ktor.client.plugins.resources.get
|
|
|
import io.ktor.client.request.head
|
|
|
import kotlinx.coroutines.Dispatchers
|
|
|
+import kotlinx.coroutines.coroutineScope
|
|
|
import kotlinx.coroutines.delay
|
|
|
+import kotlinx.coroutines.launch
|
|
|
import kotlinx.coroutines.withContext
|
|
|
import org.apache.commons.io.FileUtils
|
|
|
import org.json.JSONObject
|
|
|
@@ -43,7 +45,7 @@ import kotlin.system.exitProcess
|
|
|
|
|
|
|
|
|
const val systemTag = "$baseTag/System"
|
|
|
-const val ROOTED_PHONE = false
|
|
|
+var ROOT_ACCESS = false
|
|
|
val uniqueId: String
|
|
|
@SuppressLint("HardwareIds")
|
|
|
get() {
|
|
|
@@ -77,7 +79,29 @@ fun getContext(): Context {
|
|
|
suspend fun hasRootAccess(): Boolean {
|
|
|
var rootAccess = false
|
|
|
try {
|
|
|
- val (output, _) = shellRun("echo \"imrooted\"")
|
|
|
+ val p = withContext(Dispatchers.IO) {
|
|
|
+ ProcessBuilder("su", "-M", "-c", "echo", "imrooted").start()
|
|
|
+ }
|
|
|
+ var output = ""
|
|
|
+ coroutineScope {
|
|
|
+ launch {
|
|
|
+ p.inputStream.bufferedReader().useLines { line ->
|
|
|
+ line.forEach {
|
|
|
+ output += it + "\n"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ launch {
|
|
|
+ p.errorStream.bufferedReader().useLines { line ->
|
|
|
+ line.forEach {
|
|
|
+ Log.e(shellTag, "shellRunErr: $it")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ withContext(Dispatchers.IO) {
|
|
|
+ p.waitFor()
|
|
|
+ }
|
|
|
if (output.contains("imrooted")) {
|
|
|
rootAccess = true
|
|
|
}
|
|
|
@@ -157,11 +181,11 @@ suspend fun optimize() {
|
|
|
"pm grant ${BuildConfig.APPLICATION_ID} android.permission.POST_NOTIFICATIONS",
|
|
|
)
|
|
|
// if (Build.MODEL.startsWith("SM-F707") || Build.MODEL.startsWith("SM-F711")) {
|
|
|
- shellRun(
|
|
|
- "settings put global window_animation_scale 1",
|
|
|
- "settings put global transition_animation_scale 1",
|
|
|
- "settings put global animator_duration_scale 1"
|
|
|
- )
|
|
|
+ shellRun(
|
|
|
+ "settings put global window_animation_scale 1",
|
|
|
+ "settings put global transition_animation_scale 1",
|
|
|
+ "settings put global animator_duration_scale 1"
|
|
|
+ )
|
|
|
// }
|
|
|
}
|
|
|
|