Conversation
…ross networking and data components to prevent UI thread hangs.
…ic from BLE state
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces several improvements and refactorings to BLE and network connection management, device name handling, and service lifecycle in the AirSync app. The main focus is on streamlining BLE sync settings observation, reducing blocking calls, enhancing device name matching logic, and clarifying the separation between BLE and Wi-Fi connections. It also updates how device discovery and notification updates are handled to be more efficient and responsive.
BLE and DataStore Management:
BleGattServerto observe BLE sync enabled state via a coroutine and a cached variable (isBleSyncEnabled), replacing repeated blocking reads fromDataStoreManager. This improves responsiveness and efficiency when checking BLE sync status. [1] [2] [3]getContext()method toAirSyncAppfor easier access to the application context when needed.Device Name Handling and Matching:
BleTransportBridge.sendDeviceName()to use a persisted device name fromDataStoreManagerif available, falling back to a utility method, and made the context parameter optional.WakeupHandlerby normalizing names (trimming, lowercasing, and replacing special characters) for more reliable connection and key retrieval.Service and Notification Lifecycle:
AirSyncServiceto cache the last connected device and observe changes via a coroutine, reducing redundant blocking calls and ensuring notifications stay updated in real time. [1] [2] [3]AirSyncServiceto use coroutines for non-blocking initialization and state changes. [1] [2]Wi-Fi and BLE Connection Handling:
WebSocketUtilto better distinguish between Wi-Fi and BLE, avoid unnecessary reconnects when authenticated via BLE, and use coroutines for state updates. [1] [2] [3] [4] [5] [6]Other Improvements:
WakeupHandlerto handle edge cases and fallback scenarios more gracefully, including single-device environments.These changes collectively improve the app’s efficiency, reliability, and maintainability, especially around BLE and Wi-Fi connection management.