[PM-26094] Update Credential Manager library and remove stubs (#5947)

This commit is contained in:
Patrick Honkonen 2025-09-29 14:41:35 -04:00 committed by GitHub
parent 2363b0d619
commit 5c5bd25d16
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 17 additions and 231 deletions

View File

@ -120,12 +120,12 @@ class ImportItemsViewModel @Inject constructor(
sendEvent(
ImportItemsEvent.ShowRegisteredImportSources(
credentialTypes = listOf(
CredentialTypes.BASIC_AUTH,
CredentialTypes.PUBLIC_KEY,
CredentialTypes.TOTP,
CredentialTypes.CREDIT_CARD,
CredentialTypes.SSH_KEY,
CredentialTypes.ADDRESS,
CredentialTypes.CREDENTIAL_TYPE_BASIC_AUTH,
CredentialTypes.CREDENTIAL_TYPE_PUBLIC_KEY,
CredentialTypes.CREDENTIAL_TYPE_TOTP,
CredentialTypes.CREDENTIAL_TYPE_CREDIT_CARD,
CredentialTypes.CREDENTIAL_TYPE_SSH_KEY,
CredentialTypes.CREDENTIAL_TYPE_ADDRESS,
),
),
)

View File

@ -61,12 +61,12 @@ class ImportItemsViewModelTest : BaseViewModelTest() {
assertEquals(
ImportItemsEvent.ShowRegisteredImportSources(
listOf(
CredentialTypes.BASIC_AUTH,
CredentialTypes.PUBLIC_KEY,
CredentialTypes.TOTP,
CredentialTypes.CREDIT_CARD,
CredentialTypes.SSH_KEY,
CredentialTypes.ADDRESS,
CredentialTypes.CREDENTIAL_TYPE_BASIC_AUTH,
CredentialTypes.CREDENTIAL_TYPE_PUBLIC_KEY,
CredentialTypes.CREDENTIAL_TYPE_TOTP,
CredentialTypes.CREDENTIAL_TYPE_CREDIT_CARD,
CredentialTypes.CREDENTIAL_TYPE_SSH_KEY,
CredentialTypes.CREDENTIAL_TYPE_ADDRESS,
),
),
awaitItem(),

View File

@ -1,45 +0,0 @@
package androidx.credentials.providerevents
import android.app.Activity
import android.content.Intent
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 {
/**
* Stub implementation of the setImportCredentialsException method.
*/
fun setImportCredentialsException(intent: Intent, exception: ImportCredentialsException) {
// Stub implementation
}
/**
* Stub implementation of the setImportCredentialsResponse method.
*/
fun setImportCredentialsResponse(
context: Activity,
uri: Uri,
response: ImportCredentialsResponse,
) {
// Stub implementation
}
/**
* Stub implementation of the retrieveImportCredentialsException method.
*/
@Suppress("FunctionOnlyReturningConstant")
fun retrieveProviderImportCredentialsRequest(
intent: Intent,
): ProviderImportCredentialsRequest? {
// Stub implementation
return null
}
}

View File

@ -1,111 +0,0 @@
package androidx.credentials.providerevents
import android.annotation.SuppressLint
import android.content.Context
import android.content.pm.SigningInfo
import androidx.credentials.provider.CallingAppInfo
import androidx.credentials.providerevents.transfer.ImportCredentialsRequest
import androidx.credentials.providerevents.transfer.ImportCredentialsResponse
import androidx.credentials.providerevents.transfer.ProviderImportCredentialsResponse
import androidx.credentials.providerevents.transfer.RegisterExportRequest
import androidx.credentials.providerevents.transfer.RegisterExportResponse
import com.bitwarden.annotation.OmitFromCoverage
/**
* Placeholder interface representing a provider events manager.
*/
interface ProviderEventsManager {
/**
* Register as a credential export source.
*/
fun registerExport(request: RegisterExportRequest): RegisterExportResponse
/**
* Begin the process of importing credentials.
*/
fun importCredentials(
context: Context,
request: ImportCredentialsRequest,
): ProviderImportCredentialsResponse
@OmitFromCoverage
@Suppress("UndocumentedPublicClass")
companion object {
/**
* Create a new instance of [ProviderEventsManager].
*/
fun create(context: Context): ProviderEventsManager = StubProviderEventsManager()
}
}
/**
* Stub implementation of [ProviderEventsManager].
*/
@OmitFromCoverage
internal class StubProviderEventsManager : ProviderEventsManager {
override fun registerExport(request: RegisterExportRequest): RegisterExportResponse {
return RegisterExportResponse()
}
override fun importCredentials(
context: Context,
request: ImportCredentialsRequest,
): ProviderImportCredentialsResponse {
@SuppressLint("VisibleForTests")
return ProviderImportCredentialsResponse(
response = ImportCredentialsResponse(
responseJson = CANNED_RESPONSE,
),
callingAppInfo = CallingAppInfo(
packageName = context.packageName,
signingInfo = SigningInfo(),
origin = null,
),
)
}
}
private val CANNED_RESPONSE = """
{
"id": "3zGV3pmoSs6mT7IEAPXfOw",
"username": "",
"email": "user@email.com",
"fullName": "Test User",
"collections": [],
"items": [
{
"id": "8cCs0RV_ViySk7KCACA",
"creationAt": 1739325421,
"modifiedAt": 1739325421,
"title": "test import credentials",
"favorite": false,
"scope": {
"urls": [
"https://www.sample-url.io/"
],
"androidApps": []
},
"credentials": [
{
"type": "basic-auth",
"username": {
"fieldType": "string",
"value": "MyUsername"
}
},
{
"type": "passkey",
"credentialId": "xMA-5emp0WsQASnuNmuzQA",
"rpId": "www.sample-url.io",
"username": "user@email.com",
"userDisplayName": "user@email.com",
"userHandle": "lEn2KqNnS7SsUdVbrdoFiw",
"key": "MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgQx8Smx_KdvQ7nJXt2_62Xrn-im9ibCOtsphj_xZo_uWhRANCAARUDaIFJIUaRyUehAy_d1_a-DK63Ws_d-zkYj-uqHdrGZI0dnhazQGva4tJZQFN35iLoLzFFj_CSjqeYAEOX7Ck"
}
]
}
]
}
"""
.trimIndent()

View File

@ -1,6 +0,0 @@
package androidx.credentials.providerevents.exception
/**
* Placeholder class representing a cancellation exception for importing credentials.
*/
class ImportCredentialsCancellationException : Exception()

View File

@ -1,14 +0,0 @@
package androidx.credentials.providerevents.transfer
import android.graphics.Bitmap
/**
* Placeholder class representing an entry in the export request.
*/
data class ExportEntry(
val id: String,
val accountDisplayName: CharSequence?,
val userDisplayName: CharSequence,
val icon: Bitmap,
val supportedCredentialTypes: Set<String>,
)

View File

@ -1,16 +0,0 @@
package androidx.credentials.providerevents.transfer
import android.net.Uri
import androidx.credentials.provider.CallingAppInfo
/**
* Placeholder class for the request received by the provider after the query phase of the import
* flow is complete i.e. the user was presented with a list of entries, and the user has now made
* a selection from the list of [ExportEntry] presented on the selector UI.
*/
data class ProviderImportCredentialsRequest(
val request: ImportCredentialsRequest,
val callingAppInfo: CallingAppInfo,
val uri: Uri,
val credId: String,
)

View File

@ -1,11 +0,0 @@
package androidx.credentials.providerevents.transfer
import androidx.credentials.provider.CallingAppInfo
/**
* Placeholder class representing the response to an import request.
*/
data class ProviderImportCredentialsResponse(
val response: ImportCredentialsResponse,
val callingAppInfo: CallingAppInfo,
)

View File

@ -1,8 +0,0 @@
package androidx.credentials.providerevents.transfer
/**
* Placeholder class representing a request to register as a credential export source.
*/
data class RegisterExportRequest(
val entries: List<ExportEntry>,
)

View File

@ -1,6 +0,0 @@
package androidx.credentials.providerevents.transfer
/**
* Placeholder class representing a response to registering as a credential export source.
*/
class RegisterExportResponse

View File

@ -26,6 +26,7 @@ internal class CredentialExchangeCompletionManagerImpl(
is ExportCredentialsResult.Success -> {
IntentHandler.setImportCredentialsResponse(
context = activity,
intent = intent,
uri = exportResult.uri,
response = ImportCredentialsResponse(
responseJson = exportResult.payload,

View File

@ -28,6 +28,7 @@ class CredentialExchangeCompletionManagerTest {
context = any(),
uri = any(),
response = any(),
intent = any(),
)
} just runs
@ -54,6 +55,7 @@ class CredentialExchangeCompletionManagerTest {
context = mockActivity,
uri = mockUri,
response = any(),
intent = any(),
)
mockActivity.setResult(Activity.RESULT_OK, any())
mockActivity.finish()

View File

@ -21,8 +21,8 @@ androidxBrowser = "1.9.0"
androidxCamera = "1.4.2"
androidxComposeBom = "2025.09.00"
androidxCore = "1.17.0"
androidxCredentials = "1.5.0"
androidxCredentialsProviderEvents = "1.0.0-alpha02"
androidxCredentials = "1.6.0-beta01"
androidxCredentialsProviderEvents = "1.0.0-alpha03"
androidxHiltNavigationCompose = "1.3.0"
androidxLifecycle = "2.9.3"
androidxNavigation = "2.9.4"