Update Credential Provider Events APIs (#5926)

This commit is contained in:
Patrick Honkonen 2025-09-23 14:58:28 -04:00 committed by GitHub
parent df34db52e4
commit e965134697
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 15 additions and 21 deletions

View File

@ -1,6 +1,4 @@
@file:Suppress("unused")
package androidx.credentials.providerevents.playservices
package androidx.credentials.providerevents
import android.app.Activity
import android.content.Intent
@ -8,10 +6,12 @@ import android.net.Uri
import androidx.credentials.providerevents.exception.ImportCredentialsException
import androidx.credentials.providerevents.transfer.ImportCredentialsResponse
import androidx.credentials.providerevents.transfer.ProviderImportCredentialsRequest
import com.bitwarden.annotation.OmitFromCoverage
/**
* A stub implementation of the Credential Provider Events IntentHandler class.
*/
@OmitFromCoverage
object IntentHandler {
/**

View File

@ -12,4 +12,5 @@ data class ProviderImportCredentialsRequest(
val request: ImportCredentialsRequest,
val callingAppInfo: CallingAppInfo,
val uri: Uri,
val credId: String,
)

View File

@ -2,7 +2,7 @@ package com.bitwarden.cxf.manager
import android.app.Activity
import android.content.Intent
import androidx.credentials.providerevents.playservices.IntentHandler
import androidx.credentials.providerevents.IntentHandler
import androidx.credentials.providerevents.transfer.ImportCredentialsResponse
import com.bitwarden.cxf.manager.model.ExportCredentialsResult

View File

@ -1,17 +1,17 @@
package com.bitwarden.cxf.model
import android.net.Uri
import androidx.credentials.provider.CallingAppInfo
import android.os.Parcelable
import kotlinx.parcelize.Parcelize
/**
* A request to import the provider's credentials.
*
* @property uri the FileProvider uri that the importer will read the response from.
* @property requestJson the request to import the provider's credentials.
* @property callingAppInfo the caller's app info.
*/
data class BitwardenImportCredentialsRequest(
@Parcelize
data class ImportCredentialsRequestData(
val uri: Uri,
val requestJson: String,
val callingAppInfo: CallingAppInfo,
)
) : Parcelable

View File

@ -3,19 +3,12 @@
package com.bitwarden.cxf.util
import android.content.Intent
import androidx.credentials.providerevents.playservices.IntentHandler
import androidx.credentials.providerevents.IntentHandler
import androidx.credentials.providerevents.transfer.ProviderImportCredentialsRequest
import com.bitwarden.annotation.OmitFromCoverage
import com.bitwarden.cxf.model.BitwardenImportCredentialsRequest
/**
* Retrieves the [BitwardenImportCredentialsRequest] from the intent.
* Retrieves the [ProviderImportCredentialsRequest] from the intent.
*/
fun Intent.getProviderImportCredentialsRequest(): BitwardenImportCredentialsRequest? = IntentHandler
fun Intent.getProviderImportCredentialsRequest(): ProviderImportCredentialsRequest? = IntentHandler
.retrieveProviderImportCredentialsRequest(this)
?.let {
BitwardenImportCredentialsRequest(
uri = it.uri,
requestJson = it.request.requestJson,
callingAppInfo = it.callingAppInfo,
)
}

View File

@ -2,8 +2,8 @@ package com.bitwarden.cxf.manager
import android.app.Activity
import android.net.Uri
import androidx.credentials.providerevents.IntentHandler
import androidx.credentials.providerevents.exception.ImportCredentialsException
import androidx.credentials.providerevents.playservices.IntentHandler
import com.bitwarden.cxf.manager.model.ExportCredentialsResult
import io.mockk.Ordering
import io.mockk.every