diff options
| author | Danilo M. <danix@danix.xyz> | 2026-11-03 19:22:22 +0100 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-11-03 19:22:22 +0100 |
| commit | 3f5dec642e9cfcf3025792f7dd8dad92c6ebf773 (patch) | |
| tree | 669d0c5bd309670c6c5102d264daed730212708d /app/src/main/java | |
| parent | 89ec8dc13b03af9f7b74a82d187b9bee3c444925 (diff) | |
| download | HardenedPass-3f5dec642e9cfcf3025792f7dd8dad92c6ebf773.tar.gz HardenedPass-3f5dec642e9cfcf3025792f7dd8dad92c6ebf773.zip | |
fix(app): make the app lock work on Android 14compose
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 <noreply@anthropic.com>
Diffstat (limited to 'app/src/main/java')
| -rw-r--r-- | app/src/main/java/app/passwordstore/ui/main/LaunchActivity.kt | 13 |
1 files changed, 11 insertions, 2 deletions
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) } } |
