Skip to content

Commit 8c3cfbe

Browse files
committed
Fido: fix support when targetSdk>=35
1 parent e2b4d38 commit 8c3cfbe

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/transport/nfc/NfcTransportHandler.kt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@
66
package org.microg.gms.fido.core.transport.nfc
77

88
import android.app.Activity
9+
import android.app.ActivityOptions
910
import android.app.PendingIntent
1011
import android.content.Intent
1112
import android.content.IntentFilter
1213
import android.nfc.NfcAdapter
1314
import android.nfc.Tag
1415
import android.nfc.tech.IsoDep
16+
import android.os.Build
1517
import android.util.Log
1618
import androidx.core.app.OnNewIntentProvider
17-
import androidx.core.app.PendingIntentCompat
1819
import androidx.core.util.Consumer
1920
import com.google.android.gms.fido.fido2.api.common.AuthenticatorAssertionResponse
2021
import 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

Comments
 (0)