smartdevicelink / sdl_java_suite

SmartDeviceLink libraries for Android, Java SE, and Java EE
BSD 3-Clause "New" or "Revised" License
186 stars 171 forks source link

Suboptimal Behavior when Force Closing App Running Router Service #470

Open askirk opened 7 years ago

askirk commented 7 years ago

Current Problem Take a situation where three apps A, B, and C are connected to the head unit via Multiplex BT transport, and all through app A's Router Service. When app A is force closed, all apps disconnect from the head unit. Then app B and C reconnect, resorting to using the Legacy BT transport before one of their router service's can start up.

Ideal Behavior Upon force closing app A, a router service from app B or C should start up. B and C should then use that router service to reconnect to the head unit, still using the Multiplex BT transport.

Stacktrace Here's a stacktrace from an example I've run across:

/* App A is Force Closed and Its Router Service is Shut Down. */
/com.app.B E/SdlProxy: VERSION-INFO: Transport failure: 
/com.app.B.r D/RSVP: Supplied service name of com.app.A.SdlRouterService
/com.app.C W/SdlConnection: SDL Router service isn't trusted. Enabling legacy bluetooth connection.
/com.app.B W/SdlConnection: SDL Router service isn't trusted. Enabling legacy bluetooth connection.
/? I/ActivityManager: Start proc 20127:com.smartdevicelink.router/u0a218 for service com.app.C/.SdlRouterService
/? W/Sdl Router Service: Supplied intent was null, local router service will not contain intent
/? I/Sdl Router Service: SDL Router Service has been created
tpulatha commented 7 years ago

This would probably need a proposal for behavior change, right?

joeygrover commented 7 years ago

No, it should work in the optimal way described, but the current behavior doesn't match.

askirk commented 7 years ago

This is where the apps are deciding to fall back on legacy BT:

https://github.com/smartdevicelink/sdl_android/blob/master/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlConnection.java#L97-L106

A possible solution would be to check for any other router services before falling back and enabling legacy BT.