package com.peachpasswords.passkeys import android.app.PendingIntent import android.content.Context import android.content.Intent import android.os.Build import androidx.credentials.provider.BeginGetCredentialRequest import com.peachpasswords.credentials.CredentialProviderUnlockActivity object PasskeyUnlockIntent { fun pendingIntent(context: Context, request: BeginGetCredentialRequest): PendingIntent { val intent = Intent(context, CredentialProviderUnlockActivity::class.java) .putExtra(EXTRA_REQUEST, BeginGetCredentialRequest.asBundle(request)) return PendingIntent.getActivity( context, PasskeyPendingIntentIds.next(), intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_ONE_SHOT or mutableFlag(), ) } private fun mutableFlag(): Int = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) PendingIntent.FLAG_MUTABLE else 0 const val EXTRA_REQUEST = "com.peachpasswords.passkeys.EXTRA_BEGIN_GET_REQUEST" }