diff --git a/app/src/main/java/com/vanced/manager/core/installer/RootSplitInstallerService.kt b/app/src/main/java/com/vanced/manager/core/installer/RootSplitInstallerService.kt index 95a500d7..4fbd43e9 100644 --- a/app/src/main/java/com/vanced/manager/core/installer/RootSplitInstallerService.kt +++ b/app/src/main/java/com/vanced/manager/core/installer/RootSplitInstallerService.kt @@ -12,8 +12,9 @@ import com.topjohnwu.superuser.Shell import com.vanced.manager.ui.fragments.HomeFragment import com.vanced.manager.utils.AppUtils.sendFailure import com.vanced.manager.utils.FileInfo +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch -import kotlinx.coroutines.runBlocking import java.io.File import java.text.SimpleDateFormat import java.util.* @@ -26,15 +27,14 @@ class RootSplitInstallerService: Service() { override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { Shell.getShell { - runBlocking { - launch { - val apkFilesPath = getExternalFilesDir("apks")?.path - val fileInfoList = apkFilesPath?.let { it1 -> getFileInfoList(it1) } - if (fileInfoList != null) { - installSplitApkFiles(fileInfoList) - } + CoroutineScope(Dispatchers.IO).launch { + val apkFilesPath = getExternalFilesDir("apks")?.path + val fileInfoList = apkFilesPath?.let { it1 -> getFileInfoList(it1) } + if (fileInfoList != null) { + installSplitApkFiles(fileInfoList) } } + } stopSelf() return START_NOT_STICKY @@ -76,7 +76,7 @@ class RootSplitInstallerService: Service() { sendBroadcast(Intent(HomeFragment.VANCED_INSTALLED)) } } else - sendFailure(installResult.code, this) + sendFailure(installResult.err, this) } private fun SimpleDateFormat.tryParse(str: String) = try { diff --git a/app/src/main/java/com/vanced/manager/utils/AppUtils.kt b/app/src/main/java/com/vanced/manager/utils/AppUtils.kt index 777f08d3..ebc1e6b4 100644 --- a/app/src/main/java/com/vanced/manager/utils/AppUtils.kt +++ b/app/src/main/java/com/vanced/manager/utils/AppUtils.kt @@ -42,6 +42,14 @@ object AppUtils { } } + fun sendFailure(error: MutableList, context: Context) { + CoroutineScope(Dispatchers.IO).launch { + val intent = Intent(HomeFragment.INSTALL_FAILED) + intent.putExtra("errorMsg", error.joinToString()) + LocalBroadcastManager.getInstance(context).sendBroadcast(intent) + } + } + private fun getErrorMessage(status: Int, context: Context): String { return when (status) { PackageInstaller.STATUS_FAILURE_ABORTED -> context.getString(R.string.installation_aborted)