From 8c36c8cd13fb1618cad3beeb07f18ee2f450948a Mon Sep 17 00:00:00 2001 From: LooKeR Date: Tue, 26 Sep 2023 19:52:32 +0530 Subject: [PATCH] Reduce code --- .../com/looker/installer/installers/SessionInstaller.kt | 5 +---- .../looker/installer/installers/SessionInstallerService.kt | 7 +++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/installer/src/main/java/com/looker/installer/installers/SessionInstaller.kt b/installer/src/main/java/com/looker/installer/installers/SessionInstaller.kt index 6b653a366..49c22ce6b 100644 --- a/installer/src/main/java/com/looker/installer/installers/SessionInstaller.kt +++ b/installer/src/main/java/com/looker/installer/installers/SessionInstaller.kt @@ -84,10 +84,7 @@ internal class SessionInstaller(private val context: Context) : Installer { @SuppressLint("MissingPermission") override suspend fun uninstall(packageName: PackageName) = suspendCancellableCoroutine { cont -> - intent.putExtra( - SessionInstallerService.KEY_ACTION, - SessionInstallerService.ACTION_UNINSTALL - ) + intent.putExtra(SessionInstallerService.ACTION_UNINSTALL, true) val pendingIntent = PendingIntent.getService(context, -1, intent, flags) sessionInstaller.uninstall(packageName.name, pendingIntent.intentSender) diff --git a/installer/src/main/java/com/looker/installer/installers/SessionInstallerService.kt b/installer/src/main/java/com/looker/installer/installers/SessionInstallerService.kt index c41997b61..274d203d0 100644 --- a/installer/src/main/java/com/looker/installer/installers/SessionInstallerService.kt +++ b/installer/src/main/java/com/looker/installer/installers/SessionInstallerService.kt @@ -14,8 +14,7 @@ import com.looker.core.common.R as CommonR class SessionInstallerService : Service() { companion object { - const val KEY_ACTION = "installerAction" - const val ACTION_UNINSTALL = "uninstall" + const val ACTION_UNINSTALL = "action_uninstall" } override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int { @@ -50,7 +49,7 @@ class SessionInstallerService : Service() { val status = intent.getIntExtra(PackageInstaller.EXTRA_STATUS, -1) val name = intent.getStringExtra(PackageInstaller.EXTRA_PACKAGE_NAME) val message = intent.getStringExtra(PackageInstaller.EXTRA_STATUS_MESSAGE) - val installerAction = intent.getStringExtra(KEY_ACTION) + val isUninstall = intent.getBooleanExtra(ACTION_UNINSTALL, false) // get application name for notifications val appLabel = try { @@ -73,7 +72,7 @@ class SessionInstallerService : Service() { when (status) { PackageInstaller.STATUS_SUCCESS -> { - if (installerAction == ACTION_UNINSTALL) + if (isUninstall) // remove any notification for this app notificationManager.cancel(notificationTag, NOTIFICATION_ID_DOWNLOADING) else {