mirror of
https://github.com/YTVanced/VancedManager
synced 2024-11-23 11:45:11 +00:00
new root error handler
This commit is contained in:
parent
597078e6a7
commit
f03e681ea8
2 changed files with 17 additions and 9 deletions
|
@ -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 {
|
||||
|
|
|
@ -42,6 +42,14 @@ object AppUtils {
|
|||
}
|
||||
}
|
||||
|
||||
fun sendFailure(error: MutableList<String>, 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)
|
||||
|
|
Loading…
Reference in a new issue