66package org.microg.gms.fido.core.transport.nfc
77
88import android.app.Activity
9+ import android.app.ActivityOptions
910import android.app.PendingIntent
1011import android.content.Intent
1112import android.content.IntentFilter
1213import android.nfc.NfcAdapter
1314import android.nfc.Tag
1415import android.nfc.tech.IsoDep
16+ import android.os.Build
1517import android.util.Log
1618import androidx.core.app.OnNewIntentProvider
17- import androidx.core.app.PendingIntentCompat
1819import androidx.core.util.Consumer
1920import com.google.android.gms.fido.fido2.api.common.AuthenticatorAssertionResponse
2021import com.google.android.gms.fido.fido2.api.common.AuthenticatorAttestationResponse
@@ -39,7 +40,16 @@ class NfcTransportHandler(private val activity: Activity, callback: TransportHan
3940
4041 private suspend fun waitForNewNfcTag (adapter : NfcAdapter ): Tag {
4142 val intent = Intent (activity, activity.javaClass).apply { addFlags(Intent .FLAG_ACTIVITY_SINGLE_TOP ) }
42- val pendingIntent: PendingIntent = PendingIntentCompat .getActivity(activity, 0 , intent, 0 , true )!!
43+ val piOptions = if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .UPSIDE_DOWN_CAKE ) {
44+ ActivityOptions .makeBasic().apply {
45+ pendingIntentCreatorBackgroundActivityStartMode =
46+ ActivityOptions .MODE_BACKGROUND_ACTIVITY_START_ALLOWED
47+ }.toBundle()
48+ } else null
49+ val pendingIntent: PendingIntent = PendingIntent .getActivity(
50+ activity, 0 , intent,
51+ PendingIntent .FLAG_MUTABLE ,
52+ piOptions)!!
4353 adapter.enableForegroundDispatch(
4454 activity,
4555 pendingIntent,
0 commit comments