Add failure messages and bump version

This commit is contained in:
wingio 2023-03-26 12:05:16 -04:00
parent 1df152f41b
commit f6855e6f5b
3 changed files with 21 additions and 4 deletions

View file

@ -14,8 +14,8 @@ android {
applicationId = "dev.beefers.vendetta.manager" applicationId = "dev.beefers.vendetta.manager"
minSdk = 24 minSdk = 24
targetSdk = 33 targetSdk = 33
versionCode = 1050 versionCode = 1060
versionName = "1.0.5" versionName = "1.0.6"
buildConfigField("String", "GIT_BRANCH", "\"${getCurrentBranch()}\"") buildConfigField("String", "GIT_BRANCH", "\"${getCurrentBranch()}\"")
buildConfigField("String", "GIT_COMMIT", "\"${getLatestCommit()}\"") buildConfigField("String", "GIT_COMMIT", "\"${getLatestCommit()}\"")

View file

@ -9,6 +9,16 @@ import dev.beefers.vendetta.manager.utils.showToast
class InstallService : Service() { class InstallService : Service() {
private val messages = mapOf(
PackageInstaller.STATUS_FAILURE to R.string.install_fail_generic,
PackageInstaller.STATUS_FAILURE_BLOCKED to R.string.install_fail_blocked,
PackageInstaller.STATUS_FAILURE_INVALID to R.string.install_fail_invalid,
PackageInstaller.STATUS_FAILURE_CONFLICT to R.string.install_fail_conflict,
PackageInstaller.STATUS_FAILURE_STORAGE to R.string.install_fail_storage,
PackageInstaller.STATUS_FAILURE_INCOMPATIBLE to R.string.install_fail_incompatible,
8 /* STATUS_FAILURE_TIMEOUT (Added in Android 14) */ to R.string.install_fail_timeout
)
override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int { override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
val isInstall = intent.action == "vendetta.actions.ACTION_INSTALL" val isInstall = intent.action == "vendetta.actions.ACTION_INSTALL"
when (val statusCode = intent.getIntExtra(PackageInstaller.EXTRA_STATUS, -999)) { when (val statusCode = intent.getIntExtra(PackageInstaller.EXTRA_STATUS, -999)) {
@ -25,7 +35,7 @@ class InstallService : Service() {
PackageInstaller.STATUS_FAILURE_ABORTED -> if (isInstall) showToast(R.string.installer_aborted) PackageInstaller.STATUS_FAILURE_ABORTED -> if (isInstall) showToast(R.string.installer_aborted)
else -> { else -> {
if (isInstall) showToast(R.string.installer_failed, statusCode) if (isInstall) messages[statusCode]?.let(::showToast)
} }
} }

View file

@ -30,7 +30,14 @@
<string name="installer_success">Installed successfully</string> <string name="installer_success">Installed successfully</string>
<string name="installer_aborted">Install canceled</string> <string name="installer_aborted">Install canceled</string>
<string name="installer_failed">Failed to install: %d</string>
<string name="install_fail_generic">Failed to install: Unknown reason</string>
<string name="install_fail_blocked">Installation was blocked</string>
<string name="install_fail_invalid">One or more APKs were invalid or corrupt</string>
<string name="install_fail_conflict">Conflicts with an existing app, usually due to mismatched signatures</string>
<string name="install_fail_storage">Not enough available storage to install</string>
<string name="install_fail_incompatible">Application is incompatible with this device</string>
<string name="install_fail_timeout">Installation timed out</string>
<string name="status_ongoing">Ongoing</string> <string name="status_ongoing">Ongoing</string>
<string name="status_successful">Successful</string> <string name="status_successful">Successful</string>