Fix button widget authentication dismissed due to non-foreground window (#4066)

- Fixes the button widget authentication dialog automatically being dismissed when triggered on Android 14 QPR1+, because the window was not in the foreground. It looks like the framework check for this was bugged before QPR1, and the Home Assistant app was showing the authentication dialog before the window (which is transparent) was in the foreground.
This commit is contained in:
Joris Pelgröm 2023-12-20 18:25:06 +01:00 committed by GitHub
parent 1fa6ec463e
commit 7cc545bfac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -15,12 +15,20 @@ class WidgetAuthenticationActivity : AppCompatActivity() {
private const val TAG = "WidgetAuthenticationA"
}
private var authenticating = false
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Log.d(TAG, "onCreate in WidgetAuthenticationActivity called")
}
val authenticator = Authenticator(this, this, ::authenticationResult)
authenticator.authenticate(getString(R.string.biometric_set_title))
override fun onWindowFocusChanged(hasFocus: Boolean) {
super.onWindowFocusChanged(hasFocus)
if (hasFocus && !isFinishing && !authenticating) {
val authenticator = Authenticator(this, this, ::authenticationResult)
authenticator.authenticate(getString(R.string.biometric_set_title))
authenticating = true
}
}
private fun authenticationResult(result: Int) {