mirror of
https://github.com/YTVanced/VancedManager
synced 2024-12-02 15:57:26 +00:00
finalised root error handler
This commit is contained in:
parent
24a51c949b
commit
e1e69d4022
2 changed files with 18 additions and 2 deletions
|
@ -45,11 +45,27 @@ object AppUtils {
|
||||||
fun sendFailure(error: MutableList<String>, context: Context) {
|
fun sendFailure(error: MutableList<String>, context: Context) {
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
val intent = Intent(HomeFragment.INSTALL_FAILED)
|
val intent = Intent(HomeFragment.INSTALL_FAILED)
|
||||||
intent.putExtra("errorMsg", error.joinToString())
|
intent.putExtra("errorMsg", getErrorMessage(error.joinToString(), context))
|
||||||
LocalBroadcastManager.getInstance(context).sendBroadcast(intent)
|
LocalBroadcastManager.getInstance(context).sendBroadcast(intent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getErrorMessage(status: String, context: Context): String {
|
||||||
|
return when {
|
||||||
|
status.contains("INSTALL_FAILED_ABORTED") -> context.getString(R.string.installation_aborted)
|
||||||
|
status.contains("INSTALL_FAILED_ALREADY_EXISTS") -> context.getString(R.string.installation_conflict)
|
||||||
|
status.contains("INSTALL_FAILED_CPU_ABI_INCOMPATIBLE") -> context.getString(R.string.installation_incompatible)
|
||||||
|
status.contains("INSTALL_FAILED_INSUFFICIENT_STORAGE") -> context.getString(R.string.installation_storage)
|
||||||
|
status.contains("INSTALL_FAILED_INVALID_APK") -> context.getString(R.string.installation_invalid)
|
||||||
|
status.contains("INSTALL_PARSE_FAILED_NO_CERTIFICATES") -> context.getString(R.string.installation_signature)
|
||||||
|
else ->
|
||||||
|
if (MiuiHelper.isMiui())
|
||||||
|
context.getString(R.string.installation_miui)
|
||||||
|
else
|
||||||
|
context.getString(R.string.installation_failed)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
<string name="installation_failed">Operation failed for an unknown reason, please join our Telegram or Discord for support.</string>
|
<string name="installation_failed">Operation failed for an unknown reason, please join our Telegram or Discord for support.</string>
|
||||||
<string name="installation_incompatible">Operation failed because the app is incompatible with your device.</string>
|
<string name="installation_incompatible">Operation failed because the app is incompatible with your device.</string>
|
||||||
<string name="installation_invalid">Operation failed because the apk files are invalid.</string>
|
<string name="installation_invalid">Operation failed because the apk files are invalid.</string>
|
||||||
<string name="installation_signature">An unexpected error occurred while installing Vanced. Have you disabled apk signature verification?</string>
|
<string name="installation_signature">Operation failed because the user didn\'t disable apk signature verification</string>
|
||||||
<string name="installation_miui">An unexpected error occurred while installing Vanced. Have you disabled MIUI Optimisations?</string>
|
<string name="installation_miui">An unexpected error occurred while installing Vanced. Have you disabled MIUI Optimisations?</string>
|
||||||
<string name="installation_storage">Operation failed due to a storage error.</string>
|
<string name="installation_storage">Operation failed due to a storage error.</string>
|
||||||
<string name="installation_wait">Please wait until the installation finishes</string>
|
<string name="installation_wait">Please wait until the installation finishes</string>
|
||||||
|
|
Loading…
Reference in a new issue