Skip to content

Commit a924127

Browse files
authored
Merge pull request #1840 from smartdevicelink/hotfix/issue_1839
Hot Fix for #1839. Adding fallback logic for starting router service
2 parents c5b8054 + d424ab2 commit a924127

File tree

6 files changed

+57
-41
lines changed

6 files changed

+57
-41
lines changed

.github/workflows/android.yml

-5
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@ jobs:
3636
- name: Sdl JavaEE Tests
3737
run: ./javaEE/gradlew -p ./javaEE/javaEE test
3838

39-
- name: RPC Generator Tests
40-
run: |
41-
python3 -m pip install -r ./generator/requirements.txt
42-
python3 ./generator/test/runner.py
43-
4439
- name: Codecov
4540
uses: codecov/[email protected]
4641
with:

CHANGELOG.md

+8-24
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,13 @@
1-
# 5.6.0 Release Notes
1+
# 5.6.1 Release Notes
22

33
## Summary:
4-
||Version|
5-
|--|--|
6-
| **Protocol** | 5.4.1
7-
| **RPC** | 8.0.0
8-
| **Tested Targeting** | Android 33
94

10-
## Bug Fixes:
5+
|| Version|
6+
|---|---|
7+
| **Protocol** | 5.4.1 |
8+
| **RPC** | 8.0.0 |
9+
| **Tested Targeting** | Android 33 |
1110

