summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Grover <joeygrover@gmail.com>2018-08-16 17:16:51 -0400
committerJoey Grover <joeygrover@gmail.com>2018-08-16 17:16:51 -0400
commit0dd17deca426d9346ad381d1fd7f3c15e737e480 (patch)
tree3940b3d7be30ae2b6676d0d49562abc5fcd71d02
parent6af2915528f5f60d7b5cb1cdec79f90e84a708e9 (diff)
downloadsdl_android-0dd17deca426d9346ad381d1fd7f3c15e737e480.tar.gz
Handle older proxies connecting to new RS
Also fix a few issues with service staying open and better exiting of foreground. Added the Router Service Messaging Protocol document. Still needs updates.
-rw-r--r--sdl_android/ROUTER_SERVICE_MESSAGING_PROTOCOL.md70
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/protocol/SdlPacket.java30
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java237
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/transport/TransportBroker.java11
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/transport/TransportConstants.java7
5 files changed, 302 insertions, 53 deletions
diff --git a/sdl_android/ROUTER_SERVICE_MESSAGING_PROTOCOL.md b/sdl_android/ROUTER_SERVICE_MESSAGING_PROTOCOL.md
new file mode 100644
index 000000000..e641b8be2
--- /dev/null
+++ b/sdl_android/ROUTER_SERVICE_MESSAGING_PROTOCOL.md
@@ -0,0 +1,70 @@
+# Router Service Messaging Protocol
+
+This document should aid in the understanding and change log of the messages sent between the client proxy and the router service.
+
+Modifications between versions will likely be breaking and have to be dealt with accordingly as the binder can't handle new parcelable objects or additions to existing parcelable objects. The router service and transport broker will have to handle this appropriately.
+
+All values included are their constant names in the project, not the actual values.
+
+
+## Version 1
+
+First version of the messaging protocol. There is no versioning negotiation or awareness at this point.
+
+__Notes:__
+
+- This version can only handle a single transport. If a different transport connects/disconnects beyond the one being used by the app during the session the router service will not inform the client.
+
+`ROUTER_REGISTER_CLIENT`
+
+`APP_ID_EXTRA_STRING`
+
+`ROUTER_REGISTER_CLIENT_RESPONSE`
+
+`Message.arg1` will be results. Possible results:
+
+- `ROUTER_REGISTER_ALT_TRANSPORT_RESPONSE_SUCESS`
+- `ROUTER_REGISTER_ALT_TRANSPORT_ALREADY_CONNECTED`
+- `ROUTER_SHUTTING_DOWN_NOTIFICATION`
+- `ROUTER_SHUTTING_DOWN_REASON_NEWER_SERVICE`
+
+### Version 1.1
+
+
+## Version 2
+
+Version 2 adds the ability to perform versioning of the messaging protocol between the client app (TransportBroker) and the router service.
+
+
+### Additions
+
+
+###### TransportRecord
+
+`TransportRecord` is a new parcelable object that contains more in depth information about the transport specifics than simply supplying a `TransportType` enum as a string.
+
+### Modifications
+
+###### ROUTER\_REGISTER\_CLIENT
+
+The `ROUTER_REGISTER_CLIENT ` message now includes an integer value with key `ROUTER_MESSAGING_VERSION` that contains the clients max router service messaging protocol version.
+
+
+
+###### SdlPacket
+
+The `SdlPacket` object will now contain the messaging version and a `TransportRecord` entry. The messaging version will help inform
+
+
+###### HARDWARE\_CONNECTION\_EVENT
+
+The `HARDWARE_CONNECTION_EVENT` message has the following changes:
+
+- `Message.arg1` will now contain the actual type of event:
+ - `HARDWARE_CONNECTION_EVENT_CONNECTED`
+ - `HARDWARE_CONNECTION_EVENT_DISCONNECTED`
+- `CURRENT_HARDWARE_CONNECTED` key has been added which has a value of an `ArrayList<TransportRecord`. It will always contain the currently connected hardware from the router service.
+- During a disconnect, `TRANSPORT_DISCONNECTED` key has been added that contains a `` of the transport that previously disconnected
+- The extra from the `HARDWARE_CONNECTION_EVENT` message has been deprecated in favor of `TRANSPORT_DISCONNECTED`.
+
+
diff --git a/sdl_android/src/main/java/com/smartdevicelink/protocol/SdlPacket.java b/sdl_android/src/main/java/com/smartdevicelink/protocol/SdlPacket.java
index 87b4dec4a..2060aeee3 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/protocol/SdlPacket.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/protocol/SdlPacket.java
@@ -73,6 +73,8 @@ public class SdlPacket implements Parcelable{
int priorityCoefficient;
byte[] payload = null;
HashMap<String, Object> bsonPayload;
+
+ int messagingVersion = 1;
TransportType transportType;
public SdlPacket(int version, boolean encryption, int frameType,
@@ -307,6 +309,10 @@ public class SdlPacket implements Parcelable{
return builder.toString();
}
+
+ public void setMessagingVersion(int version){
+ this.messagingVersion = version;
+ }
@@ -314,13 +320,7 @@ public class SdlPacket implements Parcelable{
* *********************************************************** Parceable Overrides *****************************************************************
*****************************************************************************************************************************************************/
- /**
- * Version 2 additions
- * -----------------------------
- * <br>TransportType Included | 1 if included, 0 if not
- * <br>TransportType Name | String of transport type name
- */
- private static final int PARCEL_VERSION = 2;
+
//I think this is FIFO...right?
public SdlPacket(Parcel p) {
@@ -336,11 +336,12 @@ public class SdlPacket implements Parcelable{
payload = new byte[dataSize];
p.readByteArray(payload);
}
+
this.priorityCoefficient = p.readInt();
if(p.dataAvail() > 0) {
- int parcelVersion = p.readInt();
- if(parcelVersion >= 2) {
+ messagingVersion = p.readInt();
+ if(messagingVersion >= 2) {
if (p.readInt() == 1) { //We should have a transport type attached
String transportName = p.readString();
if(transportName != null){
@@ -349,7 +350,6 @@ public class SdlPacket implements Parcelable{
}
}
}
-
}
@@ -376,11 +376,13 @@ public class SdlPacket implements Parcelable{
dest.writeInt(priorityCoefficient);
///Additions after initial creation
- dest.writeInt(PARCEL_VERSION);
+ if(messagingVersion > 1){
+ dest.writeInt(messagingVersion);
- dest.writeInt(transportType!=null? 1 : 0);
- if(transportType != null){
- dest.writeString(transportType.name());
+ dest.writeInt(transportType!=null? 1 : 0);
+ if(transportType != null){
+ dest.writeString(transportType.name());
+ }
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java b/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java
index 1bea816e4..9a61f96a8 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java
@@ -291,7 +291,9 @@ public class SdlRouterService extends Service{
case BluetoothAdapter.STATE_OFF:
Log.d(TAG, "Bluetooth is shutting off, SDL Router Service is closing.");
connectAsClient = false;
- shouldServiceRemainOpen(intent);
+ if(!shouldServiceRemainOpen(intent)){
+ closeSelf();
+ }
return;
default:
break;
@@ -389,9 +391,12 @@ public class SdlRouterService extends Service{
}
break;
}
-
- RegisteredApp app = service.new RegisteredApp(appId,msg.replyTo);
- synchronized(service.REGISTERED_APPS_LOCK){
+
+ int routerMessagingVersion = receivedBundle.getInt(TransportConstants.ROUTER_MESSAGING_VERSION,1);
+
+ RegisteredApp app = service.new RegisteredApp(appId, routerMessagingVersion, msg.replyTo);
+
+ synchronized(service.REGISTERED_APPS_LOCK){
RegisteredApp old = registeredApps.put(app.getAppId(), app);
if(old!=null){
Log.w(TAG, "Replacing already existing app with this app id");
@@ -406,7 +411,9 @@ public class SdlRouterService extends Service{
if(service.isTransportConnected){
ArrayList<TransportRecord> records = service.getConnectedTransports();
returnBundle.putString(TransportConstants.HARDWARE_CONNECTED, records.get(records.size()-1).getType().name());
- returnBundle.putParcelableArrayList(TransportConstants.CURRENT_HARDWARE_CONNECTED,records);
+ if(app.routerMessagingVersion > 1) {
+ returnBundle.putParcelableArrayList(TransportConstants.CURRENT_HARDWARE_CONNECTED, records);
+ }
if(MultiplexBluetoothTransport.currentlyConnectedDevice!=null){
returnBundle.putString(CONNECTED_DEVICE_STRING_EXTRA_NAME, MultiplexBluetoothTransport.currentlyConnectedDevice);
@@ -464,24 +471,7 @@ public class SdlRouterService extends Service{
if(buffAppId == null){
buffAppId = "" + receivedBundle.getLong(TransportConstants.APP_ID_EXTRA, -1);
}
- TransportType transportType = TransportType.valueForString(receivedBundle.getString(TransportConstants.TRANSPORT));
- if(transportType == null){
- /* We check bluetooth first because we assume if this value
- * isn't included it is an older version of the proxy and
- * therefore will be expecting this to be bluetooth.
- */
- if(service.bluetoothTransport != null && service.bluetoothTransport.isConnected()){
- transportType = TransportType.BLUETOOTH;
- } else if(service.usbTransport!= null && service.usbTransport.isConnected()){
- transportType = TransportType.USB;
- } else if(service.tcpTransport != null && service.tcpTransport.isConnected()){
- transportType = TransportType.TCP;
- }
- //Log.d(TAG, "Transport type was null, so router set it to " + transportType.name());
- receivedBundle.putString(TransportConstants.TRANSPORT, transportType.name());
- }else{
- //Log.d(TAG, "Transport type of packet to send: " + transportType.name());
- }
+
RegisteredApp buffApp;
synchronized(service.REGISTERED_APPS_LOCK){
buffApp = registeredApps.get(buffAppId);
@@ -492,6 +482,23 @@ public class SdlRouterService extends Service{
buffApp.handleIncommingClientMessage(receivedBundle);
}else{
//Log.d(TAG, "Write bytes to transport");
+ TransportType transportType = TransportType.valueForString(receivedBundle.getString(TransportConstants.TRANSPORT));
+ if(transportType == null){
+
+ /* We check bluetooth first because we assume if this value
+ * isn't included it is an older version of the proxy and
+ * therefore will be expecting this to be bluetooth.
+ */
+ if(service.bluetoothTransport != null && service.bluetoothTransport.isConnected()){
+ transportType = TransportType.BLUETOOTH;
+ } else if(service.usbTransport!= null && service.usbTransport.isConnected()){
+ transportType = TransportType.USB;
+ } else if(service.tcpTransport != null && service.tcpTransport.isConnected()){
+ transportType = TransportType.TCP;
+ }
+ //Log.d(TAG, "Transport type was null, so router set it to " + transportType.name());
+ receivedBundle.putString(TransportConstants.TRANSPORT, transportType.name());
+ }
service.writeBytesToTransport(receivedBundle);
}
}
@@ -871,15 +878,65 @@ public class SdlRouterService extends Service{
Iterator<RegisteredApp> it = apps.iterator();
while(it.hasNext()){
RegisteredApp app = it.next();
- result = app.sendMessage(message);
- if(result == RegisteredApp.SEND_MESSAGE_ERROR_MESSENGER_DEAD_OBJECT){
- app.close();
- it.remove();
+ //Format the message for the receiving app and appropriate messaging version
+ if(formatMessage(app, message)) {
+ result = app.sendMessage(message);
+ if (result == RegisteredApp.SEND_MESSAGE_ERROR_MESSENGER_DEAD_OBJECT) {
+ app.close();
+ it.remove();
+ }
}
}
}
}
+
+ /**
+ * Formats the message for the app that is to receive it
+ * @param app
+ * @param message
+ * @return if the message should be sent or not
+ */
+ protected boolean formatMessage(RegisteredApp app, Message message){
+ if( app.routerMessagingVersion <= 1){
+ Bundle bundle = message.getData();
+ if (bundle != null){
+ if(message.what == TransportConstants.HARDWARE_CONNECTION_EVENT) {
+
+ switch (message.arg1){
+ case TransportConstants.HARDWARE_CONNECTION_EVENT_CONNECTED:
+ if(app.isRegisteredOnTransport(-1, null)){
+ //App is already registered on a transport and does not need this update
+ return false;
+ }
+ break;
+ case TransportConstants.HARDWARE_CONNECTION_EVENT_DISCONNECTED:
+ if(bundle.containsKey(TransportConstants.HARDWARE_DISCONNECTED)){
+ TransportType transportType = TransportType.valueOf(bundle.getString(TransportConstants.HARDWARE_DISCONNECTED));
+ if(!app.isRegisteredOnTransport(-1, transportType)){
+ //App is not registered on this transport, not sending
+ return false;
+ }
+ }
+ if (bundle.containsKey(TransportConstants.TRANSPORT_DISCONNECTED)) {
+ //Unable to handle new parcel TransportRecord
+ bundle.remove(TransportConstants.TRANSPORT_DISCONNECTED);
+ }
+ break;
+ }
+
+ //All connection event messages should have this as part of the bundle
+ if (bundle.containsKey(TransportConstants.CURRENT_HARDWARE_CONNECTED)) {
+ //Unable to handle new parcel TransportRecord
+ bundle.remove(TransportConstants.CURRENT_HARDWARE_CONNECTED);
+ }
+
+
+ }
+ }
+ }
+ return true;
+ }
@SuppressWarnings("unused")
private void pingClients(){
@@ -1087,7 +1144,9 @@ public class SdlRouterService extends Service{
}
}
}
- shouldServiceRemainOpen(intent);
+ if(!shouldServiceRemainOpen(intent)){
+ closeSelf();
+ }
return super.onStartCommand(intent, flags, startId);
}
@@ -1360,8 +1419,9 @@ public class SdlRouterService extends Service{
*/
public boolean shouldServiceRemainOpen(Intent intent){
//Log.d(TAG, "Determining if this service should remain open");
+ ArrayList<TransportRecord> connectedTransports = getConnectedTransports();
- if(!getConnectedTransports().isEmpty()){ // stay open if we have any transports connected
+ if(connectedTransports != null && !connectedTransports.isEmpty()){ // stay open if we have any transports connected
Log.d(TAG, "1 or more transports connected, remaining open");
return true;
}else if(altTransportService!=null || altTransportTimerHandler !=null){
@@ -1376,8 +1436,8 @@ public class SdlRouterService extends Service{
}else if(!bluetoothAvailable()){//If bluetooth isn't on...there's nothing to see here
//Bluetooth is off, we should shut down
Log.d(TAG, "Bluetooth not available, shutting down service");
- closeSelf();
- return false;
+
+ return connectedTransports.size() > 0; //If a transport is connected the list will be >0
}else{
Log.d(TAG, "Service to remain open");
return true;
@@ -1389,11 +1449,14 @@ public class SdlRouterService extends Service{
*/
public void closeSelf(){
closing = true;
+
if(getBaseContext()!=null){
stopSelf();
- }else{
- onDestroy();
}
+
+ //For good measure.
+ onDestroy();
+
}
private synchronized void initBluetoothSerialService(){
if(legacyModeEnabled){
@@ -1461,6 +1524,7 @@ public class SdlRouterService extends Service{
private Message createHardwareConnectedMessage(final TransportRecord record){
Message message = Message.obtain();
message.what = TransportConstants.HARDWARE_CONNECTION_EVENT;
+ message.arg1 = TransportConstants.HARDWARE_CONNECTION_EVENT_CONNECTED;
Bundle bundle = new Bundle();
bundle.putString(TransportConstants.HARDWARE_CONNECTED, record.getType().name());
bundle.putParcelableArrayList(TransportConstants.CURRENT_HARDWARE_CONNECTED, getConnectedTransports());
@@ -1482,6 +1546,8 @@ public class SdlRouterService extends Service{
if(registeredApps != null && !registeredApps.isEmpty()){
Message message = Message.obtain();
message.what = TransportConstants.HARDWARE_CONNECTION_EVENT;
+ message.arg1 = TransportConstants.HARDWARE_CONNECTION_EVENT_DISCONNECTED;
+
Bundle bundle = new Bundle();
bundle.putParcelable(TRANSPORT_DISCONNECTED, record);
//For legacy
@@ -1499,6 +1565,11 @@ public class SdlRouterService extends Service{
// Updates notification to one of still connected transport
enterForeground("Connected to " + transports.get(transports.size() - 1),0);
return;
+ }else{
+ exitForeground();//Leave our foreground state as we don't have a connection anymore
+ if(!shouldServiceRemainOpen(null)){
+ closeSelf();
+ }
}
if(altTransportService!=null){ //If we still have an alt transport open, then we don't need to tell the clients to close
@@ -1524,7 +1595,6 @@ public class SdlRouterService extends Service{
isTransportConnected = false;
stopClientPings();
- exitForeground();//Leave our foreground state as we don't have a connection anymore
PacketWriteTaskMaster packetWriteTaskMaster = packetWriteTaskMasterMap.remove(record.getType());
if(packetWriteTaskMaster!=null){
@@ -1854,6 +1924,7 @@ public class SdlRouterService extends Service{
if(packetSize < ByteArrayMessageSpliter.MAX_BINDER_SIZE){ //This is a small enough packet just send on through
//Log.w(TAG, " Packet size is just right " + packetSize + " is smaller than " + ByteArrayMessageSpliter.MAX_BINDER_SIZE + " = " + (packetSize<ByteArrayMessageSpliter.MAX_BINDER_SIZE));
message.what = TransportConstants.ROUTER_RECEIVED_PACKET;
+ packet.setMessagingVersion(app.routerMessagingVersion);
bundle.putParcelable(FORMED_PACKET_EXTRA_NAME, packet);
bundle.putInt(TransportConstants.BYTES_TO_SEND_FLAGS, TransportConstants.BYTES_TO_SEND_FLAG_NONE);
message.setData(bundle);
@@ -1888,7 +1959,7 @@ public class SdlRouterService extends Service{
}
}else{ //If we can't find a session for this packet we just drop the packet
- Log.e(TAG, "App Id was NULL for session!");
+ Log.e(TAG, "App Id was NULL for session! " + session);
TransportType transportType = packet.getTransportType();
if(removeSessionFromMap(session, Arrays.asList(transportType))){ //If we found the session id still tied to an app in our map we need to remove it and send the proper shutdown sequence.
Log.i(TAG, "Removed session from map. Sending unregister request to module.");
@@ -2084,7 +2155,9 @@ public class SdlRouterService extends Service{
public void run() {
altTransportTimerHandler = null;
altTransportTimerRunnable = null;
- shouldServiceRemainOpen(null);
+ if(!shouldServiceRemainOpen(null)){
+ closeSelf();
+ }
}
};
altTransportTimerHandler.postDelayed(altTransportTimerRunnable, ALT_TRANSPORT_TIMEOUT_RUNNABLE);
@@ -2604,6 +2677,8 @@ public class SdlRouterService extends Service{
final Messenger messenger;
final Vector<Long> sessionIds;
final Vector<TransportType> awaitingSession;
+ final int routerMessagingVersion;
+
ByteAraryMessageAssembler buffer;
int priorityForBuffingMessage;
DeathRecipient deathNote = null;
@@ -2621,6 +2696,7 @@ public class SdlRouterService extends Service{
* @param appId the supplied id for this app that is attempting to register
* @param messenger the specific messenger that is tied to this app
*/
+ @Deprecated
public RegisteredApp(String appId, Messenger messenger){
this.appId = appId;
this.messenger = messenger;
@@ -2630,6 +2706,25 @@ public class SdlRouterService extends Service{
registeredTransports = new SparseArray<ArrayList<TransportType>>();
awaitingSession = new Vector<>();
setDeathNote();
+ routerMessagingVersion = 1;
+ }
+
+ /**
+ * This is a simple class to hold onto a reference of a registered app.
+ * @param appId the supplied id for this app that is attempting to register
+ * @param routerMessagingVersion
+ * @param messenger the specific messenger that is tied to this app
+ */
+ public RegisteredApp(String appId, int routerMessagingVersion, Messenger messenger){
+ this.appId = appId;
+ this.messenger = messenger;
+ this.sessionIds = new Vector<Long>();
+ this.queues = new HashMap<>();
+ queueWaitHandler = new Handler();
+ registeredTransports = new SparseArray<ArrayList<TransportType>>();
+ awaitingSession = new Vector<>();
+ setDeathNote(); //messaging Version
+ this.routerMessagingVersion = routerMessagingVersion;
}
@@ -2703,7 +2798,10 @@ public class SdlRouterService extends Service{
*/
public void setSessionId(int position,long sessionId) throws ArrayIndexOutOfBoundsException {
this.sessionIds.set(position, sessionId);
- this.registeredTransports.put((int)sessionId, new ArrayList<TransportType>());
+ Log.d(TAG, "Set session id: " + sessionId);
+ synchronized (TRANSPORT_LOCK){
+ this.registeredTransports.put((int)sessionId, new ArrayList<TransportType>());
+ }
}
@SuppressWarnings("unused")
@@ -2716,6 +2814,7 @@ public class SdlRouterService extends Service{
}
protected void registerTransport(int sessionId, TransportType transportType){
+ Log.d(TAG, appId + " app id " + sessionId + " session regisistering transport: " + transportType);
synchronized (TRANSPORT_LOCK){
ArrayList<TransportType> transportTypes = this.registeredTransports.get(sessionId);
if(transportTypes!= null){
@@ -2729,10 +2828,41 @@ public class SdlRouterService extends Service{
}
}
+ /**
+ *
+ * @param sessionId the session id to find if a transport is registered. -1 for sessionId will
+ * trigger a search through all sessions.
+ * @param transportType the transport type to find if a transport is registered. If null is
+ * passed, will return true for any transport being registered on
+ * @return
+ */
protected boolean isRegisteredOnTransport(int sessionId, TransportType transportType){
synchronized (TRANSPORT_LOCK){
if(this.registeredTransports.indexOfKey(sessionId) >= 0){
+ if(transportType == null){
+ return this.registeredTransports.get(sessionId).size() > 0;
+ }
return this.registeredTransports.get(sessionId).indexOf(transportType) >= 0;
+ }else if(sessionId < 0 ){
+
+ //Check if any session is registered on this transport
+ int numberOfSessions = registeredTransports.size();
+ ArrayList<TransportType> transportTypes;
+ for(int i = 0; i < numberOfSessions; i++){
+ transportTypes = registeredTransports.valueAt(i);
+ if(transportTypes != null) {
+ if(transportType == null && transportTypes.size() > 0){
+ return true;
+ }
+ for (TransportType type : transportTypes) {
+ if (type.equals(transportType)) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+
}else{
return false;
}
@@ -2772,10 +2902,43 @@ public class SdlRouterService extends Service{
}
}
+
+ /**
+ * This method will attempt to return a transport type that can be associated to this
+ * registered app
+ * @return
+ */
+ private TransportType getCompatPrimaryTransport(){
+ if(this.registeredTransports != null){
+ List<TransportType> transportTypes = this.registeredTransports.valueAt(0);
+ if(transportTypes != null){
+ if(transportTypes.get(0) != null){
+ return transportTypes.get(0);
+ }
+ }
+ }
+
+ //No transport stored
+ if(bluetoothTransport != null && bluetoothTransport.isConnected()){
+ return TransportType.BLUETOOTH;
+ } else if(usbTransport!= null && usbTransport.isConnected()){
+ return TransportType.USB;
+ } else if(tcpTransport != null && tcpTransport.isConnected()){
+ return TransportType.TCP;
+ }
+
+ return TransportType.BLUETOOTH;
+ }
+
@SuppressWarnings("SameReturnValue")
public boolean handleIncommingClientMessage(final Bundle receivedBundle){
int flags = receivedBundle.getInt(TransportConstants.BYTES_TO_SEND_FLAGS, TransportConstants.BYTES_TO_SEND_FLAG_NONE);
TransportType transportType = TransportType.valueForString(receivedBundle.getString(TransportConstants.TRANSPORT));
+ if(transportType == null){
+ transportType = getCompatPrimaryTransport();
+ receivedBundle.putString(TransportConstants.TRANSPORT, transportType.name());
+ Log.d(TAG, "Setting transport as: " + transportType);
+ }
if(flags!=TransportConstants.BYTES_TO_SEND_FLAG_NONE){
byte[] packet = receivedBundle.getByteArray(TransportConstants.BYTES_TO_SEND_EXTRA_NAME);
diff --git a/sdl_android/src/main/java/com/smartdevicelink/transport/TransportBroker.java b/sdl_android/src/main/java/com/smartdevicelink/transport/TransportBroker.java
index e3b73593d..4fa1792ba 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/transport/TransportBroker.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/transport/TransportBroker.java
@@ -35,6 +35,15 @@ import java.util.Locale;
public class TransportBroker {
private static final String TAG = "SdlTransportBroker";
+
+ /**
+ * Version 2 additions
+ * -----------------------------
+ * <br>TransportRecord as a parcel
+ */
+ private static final int MAX_MESSAGING_VERSION = 2;
+ private static final int MIN_MESSAGING_VERSION = 1;
+
private final String WHERE_TO_REPLY_PREFIX = "com.sdl.android.";
private String appId = null;
private String whereToReply = null;
@@ -57,6 +66,7 @@ public class TransportBroker {
private ServiceConnection routerConnection;
private int routerServiceVersion = 1;
+ private int messagingVersion = MAX_MESSAGING_VERSION;
private void initRouterConnection(){
routerConnection= new ServiceConnection() {
@@ -582,6 +592,7 @@ public class TransportBroker {
Bundle bundle = new Bundle();
bundle.putLong(TransportConstants.APP_ID_EXTRA,convertAppId(appId)); //We send this no matter what due to us not knowing what router version we are connecting to
bundle.putString(TransportConstants.APP_ID_EXTRA_STRING, appId);
+ bundle.putInt(TransportConstants.ROUTER_MESSAGING_VERSION, messagingVersion);
msg.setData(bundle);
sendMessageToRouterService(msg);
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/transport/TransportConstants.java b/sdl_android/src/main/java/com/smartdevicelink/transport/TransportConstants.java
index f9ac693cd..a97ac7e52 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/transport/TransportConstants.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/transport/TransportConstants.java
@@ -31,12 +31,13 @@ public class TransportConstants {
public static final String FORCE_TRANSPORT_CONNECTED = "force_connect"; //This is legacy, do not refactor this.
public static final String ROUTER_SERVICE_VALIDATED = "router_service_validated";
-
+ @Deprecated
public static final String REPLY_TO_INTENT_EXTRA = "ReplyAddress";
public static final String CONNECT_AS_CLIENT_BOOLEAN_EXTRA = "connectAsClient";
public static final String PACKAGE_NAME_STRING = "package.name";
public static final String APP_ID_EXTRA = "app.id";//Sent as a Long. This is no longer used
public static final String APP_ID_EXTRA_STRING = "app.id.string";
+ public static final String ROUTER_MESSAGING_VERSION = "router.messaging.version";
public static final String SESSION_ID_EXTRA = "session.id";
@@ -146,7 +147,9 @@ public class TransportConstants {
* attached to the message
*/
public static final int HARDWARE_CONNECTION_EVENT = 0x05;
-
+ public static final int HARDWARE_CONNECTION_EVENT_CONNECTED = 0x10;
+ public static final int HARDWARE_CONNECTION_EVENT_DISCONNECTED = 0x30;
+
public static final int ROUTER_REQUEST_BT_CLIENT_CONNECT = 0x10;
public static final int ROUTER_REQUEST_BT_CLIENT_CONNECT_RESPONSE = 0x11;