[PR #1917] [MERGED] [EC-234] [BEEEP] Improved BroadcastService and added exception handling on async void callbacks #3218

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

📋 Pull Request Information

Original PR: https://github.com/bitwarden/android/pull/1917
Author: @fedemkr
Created: 5/20/2022
Status: Merged
Merged: 7/5/2022
Merged by: @fedemkr

Base: masterHead: TDL-14-improve-broadcastservice


📝 Commits (2)

  • 558d599 Improved BroadcastService and added try...catch on async void callbacks
  • c0d648c Merge branch 'master' into TDL-14-improve-broadcastservice

📊 Changes

12 files changed (+306 additions, -228 deletions)

View changed files

📝 src/Android/MainApplication.cs (+5 -4)
📝 src/App/App.xaml.cs (+73 -65)
📝 src/App/Pages/Accounts/HomePage.xaml.cs (+1 -1)
📝 src/App/Pages/Send/SendGroupingsPage/SendGroupingsPage.xaml.cs (+20 -12)
📝 src/App/Pages/Vault/AutofillCiphersPage.xaml.cs (+20 -12)
📝 src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml.cs (+20 -12)
📝 src/App/Pages/Vault/ViewPage.xaml.cs (+32 -24)
📝 src/Core/Abstractions/IBroadcasterService.cs (+2 -1)
📝 src/Core/Services/BroadcasterService.cs (+43 -16)
📝 src/iOS.Core/Renderers/CustomTabbedRenderer.cs (+1 -1)
📝 src/iOS.Core/Utilities/iOSCoreHelpers.cs (+5 -3)
📝 src/iOS/AppDelegate.cs (+84 -77)

📄 Description

Type of change

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

Objective

Improve BroadcastService on exception handling and also add try...catch on async void callbacks of the BroadcastService.

Code changes

  • BroadcastService.cs: Splitted Send(Message message, string id) because currently the id is not being sent by any method so we're doing some checks inside that never apply. Thus it made sense to split it so that we avoid this little overhead (and also the other method will be stripped out by the linker unless we call it from somewhere). In addition, exception handling was added to the call of the message action because it was being swallowed by the task thus we were not getting any reports to AppCenter if something failed.
  • Every other place: Changed unused async Action callback to be plain Action callback and in the places where async was needed, try...catch was added to handle the exception, because if not on an async void the exception doesn't bubble up to the caller task and just crashes the app.

###Notes:
BroadcastService and the IMessagingService needs further refactoring to improve the code and the dev experience but I'll do it on a different PR.

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/1917 **Author:** [@fedemkr](https://github.com/fedemkr) **Created:** 5/20/2022 **Status:** ✅ Merged **Merged:** 7/5/2022 **Merged by:** [@fedemkr](https://github.com/fedemkr) **Base:** `master` ← **Head:** `TDL-14-improve-broadcastservice` --- ### 📝 Commits (2) - [`558d599`](https://github.com/bitwarden/android/commit/558d5995dd9c193f7c1fb270b0aa33f757d76ffd) Improved BroadcastService and added try...catch on async void callbacks - [`c0d648c`](https://github.com/bitwarden/android/commit/c0d648ca474bc8afe4209a0bd6ddacf40b4897e8) Merge branch 'master' into TDL-14-improve-broadcastservice ### 📊 Changes **12 files changed** (+306 additions, -228 deletions) <details> <summary>View changed files</summary> 📝 `src/Android/MainApplication.cs` (+5 -4) 📝 `src/App/App.xaml.cs` (+73 -65) 📝 `src/App/Pages/Accounts/HomePage.xaml.cs` (+1 -1) 📝 `src/App/Pages/Send/SendGroupingsPage/SendGroupingsPage.xaml.cs` (+20 -12) 📝 `src/App/Pages/Vault/AutofillCiphersPage.xaml.cs` (+20 -12) 📝 `src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml.cs` (+20 -12) 📝 `src/App/Pages/Vault/ViewPage.xaml.cs` (+32 -24) 📝 `src/Core/Abstractions/IBroadcasterService.cs` (+2 -1) 📝 `src/Core/Services/BroadcasterService.cs` (+43 -16) 📝 `src/iOS.Core/Renderers/CustomTabbedRenderer.cs` (+1 -1) 📝 `src/iOS.Core/Utilities/iOSCoreHelpers.cs` (+5 -3) 📝 `src/iOS/AppDelegate.cs` (+84 -77) </details> ### 📄 Description ## Type of change - [ ] Bug fix - [ ] New feature development - [X] 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--> Improve `BroadcastService` on exception handling and also add `try...catch` on async void callbacks of the `BroadcastService`. ## 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--> * **BroadcastService.cs:** Splitted `Send(Message message, string id)` because currently the `id` is not being sent by any method so we're doing some checks inside that never apply. Thus it made sense to split it so that we avoid this little overhead (and also the other method will be stripped out by the linker unless we call it from somewhere). In addition, exception handling was added to the call of the message action because it was being swallowed by the task thus we were not getting any reports to AppCenter if something failed. * **Every other place:** Changed unused async Action callback to be plain Action callback and in the places where async was needed, try...catch was added to handle the exception, because if not on an async void the exception doesn't bubble up to the caller task and just crashes the app. ###Notes: `BroadcastService` and the `IMessagingService` needs further refactoring to improve the code and the dev experience but I'll do it on a different PR. ## 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 2025-11-26 23:29:51 -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#3218