[PR #2206] [MERGED] [EC-581] Implement Apple Watch MVP Sync #3428

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

📋 Pull Request Information

Original PR: https://github.com/bitwarden/android/pull/2206
Author: @fedemkr
Created: 11/26/2022
Status: Merged
Merged: 11/29/2022
Merged by: @fedemkr

Base: feature/apple-watch-mvpHead: feature/EC-581-apple-watch-mvp-sync


📝 Commits (5)

  • 68544e1 EC-581 Implemented sync iPhone -> watchOS, fix some issues with the watch database and sync flows for login/locks/multiple accounts
  • fd2122f Merge branch 'feature/apple-watch-mvp' into feature/EC-581-apple-watch-mvp-sync
  • d08d57a EC-581 Added watch sync on unlocking and need setup state when no user is synced and the session is not active
  • f73b2b2 EC-581 Removed unused method
  • 05f9b7b EC-581 Fix format

📊 Changes

51 files changed (+834 additions, -247 deletions)

View changed files

📝 src/Android/Android.csproj (+1 -0)
📝 src/Android/MainApplication.cs (+10 -2)
📝 src/Android/Services/DeviceActionService.cs (+0 -1)
src/Android/Services/WatchDeviceService.cs (+24 -0)
📝 src/App/Abstractions/IDeviceActionService.cs (+2 -5)
📝 src/App/Pages/Accounts/LockPageViewModel.cs (+3 -0)
📝 src/App/Pages/Settings/SettingsPage/SettingsPageViewModel.cs (+2 -11)
📝 src/App/Pages/Vault/CipherAddEditPageViewModel.cs (+4 -0)
📝 src/App/Pages/Vault/CipherDetailsPageViewModel.cs (+5 -0)
📝 src/App/Pages/Vault/GroupingsPage/GroupingsPageViewModel.cs (+0 -14)
src/App/Services/BaseWatchDeviceService.cs (+100 -0)
📝 src/App/Utilities/AccountManagement/AccountsManager.cs (+7 -1)
📝 src/Core/Abstractions/ICipherService.cs (+1 -1)
📝 src/Core/Abstractions/IStateService.cs (+1 -0)
src/Core/Abstractions/IWatchDeviceService.cs (+9 -0)
src/Core/Enums/WatchState.cs (+13 -0)
📝 src/Core/Models/View/SimpleCipherView.cs (+15 -4)
src/Core/Models/View/WatchDTO.cs (+44 -0)
📝 src/Core/Services/AuthService.cs (+3 -0)
📝 src/Core/Services/CipherService.cs (+14 -3)

...and 31 more files

📄 Description

Type of change

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

Objective

Implement synchronization iPhone -> WatchOS

Code changes

iOS

  • IWatchDeviceService, BaseWatchDeviceService, WatchDeviceService: Added this service to handle the communication with the Apple Watch.
  • WatchState: States to be synced with the Watch
  • SimpleCipherView: Removed OrganizationUseTotp given that it was not being used on the Watch and added login uris that are used to display the cipher icon on the Watch
  • WatchDTO: Added this dto to be used in the communication iPhone -> Watch which syncs State, Ciphers, User, Environment and Settings data.
  • IDeviceActionService, DeviceActionService: Removed Watch related methods given that they've been moved to the aforementioned service
  • LockPageViewModel: Added Watch Sync on unlocking
  • CipherAddEditPageViewModel, CipherDetailPageViewModel: Added Watch Sync when adding/editing/deleting ciphers
  • AccountsManager: Added Watch Sync on account switching
  • ICipherService, CipherService: Added filter when getting the ciphers so it can be applied before decrypting and improve performance.
  • IStateService, StateService: Added GetActiveUserCustomDataAsync(Func<Account, T> dataMapper) to get custom data from the account that can be "queried" by the mapper
  • AuthService: Added Watch Sync when logging out
  • SyncService: Added Watch Sync when syncing on the iPhone
  • WCSessionManager: Clear and improved some methods

watchOS

  • CoreDataHelper: Fix batch insert and delete
  • BitwardenDB.xcdatamodel: Made id and userId non-Transformable to be able to filter by them
  • CipherEntity: Added userId and removed organizationUseTotp
  • KeychainHelper: Improved the code to be more bullet proof on edge case scenarios
  • WatchDTO: Dto used for the iPhone -> Watch synchronization
  • CipherService: Improved methods for fetching and deleting to be able to filter
  • StateService: Added state properties to be fetched/saved in the keychain
  • BWState: Added isDestructive computed property to be easier to reference on the state that clear the database
  • ErrorExtensions: Helpers to have more information on the error
  • JSONDecoderExtensions: Added upperToLowerCamelCase KeyDecodingStrategy to be able to "lowerize" the first letter of the keys on a JSON. Used on the sync
  • CipherListViewModel: Implemented logic to display the state depending on the synced values and filtered the fetch by the current user
  • CipherListView: Fixed some UI issues with the row background and other minor ones.
  • WatchConnectivityManager: Implemented the logic for the synchronization and added a subject to report value changes

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

🔄 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/2206 **Author:** [@fedemkr](https://github.com/fedemkr) **Created:** 11/26/2022 **Status:** ✅ Merged **Merged:** 11/29/2022 **Merged by:** [@fedemkr](https://github.com/fedemkr) **Base:** `feature/apple-watch-mvp` ← **Head:** `feature/EC-581-apple-watch-mvp-sync` --- ### 📝 Commits (5) - [`68544e1`](https://github.com/bitwarden/android/commit/68544e19823a311d6f3f0dcdcba096a0ebccbb96) EC-581 Implemented sync iPhone -> watchOS, fix some issues with the watch database and sync flows for login/locks/multiple accounts - [`fd2122f`](https://github.com/bitwarden/android/commit/fd2122f644c95a6aefbcbb948e19d7c9adf4bacc) Merge branch 'feature/apple-watch-mvp' into feature/EC-581-apple-watch-mvp-sync - [`d08d57a`](https://github.com/bitwarden/android/commit/d08d57a6e469a94a7984ad94b675b4b64e133087) EC-581 Added watch sync on unlocking and need setup state when no user is synced and the session is not active - [`f73b2b2`](https://github.com/bitwarden/android/commit/f73b2b21b45c090e487effc086fda6eb9f0be553) EC-581 Removed unused method - [`05f9b7b`](https://github.com/bitwarden/android/commit/05f9b7b05a54cca29eab5540fbdece91f022b676) EC-581 Fix format ### 📊 Changes **51 files changed** (+834 additions, -247 deletions) <details> <summary>View changed files</summary> 📝 `src/Android/Android.csproj` (+1 -0) 📝 `src/Android/MainApplication.cs` (+10 -2) 📝 `src/Android/Services/DeviceActionService.cs` (+0 -1) ➕ `src/Android/Services/WatchDeviceService.cs` (+24 -0) 📝 `src/App/Abstractions/IDeviceActionService.cs` (+2 -5) 📝 `src/App/Pages/Accounts/LockPageViewModel.cs` (+3 -0) 📝 `src/App/Pages/Settings/SettingsPage/SettingsPageViewModel.cs` (+2 -11) 📝 `src/App/Pages/Vault/CipherAddEditPageViewModel.cs` (+4 -0) 📝 `src/App/Pages/Vault/CipherDetailsPageViewModel.cs` (+5 -0) 📝 `src/App/Pages/Vault/GroupingsPage/GroupingsPageViewModel.cs` (+0 -14) ➕ `src/App/Services/BaseWatchDeviceService.cs` (+100 -0) 📝 `src/App/Utilities/AccountManagement/AccountsManager.cs` (+7 -1) 📝 `src/Core/Abstractions/ICipherService.cs` (+1 -1) 📝 `src/Core/Abstractions/IStateService.cs` (+1 -0) ➕ `src/Core/Abstractions/IWatchDeviceService.cs` (+9 -0) ➕ `src/Core/Enums/WatchState.cs` (+13 -0) 📝 `src/Core/Models/View/SimpleCipherView.cs` (+15 -4) ➕ `src/Core/Models/View/WatchDTO.cs` (+44 -0) 📝 `src/Core/Services/AuthService.cs` (+3 -0) 📝 `src/Core/Services/CipherService.cs` (+14 -3) _...and 31 more files_ </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--> Implement synchronization iPhone -> WatchOS ## 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--> ### iOS * **IWatchDeviceService, BaseWatchDeviceService, WatchDeviceService:** Added this service to handle the communication with the Apple Watch. * **WatchState:** States to be synced with the Watch * **SimpleCipherView:** Removed `OrganizationUseTotp` given that it was not being used on the Watch and added login uris that are used to display the cipher icon on the Watch * **WatchDTO:** Added this dto to be used in the communication iPhone -> Watch which syncs State, Ciphers, User, Environment and Settings data. * **IDeviceActionService, DeviceActionService:** Removed Watch related methods given that they've been moved to the aforementioned service * **LockPageViewModel:** Added Watch Sync on unlocking * **CipherAddEditPageViewModel, CipherDetailPageViewModel:** Added Watch Sync when adding/editing/deleting ciphers * **AccountsManager:** Added Watch Sync on account switching * **ICipherService, CipherService:** Added filter when getting the ciphers so it can be applied before decrypting and improve performance. * **IStateService, StateService:** Added `GetActiveUserCustomDataAsync(Func<Account, T> dataMapper)` to get custom data from the account that can be "queried" by the mapper * **AuthService:** Added Watch Sync when logging out * **SyncService:** Added Watch Sync when syncing on the iPhone * **WCSessionManager:** Clear and improved some methods ### watchOS * **CoreDataHelper:** Fix batch insert and delete * **BitwardenDB.xcdatamodel:** Made `id` and `userId` non-Transformable to be able to filter by them * **CipherEntity:** Added `userId` and removed `organizationUseTotp` * **KeychainHelper:** Improved the code to be more bullet proof on edge case scenarios * **WatchDTO:** Dto used for the iPhone -> Watch synchronization * **CipherService:** Improved methods for fetching and deleting to be able to filter * **StateService:** Added state properties to be fetched/saved in the keychain * **BWState:** Added `isDestructive` computed property to be easier to reference on the state that clear the database * **ErrorExtensions:** Helpers to have more information on the error * **JSONDecoderExtensions:** Added `upperToLowerCamelCase` KeyDecodingStrategy to be able to "lowerize" the first letter of the keys on a JSON. Used on the sync * **CipherListViewModel:** Implemented logic to display the state depending on the synced values and filtered the fetch by the current user * **CipherListView:** Fixed some UI issues with the row background and other minor ones. * **WatchConnectivityManager:** Implemented the logic for the synchronization and added a subject to report value changes ## 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 --- <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 2025-11-26 23:32:39 -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#3428