[PR #1741] [MERGED] Account switching migration service #110128

Closed
opened 2026-06-06 05:51:27 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/bitwarden/android/pull/1741
Author: @mpbw2
Created: 1/31/2022
Status: Merged
Merged: 1/31/2022
Merged by: @mpbw2

Base: accountswitchingHead: accountswitching-migration-service


📝 Commits (1)

  • b56f91a single account migration to multi-account on app update

📊 Changes

14 files changed (+537 additions, -179 deletions)

View changed files

📝 src/Android/MainApplication.cs (+3 -0)
📝 src/App/Pages/Accounts/LockPage.xaml.cs (+2 -10)
📝 src/App/Pages/BaseContentPage.cs (+1 -1)
📝 src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml.cs (+0 -28)
📝 src/App/Services/MobileStorageService.cs (+3 -27)
📝 src/Core/Abstractions/IAppIdService.cs (+1 -0)
src/Core/Abstractions/IStateMigrationService.cs (+10 -0)
📝 src/Core/Abstractions/IStateService.cs (+0 -9)
📝 src/Core/Constants.cs (+1 -4)
📝 src/Core/Services/AppIdService.cs (+19 -14)
src/Core/Services/StateMigrationService.cs (+419 -0)
📝 src/Core/Services/StateService.cs (+74 -85)
📝 src/Core/Utilities/ServiceContainer.cs (+1 -1)
📝 src/iOS.Core/Utilities/iOSCoreHelpers.cs (+3 -0)

📄 Description

Type of change

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

Objective

Migrate existing user data to the new multi-account storage pattern upon app update.

Code changes

  • MainApplication.cs: Init StateMigrationService with the required storage services
  • LockPage.xaml.cs: Remove avatar appearance condition since it will always been shown here
  • GroupingsPage.xaml.xs: Remove old v1-to-v2 migration code (some of which was moved to StateMigrationService)
  • BaseContentPage.cs: Change avatar appearance condition to the presence of any active account, which should only ever be false before the very first login
  • MobileStorageService.cs: Remove old migration keys & logic, add key for state version
  • AppIdService.cs: Reverted to pre-multi-account state due to infinite loop during migration when it was using the state service (this particular value isn't user-specific so it's ok if it isn't managed by the state service)
  • StateMigrationService.cs: Service that performs the migration. As the mobile app had a previous migration, that was moved here as the "1 to 2" migration. The multi-account migration was added as "2 to 3".
  • StateService.cs: Removed unused methods, added migration check and trigger, changed ProtectedPin to default storage (was never in secure storage), changed account removal to clean house since it felt dirty to have settings restored when logging back in after previously removing an account (doesn't apply to logout as a vault timeout action), set new account theme to the current theme to avoid the jarring effect of possible theme change when adding a new account
  • ServiceContainer.cs: Restore storageService to appIdService
  • Constants.cs: Add/remove appropriate keys
  • iOSCoreHelpers.cs: Init StateMigrationService with the required storage services

Testing requirements

Create account with previous (non-account-switching build) then update to account switching build and confirm all data and settings is still intact

Before you submit

  • I have added unit tests where it makes sense to do so (encouraged but not required)
  • This change requires a documentation update (notify the documentation team)
  • This change has particular deployment requirements (notify the DevOps team)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/bitwarden/android/pull/1741 **Author:** [@mpbw2](https://github.com/mpbw2) **Created:** 1/31/2022 **Status:** ✅ Merged **Merged:** 1/31/2022 **Merged by:** [@mpbw2](https://github.com/mpbw2) **Base:** `accountswitching` ← **Head:** `accountswitching-migration-service` --- ### 📝 Commits (1) - [`b56f91a`](https://github.com/bitwarden/android/commit/b56f91a70918cf8e3956a6a97d36c5c85239490f) single account migration to multi-account on app update ### 📊 Changes **14 files changed** (+537 additions, -179 deletions) <details> <summary>View changed files</summary> 📝 `src/Android/MainApplication.cs` (+3 -0) 📝 `src/App/Pages/Accounts/LockPage.xaml.cs` (+2 -10) 📝 `src/App/Pages/BaseContentPage.cs` (+1 -1) 📝 `src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml.cs` (+0 -28) 📝 `src/App/Services/MobileStorageService.cs` (+3 -27) 📝 `src/Core/Abstractions/IAppIdService.cs` (+1 -0) ➕ `src/Core/Abstractions/IStateMigrationService.cs` (+10 -0) 📝 `src/Core/Abstractions/IStateService.cs` (+0 -9) 📝 `src/Core/Constants.cs` (+1 -4) 📝 `src/Core/Services/AppIdService.cs` (+19 -14) ➕ `src/Core/Services/StateMigrationService.cs` (+419 -0) 📝 `src/Core/Services/StateService.cs` (+74 -85) 📝 `src/Core/Utilities/ServiceContainer.cs` (+1 -1) 📝 `src/iOS.Core/Utilities/iOSCoreHelpers.cs` (+3 -0) </details> ### 📄 Description ## Type of change - [ ] Bug fix - [X] New feature development - [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc) - [ ] Build/deploy pipeline (DevOps) - [ ] Other ## Objective <!--Describe what the purpose of this PR is. For example: what bug you're fixing or what new feature you're adding--> Migrate existing user data to the new multi-account storage pattern upon app update. ## Code changes <!--Explain the changes you've made to each file or major component. This should help the reviewer understand your changes--> <!--Also refer to any related changes or PRs in other repositories--> * **MainApplication.cs:** Init `StateMigrationService` with the required storage services * **LockPage.xaml.cs:** Remove avatar appearance condition since it will always been shown here * **GroupingsPage.xaml.xs:** Remove old v1-to-v2 migration code (some of which was moved to `StateMigrationService`) * **BaseContentPage.cs:** Change avatar appearance condition to the presence of any active account, which should only ever be false before the very first login * **MobileStorageService.cs:** Remove old migration keys & logic, add key for state version * **AppIdService.cs:** Reverted to pre-multi-account state due to infinite loop during migration when it was using the state service (this particular value isn't user-specific so it's ok if it isn't managed by the state service) * **StateMigrationService.cs:** Service that performs the migration. As the mobile app had a previous migration, that was moved here as the "1 to 2" migration. The multi-account migration was added as "2 to 3". * **StateService.cs:** Removed unused methods, added migration check and trigger, changed ProtectedPin to default storage (was never in secure storage), changed account removal to clean house since it felt dirty to have settings restored when logging back in after previously removing an account (doesn't apply to logout as a vault timeout action), set new account theme to the current theme to avoid the jarring effect of possible theme change when adding a new account * **ServiceContainer.cs:** Restore storageService to appIdService * **Constants.cs:** Add/remove appropriate keys * **iOSCoreHelpers.cs:** Init `StateMigrationService` with the required storage services ## Testing requirements <!--What functionality requires testing by QA? This includes testing new behavior and regression testing--> Create account with previous (non-account-switching build) then update to account switching build and confirm all data and settings is still intact ## Before you submit - [ ] I have added **unit tests** where it makes sense to do so (encouraged but not required) - [ ] This change requires a **documentation update** (notify the documentation team) - [ ] This change has particular **deployment requirements** (notify the DevOps team) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-06-06 05:51:27 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/android#110128