[PR #3155] [PM-7385] Fix for allowing switching accounts while creating a passkey of Android #4057

Closed
opened 2025-11-26 23:40:06 -06:00 by GiteaMirror · 0 comments
Owner

Original Pull Request: https://github.com/bitwarden/android/pull/3155

State: closed
Merged: Yes


Type of change

  • Bug fix
  • New feature development
  • Tech debt (refactoring, code cleanup, dependency upgrades, etc)
  • Build/deploy pipeline (DevOps)
  • Other

Objective

The objective is to allow switching accounts during the create passkey flow.

Code changes

Updated EnsureUnlockedVaultAsync on Android to trigger the unlock flow like on iOS. This allows the account switching process to work.
Also had to expose the TaskCompletionSource for confirmCredential so that other parts of the app can stop navigations when a create passkey flow is already running.
A new TaskCompletionSource was also created for the unlockVault process that can get triggered during the credential creation when switching accounts.
To avoid additional erratic app behaviors the app is no longer relying on Options.Fido2CredentialAction and Options.FromFido2Framework after the Fido process starts. We use "new" TaskCompletionSource instead to know if the flow is still running.
There's also a fix included for scenarios where tapping on cipher won't do anything (in this case after switching).

  • Fido2MakeCredentialUserInterface.cs: Updated EnsureUnlockedVaultAsync to trigger the vault unlocked process if it's not already unlocked. Also added a new unlock vault TaskCompletionSource to allow this.
  • DeviceActionService.cs: We ensure we reset the Options.Fido2CredentialAction and Options.FromFido2Framework to avoid erratic behaviors that we could get after the Create passkey flow was not running anymore. We use the IsConfirmingNewCredential and IsWaitingUnlockVault instead to know that the flow is still running.
  • IFido2MakeCredentialConfirmationUserInterface.cs: Added the definitions for the unlock vault and confirm credential TaskCompletionSource methods.
  • App.xaml.cs: Added new event for Android navigations and added a check on Navigate() to avoid navigating again when we are already running the create passkey flow.
  • AccountsManager.cs: Check to avoid restarting the create passkey flow when we are already running it.
  • AppHelpers.cs: Added block to "inform" the IFido2MakeCredentialConfirmationUserInterface that the Vault was unlocked.
  • AutofillCiphersPageViewModel.cs.cs: Changes to use _fido2MakeCredentialConfirmationUserInterface.Value.IsConfirmingNewCredential instead of _appOptions.FromFido2Framework
  • CipherAddEditPage.xaml.cs: Changes to use _fido2MakeCredentialConfirmationUserInterface.Value.IsConfirmingNewCredential instead of _appOptions.FromFido2Framework
  • CipherAddEditPageViewModel.cs: Changes to use _fido2MakeCredentialConfirmationUserInterface.Value.IsConfirmingNewCredential instead of _appOptions.FromFido2Framework

Before you submit

  • Please check for formatting errors (dotnet format --verify-no-changes) (required)
  • Please add unit tests where it makes sense to do so (encouraged but not required)
  • If this change requires a documentation update - notify the documentation team
  • If this change has particular deployment requirements - notify the DevOps team
**Original Pull Request:** https://github.com/bitwarden/android/pull/3155 **State:** closed **Merged:** Yes --- ## Type of change - [ ] Bug fix - [x] New feature development - [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc) - [ ] Build/deploy pipeline (DevOps) - [ ] Other ## Objective The objective is to allow switching accounts during the create passkey flow. ## Code changes Updated `EnsureUnlockedVaultAsync` on Android to trigger the unlock flow like on iOS. This allows the account switching process to work. Also had to expose the TaskCompletionSource for confirmCredential so that other parts of the app can stop navigations when a create passkey flow is already running. A new TaskCompletionSource was also created for the unlockVault process that can get triggered during the credential creation when switching accounts. To avoid additional erratic app behaviors the app is no longer relying on `Options.Fido2CredentialAction` and `Options.FromFido2Framework` after the Fido process starts. We use "new" TaskCompletionSource instead to know if the flow is still running. There's also a fix included for scenarios where tapping on cipher won't do anything (in this case after switching). * **Fido2MakeCredentialUserInterface.cs:** Updated `EnsureUnlockedVaultAsync` to trigger the vault unlocked process if it's not already unlocked. Also added a new unlock vault `TaskCompletionSource` to allow this. * **DeviceActionService.cs:** We ensure we reset the `Options.Fido2CredentialAction` and `Options.FromFido2Framework` to avoid erratic behaviors that we could get after the Create passkey flow was not running anymore. We use the `IsConfirmingNewCredential` and `IsWaitingUnlockVault` instead to know that the flow is still running. * **IFido2MakeCredentialConfirmationUserInterface.cs:** Added the definitions for the unlock vault and confirm credential TaskCompletionSource methods. * **App.xaml.cs:** Added new event for Android navigations and added a check on Navigate() to avoid navigating again when we are already running the create passkey flow. * **AccountsManager.cs:** Check to avoid restarting the create passkey flow when we are already running it. * **AppHelpers.cs:** Added block to "inform" the `IFido2MakeCredentialConfirmationUserInterface` that the Vault was unlocked. * **AutofillCiphersPageViewModel.cs.cs:** Changes to use `_fido2MakeCredentialConfirmationUserInterface.Value.IsConfirmingNewCredential` instead of `_appOptions.FromFido2Framework` * **CipherAddEditPage.xaml.cs:** Changes to use `_fido2MakeCredentialConfirmationUserInterface.Value.IsConfirmingNewCredential` instead of `_appOptions.FromFido2Framework` * **CipherAddEditPageViewModel.cs:** Changes to use `_fido2MakeCredentialConfirmationUserInterface.Value.IsConfirmingNewCredential` instead of `_appOptions.FromFido2Framework` ## Before you submit - Please check for formatting errors (`dotnet format --verify-no-changes`) (required) - Please add **unit tests** where it makes sense to do so (encouraged but not required) - If this change requires a **documentation update** - notify the documentation team - If this change has particular **deployment requirements** - notify the DevOps team
GiteaMirror added the pull-request label 2025-11-26 23:40:06 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/android#4057