From 3f5dec642e9cfcf3025792f7dd8dad92c6ebf773 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Tue, 3 Nov 2026 19:22:22 +0100 Subject: fix(app): make the app lock work on Android 14 LaunchActivity showed the screen lock prompt from onCreate, before the activity was on top. Android 14's SystemUI evicts a prompt whose app is not the top activity ("Evicting client due to top activity is not ..."), so the prompt closed at once with ERROR_CANCELED and the app quit. This is upstream issue 2802, which upstream worked around by disabling the setting on Android 14. The prompt now opens on the first window focus. LaunchActivity also used a translucent theme, so after unlocking the home screen showed through until MainActivity drew. It now uses the app's opaque theme. Verified on an Android 14 tablet with a PIN-only screen lock: unlock opens the app without a flash of the home screen, cancel closes it, and turning the lock off asks for the PIN. Co-Authored-By: Claude Opus 5.5 --- .../main/java/app/passwordstore/ui/main/LaunchActivity.kt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'app/src/main/java') diff --git a/app/src/main/java/app/passwordstore/ui/main/LaunchActivity.kt b/app/src/main/java/app/passwordstore/ui/main/LaunchActivity.kt index 66b5cf1f..6f07a51a 100644 --- a/app/src/main/java/app/passwordstore/ui/main/LaunchActivity.kt +++ b/app/src/main/java/app/passwordstore/ui/main/LaunchActivity.kt @@ -22,10 +22,21 @@ import java.io.File @SuppressLint("CustomSplashScreen") class LaunchActivity : AppCompatActivity() { + private var prompted = false + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + if (!sharedPrefs.getBoolean(PreferenceKeys.BIOMETRIC_AUTH_2, false)) startTargetActivity(true) + } + + // The prompt waits for window focus: Android 14's SystemUI dismisses a prompt shown while its + // activity is not yet on top (shown from onCreate), with ERROR_CANCELED, closing the app at once. + override fun onWindowFocusChanged(hasFocus: Boolean) { + super.onWindowFocusChanged(hasFocus) + if (!hasFocus || prompted || isFinishing) return val prefs = sharedPrefs if (prefs.getBoolean(PreferenceKeys.BIOMETRIC_AUTH_2, false)) { + prompted = true BiometricAuthenticator.authenticate(this) { result -> when (result) { is Result.Success -> { @@ -43,8 +54,6 @@ class LaunchActivity : AppCompatActivity() { is Result.Retry -> {} } } - } else { - startTargetActivity(true) } } -- cgit v1.2.3