-
Notifications
You must be signed in to change notification settings - Fork 263
Add Signal API implementation (Provider) #160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @neelanshsahai, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request introduces the implementation of the Android Credential Provider Events API (Signal API) into the MyVault application. This allows the credential provider to receive and respond to various signals from the Android system, such as requests to hide/unhide specific credentials or update user details associated with credentials. The changes include integrating new dependencies, defining a dedicated service to handle these signals, updating the data layer to manage credential visibility, and enhancing the UI to reflect these changes, along with notification support.
Highlights
- Signal API Integration: The pull request integrates the Android Credential Provider Events API, enabling the MyVault application to receive and process various signals from the Android system's credential manager. This includes handling requests to hide/unhide credentials and update user details.
- Credential Visibility Management: A new 'hidden' flag has been introduced for 'PasskeyItem's, allowing the credential provider to manage the visibility of credentials. This enables the system to instruct the provider to hide or unhide specific credentials from the user's view.
- Dynamic User Detail Updates: The implementation now supports updating user details, such as username and display name, for passkeys in response to 'SignalCurrentUserDetailsRequest' events, ensuring credential information remains current.
- Notification Support: A notification system has been added to provide immediate feedback to the user when a Signal API event is successfully processed by the credential provider, enhancing transparency.
- Database and UI Updates: The local database schema has been updated to accommodate the new 'hidden' status for passkeys, and the UI components have been modified to filter and display only non-hidden passkeys, ensuring a consistent user experience.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request adds the Signal API implementation to the credential provider, allowing it to react to events from relying parties, such as credential updates or deletions. The changes include a new service to handle these signals, UI updates to reflect credential state, and necessary database modifications. My review has identified a critical performance issue due to blocking the main thread, a logic bug in a database query, and some leftover debugging code that should be cleaned up.
...p/src/main/java/com/example/android/authentication/myvault/data/CredentialProviderService.kt
Outdated
Show resolved
Hide resolved
...p/src/main/java/com/example/android/authentication/myvault/data/CredentialProviderService.kt
Outdated
Show resolved
Hide resolved
...p/src/main/java/com/example/android/authentication/myvault/data/CredentialProviderService.kt
Outdated
Show resolved
Hide resolved
...lt/app/src/main/java/com/example/android/authentication/myvault/data/room/MyVaultDatabase.kt
Outdated
Show resolved
Hide resolved
for (i in 0 until value.length()) { | ||
val item = value.get(i) | ||
if (item is String) { | ||
listAllAcceptedCredIds.add(item) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here as well
...t/app/src/main/java/com/example/android/authentication/myvault/data/CredentialsDataSource.kt
Outdated
Show resolved
Hide resolved
...r/MyVault/app/src/main/java/com/example/android/authentication/myvault/ui/home/HomeScreen.kt
Outdated
Show resolved
Hide resolved
d4814f5
to
1ac8dfc
Compare
...p/src/main/java/com/example/android/authentication/myvault/data/CredentialProviderService.kt
Outdated
Show resolved
Hide resolved
...p/src/main/java/com/example/android/authentication/myvault/data/CredentialProviderService.kt
Outdated
Show resolved
Hide resolved
...p/src/main/java/com/example/android/authentication/myvault/data/CredentialProviderService.kt
Outdated
Show resolved
Hide resolved
...t/app/src/main/java/com/example/android/authentication/myvault/data/CredentialsRepository.kt
Outdated
Show resolved
Hide resolved
...der/MyVault/app/src/main/java/com/example/android/authentication/myvault/data/PasskeyItem.kt
Show resolved
Hide resolved
...lt/app/src/main/java/com/example/android/authentication/myvault/data/room/MyVaultDatabase.kt
Outdated
Show resolved
Hide resolved
...er/MyVault/app/src/main/java/com/example/android/authentication/myvault/NotificationUtils.kt
Show resolved
Hide resolved
...p/src/main/java/com/example/android/authentication/myvault/data/CredentialProviderService.kt
Show resolved
Hide resolved
...p/src/main/java/com/example/android/authentication/myvault/data/CredentialProviderService.kt
Outdated
Show resolved
Hide resolved
...p/src/main/java/com/example/android/authentication/myvault/data/CredentialProviderService.kt
Outdated
Show resolved
Hide resolved
for (i in 0 until value.length()) { | ||
val item = value.get(i) | ||
if (item is String) { | ||
listAllAcceptedCredIds.add(item) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here as well
...p/src/main/java/com/example/android/authentication/myvault/data/CredentialProviderService.kt
Outdated
Show resolved
Hide resolved
...lt/app/src/main/java/com/example/android/authentication/myvault/data/room/MyVaultDatabase.kt
Outdated
Show resolved
Hide resolved
...ider/MyVault/app/src/main/java/com/example/android/authentication/myvault/ui/MainActivity.kt
Outdated
Show resolved
Hide resolved
228dbfd
to
9ad3dbe
Compare
...p/src/main/java/com/example/android/authentication/myvault/data/CredentialProviderService.kt
Show resolved
Hide resolved
...er/MyVault/app/src/main/java/com/example/android/authentication/myvault/NotificationUtils.kt
Show resolved
Hide resolved
...t/app/src/main/java/com/example/android/authentication/myvault/data/CredentialsRepository.kt
Show resolved
Hide resolved
...t/app/src/main/java/com/example/android/authentication/myvault/data/CredentialsRepository.kt
Show resolved
Hide resolved
768b319
to
f334169
Compare
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request successfully implements the Signal API for the credential provider. It correctly adds the necessary dependencies, manifest entries for the new service, and UI changes to handle hidden credentials. The core logic resides in the new CredentialProviderService
, which listens for and processes signals from relying parties. My review focuses on improving the robustness and performance of this new service. Key feedback points include using the appropriate Coroutine Dispatcher for I/O operations, improving error logging by replacing printStackTrace
with Log.e
, and ensuring database access methods are correctly marked as suspend
to prevent blocking the main thread. I've also included a suggestion to refactor some logic for better code clarity.
...t/app/src/main/java/com/example/android/authentication/myvault/data/CredentialsDataSource.kt
Outdated
Show resolved
Hide resolved
...lt/app/src/main/java/com/example/android/authentication/myvault/data/room/MyVaultDatabase.kt
Outdated
Show resolved
Hide resolved
...ider/MyVault/app/src/main/java/com/example/android/authentication/myvault/AppDependencies.kt
Outdated
Show resolved
Hide resolved
...p/src/main/java/com/example/android/authentication/myvault/data/CredentialProviderService.kt
Show resolved
Hide resolved
val listAllAcceptedCredIds = mutableListOf<String>() | ||
when (val value = request.get(ACCEPTED_CREDENTIAL_IDS)) { | ||
is String -> listAllAcceptedCredIds.add(value) | ||
is JSONArray -> { | ||
for (i in 0 until value.length()) { | ||
val item = value.get(i) | ||
if (item is String) { | ||
listAllAcceptedCredIds.add(item) | ||
} | ||
} | ||
} | ||
|
||
else -> { /*do nothing*/ | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block for parsing ACCEPTED_CREDENTIAL_IDS
can be made more concise and functional using a when
expression and mapNotNull
for the JSONArray
case. This improves readability and reduces mutability.
val listAllAcceptedCredIds = when (val value = request.get(ACCEPTED_CREDENTIAL_IDS)) {
is String -> listOf(value)
is JSONArray -> (0 until value.length()).mapNotNull { value.optString(it) }
else -> emptyList()
}
...p/src/main/java/com/example/android/authentication/myvault/data/CredentialProviderService.kt
Show resolved
Hide resolved
...p/src/main/java/com/example/android/authentication/myvault/data/CredentialProviderService.kt
Show resolved
Hide resolved
Change-Id: I5284a17da9791cd64e8d7ea8befe96dd5c770e76
f334169
to
27d7c47
Compare
Change-Id: I0571c151e62851634783b2aa8943b47fb84eea36
27d7c47
to
cfaaaed
Compare
No description provided.