Skip to content
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

Hot Fix for #1839. Adding fallback logic for starting router service #1840

Merged
merged 6 commits into from
Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ jobs:
- name: Sdl JavaEE Tests
run: ./javaEE/gradlew -p ./javaEE/javaEE test

- name: RPC Generator Tests
run: |
python3 -m pip install -r ./generator/requirements.txt
python3 ./generator/test/runner.py

- name: Codecov
uses: codecov/[email protected]
with:
Expand Down
32 changes: 8 additions & 24 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,13 @@
# 5.6.0 Release Notes
# 5.6.1 Release Notes

## Summary:
||Version|
|--|--|
| **Protocol** | 5.4.1
| **RPC** | 8.0.0
| **Tested Targeting** | Android 33

## Bug Fixes:
|| Version|
|---|---|
| **Protocol** | 5.4.1 |
| **RPC** | 8.0.0 |
| **Tested Targeting** | Android 33 |

- [Images not displaying correctly on Alerts sent via AlertManager](https://github.com/smartdevicelink/sdl_java_suite/issues/1835)

- [TemplateConfiguration not set in currentScreenData in TextAndGraphicManager on RPC >= 6 ](https://github.com/smartdevicelink/sdl_java_suite/issues/1833)

- [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)

- [ForegroundServiceStartNotAllowedException in SdlRouterStatusProvider](https://github.com/smartdevicelink/sdl_java_suite/issues/1829)

- [`DisplayCapabilities` `ScreenParams` null in SystemCapabilityManager](https://github.com/smartdevicelink/sdl_java_suite/issues/1824)

- [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)

- [Android 13 issues](https://github.com/smartdevicelink/sdl_java_suite/issues/1812)

- [ForegroundServiceStartNotAllowedException in SdlRouterService ](https://github.com/smartdevicelink/sdl_java_suite/issues/1815)

- [SdlArtwork clone issue](https://github.com/smartdevicelink/sdl_java_suite/issues/1818)
## Bug Fix / Enhancements:

- [Nearby Devices permission on Android 12 and Above #1839](https://github.com/smartdevicelink/sdl_java_suite/issues/1839)
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.6.0
5.6.1
2 changes: 1 addition & 1 deletion android/sdl_android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 33
versionCode 24
versionCode 25
versionName new File(projectDir.path, ('/../../VERSION')).text.trim()
buildConfigField "String", "VERSION_NAME", '\"' + versionName + '\"'
resValue "string", "SDL_LIB_VERSION", '\"' + versionName + '\"'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,25 +303,33 @@ public void onComplete(Vector<ComponentName> routerServices) {
final boolean sdlDeviceListenerEnabled = SdlDeviceListener.isFeatureSupported(sdlAppInfoList);
if (sdlDeviceListenerEnabled) {
String myPackage = context.getPackageName();
String routerServicePackage = null;
ComponentName routerService = null;
boolean isPreAndroid12RSOnDevice = false;
if (sdlAppInfoList != null && !sdlAppInfoList.isEmpty() && sdlAppInfoList.get(0).getRouterServiceComponentName() != null) {
routerServicePackage = sdlAppInfoList.get(0).getRouterServiceComponentName().getPackageName();
routerService = sdlAppInfoList.get(0).getRouterServiceComponentName();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
isPreAndroid12RSOnDevice = isPreAndroid12RSOnDevice(sdlAppInfoList, context);
// 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
if (!isPreAndroid12RSOnDevice(sdlAppInfoList) && !AndroidTools.isPermissionGranted(BLUETOOTH_CONNECT, context, routerServicePackage) && sdlAppInfoList.size() > 1) {
if (!isPreAndroid12RSOnDevice
&& !AndroidTools.isPermissionGranted(BLUETOOTH_CONNECT, context, routerService.getPackageName())
&& sdlAppInfoList.size() > 1) {
for (SdlAppInfo appInfo : sdlAppInfoList) {
if (AndroidTools.isPermissionGranted(BLUETOOTH_CONNECT, context, appInfo.getRouterServiceComponentName().getPackageName())) {
//If this app in the list has BT Connect permissions, we want to use that apps RS
routerServicePackage = appInfo.getRouterServiceComponentName().getPackageName();
routerService = appInfo.getRouterServiceComponentName();
break;
}
}
}
}
}
if (routerService == null) {
DebugTool.logError(TAG, "Router service was null, aborting.");
return;
}
DebugTool.logInfo(TAG, ": This app's package: " + myPackage);
DebugTool.logInfo(TAG, ": Router service app's package: " + routerServicePackage);
if (myPackage != null && myPackage.equalsIgnoreCase(routerServicePackage)) {
DebugTool.logInfo(TAG, ": Router service app's package: " + routerService.getPackageName());
if (myPackage != null && myPackage.equalsIgnoreCase(routerService.getPackageName())) {
//If the device is not null the listener should start as well as the
//case where this app was installed after BT connected and is the
//only SDL app installed on the device. (Rare corner case)
Expand All @@ -333,6 +341,16 @@ public void onComplete(Vector<ComponentName> routerServices) {
} else {
DebugTool.logInfo(TAG, "Not starting device listener, bluetooth device is null and other SDL apps installed.");
}
} else if (isPreAndroid12RSOnDevice) {
//If the RS app has the BLUETOOTH_CONNECT permission that means it
//will use its proper flow. If it doesn't, it's router service
//must be started to kick off the chain of staring a valid RS.
if (!AndroidTools.isPermissionGranted(BLUETOOTH_CONNECT, context, routerService.getPackageName())) {
DebugTool.logInfo(TAG, "Starting newest RS because of older version of the library on device.");
startRouterService(context, routerService, false, device, false, vehicleType);
} else {
DebugTool.logInfo(TAG, "Newest RS app should be starting sequence correctly.");
}
} else {
DebugTool.logInfo(TAG, ": Not the app to start the router service nor device listener");
}
Expand Down Expand Up @@ -644,7 +662,9 @@ public boolean onTransportConnected(Context context, BluetoothDevice bluetoothDe
ComponentName routerService = sdlAppInfoList.get(0).getRouterServiceComponentName();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
// 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
if (!isPreAndroid12RSOnDevice(sdlAppInfoList) && !AndroidTools.isPermissionGranted(BLUETOOTH_CONNECT, context, routerService.getPackageName()) && sdlAppInfoList.size() > 1) {
if (!isPreAndroid12RSOnDevice(sdlAppInfoList, context)
&& !AndroidTools.isPermissionGranted(BLUETOOTH_CONNECT, context, routerService.getPackageName())
&& sdlAppInfoList.size() > 1) {
for (SdlAppInfo appInfo : sdlAppInfoList) {
if (AndroidTools.isPermissionGranted(BLUETOOTH_CONNECT, context, appInfo.getRouterServiceComponentName().getPackageName())) {
routerService = appInfo.getRouterServiceComponentName();
Expand Down Expand Up @@ -690,10 +710,27 @@ public static ComponentName consumeQueuedRouterService() {
}
}

private static boolean isPreAndroid12RSOnDevice(List<SdlAppInfo> sdlAppInfoList) {
/**
* This method will check for older versions of the SDL library on the device. Due to older
* libraries not checking for BLUETOOTH_CONNECT before beginning the process of starting the
* router service, they just start the newest router service. This flow is legacy and must be
* respected, however, if those apps do not have the BLUETOOTH_CONNECT permission themselves,
* those apps will never receive the intent that BT has connected and therefore the logic will
* never be used and we can continue to use the new process of start a router service.
*
* @param sdlAppInfoList list of SDL enabled apps on the device
* @param context an instance of a context to use to check permissions on the SDL apps
* @return if a pre v5.4 SDL enabled app is installed on the device and has the BLUETOOTH_CONNECT
* permission.
*/
private static boolean isPreAndroid12RSOnDevice(List<SdlAppInfo> sdlAppInfoList, Context context) {
for (SdlAppInfo appInfo : sdlAppInfoList) {
//If an installed app RS version is older than Android 12 update version (16)
if (appInfo.getRouterServiceVersion() < ANDROID_12_ROUTER_SERVICE_VERSION) {
//However, the app must have BLUETOOTH_CONNECT (Nearby Device) permissions,
//otherwise it doesn't matter
if (appInfo.getRouterServiceVersion() < ANDROID_12_ROUTER_SERVICE_VERSION
&& AndroidTools.isPermissionGranted(BLUETOOTH_CONNECT, context, appInfo.getRouterServiceComponentName().getPackageName())) {
DebugTool.logInfo(TAG, "Found pre-Android 12 RS on device.");
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@

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