-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android 14 foreground service type required #1860
Android 14 foreground service type required #1860
Conversation
…loy next RS if we don't have the permission
…f it has not been started at that point.
…ng SdlService, then request USB permission if we do not.
Unit test for Android currently fail due to needing to target API 34 which is in a different PR. |
# Conflicts: # android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlService.java
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the other PRs need to be finished and merged into develop, then develop back into this branch to test more properly. During the first review it seems like everything is working as it should, but will need to retest and more robustly post the rest of the fixes being merged.
android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java
Outdated
Show resolved
Hide resolved
android/sdl_android/src/main/java/com/smartdevicelink/util/AndroidTools.java
Outdated
Show resolved
Hide resolved
android/sdl_android/src/main/java/com/smartdevicelink/util/AndroidTools.java
Outdated
Show resolved
Hide resolved
android/sdl_android/src/main/java/com/smartdevicelink/util/AndroidTools.java
Outdated
Show resolved
Hide resolved
android/sdl_android/src/main/java/com/smartdevicelink/util/AndroidTools.java
Outdated
Show resolved
Hide resolved
android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java
Show resolved
Hide resolved
android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java
Outdated
Show resolved
Hide resolved
android/sdl_android/src/main/java/com/smartdevicelink/transport/UsbTransferProvider.java
Show resolved
Hide resolved
android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlReceiver.java
Outdated
Show resolved
Hide resolved
android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlReceiver.java
Outdated
Show resolved
Hide resolved
…geUSBAccessoryReceived in RS
…xt. Also make cachedContext a weak reference
# Conflicts: # android/sdl_android/src/main/java/com/smartdevicelink/util/AndroidTools.java
android/sdl_android/src/main/java/com/smartdevicelink/transport/UsbTransferProvider.java
Outdated
Show resolved
Hide resolved
try { | ||
pendingIntent.send(context, 0, cachedIntent); | ||
} catch (PendingIntent.CanceledException e) { | ||
e.printStackTrace(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's currently no call to unregister this receiver so it will potentially leak. Changed the caught exception to a generic one as well in case something happens during unregistering.
try { | |
pendingIntent.send(context, 0, cachedIntent); | |
} catch (PendingIntent.CanceledException e) { | |
e.printStackTrace(); | |
} | |
try { | |
pendingIntent.send(context, 0, cachedIntent); | |
context.unregisterReceiver(this); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} |
android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlReceiver.java
Outdated
Show resolved
Hide resolved
android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlReceiver.java
Outdated
Show resolved
Hide resolved
android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlReceiver.java
Outdated
Show resolved
Hide resolved
android/sdl_android/src/main/java/com/smartdevicelink/util/AndroidTools.java
Outdated
Show resolved
Hide resolved
android/sdl_android/src/main/java/com/smartdevicelink/util/AndroidTools.java
Outdated
Show resolved
Hide resolved
android/sdl_android/src/main/java/com/smartdevicelink/util/AndroidTools.java
Outdated
Show resolved
Hide resolved
android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlReceiver.java
Outdated
Show resolved
Hide resolved
android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java
Show resolved
Hide resolved
…to startSdlServiceIntent, remove unused import in SdlReceiver
…orid 14. Don't use get in For loop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like one last missed change request from the previous review
try { | ||
pendingIntentToStartService.send(context, 0, startSdlServiceIntent); | ||
} catch (PendingIntent.CanceledException e) { | ||
e.printStackTrace(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was missed from previous review.
try { | |
pendingIntentToStartService.send(context, 0, startSdlServiceIntent); | |
} catch (PendingIntent.CanceledException e) { | |
e.printStackTrace(); | |
} | |
} | |
try { | |
pendingIntentToStartService.send(context, 0, startSdlServiceIntent); | |
context.unregisterReceiver(this); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, looks like I made the this change in the wrong spot
Fixes #1859
This PR is ready for review.
Risk
This PR makes minor API changes.
Testing Plan
Unit Tests
Unit tests were run on the integration branch. CI check failed due to needing the app to target API 34.
Core Tests
Note: Before you install a second and third app, unplug the phone from the computer and switch the build variant before deploying the app to the phone otherwise Android Studio will kill the app.
Apps A, B and C.
Test 1:
Install App A
Accept BT permission
Install App B
Deny BT permission
Connect to TDK via AOA
Select App A to receive intent
Allow App B to connect when prompted
Observe: App B pass hosting the RS to app A and both apps connect.
Test 2:
Install App A
Deny BT permission
Install App B
Deny BT permission
Connect to TDK via AOA
Select App A to receive intent
Allow App B to connect when prompted
Observe App B passed hosting the RS to app A and both apps connect.
Test 3:
Install App A
Deny BT permission
Install App B
Deny BT permission
Install App C
Deny BT permission
Connect to TDK via AOA
Select App A to receive intent
Allow App C to connect when prompted
Allow App B to connect if you're prompted.(not 100%)
Observe App C passed hosting the RS to App B who passed to App A and Apps A and C are connected. App B may not connect.
Core version / branch / commit hash / module tested against: Sync 3
HMI name / version / branch / commit hash / module tested against: Sync 3
Summary
This pr adds the foreground service type of connectedDevice to our library. This is a requirement for Android 14.
With this addition, we are required to have either the Bluetooth Connect permission or call UsbManager.requestPermission() to have our service enter the foreground. if the connection is AOA and an app selected to host the RouterService does not have either permission, we will try to pass hosting the RouterService off to another app.
I also add the ability to be able to request the usb permission in SdlReceiver.onSdlEnabled in the event that
Changelog
Bug Fixes
CLA