From 29c6c892c723cd29cd54c2fb77cda1b443e2e08a Mon Sep 17 00:00:00 2001 From: Jays2Kings Date: Tue, 20 Jul 2021 18:06:09 -0400 Subject: [PATCH] Fixed prompt for allow app installs not showing from self updater Also making it so the silent installer doesn't run if the app is not allowed to install packages --- .../eu/kanade/tachiyomi/data/updater/AutoUpdaterJob.kt | 7 +++++++ .../eu/kanade/tachiyomi/data/updater/UpdaterBroadcast.kt | 2 +- buildSrc/src/main/kotlin/Dependencies.kt | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/updater/AutoUpdaterJob.kt b/app/src/main/java/eu/kanade/tachiyomi/data/updater/AutoUpdaterJob.kt index 8accacc6bb..f6b56477d0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/updater/AutoUpdaterJob.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/updater/AutoUpdaterJob.kt @@ -4,6 +4,7 @@ import android.app.ActivityManager import android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND import android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_VISIBLE import android.content.Context +import android.os.Build import androidx.core.app.NotificationCompat import androidx.work.Constraints import androidx.work.CoroutineWorker @@ -24,6 +25,12 @@ class AutoUpdaterJob(private val context: Context, workerParams: WorkerParameter override suspend fun doWork(): Result = coroutineScope { try { + if ( + Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && + !context.packageManager.canRequestPackageInstalls() + ) { + return@coroutineScope Result.failure() + } val result = UpdateChecker.getUpdateChecker().checkForUpdate() if (result is UpdateResult.NewUpdate<*> && !UpdaterService.isRunning()) { UpdaterNotifier(context).cancel() diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/updater/UpdaterBroadcast.kt b/app/src/main/java/eu/kanade/tachiyomi/data/updater/UpdaterBroadcast.kt index 59644902d8..78c5d94192 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/updater/UpdaterBroadcast.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/updater/UpdaterBroadcast.kt @@ -17,7 +17,7 @@ class UpdaterBroadcast : BroadcastReceiver() { when (val status = extras.getInt(PackageInstaller.EXTRA_STATUS)) { PackageInstaller.STATUS_PENDING_USER_ACTION -> { val confirmIntent = extras[Intent.EXTRA_INTENT] as? Intent - context.startActivity(confirmIntent) + context.startActivity(confirmIntent?.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)) } PackageInstaller.STATUS_SUCCESS -> { val prefs = PreferenceManager.getDefaultSharedPreferences(context) diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt index 323b22bf11..40516d71a1 100644 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -97,7 +97,7 @@ object AndroidVersions { const val minSdk = 23 const val targetSdk = 30 const val versionCode = 77 - const val versionName = "1.1.1" + const val versionName = "1.1.0" const val ndk = "22.0.7026061" }