Skip to content

Commit e1e485c

Browse files
committed
Add safeguards where RS ClassCastException occurs
1 parent c3c6b60 commit e1e485c

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3266,10 +3266,18 @@ protected void unregisterAllTransports(int sessionId) {
32663266
private TransportType getCompatPrimaryTransport() {
32673267
synchronized (TRANSPORT_LOCK) {
32683268
if (this.registeredTransports != null && this.registeredTransports.size() > 0) {
3269-
List<TransportType> transportTypes = this.registeredTransports.valueAt(0);
3270-
if (transportTypes != null) {
3271-
if (transportTypes.get(0) != null) {
3272-
return transportTypes.get(0);
3269+
Object obj = this.registeredTransports.valueAt(0);
3270+
//Lint shows to ignore this call, but there are crash logs that show otherwise
3271+
if (obj != null && obj instanceof List) {
3272+
try {
3273+
List<TransportType> transportTypes = (List<TransportType>) obj;
3274+
if (transportTypes != null) {
3275+
if (transportTypes.get(0) != null) {
3276+
return transportTypes.get(0);
3277+
}
3278+
}
3279+
} catch (ClassCastException e) {
3280+
DebugTool.logError(TAG, "Unable to cast transport list", e);
32733281
}
32743282
}
32753283
}

0 commit comments

Comments
 (0)