From 922ced0abe32be21c5b715f7773d04936e3864c9 Mon Sep 17 00:00:00 2001 From: TwistedUmbrellaX Date: Fri, 6 Sep 2024 23:21:11 -0400 Subject: [PATCH] Handle the new Android tag expiration time --- .../tagmo/nfctech/NfcActivity.kt | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/hiddenramblings/tagmo/nfctech/NfcActivity.kt b/app/src/main/java/com/hiddenramblings/tagmo/nfctech/NfcActivity.kt index 7e0233d51..89e0b33de 100644 --- a/app/src/main/java/com/hiddenramblings/tagmo/nfctech/NfcActivity.kt +++ b/app/src/main/java/com/hiddenramblings/tagmo/nfctech/NfcActivity.kt @@ -9,6 +9,7 @@ import android.content.IntentFilter import android.nfc.NfcAdapter import android.nfc.Tag import android.nfc.TagLostException +import android.os.Build import android.os.Bundle import android.provider.Settings import android.view.Menu @@ -516,6 +517,9 @@ class NfcActivity : AppCompatActivity() { Debug.warn(e) Debug.getExceptionCause(e)?.let { error -> when { + e is SecurityException -> { + + } getString(R.string.error_tag_rewrite) == error -> { withContext(Dispatchers.Main) { getErrorDialog( @@ -807,13 +811,22 @@ class NfcActivity : AppCompatActivity() { NFCIntent.ACTION_UNLOCK_UNIT, -> startNfcMonitor() } + + if (Version.isTiramisu && (NfcAdapter.ACTION_NDEF_DISCOVERED == intent.action + || NfcAdapter.ACTION_TECH_DISCOVERED == intent.action + || NfcAdapter.ACTION_TAG_DISCOVERED == intent.action)) { + val tech = tagTech ?: getString(R.string.nfc_tag) + showMessage(R.string.tag_detected, tech) + CoroutineScope(Dispatchers.IO).launch { onTagDiscovered(intent) } + } } override fun onNewIntent(intent: Intent) { super.onNewIntent(intent) - if (NfcAdapter.ACTION_NDEF_DISCOVERED == intent.action - || NfcAdapter.ACTION_TECH_DISCOVERED == intent.action - || NfcAdapter.ACTION_TAG_DISCOVERED == intent.action) { + if (Version.isLowerThan(Build.VERSION_CODES.TIRAMISU) + && (NfcAdapter.ACTION_NDEF_DISCOVERED == intent.action + || NfcAdapter.ACTION_TECH_DISCOVERED == intent.action + || NfcAdapter.ACTION_TAG_DISCOVERED == intent.action)) { val tech = tagTech ?: getString(R.string.nfc_tag) showMessage(R.string.tag_detected, tech) CoroutineScope(Dispatchers.IO).launch { onTagDiscovered(intent) }