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

@ -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)
}
}
}

View File

@ -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
}