mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-06-15 20:09:19 +00:00
Add: Long Press on Source Icon to copy link
Fix: Installer Spamming coroutines Remove: Unused Variables and methods/functions
This commit is contained in:
@ -2,8 +2,6 @@ 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?
|
||||
@ -11,21 +9,19 @@ abstract class AppInstaller {
|
||||
companion object {
|
||||
@Volatile
|
||||
private var INSTANCE: AppInstaller? = null
|
||||
suspend fun getInstance(context: Context?): AppInstaller? {
|
||||
fun getInstance(context: Context?): AppInstaller? {
|
||||
if (INSTANCE == null) {
|
||||
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)
|
||||
}
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ abstract class BaseInstaller(val context: Context) : InstallationEvents {
|
||||
companion object {
|
||||
const val ROOT_INSTALL_PACKAGE = "cat %s | pm install --user %s -t -r -S %s"
|
||||
const val ROOT_UNINSTALL_PACKAGE = "pm uninstall --user %s %s"
|
||||
const val DELETE_PACKAGE = "%s rm %s"
|
||||
}
|
||||
|
||||
private val job = Job()
|
||||
|
@ -26,7 +26,7 @@ class RootInstaller(context: Context) : BaseInstaller(context) {
|
||||
scope.launch { mRootUninstaller(packageName) }
|
||||
}
|
||||
|
||||
private suspend fun mRootInstaller(cacheFile: File) {
|
||||
private fun mRootInstaller(cacheFile: File) {
|
||||
if (rootInstallerEnabled) {
|
||||
val installCommand =
|
||||
String.format(
|
||||
@ -35,15 +35,16 @@ class RootInstaller(context: Context) : BaseInstaller(context) {
|
||||
getCurrentUserState,
|
||||
cacheFile.length()
|
||||
)
|
||||
Log.e("Install", installCommand)
|
||||
withContext(Dispatchers.IO) {
|
||||
launch {
|
||||
val result = Shell.su(installCommand).exec()
|
||||
launch {
|
||||
if (result.isSuccess) {
|
||||
Shell.su("$getUtilBoxPath rm ${cacheFile.absolutePath.quote}")
|
||||
.submit()
|
||||
}
|
||||
val deleteCommand =
|
||||
String.format(
|
||||
DELETE_PACKAGE,
|
||||
getUtilBoxPath,
|
||||
cacheFile.absolutePath.quote
|
||||
)
|
||||
scope.launch {
|
||||
Shell.su(installCommand).submit {
|
||||
if (it.isSuccess) {
|
||||
Shell.su(deleteCommand).submit()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user