mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-06-15 20:09:19 +00:00
Fix: Freeze while installing caused by new installer
This commit is contained in:
@ -2,6 +2,8 @@ package com.looker.droidify.installer
|
||||
|
||||
import android.content.Context
|
||||
import com.looker.droidify.utility.Utils.rootInstallerEnabled
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
abstract class AppInstaller {
|
||||
abstract val defaultInstaller: BaseInstaller?
|
||||
@ -9,19 +11,21 @@ abstract class AppInstaller {
|
||||
companion object {
|
||||
@Volatile
|
||||
private var INSTANCE: AppInstaller? = null
|
||||
fun getInstance(context: Context?): AppInstaller? {
|
||||
suspend fun getInstance(context: Context?): AppInstaller? {
|
||||
if (INSTANCE == null) {
|
||||
synchronized(AppInstaller::class.java) {
|
||||
if (INSTANCE == null) {
|
||||
context?.let {
|
||||
INSTANCE = object : AppInstaller() {
|
||||
override val defaultInstaller: BaseInstaller
|
||||
get() {
|
||||
return when (rootInstallerEnabled) {
|
||||
false -> DefaultInstaller(it)
|
||||
true -> RootInstaller(it)
|
||||
withContext(Dispatchers.IO) {
|
||||
synchronized(AppInstaller::class.java) {
|
||||
if (INSTANCE == null) {
|
||||
context?.let {
|
||||
INSTANCE = object : AppInstaller() {
|
||||
override val defaultInstaller: BaseInstaller
|
||||
get() {
|
||||
return when (rootInstallerEnabled) {
|
||||
false -> DefaultInstaller(it)
|
||||
true -> RootInstaller(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user