aboutsummaryrefslogtreecommitdiffstats
path: root/autofill-parser/src/main/java/com/github/androidpasswordstore
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-11-05 09:13:38 +0100
committerDanilo M. <danix@danix.xyz>2026-11-05 09:13:38 +0100
commit3c421d6449e30e65753b42977646f3d24f1e31ef (patch)
tree90c30bb62a4af37133e8b4dd3705523da969af38 /autofill-parser/src/main/java/com/github/androidpasswordstore
parentebddebeb6c4f7bc4d48196e21bf4a942c5a8b176 (diff)
downloadHardenedPass-3c421d6449e30e65753b42977646f3d24f1e31ef.tar.gz
HardenedPass-3c421d6449e30e65753b42977646f3d24f1e31ef.zip
fix(autofill-parser): open the save window on top on Android 14+
From Android 14 the framework sends the save IntentSender from the app being filled. Firefox targets SDK 34 or later and does not opt in to background activity starts, so the launch was blocked and AutofillSaveActivity opened hidden behind it: tapping Save seemed to do nothing. FixedSaveCallback now starts it from the service, which the system has bound, and opts in as the sender. Tested on an Android 14 tablet with Firefox release: the editor comes up on its own and the entry is saved. The same run confirmed the stale cached passphrase prompt, so both items leave TODO.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'autofill-parser/src/main/java/com/github/androidpasswordstore')
-rw-r--r--autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/AutofillHelper.kt29
1 files changed, 22 insertions, 7 deletions
diff --git a/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/AutofillHelper.kt b/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/AutofillHelper.kt
index bac5d7f6..9ff646c9 100644
--- a/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/AutofillHelper.kt
+++ b/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/AutofillHelper.kt
@@ -5,6 +5,7 @@
package com.github.androidpasswordstore.autofillparser
import android.annotation.SuppressLint
+import android.app.ActivityOptions
import android.app.assist.AssistStructure
import android.content.Context
import android.content.IntentSender
@@ -105,13 +106,27 @@ public class FixedSaveCallback(private val context: Context, private val callbac
}
public fun onSuccess(intentSender: IntentSender) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
- callback.onSuccess(intentSender)
- } else {
- callback.onSuccess()
- // On SDKs < 28, we cannot advise the Autofill framework to launch the save intent in
- // the context of the app that triggered the save request. Hence, we launch it here.
- applicationContext.startIntentSender(intentSender, null, 0, 0, 0)
+ when {
+ // From Android 14 the framework sends this intent from the app being filled, which does not
+ // opt in to background activity starts when it targets SDK 34 or later: the save window
+ // opens hidden behind it. This service is bound by the system, so it may start it itself.
+ Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE -> {
+ val options =
+ ActivityOptions.makeBasic()
+ .setPendingIntentBackgroundActivityStartMode(
+ ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED
+ )
+ .toBundle()
+ applicationContext.startIntentSender(intentSender, null, 0, 0, 0, options)
+ callback.onSuccess()
+ }
+ Build.VERSION.SDK_INT >= Build.VERSION_CODES.P -> callback.onSuccess(intentSender)
+ else -> {
+ callback.onSuccess()
+ // On SDKs < 28, we cannot advise the Autofill framework to launch the save intent in
+ // the context of the app that triggered the save request. Hence, we launch it here.
+ applicationContext.startIntentSender(intentSender, null, 0, 0, 0)
+ }
}
}
}