Skip to content

Commit

Permalink
Fix button widget authentication dismissed due to non-foreground wind…
Browse files Browse the repository at this point in the history
…ow (#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.
  • Loading branch information
jpelgrom authored Dec 20, 2023
1 parent 1fa6ec4 commit 7cc545b
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 7cc545b

Please sign in to comment.