Fix: Freezing during application installation with root method

This commit is contained in:
LooKeR
2021-10-20 00:27:15 +05:30
parent 5530f8e0a5
commit 617c0b8484
3 changed files with 27 additions and 6 deletions

View File

@ -25,6 +25,9 @@ import com.looker.droidify.utility.extension.resources.getColorFromAttr
import com.looker.droidify.utility.extension.resources.getDrawableCompat
import com.looker.droidify.utility.extension.text.hex
import com.topjohnwu.superuser.Shell
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.io.File
import java.security.MessageDigest
import java.security.cert.Certificate
@ -102,7 +105,7 @@ object Utils {
}
}
internal fun Activity.startPackageInstaller(cacheFileName: String) {
suspend fun Activity.startPackageInstaller(cacheFileName: String) {
val file = Cache.getReleaseFile(this, cacheFileName)
if (Preferences[Preferences.Key.RootPermission]) {
val commandBuilder = StringBuilder()
@ -110,8 +113,16 @@ object Utils {
if (verifyState == "1") commandBuilder.append("settings put global verifier_verify_adb_installs 0 ; ")
commandBuilder.append(getPackageInstallCommand(file))
commandBuilder.append(" ; settings put global verifier_verify_adb_installs $verifyState")
val result = Shell.su(commandBuilder.toString()).exec()
if (result.isSuccess) Shell.su("${getUtilBoxPath()} rm ${quote(file.absolutePath)}")
withContext(Dispatchers.IO) {
launch {
val result = Shell.su(commandBuilder.toString()).exec()
launch {
if (result.isSuccess) {
Shell.su("${getUtilBoxPath()} rm ${quote(file.absolutePath)}").submit()
}
}
}
}
} else {
val (uri, flags) = if (Android.sdk(24)) {
Pair(