Add whether Bluetooth scan is in traditional mode(ScanSettings.Builder.setLegacy()) #763
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.
While using the application recently, I encountered an issue where the device couldn't be scanned. After investigating, I found that the device's advertising type is Bluetooth 5 Advertising Extension. Upon consulting the Android documentation, I discovered that the ScanSettings.Builder.setLegacy() method was introduced in Android 26 API.
Link to Android Documentation
setLegacy(false) is a method in ScanSettings.Builder that determines whether the scan operates in "legacy" mode. With Bluetooth 5, a new scanning mode was introduced to support additional features like extended advertising and long data packets. Conversely, "legacy" mode only supports traditional advertising data types and does not accommodate Bluetooth 5's extended advertising.
Hence, when you use setLegacy(false), you're instructing the system not to employ "legacy" mode, but rather to use the new mode, enabling scanning for Bluetooth 5's extended advertisements and other new features.
Based on this understanding, I propose adding a parameter isLegacy() to confirm whether to activate scanning in legacy mode. Below is the code I added:
This change allows for flexible configuration of the scan mode, ensuring compatibility and functionality as required.