Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.simprints.fingerprint.connect.screens.issues.nfcpair

import android.nfc.TagLostException
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
Expand Down Expand Up @@ -38,6 +39,10 @@ internal class NfcPairViewModel @Inject constructor(
_showToastWithStringRes.send(R.string.fingerprint_connect_nfc_pair_toast_try_again)
} catch (e: IllegalArgumentException) {
_showToastWithStringRes.send(R.string.fingerprint_connect_nfc_pair_toast_invalid)
} catch (e: SecurityException) {
_showToastWithStringRes.send(R.string.fingerprint_connect_nfc_pair_toast_try_again)
} catch (e: TagLostException) {
_showToastWithStringRes.send(R.string.fingerprint_connect_nfc_pair_toast_try_again)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,18 @@ class NfcPairViewModelTest {
errorObserver.assertEventReceivedWithContent(R.string.fingerprint_connect_nfc_pair_toast_try_again)
}

@Test
fun `Shows error when tag moved out of field`() {
every { nfcManager.readMacAddressDataFromBluetoothEasyPairTag(any()) } returns ADDRESS
every { scannerPairingManager.isScannerAddress(any()) } returns true
every { scannerPairingManager.startPairingToDevice(any()) } throws SecurityException("Test")

val errorObserver = viewModel.showToastWithStringRes.testObserver()
viewModel.handleNfcTagDetected(mockk())

errorObserver.assertEventReceivedWithContent(R.string.fingerprint_connect_nfc_pair_toast_try_again)
}

companion object {
private const val ADDRESS = "address"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.simprints.fingerprint.infra.scanner.nfc.ComponentMifareUltralight
import java.io.Closeable

internal class AndroidMifareUltralight(
val mifare: MifareUltralight
private val mifare: MifareUltralight
) : ComponentMifareUltralight, Closeable by mifare {

override fun connect() {
Expand Down