Skip to content

Commit b467c07

Browse files
authored
change setForegroundExceptionHandler to catch foreground exception (#1849)
1 parent 19187e9 commit b467c07

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ public void onReceive(Context context, Intent intent) {
129129

130130
if (action.equalsIgnoreCase(TransportConstants.ACTION_USB_ACCESSORY_ATTACHED)) {
131131
DebugTool.logInfo(TAG, "Usb connected");
132+
setForegroundExceptionHandler();
132133
intent.setAction(null);
133134
onSdlEnabled(context, intent);
134135
return;
@@ -189,6 +190,7 @@ public void onListObtained(boolean successful) {
189190
finalIntent.putExtra(UsbManager.EXTRA_ACCESSORY, (Parcelable) null);
190191
}
191192
}
193+
setForegroundExceptionHandler();
192194
onSdlEnabled(finalContext, finalIntent);
193195
}
194196

@@ -421,7 +423,7 @@ static protected void setForegroundExceptionHandler() {
421423
public void uncaughtException(Thread t, Throwable e) {
422424
if (e != null
423425
&& e instanceof AndroidRuntimeException
424-
&& ("android.app.RemoteServiceException".equals(e.getClass().getName()) || "android.app.ForegroundServiceDidNotStartInTimeException".equals(e.getClass().getName())) //android.app.RemoteServiceException is a private class
426+
&& ("android.app.RemoteServiceException".equals(e.getClass().getName()) || e.getClass().getName().contains("ForegroundService")) //android.app.RemoteServiceException is a private class
425427
&& e.getMessage() != null
426428
&& (e.getMessage().contains("SdlRouterService") || e.getMessage().contains(serviceName))) {
427429
DebugTool.logInfo(TAG, "Handling failed startForegroundService call");

0 commit comments

Comments
 (0)