mirror of
https://github.com/YTVanced/VancedManager
synced 2024-11-27 05:23:00 +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.ui.fragments.HomeFragment
|
||||||
import com.vanced.manager.utils.AppUtils.sendFailure
|
import com.vanced.manager.utils.AppUtils.sendFailure
|
||||||
import com.vanced.manager.utils.FileInfo
|
import com.vanced.manager.utils.FileInfo
|
||||||
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.runBlocking
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
@ -26,15 +27,14 @@ class RootSplitInstallerService: Service() {
|
||||||
|
|
||||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||||
Shell.getShell {
|
Shell.getShell {
|
||||||
runBlocking {
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
launch {
|
|
||||||
val apkFilesPath = getExternalFilesDir("apks")?.path
|
val apkFilesPath = getExternalFilesDir("apks")?.path
|
||||||
val fileInfoList = apkFilesPath?.let { it1 -> getFileInfoList(it1) }
|
val fileInfoList = apkFilesPath?.let { it1 -> getFileInfoList(it1) }
|
||||||
if (fileInfoList != null) {
|
if (fileInfoList != null) {
|
||||||
installSplitApkFiles(fileInfoList)
|
installSplitApkFiles(fileInfoList)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
stopSelf()
|
stopSelf()
|
||||||
return START_NOT_STICKY
|
return START_NOT_STICKY
|
||||||
|
@ -76,7 +76,7 @@ class RootSplitInstallerService: Service() {
|
||||||
sendBroadcast(Intent(HomeFragment.VANCED_INSTALLED))
|
sendBroadcast(Intent(HomeFragment.VANCED_INSTALLED))
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
sendFailure(installResult.code, this)
|
sendFailure(installResult.err, this)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun SimpleDateFormat.tryParse(str: String) = try {
|
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 {
|
private fun getErrorMessage(status: Int, context: Context): String {
|
||||||
return when (status) {
|
return when (status) {
|
||||||
PackageInstaller.STATUS_FAILURE_ABORTED -> context.getString(R.string.installation_aborted)
|
PackageInstaller.STATUS_FAILURE_ABORTED -> context.getString(R.string.installation_aborted)
|
||||||
|
|
Loading…
Reference in a new issue