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.
This commit is contained in:
Matthew Crossman 2022-01-04 16:21:08 +11:00
parent fce311098d
commit e1fc3c656a
No known key found for this signature in database
GPG Key ID: C6B942B019794CC2
2 changed files with 3 additions and 4 deletions

View File

@ -132,7 +132,7 @@ object Preferences {
Value.EnumerationValue(Preferences.AutoSync.Wifi) Value.EnumerationValue(Preferences.AutoSync.Wifi)
) )
object AutoSyncInstall : object AutoSyncInstall :
Key<Boolean>("auto_sync_install", Value.BooleanValue(true)) Key<Boolean>("auto_sync_install", Value.BooleanValue(Android.sdk(31)))
object IncompatibleVersions : object IncompatibleVersions :
Key<Boolean>("incompatible_versions", Value.BooleanValue(false)) Key<Boolean>("incompatible_versions", Value.BooleanValue(false))

View File

@ -32,9 +32,8 @@ class InstallerService : Service() {
override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int { override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
val status = intent.getIntExtra(PackageInstaller.EXTRA_STATUS, -1) val status = intent.getIntExtra(PackageInstaller.EXTRA_STATUS, -1)
// only trigger a prompt if in foreground or below Android 10, otherwise make notification // only trigger a prompt if in foreground, otherwise make notification
// launching a prompt in the background will fail silently if (Utils.inForeground() && status == PackageInstaller.STATUS_PENDING_USER_ACTION) {
if ((!Android.sdk(29) || Utils.inForeground()) && status == PackageInstaller.STATUS_PENDING_USER_ACTION) {
// Triggers the installer prompt and "unknown apps" prompt if needed // Triggers the installer prompt and "unknown apps" prompt if needed
val promptIntent: Intent? = intent.getParcelableExtra(Intent.EXTRA_INTENT) val promptIntent: Intent? = intent.getParcelableExtra(Intent.EXTRA_INTENT)