mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-04-23 11:22:12 +00:00
Fix: Freezing during application installation with root method
This commit is contained in:
parent
5530f8e0a5
commit
617c0b8484
@ -15,6 +15,7 @@ import android.widget.FrameLayout
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
@ -34,6 +35,8 @@ import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.rxjava3.core.Observable
|
||||
import io.reactivex.rxjava3.disposables.Disposable
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class ProductFragment() : ScreenFragment(), ProductAdapter.Callbacks {
|
||||
companion object {
|
||||
@ -375,8 +378,10 @@ class ProductFragment() : ScreenFragment(), ProductAdapter.Callbacks {
|
||||
}
|
||||
(recyclerView?.adapter as? ProductAdapter)?.setStatus(status)
|
||||
if (state is DownloadService.State.Success && isResumed) {
|
||||
state.consume()
|
||||
screenActivity.startPackageInstaller(state.release.cacheFileName)
|
||||
lifecycleScope.launch(Dispatchers.IO) {
|
||||
state.consume()
|
||||
screenActivity.startPackageInstaller(state.release.cacheFileName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ import android.widget.FrameLayout
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.looker.droidify.R
|
||||
import com.looker.droidify.content.Preferences
|
||||
import com.looker.droidify.database.CursorOwner
|
||||
@ -16,6 +17,8 @@ import com.looker.droidify.utility.KParcelable
|
||||
import com.looker.droidify.utility.Utils.startPackageInstaller
|
||||
import com.looker.droidify.utility.extension.resources.getDrawableFromAttr
|
||||
import com.looker.droidify.utility.extension.text.nullIfEmpty
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
abstract class ScreenActivity : FragmentActivity() {
|
||||
companion object {
|
||||
@ -215,7 +218,9 @@ abstract class ScreenActivity : FragmentActivity() {
|
||||
is SpecialIntent.Install -> {
|
||||
val packageName = specialIntent.packageName
|
||||
if (!packageName.isNullOrEmpty()) {
|
||||
specialIntent.cacheFileName?.let { startPackageInstaller(it) }
|
||||
lifecycleScope.launch(Dispatchers.IO) {
|
||||
specialIntent.cacheFileName?.let { startPackageInstaller(it) }
|
||||
}
|
||||
}
|
||||
Unit
|
||||
}
|
||||
|
@ -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(
|
||||
|
Loading…
x
Reference in New Issue
Block a user