summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBilal Alsharifi <599206+bilal-alsharifi@users.noreply.github.com>2019-05-03 11:22:30 -0400
committerGitHub <noreply@github.com>2019-05-03 11:22:30 -0400
commitb17def774c411f9165f24298dc8032a8105363e7 (patch)
tree58ea3d4340ea6f43cb486d2493c6cbf3271a7a64
parent209c17ebb40a0b552fcc40b084e2f5422f52bf6a (diff)
parentd06ccfc4b5f70543eac64adc9735c8126550fe2b (diff)
downloadsdl_android-b17def774c411f9165f24298dc8032a8105363e7.tar.gz
Merge pull request #1054 from smartdevicelink/bugfix/issue_1051_legacy_mode
Handle origin modules (Rpc Version 1.0 & Protocol Version 1.0)
-rw-r--r--android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java10
-rw-r--r--android/sdl_android/src/main/java/com/smartdevicelink/transport/TransportManager.java67
-rw-r--r--base/src/main/java/com/smartdevicelink/proxy/rpc/DisplayCapabilities.java74
-rw-r--r--base/src/main/java/com/smartdevicelink/proxy/rpc/SoftButtonCapabilities.java75
4 files changed, 154 insertions, 72 deletions
diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java b/android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java
index 1cabf9b89..41a173ee9 100644
--- a/android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java
+++ b/android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java
@@ -6302,8 +6302,14 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
if (sdlMsgVersion == null) {
sdlMsgVersion = new SdlMsgVersion();
- sdlMsgVersion.setMajorVersion(MAX_SUPPORTED_RPC_VERSION.getMajor());
- sdlMsgVersion.setMinorVersion(MAX_SUPPORTED_RPC_VERSION.getMinor());
+ if(protocolVersion.getMajor() == 1) {
+ DebugTool.logInfo("Connected to an older module, must send 1.0.0 as RPC spec");
+ sdlMsgVersion.setMajorVersion(1);
+ sdlMsgVersion.setMinorVersion(0);
+ }else {
+ sdlMsgVersion.setMajorVersion(MAX_SUPPORTED_RPC_VERSION.getMajor());
+ sdlMsgVersion.setMinorVersion(MAX_SUPPORTED_RPC_VERSION.getMinor());
+ }
}
if (languageDesired == null) {
languageDesired = Language.EN_US;
diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/TransportManager.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/TransportManager.java
index ad4b41b84..a2e7cf5cd 100644
--- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/TransportManager.java
+++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/TransportManager.java
@@ -49,6 +49,7 @@ import com.smartdevicelink.protocol.SdlPacket;
import com.smartdevicelink.protocol.enums.ControlFrameTags;
import com.smartdevicelink.transport.enums.TransportType;
import com.smartdevicelink.transport.utl.TransportRecord;
+import com.smartdevicelink.util.DebugTool;
import java.lang.ref.WeakReference;
import java.util.List;
@@ -262,6 +263,7 @@ public class TransportManager extends TransportManagerBase{
protected class TransportBrokerImpl extends TransportBroker{
+ boolean shuttingDown = false;
public TransportBrokerImpl(Context context, String appId, ComponentName routerService){
super(context,appId,routerService);
}
@@ -274,8 +276,12 @@ public class TransportManager extends TransportManagerBase{
}
@Override
- public boolean onHardwareConnected(List<TransportRecord> transports) {
+ public synchronized boolean onHardwareConnected(List<TransportRecord> transports) {
super.onHardwareConnected(transports);
+ DebugTool.logInfo("OnHardwareConnected");
+ if(shuttingDown){
+ return false;
+ }
synchronized (TRANSPORT_STATUS_LOCK){
transportStatus.clear();
transportStatus.addAll(transports);
@@ -286,14 +292,16 @@ public class TransportManager extends TransportManagerBase{
@Override
- public void onHardwareDisconnected(TransportRecord record, List<TransportRecord> connectedTransports) {
+ public synchronized void onHardwareDisconnected(TransportRecord record, List<TransportRecord> connectedTransports) {
if(record != null){
Log.d(TAG, "Transport disconnected - " + record);
}else{
Log.d(TAG, "Transport disconnected");
}
-
+ if(shuttingDown){
+ return;
+ }
synchronized (TRANSPORT_STATUS_LOCK){
boolean wasRemoved = TransportManager.this.transportStatus.remove(record);
//Might check connectedTransports vs transportStatus to ensure they are equal
@@ -328,10 +336,12 @@ public class TransportManager extends TransportManagerBase{
if(isLegacyModeEnabled()
&& record != null
- && TransportType.BLUETOOTH.equals(record.getType()) //Make sure it's bluetooth that has be d/c
- && legacyBluetoothTransport == null){ //Make sure we aren't already in legacy mode
- //Legacy mode has been enabled so we need to cycle
- enterLegacyMode("Router service has enabled legacy mode");
+ && TransportType.BLUETOOTH.equals(record.getType())){ //Make sure it's bluetooth that has be d/c
+ //&& legacyBluetoothTransport == null){ //Make sure we aren't already in legacy mode
+ if(legacyBluetoothTransport == null) {
+ //Legacy mode has been enabled so we need to cycle
+ enterLegacyModeAndStart("Router service has enabled legacy mode");
+ }
}else{
//Inform the transport listener that a transport has disconnected
transportListener.onTransportDisconnected("", record, connectedTransports);
@@ -339,13 +349,52 @@ public class TransportManager extends TransportManagerBase{
}
@Override
+ public synchronized void onLegacyModeEnabled() {
+ if(shuttingDown){
+ return;
+ }
+ if( legacyBluetoothTransport == null){
+ //First remove the connected bluetooth transport if one exists
+ TransportRecord toBeRemoved = null;
+ for (TransportRecord transportRecord : TransportManager.this.transportStatus) {
+ if (TransportType.BLUETOOTH.equals(transportRecord.getType())) {
+ //There was a previously connected bluetooth transport through the router service
+ toBeRemoved = transportRecord;
+ break;
+ }
+ }
+
+ if(toBeRemoved != null){ //Remove item after the loop to avoid concurrent modifications
+ TransportManager.this.transportStatus.remove(toBeRemoved);
+ }
+
+ enterLegacyModeAndStart("Router service has enabled legacy mode");
+ }
+ }
+
+ @Override
public void onPacketReceived(Parcelable packet) {
if(packet!=null){
transportListener.onPacketReceived((SdlPacket)packet);
}
}
+
+ @Override
+ public synchronized void stop() {
+ shuttingDown = true;
+ super.stop();
+ }
}
+ void enterLegacyModeAndStart(final String info){
+ enterLegacyMode(info);
+ if(legacyBluetoothTransport != null
+ && legacyBluetoothTransport.getState() == MultiplexBaseTransport.STATE_NONE){
+ legacyBluetoothTransport.start();
+ }
+ }
+
+
@Override
synchronized void enterLegacyMode(final String info){
if(legacyBluetoothTransport != null && legacyBluetoothHandler != null){
@@ -434,6 +483,10 @@ public class TransportManager extends TransportManagerBase{
// Currently attempting to connect - update UI?
break;
case MultiplexBaseTransport.STATE_LISTEN:
+ if(service.transport != null){
+ service.transport.stop();
+ service.transport = null;
+ }
break;
case MultiplexBaseTransport.STATE_NONE:
// We've just lost the connection
diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/DisplayCapabilities.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/DisplayCapabilities.java
index fc093f0a8..32677230b 100644
--- a/base/src/main/java/com/smartdevicelink/proxy/rpc/DisplayCapabilities.java
+++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/DisplayCapabilities.java
@@ -1,34 +1,34 @@
-/*
- * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
+/*
+ * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
package com.smartdevicelink.proxy.rpc;
import android.support.annotation.NonNull;
@@ -36,6 +36,7 @@ import android.support.annotation.NonNull;
import com.smartdevicelink.proxy.RPCStruct;
import com.smartdevicelink.proxy.rpc.enums.DisplayType;
import com.smartdevicelink.proxy.rpc.enums.MediaClockFormat;
+import com.smartdevicelink.util.Version;
import java.util.Hashtable;
import java.util.List;
@@ -142,6 +143,17 @@ public class DisplayCapabilities extends RPCStruct {
setMediaClockFormats(mediaClockFormats);
setGraphicSupported(graphicSupported);
}
+
+ @Override
+ public void format(Version rpcVersion, boolean formatParams) {
+ super.format(rpcVersion, formatParams);
+ if(!store.containsKey(KEY_GRAPHIC_SUPPORTED)){
+ // At some point this was added to the RPC spec as mandatory but at least in v1.0.0
+ // it was not included.
+ store.put(KEY_GRAPHIC_SUPPORTED, new Boolean(false));
+ }
+ }
+
/**
* Get the type of display
* @return the type of display
diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/SoftButtonCapabilities.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/SoftButtonCapabilities.java
index 27d60290b..af770a1c9 100644
--- a/base/src/main/java/com/smartdevicelink/proxy/rpc/SoftButtonCapabilities.java
+++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/SoftButtonCapabilities.java
@@ -1,39 +1,40 @@
-/*
- * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
+/*
+ * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
package com.smartdevicelink.proxy.rpc;
import android.support.annotation.NonNull;
import com.smartdevicelink.proxy.RPCStruct;
+import com.smartdevicelink.util.Version;
import java.util.Hashtable;
@@ -114,7 +115,17 @@ public class SoftButtonCapabilities extends RPCStruct {
setUpDownAvailable(upDownAvailable);
setImageSupported(imageSupported);
}
-
+
+ @Override
+ public void format(Version rpcVersion, boolean formatParams) {
+ super.format(rpcVersion, formatParams);
+ if(!store.containsKey(KEY_IMAGE_SUPPORTED)){
+ // At some point this was added to the RPC spec as mandatory but at least in v1.0.0
+ // it was not included.
+ store.put(KEY_IMAGE_SUPPORTED, new Boolean(false));
+ }
+ }
+
/**
* set the button supports a short press.
* @param shortPressAvailable whether the button supports a short press.