Skip to content

Commit 9946777

Browse files
Merge pull request #1360 from smartdevicelink/hotfix/issue_1351
Fix #1351
2 parents b7a905e + b6a0a62 commit 9946777

File tree

6 files changed

+84
-66
lines changed

6 files changed

+84
-66
lines changed

CHANGELOG.md

Lines changed: 3 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 4.11.0 Release Notes
1+
# 4.11.1 Release Notes
22

33
### Summary:
44
||Version|
@@ -7,62 +7,6 @@
77
| **RPC** |6.0.0
88
| **Tested Targeting** |Android 29
99

10-
## Features
10+
## Hotfix
1111

12-
- [[SDL 0234] Proxy Library RPC Generation](https://github.com/smartdevicelink/sdl_java_suite/issues/1090)
13-
14-
- [[SDL 0124] SDLImageUploadManager](https://github.com/smartdevicelink/sdl_java_suite/issues/1326)
15-
16-
- [[SDL 0191] Retry Failed File Uploads](https://github.com/smartdevicelink/sdl_java_suite/issues/830)
17-
18-
- [[SDL 0220] Support for Android custom RouterService](https://github.com/smartdevicelink/sdl_java_suite/issues/1079)
19-
20-
- [Use GitHub Actions ](https://github.com/smartdevicelink/sdl_java_suite/pull/1233)
21-
22-
23-
## Enhancements
24-
25-
- [Align SystemCapabilityManager with iOS](https://github.com/smartdevicelink/sdl_java_suite/issues/1324)
26-
27-
- [SystemCapabilityManager doesn't fully support capability subscriptions ](https://github.com/smartdevicelink/sdl_java_suite/issues/1255)
28-
29-
- [Align Video Streaming State with iOS](https://github.com/smartdevicelink/sdl_java_suite/issues/1331)
30-
31-
- [SoftButtonObject override Equals method](https://github.com/smartdevicelink/sdl_java_suite/issues/1257)
32-
33-
- [Lock Screen Icon is not cached](https://github.com/smartdevicelink/sdl_java_suite/issues/1316)
34-
35-
- [Update License to 2020](https://github.com/smartdevicelink/sdl_java_suite/issues/1264)
36-
37-
38-
## Bug Fixes
39-
40-
- [Inconsistently in ScreenManager behavior if displayCapabilities is null](https://github.com/smartdevicelink/sdl_java_suite/issues/1310)
41-
42-
- [Remove left over code in hellosdl](https://github.com/smartdevicelink/sdl_java_suite/pull/1330)
43-
44-
- [VideoStreaming does not start during HMI Level "LIMITED".](https://github.com/smartdevicelink/sdl_java_suite/issues/1289)
45-
46-
- [Scale Workaround for legacy high-res displays](https://github.com/smartdevicelink/sdl_java_suite/issues/1282)
47-
48-
- [Refactor router service's exitForeground logic](https://github.com/smartdevicelink/sdl_java_suite/pull/1311)
49-
50-
- [No Overwrite property for SdlFiles](https://github.com/smartdevicelink/sdl_java_suite/issues/1302)
51-
52-
- [Deprecate DeviceInfo.DEVICE_OS](https://github.com/smartdevicelink/sdl_java_suite/issues/1290)
53-
54-
- [Missing enums ](https://github.com/smartdevicelink/sdl_java_suite/issues/1283)
55-
56-
- [BaseFileManager UploadFiles handles static icons differently then UploadFile](https://github.com/smartdevicelink/sdl_java_suite/issues/1284)
57-
58-
- [USB transport drops remaining data after PSM FINISHED or ERROR state](https://github.com/smartdevicelink/sdl_java_suite/issues/1279)
59-
60-
- [Delete notification channel when possible](https://github.com/smartdevicelink/sdl_java_suite/pull/1271)
61-
62-
- [Null pointer exception in startStream if hapticSpatialDataSupported is missing](https://github.com/smartdevicelink/sdl_java_suite/issues/1245)
63-
64-
- [Issue in VoiceCommandManager.setVoiceCommands()](https://github.com/smartdevicelink/sdl_java_suite/issues/1293)
65-
66-
- [Video streaming doesn't start again after closing the app using voice commands](https://github.com/smartdevicelink/sdl_java_suite/issues/1248)
67-
68-
- [Potential NPE in TextAndGraphicManager](https://github.com/smartdevicelink/sdl_java_suite/issues/1237)
12+
- [Samsung devices not properly managing notification channels](https://github.com/smartdevicelink/sdl_java_suite/issues/1351)

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.11.0
1+
4.11.1

android/sdl_android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ android {
77
defaultConfig {
88
minSdkVersion 8
99
targetSdkVersion 29
10-
versionCode 12
10+
versionCode 13
1111
versionName new File(projectDir.path, ('/../../VERSION')).text.trim()
1212
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1313
resValue "string", "SDL_LIB_VERSION", '\"' + versionName + '\"'

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

Lines changed: 77 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,16 @@
6363
import android.os.Handler;
6464
import android.os.IBinder;
6565
import android.os.IBinder.DeathRecipient;
66+
import android.os.Looper;
6667
import android.os.Message;
6768
import android.os.Messenger;
6869
import android.os.Parcel;
6970
import android.os.ParcelFileDescriptor;
7071
import android.os.Parcelable;
7172
import android.os.RemoteException;
72-
import android.service.notification.StatusBarNotification;
7373
import android.support.annotation.NonNull;
7474
import android.support.v4.app.NotificationCompat;
75+
import android.util.AndroidRuntimeException;
7576
import android.util.Log;
7677
import android.util.SparseArray;
7778
import android.util.SparseIntArray;
@@ -139,7 +140,7 @@ public class SdlRouterService extends Service{
139140
/**
140141
* <b> NOTE: DO NOT MODIFY THIS UNLESS YOU KNOW WHAT YOU'RE DOING.</b>
141142
*/
142-
protected static final int ROUTER_SERVICE_VERSION_NUMBER = 11;
143+
protected static final int ROUTER_SERVICE_VERSION_NUMBER = 12;
143144

144145
private static final String ROUTER_SERVICE_PROCESS = "com.smartdevicelink.router";
145146

@@ -185,11 +186,18 @@ public class SdlRouterService extends Service{
185186
* Preference location where the service stores known SDL status based on device address
186187
*/
187188
protected static final String SDL_DEVICE_STATUS_SHARED_PREFS = "sdl.device.status";
189+
/**
190+
* Preference location where generic key/values can be stored
191+
*/
192+
protected static final String SDL_ROUTER_SERVICE_PREFS = "sdl.router.service.prefs";
193+
protected static final String KEY_AVOID_NOTIFICATION_CHANNEL_DELETE = "avoidNotificationChannelDelete";
194+
188195

189196

190197

191198
private static boolean connectAsClient = false;
192199
private static boolean closing = false;
200+
private static Thread.UncaughtExceptionHandler routerServiceExceptionHandler = null;
193201

194202
private Handler altTransportTimerHandler, foregroundTimeoutHandler;
195203
private Runnable altTransportTimerRunnable, foregroundTimeoutRunnable;
@@ -1099,6 +1107,8 @@ private boolean initCheck(){
10991107
@Override
11001108
public void onCreate() {
11011109
super.onCreate();
1110+
//Add this first to avoid the runtime exceptions for the entire lifecycle of the service
1111+
setRouterServiceExceptionHandler();
11021112
//This must be done regardless of if this service shuts down or not
11031113
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
11041114
hasCalledStartForeground = false;
@@ -1196,6 +1206,43 @@ public void startUpSequence(){
11961206
startSequenceComplete= true;
11971207
}
11981208

1209+
/**
1210+
* This method will set a new UncaughtExceptionHandler for the current thread. The only
1211+
* purpose of the custom UncaughtExceptionHandler is to catch the rare occurrence that the
1212+
* a specific mobile device/OS can't properly handle the deletion and creation of the foreground
1213+
* notification channel that is necessary for foreground services after Android Oreo.
1214+
* The new UncaughtExceptionHandler will catch that specific exception and tell the
1215+
* main looper to continue forward. This still leaves the SdlRouterService killed, but prevents
1216+
* an ANR to the app that makes the startForegroundService call. It will set a flag that will
1217+
* prevent the channel from being deleted in the future and therefore avoiding this exception.
1218+
*/
1219+
protected void setRouterServiceExceptionHandler() {
1220+
final Thread.UncaughtExceptionHandler defaultUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
1221+
if (defaultUncaughtExceptionHandler != routerServiceExceptionHandler) {
1222+
routerServiceExceptionHandler = new Thread.UncaughtExceptionHandler() {
1223+
@Override
1224+
public void uncaughtException(Thread t, Throwable e) {
1225+
if (e != null
1226+
&& e instanceof AndroidRuntimeException
1227+
&& "android.app.RemoteServiceException".equals(e.getClass().getName()) //android.app.RemoteServiceException is a private class
1228+
&& e.getMessage().contains("invalid channel for service notification")) { //This is the message received in the exception for notification channel issues
1229+
1230+
// Set the flag to not delete the notification channel to avoid this exception in the future
1231+
try{
1232+
SdlRouterService.this.setSdlRouterServicePrefs(KEY_AVOID_NOTIFICATION_CHANNEL_DELETE, true);
1233+
}catch (Exception exception){
1234+
//Unable to save flag for KEY_AVOID_NOTIFICATION_CHANNEL_DELETE
1235+
}
1236+
Looper.loop();
1237+
} else if (defaultUncaughtExceptionHandler != null) { //No other exception should be handled
1238+
defaultUncaughtExceptionHandler.uncaughtException(t, e);
1239+
}
1240+
}
1241+
};
1242+
Thread.setDefaultUncaughtExceptionHandler(routerServiceExceptionHandler);
1243+
}
1244+
}
1245+
11991246

12001247
@SuppressLint({"NewApi", "MissingPermission"})
12011248
@Override
@@ -1528,7 +1575,7 @@ private void exitForeground(){
15281575
if (notificationManager!= null){
15291576
try {
15301577
notificationManager.cancelAll();
1531-
if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
1578+
if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && !getBooleanPref(KEY_AVOID_NOTIFICATION_CHANNEL_DELETE,false)) {
15321579
notificationManager.deleteNotificationChannel(SDL_NOTIFICATION_CHANNEL_ID);
15331580
}
15341581
} catch (Exception e) {
@@ -2445,6 +2492,33 @@ protected boolean hasSDLConnected(String address){
24452492
return preferences.contains(address) && preferences.getBoolean(address,false);
24462493
}
24472494

2495+
/**
2496+
* Set specific settings through key/value to the SDL_ROUTER_SERVICE_PREFS
2497+
* @param key the key of the pair to set in the preferences
2498+
* @param value boolean to attach to key in the preferences
2499+
*/
2500+
protected void setSdlRouterServicePrefs(String key, boolean value){
2501+
SharedPreferences preferences = this.getSharedPreferences(SDL_ROUTER_SERVICE_PREFS, Context.MODE_PRIVATE);
2502+
SharedPreferences.Editor editor = preferences.edit();
2503+
editor.putBoolean(key,value);
2504+
editor.commit();
2505+
Log.d(TAG, "Preference set: " + key + " : " + value);
2506+
}
2507+
2508+
/**
2509+
* Retrieves a boolean value for the given key in the SDL_ROUTER_SERVICE_PREFS
2510+
* @param key the string key that will be used to retrieve the boolean value
2511+
* @param defaultValue if they key does not exist or there is no value to be found, this is the
2512+
* value that will be returned
2513+
* @return the value associated with the supplied key or defaultValue if one does not exist
2514+
*/
2515+
protected boolean getBooleanPref(String key, boolean defaultValue){
2516+
SharedPreferences preferences = this.getSharedPreferences(SDL_ROUTER_SERVICE_PREFS, Context.MODE_PRIVATE);
2517+
if(preferences != null){
2518+
return preferences.getBoolean(key, defaultValue);
2519+
}
2520+
return false;
2521+
}
24482522

24492523

24502524
/* ***********************************************************************************************************************************************************************

android/sdl_android/src/main/res/values/sdl.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<resources>
33
<string name="sdl_router_service_version_name" translatable="false">sdl_router_version</string>
44

5-
<integer name="sdl_router_service_version_value">11</integer>
5+
<integer name="sdl_router_service_version_value">12</integer>
66

77
<string name="sdl_router_service_is_custom_name" translatable="false">sdl_custom_router</string>
88
</resources>

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

Lines changed: 1 addition & 1 deletion
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 = "4.11.0";
35+
public static final String VERSION_NAME = "4.11.1";
3636
}

0 commit comments

Comments
 (0)