Skip to content

Commit

Permalink
Appverifier: Fix NFC engagement problem on first run after install. (#…
Browse files Browse the repository at this point in the history
…857)

This change addresses an NFC engagement issue that could occur on the first run of AppVerifier after installation. The root cause was an incorrect handling of the Android activity lifecycle events that occur when the permission-requesting activity returns to the main application activity or fragment. The fix ensures that the VerificationHelper instance is initialized during the ON_RESUME lifecycle event, rather than ON_START, to avoid race conditions and ensure proper setup.

Tested manually. Tap with the phone running Wallet.

Signed-off-by: koukarine <[email protected]>
  • Loading branch information
koukarine authored Jan 30, 2025
1 parent bb9ea05 commit 9d361aa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ class RequestOptionsFragment() : Fragment() {
// Always call to cancel any connection that could be on progress
transferManager.disconnect()
}
transferManager.initVerificationHelper()
observeTransferManager()
}

Expand Down Expand Up @@ -301,6 +300,7 @@ class RequestOptionsFragment() : Fragment() {
checkRequiredPermissions()
val adapter = NfcAdapter.getDefaultAdapter(requireContext())
if (adapter != null) {
transferManager.initVerificationHelper()
transferManager.setNdefDeviceEngagement(
adapter,
requireActivity()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,11 @@ class MdocReaderPrompt(
verification.disconnect()
super.onDismiss(dialog)
}

override fun onResume() {
super.onResume()
initializeWithContext()
}
}

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ fun ReaderScreen(
val lifecycleOwner = LocalLifecycleOwner.current
DisposableEffect(lifecycleOwner) {
val observer = LifecycleEventObserver { _, event ->
if (event == Lifecycle.Event.ON_START) {
if (event in listOf(Lifecycle.Event.ON_START, Lifecycle.Event.ON_RESUME)) {
model.startRequest(
activity,
availableRequests[0].second,
Expand Down

0 comments on commit 9d361aa

Please sign in to comment.