[SDL-0301] SDL Device Listener#1384
Merged
bilal-alsharifi merged 9 commits intodevelopfrom Jun 29, 2020
Merged
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #1384 +/- ##
=============================================
- Coverage 46.01% 45.48% -0.53%
- Complexity 4461 4463 +2
=============================================
Files 494 495 +1
Lines 24905 25318 +413
Branches 2954 3066 +112
=============================================
+ Hits 11459 11517 +58
- Misses 12734 13087 +353
- Partials 712 714 +2
|
bilal-alsharifi
suggested changes
Jun 24, 2020
android/sdl_android/src/main/java/com/smartdevicelink/transport/utl/SdlDeviceListener.java
Outdated
Show resolved
Hide resolved
android/sdl_android/src/main/java/com/smartdevicelink/transport/utl/SdlDeviceListener.java
Outdated
Show resolved
Hide resolved
android/sdl_android/src/main/java/com/smartdevicelink/transport/utl/SdlDeviceListener.java
Outdated
Show resolved
Hide resolved
| * will listen for 30 seconds, if it is not, this will listen for 15 seconds instead. | ||
| */ | ||
| public void start() { | ||
| if (hasSDLConnected(contextWeakReference.get(), connectedDevice.getAddress())) { |
Contributor
There was a problem hiding this comment.
if I install the app while BT is already on, the connectedDevice comes as null so the app crashes with this exception
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.bluetooth.BluetoothDevice.getAddress()' on a null object reference
at com.smartdevicelink.transport.utl.SdlDeviceListener.start(SdlDeviceListener.java:88)
at com.smartdevicelink.transport.SdlBroadcastReceiver$2.onComplete(SdlBroadcastReceiver.java:298)
at com.smartdevicelink.util.ServiceFinder.onFinished(ServiceFinder.java:124)
at com.smartdevicelink.util.ServiceFinder.access$000(ServiceFinder.java:58)
at com.smartdevicelink.util.ServiceFinder$1.run(ServiceFinder.java:84)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Member
Author
There was a problem hiding this comment.
Bluetooth had to be on and connected for me to see this error, but added a null check before this now so it should throw an error. It's not an easy task to get the connected bluetooth device, so I'm not sure if it is really worth the effort at the moment.
Co-authored-by: Bilal Alsharifi <599206+bilal-alsharifi@users.noreply.github.com>
bilal-alsharifi
approved these changes
Jun 25, 2020
bilal-alsharifi
approved these changes
Jun 29, 2020
5 tasks
5 tasks
5 tasks
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.
Fixes #1348
This PR is ready for review.
Risk
This PR makes minor API changes.
Testing Plan
Unit Tests
Smoke Tests
Basic Functionality Tests
First Connection (Success)
Second Connection When First Connection was Successful
Second Connection When First Connection was NOT Successful
Test with Non SDL Device (Bluetooth headphones)
Multiple App Tests
Hello SDL and app with library version 4.11.1
SdlBroadcastReceiverin the methodwakeUpRouterService. This should go after the synchronized call onDEVICE_LISTENER_LOCK. After this lock, the code will only continue past if the SDL Device Listener feature is unable to be used.Hello SDL and second app with this branch
This test should be ran multiple times
1. If the IVI system does not connect, the listener should close itself and no service should be started.
2. If the IVI system does connect to the SDL Device Listener's RFCOMM channel, the flow should be as described in Test 1 Starting at Step 7.
Hello SDL and second app with this branch but newer router service
1. If the IVI system does not connect, the listener should close itself and no service should be started.
2. If the IVI system does connect to the SDL Device Listener's RFCOMM channel, the flow should be as described in Test 1 Starting at Step 7.
Hello SDL and second app with this branch, save successful connection
1. If the IVI system does not connect, the listener should close itself and no service should be started.
2. If the IVI system does connect to the SDL Device Listener's RFCOMM channel, the flow should be as described in Test 1 Starting at Step 7.
Additional Test Considerations
Summary
With this implementation the router service should not start until the bluetooth device has been confirmed to be an SDL device. This is done by opening an RFCOMM channel from the broadcast receiver that listens first. Only after a successful connection there will it start the router service. The caveat to this feature is that it is breaking behavior from previous library versions. Therefore, a check must be done against all other SDL apps that they have been updated to this version of the router service. If they have not, the old flow will continue, but if they are this feature will be enabled.
Changelog
Enhancements
SdlDeviceListenerclass was added and implemented in supporting proposal SDL-0301CLA