Skip to content

Commit

Permalink
add intents for PasswordProviderProcessor
Browse files Browse the repository at this point in the history
  • Loading branch information
Nailik committed Oct 17, 2024
1 parent 83264b4 commit 5d26381
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,38 @@ interface IntentManager {
requestCode: Int,
): PendingIntent

/**
* Creates a pending intent to use when providing [androidx.credentials.provider.CreateEntry]
* instances for Password credential creation.
*/
fun createPasswordCreationPendingIntent(
action: String,
userId: String,
requestCode: Int,
): PendingIntent

/**
* Creates a pending intent to use when providing
* [androidx.credentials.provider.CredentialEntry] instances for Password credential filling.
*/
fun createPasswordGetCredentialPendingIntent(
action: String,
userId: String,
credentialId: String,
cipherId: String,
requestCode: Int,
): PendingIntent

/**
* Creates a pending intent to use when providing
* [androidx.credentials.provider.AuthenticationAction] instances for Password credential filling.
*/
fun createPasswordUnlockPendingIntent(
action: String,
userId: String,
requestCode: Int,
): PendingIntent

/**
* Open the default email app on device.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,61 @@ class IntentManagerImpl(
)
}

override fun createPasswordCreationPendingIntent(
action: String,
userId: String,
requestCode: Int,
): PendingIntent {
val intent = Intent(action)
.setPackage(context.packageName)
.putExtra(EXTRA_KEY_USER_ID, userId)

return PendingIntent.getActivity(
/* context = */ context,
/* requestCode = */ requestCode,
/* intent = */ intent,
/* flags = */ PendingIntent.FLAG_UPDATE_CURRENT.toPendingIntentMutabilityFlag(),
)
}

override fun createPasswordGetCredentialPendingIntent(
action: String,
userId: String,
credentialId: String,
cipherId: String,
requestCode: Int
): PendingIntent {
val intent = Intent(action)
.setPackage(context.packageName)
.putExtra(EXTRA_KEY_USER_ID, userId)
.putExtra(EXTRA_KEY_CREDENTIAL_ID, credentialId)
.putExtra(EXTRA_KEY_CIPHER_ID, cipherId)

return PendingIntent.getActivity(
/* context = */ context,
/* requestCode = */ requestCode,
/* intent = */ intent,
/* flags = */ PendingIntent.FLAG_UPDATE_CURRENT.toPendingIntentMutabilityFlag(),
)
}

override fun createPasswordUnlockPendingIntent(
action: String,
userId: String,
requestCode: Int,
): PendingIntent {
val intent = Intent(action)
.setPackage(context.packageName)
.putExtra(EXTRA_KEY_USER_ID, userId)

return PendingIntent.getActivity(
/* context = */ context,
/* requestCode = */ requestCode,
/* intent = */ intent,
/* flags = */ PendingIntent.FLAG_UPDATE_CURRENT.toPendingIntentMutabilityFlag(),
)
}

override fun startDefaultEmailApplication() {
val intent = Intent(Intent.ACTION_MAIN)
intent.addCategory(Intent.CATEGORY_APP_EMAIL)
Expand Down

0 comments on commit 5d26381

Please sign in to comment.