From 3c421d6449e30e65753b42977646f3d24f1e31ef Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Thu, 5 Nov 2026 09:13:38 +0100 Subject: 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 --- .../autofillparser/AutofillHelper.kt | 29 ++++++++++++++++------ 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'autofill-parser/src/main/java') 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) + } } } } -- cgit v1.2.3