summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Grover <joeygrover@gmail.com>2019-03-14 17:08:45 -0400
committerJoey Grover <joeygrover@gmail.com>2019-03-14 17:08:45 -0400
commit44b1b5d342c1874a6cf5cbceeed07f4a1557a952 (patch)
tree05ab39aab1d1e08d7e105e6f3c1f9e788ebe7e28
parent419f6977efd36920eab6b199f3f251fdf4e22ea7 (diff)
parenta1bd40e23706ec3d15c5bdc51ae17100870b49c0 (diff)
downloadsdl_android-44b1b5d342c1874a6cf5cbceeed07f4a1557a952.tar.gz
Merge branch 'feature/sdl_java_base' of https://github.com/smartdevicelink/sdl_android into feature/fix_mes
# Conflicts: # base/src/main/java/com/smartdevicelink/transport/TransportManager.java # javaSE/src/main/java/com/smartdevicelink/managers/SdlManager.java # javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java
-rw-r--r--android/sdl_android/build.gradle2
-rw-r--r--android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java94
-rw-r--r--base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java4
-rw-r--r--base/src/main/java/com/smartdevicelink/proxy/SystemCapabilityManager.java2
-rw-r--r--base/src/main/java/com/smartdevicelink/transport/TransportManager.java1
-rw-r--r--javaEE/build.gradle2
-rw-r--r--javaEE/src/main/java/hello_sdl_ee/Main.java4
-rw-r--r--javaSE/build.gradle2
-rw-r--r--javaSE/src/main/java/com/smartdevicelink/managers/SdlManager.java23
-rw-r--r--javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java82
-rw-r--r--javaSE/src/main/java/hello_sdl/Main.java30
11 files changed, 193 insertions, 53 deletions
diff --git a/android/sdl_android/build.gradle b/android/sdl_android/build.gradle
index c635abf97..1b0503c55 100644
--- a/android/sdl_android/build.gradle
+++ b/android/sdl_android/build.gradle
@@ -58,7 +58,7 @@ buildscript {
mavenCentral()
}
dependencies {
- classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.1'
+ classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
}
}
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 4341375de..c912ed119 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
@@ -98,7 +98,6 @@ import com.smartdevicelink.transport.enums.TransportType;
import com.smartdevicelink.util.CorrelationIdGenerator;
import com.smartdevicelink.util.DebugTool;
import com.smartdevicelink.util.FileUtls;
-import com.smartdevicelink.util.HttpUtils;
import com.smartdevicelink.util.Version;
import org.json.JSONArray;
@@ -158,6 +157,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
OUTGOING_MESSAGE_QUEUE_THREAD_LOCK = new Object(),
INTERNAL_MESSAGE_QUEUE_THREAD_LOCK = new Object(),
ON_UPDATE_LISTENER_LOCK = new Object(),
+ RPC_LISTENER_LOCK = new Object(),
ON_NOTIFICATION_LISTENER_LOCK = new Object();
private final Object APP_INTERFACE_REGISTERED_LOCK = new Object();
@@ -259,6 +259,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
protected SparseArray<OnRPCResponseListener> rpcResponseListeners = null;
protected SparseArray<CopyOnWriteArrayList<OnRPCNotificationListener>> rpcNotificationListeners = null;
protected SparseArray<CopyOnWriteArrayList<OnRPCRequestListener>> rpcRequestListeners = null;
+ protected SparseArray<CopyOnWriteArrayList<OnRPCListener>> rpcListeners = null;
protected VideoStreamingManager manager; //Will move to SdlSession once the class becomes public
@@ -365,14 +366,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
@Override
public void addOnRPCListener(FunctionID responseId, OnRPCListener listener) {
- DebugTool.logError("Proxy.addOnRPCResponseListener() is not implemented yet");
-
+ SdlProxyBase.this.addOnRPCListener(responseId, listener);
}
@Override
public boolean removeOnRPCListener(FunctionID responseId, OnRPCListener listener) {
- DebugTool.logError("Proxy.removeOnRPCResponseListener() is not implemented yet");
- return false;
+ return SdlProxyBase.this.removeOnRPCListener(responseId, listener);
}
@Override
@@ -940,6 +939,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
rpcResponseListeners = new SparseArray<OnRPCResponseListener>();
rpcNotificationListeners = new SparseArray<CopyOnWriteArrayList<OnRPCNotificationListener>>();
rpcRequestListeners = new SparseArray<CopyOnWriteArrayList<OnRPCRequestListener>>();
+ rpcListeners = new SparseArray<CopyOnWriteArrayList<OnRPCListener>>();
// Initialize the proxy
try {
@@ -2195,6 +2195,20 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
}
@SuppressWarnings("UnusedReturnValue")
+ public boolean onRPCReceived(RPCMessage message){
+ synchronized(RPC_LISTENER_LOCK){
+ CopyOnWriteArrayList<OnRPCListener> listeners = rpcListeners.get(FunctionID.getFunctionId(message.getFunctionName()));
+ if(listeners!=null && listeners.size()>0) {
+ for (OnRPCListener listener : listeners) {
+ listener.onReceived(message);
+ }
+ return true;
+ }
+ return false;
+ }
+ }
+
+ @SuppressWarnings("UnusedReturnValue")
public boolean onRPCRequestReceived(RPCRequest request){
synchronized(ON_NOTIFICATION_LISTENER_LOCK){
CopyOnWriteArrayList<OnRPCRequestListener> listeners = rpcRequestListeners.get(FunctionID.getFunctionId(request.getFunctionName()));
@@ -2227,7 +2241,37 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
}
/**
- * This will ad a listener for the specific type of request. As of now it will only allow
+ * This will add a listener for the specific type of message. As of now it will only allow
+ * a single listener per request function id
+ * @param messageId The message type that this listener is designated for
+ * @param listener The listener that will be called when a request of the provided type is received
+ */
+ @SuppressWarnings("unused")
+ public void addOnRPCListener(FunctionID messageId, OnRPCListener listener){
+ synchronized(RPC_LISTENER_LOCK){
+ if(messageId != null && listener != null){
+ if(rpcListeners.indexOfKey(messageId.getId()) < 0 ){
+ rpcListeners.put(messageId.getId(),new CopyOnWriteArrayList<OnRPCListener>());
+ }
+ rpcListeners.get(messageId.getId()).add(listener);
+ }
+ }
+ }
+
+ public boolean removeOnRPCListener(FunctionID messageId, OnRPCListener listener){
+ synchronized(RPC_LISTENER_LOCK){
+ if(rpcListeners!= null
+ && messageId != null
+ && listener != null
+ && rpcListeners.indexOfKey(messageId.getId()) >= 0){
+ return rpcListeners.get(messageId.getId()).remove(listener);
+ }
+ }
+ return false;
+ }
+
+ /**
+ * This will add a listener for the specific type of request. As of now it will only allow
* a single listener per request function id
* @param requestId The request type that this listener is designated for
* @param listener The listener that will be called when a request of the provided type is received
@@ -2330,25 +2374,33 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
}
private void handleRPCMessage(Hashtable<String, Object> hash) {
- RPCMessage rpcMsg = new RPCMessage(hash);
- //Call format to ensure the RPC is ready to be handled regardless of RPC spec version
+
+ if (hash == null){
+ DebugTool.logError("handleRPCMessage: hash is null, returning.");
+ return;
+ }
+
+ RPCMessage rpcMsg = RpcConverter.convertTableToRpc(hash);
+
+ if (rpcMsg == null){
+ DebugTool.logError("handleRPCMessage: rpcMsg is null, returning.");
+ return;
+ }
+
+ SdlTrace.logRPCEvent(InterfaceActivityDirection.Receive, rpcMsg, SDL_LIB_TRACE_KEY);
+
String functionName = rpcMsg.getFunctionName();
String messageType = rpcMsg.getMessageType();
- SdlTrace.logRPCEvent(InterfaceActivityDirection.Receive, rpcMsg, SDL_LIB_TRACE_KEY);
+ rpcMsg.format(rpcSpecVersion, true);
+
+ onRPCReceived(rpcMsg); // Should only be called for internal use
// Requests need to be listened for using the SDLManager's addOnRPCRequestListener method.
// Requests are not supported by IProxyListenerBase
if (messageType.equals(RPCMessage.KEY_REQUEST)) {
- RPCMessage convertedRPCMsg = RpcConverter.convertTableToRpc(hash);
-
- if (convertedRPCMsg != null) {
- convertedRPCMsg.format(rpcSpecVersion, true);
- onRPCRequestReceived((RPCRequest) convertedRPCMsg);
- }else{
- DebugTool.logError("Received a null RPC Request, discarding.");
- }
+ onRPCRequestReceived((RPCRequest) rpcMsg);
} else if (messageType.equals(RPCMessage.KEY_RESPONSE)) {
// Check to ensure response is not from an internal message (reserved correlation ID)
@@ -3089,14 +3141,6 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
// SetDisplayLayout
final SetDisplayLayoutResponse msg = new SetDisplayLayoutResponse(hash);
msg.format(rpcSpecVersion,true);
- // successfully changed display layout - update layout capabilities
- if(msg.getSuccess() && _systemCapabilityManager!=null){
- _systemCapabilityManager.setCapability(SystemCapabilityType.DISPLAY, msg.getDisplayCapabilities());
- _systemCapabilityManager.setCapability(SystemCapabilityType.BUTTON, msg.getButtonCapabilities());
- _systemCapabilityManager.setCapability(SystemCapabilityType.PRESET_BANK, msg.getPresetBankCapabilities());
- _systemCapabilityManager.setCapability(SystemCapabilityType.SOFTBUTTON, msg.getSoftButtonCapabilities());
- }
-
if (_callbackToUIThread) {
// Run in UI thread
_mainUIHandler.post(new Runnable() {
diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java
index df8e65837..4f4bb7029 100644
--- a/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java
+++ b/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java
@@ -348,7 +348,9 @@ abstract public class BaseScreenManager extends BaseSubManager {
if (!success){
updateSuccessful = false;
}
- listener.onComplete(updateSuccessful);
+ if (listener != null) {
+ listener.onComplete(updateSuccessful);
+ }
}
});
}
diff --git a/base/src/main/java/com/smartdevicelink/proxy/SystemCapabilityManager.java b/base/src/main/java/com/smartdevicelink/proxy/SystemCapabilityManager.java
index 5cb798869..12c945b2a 100644
--- a/base/src/main/java/com/smartdevicelink/proxy/SystemCapabilityManager.java
+++ b/base/src/main/java/com/smartdevicelink/proxy/SystemCapabilityManager.java
@@ -16,8 +16,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
-import static com.smartdevicelink.protocol.enums.FunctionID.SET_DISPLAY_LAYOUT;
-
public class SystemCapabilityManager {
private final HashMap<SystemCapabilityType, Object> cachedSystemCapabilities;
private final HashMap<SystemCapabilityType, CopyOnWriteArrayList<OnSystemCapabilityListener>> onSystemCapabilityListeners;
diff --git a/base/src/main/java/com/smartdevicelink/transport/TransportManager.java b/base/src/main/java/com/smartdevicelink/transport/TransportManager.java
index 814800395..7353bb7ae 100644
--- a/base/src/main/java/com/smartdevicelink/transport/TransportManager.java
+++ b/base/src/main/java/com/smartdevicelink/transport/TransportManager.java
@@ -39,7 +39,6 @@ import com.smartdevicelink.protocol.SdlPacket;
import com.smartdevicelink.transport.enums.TransportType;
import com.smartdevicelink.transport.utl.TransportRecord;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
diff --git a/javaEE/build.gradle b/javaEE/build.gradle
index 7b8f6e668..325ad2f7c 100644
--- a/javaEE/build.gradle
+++ b/javaEE/build.gradle
@@ -3,7 +3,7 @@ apply plugin: 'java-library'
group 'com.smartdevicelink'
version '4.7.2'
-sourceCompatibility = 1.8
+sourceCompatibility = 1.7
buildscript {
repositories {
diff --git a/javaEE/src/main/java/hello_sdl_ee/Main.java b/javaEE/src/main/java/hello_sdl_ee/Main.java
index 1105c1bed..85307fa52 100644
--- a/javaEE/src/main/java/hello_sdl_ee/Main.java
+++ b/javaEE/src/main/java/hello_sdl_ee/Main.java
@@ -68,7 +68,7 @@ public class Main {
public static void attemptSdlManager(){
SdlManager.Builder builder = new SdlManager.Builder("234523452345234", "JavaChip", new SdlManagerListener() {
@Override
- public void onStart(SdlManager manager) {
+ public void onStart(final SdlManager manager) {
Log.i(TAG, "OnStart");
manager.addOnRPCNotificationListener(FunctionID.ON_HMI_STATUS, new OnRPCNotificationListener() {
@Override
@@ -124,7 +124,7 @@ public class Main {
WebSocketServerConfig serverConfig = new WebSocketServerConfig(5679,0);
LifecycleManager lifer = new LifecycleManager(config, serverConfig, new LifecycleManager.LifecycleListener() {
@Override
- public void onProxyConnected(LifecycleManager lifeCycleManager) {
+ public void onProxyConnected(final LifecycleManager lifeCycleManager) {
System.out.print("On proxy CONNECTED");
lifeCycleManager.addOnRPCNotificationListener(FunctionID.ON_HMI_STATUS, new OnRPCNotificationListener() {
diff --git a/javaSE/build.gradle b/javaSE/build.gradle
index 4f8b00ee2..bd791ffc1 100644
--- a/javaSE/build.gradle
+++ b/javaSE/build.gradle
@@ -3,7 +3,7 @@ apply plugin: 'java-library'
group 'com.smartdevicelink'
version '4.7.2'
-sourceCompatibility = 1.8
+sourceCompatibility = 1.7
buildscript {
diff --git a/javaSE/src/main/java/com/smartdevicelink/managers/SdlManager.java b/javaSE/src/main/java/com/smartdevicelink/managers/SdlManager.java
index 3418b8d33..e81069f53 100644
--- a/javaSE/src/main/java/com/smartdevicelink/managers/SdlManager.java
+++ b/javaSE/src/main/java/com/smartdevicelink/managers/SdlManager.java
@@ -49,6 +49,7 @@ import com.smartdevicelink.proxy.rpc.*;
import com.smartdevicelink.proxy.rpc.enums.*;
import com.smartdevicelink.proxy.rpc.listeners.OnMultipleRequestListener;
import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener;
+import com.smartdevicelink.proxy.rpc.listeners.OnRPCRequestListener;
import com.smartdevicelink.security.SdlSecurityBase;
import com.smartdevicelink.transport.BaseTransportConfig;
import com.smartdevicelink.transport.enums.TransportType;
@@ -392,14 +393,10 @@ public class SdlManager extends BaseSdlManager{
/**
* Send RPC Message <br>
- * <strong>Note: Only takes type of RPCRequest for now, notifications and responses will be thrown out</strong>
* @param message RPCMessage
*/
public void sendRPC(RPCMessage message) {
-
- if (message instanceof RPCRequest){
- lifecycleManager.sendRPC(message);
- }
+ lifecycleManager.sendRPC(message);
}
/**
@@ -468,6 +465,22 @@ public class SdlManager extends BaseSdlManager{
lifecycleManager.removeOnRPCNotificationListener(notificationId, listener);
}
+ /**
+ * Add an OnRPCRequestListener
+ * @param listener listener that will be called when a request is received
+ */
+ public void addOnRPCRequestListener(FunctionID requestId, OnRPCRequestListener listener){
+ lifecycleManager.addOnRPCRequestListener(requestId,listener);
+ }
+
+ /**
+ * Remove an OnRPCRequestListener
+ * @param listener listener that was previously added
+ */
+ public void removeOnRPCRequestListener(FunctionID requestId, OnRPCRequestListener listener){
+ lifecycleManager.removeOnRPCRequestListener(requestId, listener);
+ }
+
// LIFECYCLE / OTHER
// STARTUP
diff --git a/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java b/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java
index ec2fc138d..62740894f 100644
--- a/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java
+++ b/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java
@@ -81,6 +81,7 @@ public class LifecycleManager extends BaseLifecycleManager {
// Sdl Synchronization Objects
private static final Object RPC_LISTENER_LOCK = new Object(),
ON_UPDATE_LISTENER_LOCK = new Object(),
+ ON_REQUEST_LISTENER_LOCK = new Object(),
ON_NOTIFICATION_LISTENER_LOCK = new Object();
@@ -91,9 +92,11 @@ public class LifecycleManager extends BaseLifecycleManager {
//protected Version protocolVersion = new Version(1,0,0);
protected Version rpcSpecVersion = MAX_SUPPORTED_RPC_VERSION;
- protected final HashMap<Integer,CopyOnWriteArrayList<OnRPCListener>> rpcListeners;
- protected final HashMap<Integer, OnRPCResponseListener> rpcResponseListeners;
- protected final HashMap<Integer, CopyOnWriteArrayList<OnRPCNotificationListener>> rpcNotificationListeners;
+
+ private final HashMap<Integer,CopyOnWriteArrayList<OnRPCListener>> rpcListeners;
+ private final HashMap<Integer, OnRPCResponseListener> rpcResponseListeners;
+ private final HashMap<Integer, CopyOnWriteArrayList<OnRPCNotificationListener>> rpcNotificationListeners;
+ private final HashMap<Integer, CopyOnWriteArrayList<OnRPCRequestListener>> rpcRequestListeners;
protected final SystemCapabilityManager systemCapabilityManager;
@@ -116,6 +119,7 @@ public class LifecycleManager extends BaseLifecycleManager {
this.rpcListeners = new HashMap<>();
this.rpcResponseListeners = new HashMap<>();
this.rpcNotificationListeners = new HashMap<>();
+ this.rpcRequestListeners = new HashMap<>();
this.appConfig = appConfig;
this.session = new SdlSession(this, config);
@@ -312,7 +316,7 @@ public class LifecycleManager extends BaseLifecycleManager {
case ON_HASH_CHANGE:
break;
case ON_SYSTEM_REQUEST:
- OnSystemRequest onSystemRequest = (OnSystemRequest) message;
+ final OnSystemRequest onSystemRequest = (OnSystemRequest) message;
if ((onSystemRequest.getUrl() != null) &&
(((onSystemRequest.getRequestType() == RequestType.PROPRIETARY) && (onSystemRequest.getFileType() == FileType.JSON))
|| ((onSystemRequest.getRequestType() == RequestType.HTTP) && (onSystemRequest.getFileType() == FileType.BINARY)))) {
@@ -523,7 +527,7 @@ public class LifecycleManager extends BaseLifecycleManager {
}
/**
- * This will ad a listener for the specific type of notification. As of now it will only allow
+ * This will add a listener for the specific type of notification. As of now it will only allow
* a single listener per notification function id
* @param notificationId The notification type that this listener is designated for
* @param listener The listener that will be called when a notification of the provided type is received
@@ -565,7 +569,56 @@ public class LifecycleManager extends BaseLifecycleManager {
return false;
}
+ @SuppressWarnings("UnusedReturnValue")
+ private boolean onRPCRequestReceived(RPCRequest request){
+ if(request == null){
+ DebugTool.logError("onRPCRequestReceived - request was null");
+ return false;
+ }
+ DebugTool.logInfo("onRPCRequestReceived - " + request.getFunctionName() );
+
+ synchronized(ON_REQUEST_LISTENER_LOCK){
+ CopyOnWriteArrayList<OnRPCRequestListener> listeners = rpcRequestListeners.get(FunctionID.getFunctionId(request.getFunctionName()));
+ if(listeners!=null && listeners.size()>0) {
+ for (OnRPCRequestListener listener : listeners) {
+ listener.onRequest(request);
+ }
+ return true;
+ }
+ return false;
+ }
+ }
+
+ /**
+ * This will add a listener for the specific type of request. As of now it will only allow
+ * a single listener per request function id
+ * @param requestId The request type that this listener is designated for
+ * @param listener The listener that will be called when a request of the provided type is received
+ */
+ @SuppressWarnings("unused")
+ public void addOnRPCRequestListener(FunctionID requestId, OnRPCRequestListener listener){
+ synchronized(ON_REQUEST_LISTENER_LOCK){
+ if(requestId != null && listener != null){
+ if(!rpcRequestListeners.containsKey(requestId.getId())){
+ rpcRequestListeners.put(requestId.getId(),new CopyOnWriteArrayList<OnRPCRequestListener>());
+ }
+ rpcRequestListeners.get(requestId.getId()).add(listener);
+ }
+ }
+ }
+ @SuppressWarnings("UnusedReturnValue")
+ public boolean removeOnRPCRequestListener(FunctionID requestId, OnRPCRequestListener listener){
+ synchronized(ON_REQUEST_LISTENER_LOCK){
+ if(rpcRequestListeners!= null
+ && requestId != null
+ && listener != null
+ && rpcRequestListeners.containsKey(requestId.getId())){
+ return rpcRequestListeners.get(requestId.getId()).remove(listener);
+ }
+ }
+ return false;
+ }
/* *******************************************************************************************************
**************************************** RPC LISTENERS !! END !! ****************************************
@@ -593,6 +646,7 @@ public class LifecycleManager extends BaseLifecycleManager {
Integer corrId = ((RPCRequest)message).getCorrelationID();
if( corrId== null) {
Log.e(TAG, "No correlation ID attached to request. Not sending");
+ return;
}else{
pm.setCorrID(corrId);
@@ -601,6 +655,16 @@ public class LifecycleManager extends BaseLifecycleManager {
addOnRPCResponseListener(listener, corrId, msgBytes.length);
}
}
+ }else if (RPCMessage.KEY_RESPONSE.equals(message.getMessageType())){
+ RPCResponse response = (RPCResponse) message;
+ if (response.getCorrelationID() == null) {
+ //Log error here
+ //throw new SdlException("CorrelationID cannot be null. RPC: " + response.getFunctionName(), SdlExceptionCause.INVALID_ARGUMENT);
+ Log.e(TAG, "No correlation ID attached to response. Not sending");
+ return;
+ } else {
+ pm.setCorrID(response.getCorrelationID());
+ }
}
if (message.getBulkData() != null){
@@ -672,6 +736,11 @@ public class LifecycleManager extends BaseLifecycleManager {
}else if(RPCMessage.KEY_NOTIFICATION.equals(messageType)){
onRPCNotificationReceived((RPCNotification)rpc);
+
+ } else if (RPCMessage.KEY_REQUEST.equals(messageType)){
+
+ onRPCRequestReceived((RPCRequest) rpc);
+
}
}else{
Log.w(TAG, "Shouldn't be here");
@@ -1144,6 +1213,9 @@ public class LifecycleManager extends BaseLifecycleManager {
if (rpcNotificationListeners != null) {
rpcNotificationListeners.clear();
}
+ if (rpcRequestListeners != null) {
+ rpcRequestListeners.clear();
+ }
if (session != null && session.getIsConnected()) {
session.close();
}
diff --git a/javaSE/src/main/java/hello_sdl/Main.java b/javaSE/src/main/java/hello_sdl/Main.java
index fd88dc032..afe738f3b 100644
--- a/javaSE/src/main/java/hello_sdl/Main.java
+++ b/javaSE/src/main/java/hello_sdl/Main.java
@@ -7,12 +7,14 @@ import com.smartdevicelink.managers.lifecycle.LifecycleManager;
import com.smartdevicelink.marshal.JsonRPCMarshaller;
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCNotification;
+import com.smartdevicelink.proxy.RPCRequest;
import com.smartdevicelink.proxy.callbacks.OnServiceEnded;
import com.smartdevicelink.proxy.callbacks.OnServiceNACKed;
import com.smartdevicelink.proxy.rpc.*;
import com.smartdevicelink.proxy.rpc.enums.HMILevel;
import com.smartdevicelink.proxy.rpc.enums.SdlDisconnectedReason;
import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener;
+import com.smartdevicelink.proxy.rpc.listeners.OnRPCRequestListener;
import com.smartdevicelink.transport.WebSocketServerConfig;
import com.smartdevicelink.util.Version;
import org.json.JSONException;
@@ -24,7 +26,8 @@ public class Main {
public static void main(String[] args) {
// testRAIString();
- startSdl();
+ //startSdl();
+ attemptSdlManager();
}
public static void testRAI(){
@@ -68,7 +71,7 @@ public class Main {
public static void attemptSdlManager(){
SdlManager.Builder builder = new SdlManager.Builder("234523452345234", "JavaChip", new SdlManagerListener() {
@Override
- public void onStart(SdlManager manager) {
+ public void onStart(final SdlManager manager) {
Log.i(TAG, "OnStart");
manager.addOnRPCNotificationListener(FunctionID.ON_HMI_STATUS, new OnRPCNotificationListener() {
@Override
@@ -83,12 +86,21 @@ public class Main {
show.setMainField2("YEET THAT SUCKER!");
manager.sendRPC(show);
Log.i(TAG, "Attempting sending show");
-
-
}
}
}
});
+
+ manager.addOnRPCRequestListener(FunctionID.SEND_LOCATION, new OnRPCRequestListener() {
+ @Override
+ public void onRequest(RPCRequest request) {
+ try {
+ Log.i(TAG, request.serializeJSON().toString());
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ }
+ });
}
@Override
@@ -103,10 +115,10 @@ public class Main {
}
});
//FIXME have to add websocket setting
- SdlManager manager = builder.build();
- manager.start();
-
-
+ WebSocketServerConfig serverConfig = new WebSocketServerConfig(5679,0);
+ builder.setTransportType(serverConfig);
+ SdlManager manager = builder.build();
+ manager.start();
}
public static void startSdl(){
@@ -124,7 +136,7 @@ public class Main {
WebSocketServerConfig serverConfig = new WebSocketServerConfig(5679,0);
LifecycleManager lifer = new LifecycleManager(config, serverConfig, new LifecycleManager.LifecycleListener() {
@Override
- public void onProxyConnected(LifecycleManager lifeCycleManager) {
+ public void onProxyConnected(final LifecycleManager lifeCycleManager) {
System.out.print("On proxy CONNECTED");
lifeCycleManager.addOnRPCNotificationListener(FunctionID.ON_HMI_STATUS, new OnRPCNotificationListener() {