From e1fc3c656ab8e7154b9b138d1f7dd84de01695c6 Mon Sep 17 00:00:00 2001 From: Matthew Crossman Date: Tue, 4 Jan 2022 16:21:08 +1100 Subject: [PATCH] Make auto-update default on Android 12+ & stop background prompts. Sets preference for auto updates to true by default if device runs Android 12 and later. Reverts change allowing the install prompt to show up from the background and instead require the notification on all Android versions. --- src/main/kotlin/com/looker/droidify/content/Preferences.kt | 2 +- .../kotlin/com/looker/droidify/installer/InstallerService.kt | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/com/looker/droidify/content/Preferences.kt b/src/main/kotlin/com/looker/droidify/content/Preferences.kt index afcd9a27..cbc7dcfa 100644 --- a/src/main/kotlin/com/looker/droidify/content/Preferences.kt +++ b/src/main/kotlin/com/looker/droidify/content/Preferences.kt @@ -132,7 +132,7 @@ object Preferences { Value.EnumerationValue(Preferences.AutoSync.Wifi) ) object AutoSyncInstall : - Key("auto_sync_install", Value.BooleanValue(true)) + Key("auto_sync_install", Value.BooleanValue(Android.sdk(31))) object IncompatibleVersions : Key("incompatible_versions", Value.BooleanValue(false)) diff --git a/src/main/kotlin/com/looker/droidify/installer/InstallerService.kt b/src/main/kotlin/com/looker/droidify/installer/InstallerService.kt index 6946e8a2..2be4a9e8 100644 --- a/src/main/kotlin/com/looker/droidify/installer/InstallerService.kt +++ b/src/main/kotlin/com/looker/droidify/installer/InstallerService.kt @@ -32,9 +32,8 @@ class InstallerService : Service() { override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int { val status = intent.getIntExtra(PackageInstaller.EXTRA_STATUS, -1) - // only trigger a prompt if in foreground or below Android 10, otherwise make notification - // launching a prompt in the background will fail silently - if ((!Android.sdk(29) || Utils.inForeground()) && status == PackageInstaller.STATUS_PENDING_USER_ACTION) { + // only trigger a prompt if in foreground, otherwise make notification + if (Utils.inForeground() && status == PackageInstaller.STATUS_PENDING_USER_ACTION) { // Triggers the installer prompt and "unknown apps" prompt if needed val promptIntent: Intent? = intent.getParcelableExtra(Intent.EXTRA_INTENT)