12-
- [Images not displaying correctly on Alerts sent via AlertManager](https://github.com/smartdevicelink/sdl_java_suite/issues/1835)
13-
14-
- [TemplateConfiguration not set in currentScreenData in TextAndGraphicManager on RPC >= 6 ](https://github.com/smartdevicelink/sdl_java_suite/issues/1833)
15-
16-
- [Setting bad data in one T&G field then good data quickly in another can lead to the good data failing.](https://github.com/smartdevicelink/sdl_java_suite/issues/1828)
17-
18-
- [ForegroundServiceStartNotAllowedException in SdlRouterStatusProvider](https://github.com/smartdevicelink/sdl_java_suite/issues/1829)
19-
20-
- [`DisplayCapabilities` `ScreenParams` null in SystemCapabilityManager](https://github.com/smartdevicelink/sdl_java_suite/issues/1824)
21-
22-
- [Media app does not disappear from Sync after bluetooth connection is turned off when USB is plugged in if the app RequiresAudioSupport flag is set to true](https://github.com/smartdevicelink/sdl_java_suite/issues/1802)
23-
24-
- [Android 13 issues](https://github.com/smartdevicelink/sdl_java_suite/issues/1812)
25-
26-
- [ForegroundServiceStartNotAllowedException in SdlRouterService ](https://github.com/smartdevicelink/sdl_java_suite/issues/1815)
27-
28-
- [SdlArtwork clone issue](https://github.com/smartdevicelink/sdl_java_suite/issues/1818)
11+
## Bug Fix / Enhancements:
2912

13+
- [Nearby Devices permission on Android 12 and Above #1839](https://github.com/smartdevicelink/sdl_java_suite/issues/1839)

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5.6.0
1+
5.6.1

android/sdl_android/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ android {
55
defaultConfig {
66
minSdkVersion 16
77
targetSdkVersion 33
8-
versionCode 24
8+
versionCode 25
99
versionName new File(projectDir.path, ('/../../VERSION')).text.trim()
1010
buildConfigField "String", "VERSION_NAME", '\"' + versionName + '\"'
1111
resValue "string", "SDL_LIB_VERSION", '\"' + versionName + '\"'

android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlBroadcastReceiver.java

+46-9
Original file line numberDiff line numberDiff line change
@@ -303,25 +303,33 @@ public void onComplete(Vector<ComponentName> routerServices) {
303303
final boolean sdlDeviceListenerEnabled = SdlDeviceListener.isFeatureSupported(sdlAppInfoList);
304304
if (sdlDeviceListenerEnabled) {
305305
String myPackage = context.getPackageName();
306-
String routerServicePackage = null;
306+
ComponentName routerService = null;
307+
boolean isPreAndroid12RSOnDevice = false;
307308
if (sdlAppInfoList != null && !sdlAppInfoList.isEmpty() && sdlAppInfoList.get(0).getRouterServiceComponentName() != null) {
308-
routerServicePackage = sdlAppInfoList.get(0).getRouterServiceComponentName().getPackageName();
309+
routerService = sdlAppInfoList.get(0).getRouterServiceComponentName();
309310
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
311+
isPreAndroid12RSOnDevice = isPreAndroid12RSOnDevice(sdlAppInfoList, context);
310312
// If all apps have a RS newer than the Android 12 update, chosen app does not have BT Connect permissions, and more than 1 sdl app is installed
311-
if (!isPreAndroid12RSOnDevice(sdlAppInfoList) && !AndroidTools.isPermissionGranted(BLUETOOTH_CONNECT, context, routerServicePackage) && sdlAppInfoList.size() > 1) {
313+
if (!isPreAndroid12RSOnDevice
314+
&& !AndroidTools.isPermissionGranted(BLUETOOTH_CONNECT, context, routerService.getPackageName())
315+
&& sdlAppInfoList.size() > 1) {
312316
for (SdlAppInfo appInfo : sdlAppInfoList) {
313317
if (AndroidTools.isPermissionGranted(BLUETOOTH_CONNECT, context, appInfo.getRouterServiceComponentName().getPackageName())) {
314318
//If this app in the list has BT Connect permissions, we want to use that apps RS
315-
routerServicePackage = appInfo.getRouterServiceComponentName().getPackageName();
319+
routerService = appInfo.getRouterServiceComponentName();
316320
break;
317321
}
318322
}
319323
}
320324
}
321325
}
326+
if (routerService == null) {
327+
DebugTool.logError(TAG, "Router service was null, aborting.");
328+
return;
329+
}
322330
DebugTool.logInfo(TAG, ": This app's package: " + myPackage);
323-
DebugTool.logInfo(TAG, ": Router service app's package: " + routerServicePackage);
324-
if (myPackage != null && myPackage.equalsIgnoreCase(routerServicePackage)) {
331+
DebugTool.logInfo(TAG, ": Router service app's package: " + routerService.getPackageName());
332+
if (myPackage != null && myPackage.equalsIgnoreCase(routerService.getPackageName())) {
325333
//If the device is not null the listener should start as well as the
326334
//case where this app was installed after BT connected and is the
327335
//only SDL app installed on the device. (Rare corner case)
@@ -333,6 +341,16 @@ public void onComplete(Vector<ComponentName> routerServices) {
333341
} else {
334342
DebugTool.logInfo(TAG, "Not starting device listener, bluetooth device is null and other SDL apps installed.");
335343
}
344+
} else if (isPreAndroid12RSOnDevice) {
345+
//If the RS app has the BLUETOOTH_CONNECT permission that means it
346+
//will use its proper flow. If it doesn't, it's router service
347+
//must be started to kick off the chain of staring a valid RS.
348+
if (!AndroidTools.isPermissionGranted(BLUETOOTH_CONNECT, context, routerService.getPackageName())) {
349+
DebugTool.logInfo(TAG, "Starting newest RS because of older version of the library on device.");
350+
startRouterService(context, routerService, false, device, false, vehicleType);
351+
} else {
352+
DebugTool.logInfo(TAG, "Newest RS app should be starting sequence correctly.");
353+
}
336354
} else {
337355
DebugTool.logInfo(TAG, ": Not the app to start the router service nor device listener");
338356
}
@@ -644,7 +662,9 @@ public boolean onTransportConnected(Context context, BluetoothDevice bluetoothDe
644662
ComponentName routerService = sdlAppInfoList.get(0).getRouterServiceComponentName();
645663
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
646664
// If all apps have a RS newer than the Android 12 update, chosen app does not have BT Connect permissions, and more than 1 sdl app is installed
647-
if (!isPreAndroid12RSOnDevice(sdlAppInfoList) && !AndroidTools.isPermissionGranted(BLUETOOTH_CONNECT, context, routerService.getPackageName()) && sdlAppInfoList.size() > 1) {
665+
if (!isPreAndroid12RSOnDevice(sdlAppInfoList, context)
666+
&& !AndroidTools.isPermissionGranted(BLUETOOTH_CONNECT, context, routerService.getPackageName())
667+
&& sdlAppInfoList.size() > 1) {
648668
for (SdlAppInfo appInfo : sdlAppInfoList) {
649669
if (AndroidTools.isPermissionGranted(BLUETOOTH_CONNECT, context, appInfo.getRouterServiceComponentName().getPackageName())) {
650670
routerService = appInfo.getRouterServiceComponentName();
@@ -690,10 +710,27 @@ public static ComponentName consumeQueuedRouterService() {
690710
}
691711
}
692712

693-
private static boolean isPreAndroid12RSOnDevice(List<SdlAppInfo> sdlAppInfoList) {
713+
/**
714+
* This method will check for older versions of the SDL library on the device. Due to older
715+
* libraries not checking for BLUETOOTH_CONNECT before beginning the process of starting the
716+
* router service, they just start the newest router service. This flow is legacy and must be
717+
* respected, however, if those apps do not have the BLUETOOTH_CONNECT permission themselves,
718+
* those apps will never receive the intent that BT has connected and therefore the logic will
719+
* never be used and we can continue to use the new process of start a router service.
720+
*
721+
* @param sdlAppInfoList list of SDL enabled apps on the device
722+
* @param context an instance of a context to use to check permissions on the SDL apps
723+
* @return if a pre v5.4 SDL enabled app is installed on the device and has the BLUETOOTH_CONNECT
724+
* permission.
725+
*/
726+
private static boolean isPreAndroid12RSOnDevice(List<SdlAppInfo> sdlAppInfoList, Context context) {
694727
for (SdlAppInfo appInfo : sdlAppInfoList) {
695728
//If an installed app RS version is older than Android 12 update version (16)
696-
if (appInfo.getRouterServiceVersion() < ANDROID_12_ROUTER_SERVICE_VERSION) {
729+
//However, the app must have BLUETOOTH_CONNECT (Nearby Device) permissions,
730+
//otherwise it doesn't matter
731+
if (appInfo.getRouterServiceVersion() < ANDROID_12_ROUTER_SERVICE_VERSION
732+
&& AndroidTools.isPermissionGranted(BLUETOOTH_CONNECT, context, appInfo.getRouterServiceComponentName().getPackageName())) {
733+
DebugTool.logInfo(TAG, "Found pre-Android 12 RS on device.");
697734
return true;
698735
}
699736
}

javaSE/javaSE/src/main/java/com/smartdevicelink/BuildConfig.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232

3333
// THIS FILE IS AUTO GENERATED, DO NOT MODIFY!!
3434
public final class BuildConfig {
35-
public static final String VERSION_NAME = "5.6.0";
35+
public static final String VERSION_NAME = "5.6.1";
3636
}

0 commit comments

Comments
 (0)