summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Grover <joeygrover@gmail.com>2019-03-15 18:30:28 +0100
committerGitHub <noreply@github.com>2019-03-15 18:30:28 +0100
commitb11eeb2ca9784e3a59e53f2bf4c5f9ef51b0e63f (patch)
tree68fc462b5d72b69c91e3b4f7e15f44a80d09fffe
parent7529355b13c14368272a1254bed8a9cdd5931cb0 (diff)
parent1cb2d9bc219169f8c5138f9188277c870f660b42 (diff)
downloadsdl_android-b11eeb2ca9784e3a59e53f2bf4c5f9ef51b0e63f.tar.gz
Merge pull request #1000 from smartdevicelink/feature/lcm_private_methods
Reduce public methods in LCM
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SystemCapabilityManagerTests.java16
-rw-r--r--android/sdl_android/src/main/java/com/smartdevicelink/managers/SdlManager.java19
-rw-r--r--android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java19
-rw-r--r--base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseLifecycleManager.java4
-rw-r--r--base/src/main/java/com/smartdevicelink/proxy/interfaces/ISdl.java34
-rw-r--r--javaSE/src/main/java/com/smartdevicelink/managers/SdlManager.java27
-rw-r--r--javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java349
7 files changed, 288 insertions, 180 deletions
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SystemCapabilityManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SystemCapabilityManagerTests.java
index a7b49489e..6dd039211 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SystemCapabilityManagerTests.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SystemCapabilityManagerTests.java
@@ -28,6 +28,7 @@ import com.smartdevicelink.proxy.rpc.enums.SystemCapabilityType;
import com.smartdevicelink.proxy.rpc.listeners.OnMultipleRequestListener;
import com.smartdevicelink.proxy.rpc.listeners.OnRPCListener;
import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener;
+import com.smartdevicelink.proxy.rpc.listeners.OnRPCRequestListener;
import com.smartdevicelink.streaming.audio.AudioStreamingCodec;
import com.smartdevicelink.streaming.audio.AudioStreamingParams;
import com.smartdevicelink.streaming.video.VideoStreamingParameters;
@@ -182,12 +183,27 @@ public class SystemCapabilityManagerTests extends AndroidTestCase2 {
}
@Override
+ public void sendSequentialRPCs(List<? extends RPCMessage> rpcs, OnMultipleRequestListener listener) {
+
+ }
+
+ @Override
public void addOnRPCNotificationListener(FunctionID notificationId, OnRPCNotificationListener listener) {}
@Override
public boolean removeOnRPCNotificationListener(FunctionID notificationId, OnRPCNotificationListener listener) {return false;}
@Override
+ public void addOnRPCRequestListener(FunctionID functionID, OnRPCRequestListener listener) {
+
+ }
+
+ @Override
+ public boolean removeOnRPCRequestListener(FunctionID functionID, OnRPCRequestListener listener) {
+ return false;
+ }
+
+ @Override
public void addOnRPCListener(FunctionID responseId, OnRPCListener listener) { }
@Override
diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/managers/SdlManager.java b/android/sdl_android/src/main/java/com/smartdevicelink/managers/SdlManager.java
index ee9da050a..c75f46bbf 100644
--- a/android/sdl_android/src/main/java/com/smartdevicelink/managers/SdlManager.java
+++ b/android/sdl_android/src/main/java/com/smartdevicelink/managers/SdlManager.java
@@ -717,6 +717,15 @@ public class SdlManager extends BaseSdlManager{
}
@Override
+ public void sendSequentialRPCs(List<? extends RPCMessage> rpcs, OnMultipleRequestListener listener) {
+ try {
+ proxy.sendSequentialRequests(rpcs,listener);
+ } catch (SdlException e) {
+ DebugTool.logError("Issue sending sequential RPCs ", e);
+ }
+ }
+
+ @Override
public void addOnRPCNotificationListener(FunctionID notificationId, OnRPCNotificationListener listener) {
proxy.addOnRPCNotificationListener(notificationId,listener);
}
@@ -727,6 +736,16 @@ public class SdlManager extends BaseSdlManager{
}
@Override
+ public void addOnRPCRequestListener(FunctionID functionID, OnRPCRequestListener listener) {
+ proxy.addOnRPCRequestListener(functionID, listener);
+ }
+
+ @Override
+ public boolean removeOnRPCRequestListener(FunctionID functionID, OnRPCRequestListener listener) {
+ return proxy.removeOnRPCRequestListener(functionID, listener);
+ }
+
+ @Override
public void addOnRPCListener(final FunctionID responseId, final OnRPCListener listener) {
proxyBridge.addRpcListener(responseId, listener);
}
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 c912ed119..832e86673 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
@@ -355,6 +355,15 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
}
@Override
+ public void sendSequentialRPCs(List<? extends RPCMessage> rpcs, OnMultipleRequestListener listener) {
+ try{
+ SdlProxyBase.this.sendSequentialRequests(rpcs,listener);
+ }catch (SdlException e ){
+ DebugTool.logError("Issue sending sequential RPCs ", e);
+ }
+ }
+
+ @Override
public void addOnRPCNotificationListener(FunctionID notificationId, OnRPCNotificationListener listener) {
SdlProxyBase.this.addOnRPCNotificationListener(notificationId,listener);
}
@@ -365,6 +374,16 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
}
@Override
+ public void addOnRPCRequestListener(FunctionID functionID, OnRPCRequestListener listener) {
+ SdlProxyBase.this.addOnRPCRequestListener(functionID,listener);
+ }
+
+ @Override
+ public boolean removeOnRPCRequestListener(FunctionID functionID, OnRPCRequestListener listener) {
+ return SdlProxyBase.this.removeOnRPCRequestListener(functionID,listener);
+ }
+
+ @Override
public void addOnRPCListener(FunctionID responseId, OnRPCListener listener) {
SdlProxyBase.this.addOnRPCListener(responseId, listener);
}
diff --git a/base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseLifecycleManager.java b/base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseLifecycleManager.java
index 20df70a78..254b0d505 100644
--- a/base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseLifecycleManager.java
+++ b/base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseLifecycleManager.java
@@ -32,7 +32,5 @@
package com.smartdevicelink.managers.lifecycle;
-import com.smartdevicelink.SdlConnection.ISdlConnectionListener;
-
-abstract class BaseLifecycleManager implements ISdlConnectionListener {
+abstract class BaseLifecycleManager {
}
diff --git a/base/src/main/java/com/smartdevicelink/proxy/interfaces/ISdl.java b/base/src/main/java/com/smartdevicelink/proxy/interfaces/ISdl.java
index d97d64735..f2eea597c 100644
--- a/base/src/main/java/com/smartdevicelink/proxy/interfaces/ISdl.java
+++ b/base/src/main/java/com/smartdevicelink/proxy/interfaces/ISdl.java
@@ -6,6 +6,7 @@ import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.protocol.enums.SessionType;
import com.smartdevicelink.proxy.RPCMessage;
import com.smartdevicelink.proxy.RPCRequest;
+import com.smartdevicelink.proxy.rpc.listeners.OnRPCRequestListener;
import com.smartdevicelink.util.Version;
import com.smartdevicelink.proxy.rpc.SdlMsgVersion;
import com.smartdevicelink.proxy.rpc.enums.SystemCapabilityType;
@@ -148,10 +149,23 @@ public interface ISdl {
void sendRequests(List<? extends RPCRequest> rpcs, final OnMultipleRequestListener listener);
/**
- * Add an OnRPCNotificationListener for specified notification
- * @param notificationId FunctionID of the notification that is to be listened for
- * @param listener listener that should be added for the notification ID
+ * Takes a list of RPCMessages and sends it to SDL in a synchronous fashion. Responses are captured through callback on OnMultipleRequestListener.
+ * For sending requests asynchronously, use sendRequests <br>
+ *
+ * <strong>NOTE: This will override any listeners on individual RPCs</strong><br>
+ *
+ * <strong>ADDITIONAL NOTE: This only takes the type of RPCRequest for now, notifications and responses will be thrown out</strong>
+ *
+ * @param rpcs is the list of RPCMessages being sent
+ * @param listener listener for updates and completions
*/
+ void sendSequentialRPCs(final List<? extends RPCMessage> rpcs, final OnMultipleRequestListener listener);
+
+ /**
+ * Add an OnRPCNotificationListener for specified notification
+ * @param notificationId FunctionID of the notification that is to be listened for
+ * @param listener listener that should be added for the notification ID
+ */
void addOnRPCNotificationListener(FunctionID notificationId, OnRPCNotificationListener listener);
/**
@@ -162,6 +176,20 @@ public interface ISdl {
boolean removeOnRPCNotificationListener(FunctionID notificationId, OnRPCNotificationListener listener);
/**
+ * Add an OnRPCRequestListener for specified request
+ * @param functionID FunctionID of the request that is to be listened for
+ * @param listener listener that should be added for the request ID
+ */
+ void addOnRPCRequestListener(FunctionID functionID, OnRPCRequestListener listener);
+
+ /**
+ * Removes an OnRPCRequestListener for specified request
+ * @param functionID FunctionID of the request that was to be listened for
+ * @param listener listener that was previously added for the request ID
+ */
+ boolean removeOnRPCRequestListener(FunctionID functionID, OnRPCRequestListener listener);
+
+ /**
* Add an OnRPCResponseListener for specified response
* @param responseId FunctionID of the response that is to be listened for
* @param listener listener that should be added for the response ID
diff --git a/javaSE/src/main/java/com/smartdevicelink/managers/SdlManager.java b/javaSE/src/main/java/com/smartdevicelink/managers/SdlManager.java
index e81069f53..3a4a8914e 100644
--- a/javaSE/src/main/java/com/smartdevicelink/managers/SdlManager.java
+++ b/javaSE/src/main/java/com/smartdevicelink/managers/SdlManager.java
@@ -228,7 +228,6 @@ public class SdlManager extends BaseSdlManager{
this.fileManager = new FileManager(_internalInterface);
this.screenManager = new ScreenManager(_internalInterface, this.fileManager);
-
// Start sub managers
this.permissionManager.start(subManagerListener);
this.fileManager.start(subManagerListener);
@@ -325,7 +324,7 @@ public class SdlManager extends BaseSdlManager{
* @return a SystemCapabilityManager object
*/
public SystemCapabilityManager getSystemCapabilityManager(){
- return lifecycleManager.getSystemCapabilityManager();
+ return lifecycleManager.getSystemCapabilityManager(this);
}
/**
@@ -396,7 +395,7 @@ public class SdlManager extends BaseSdlManager{
* @param message RPCMessage
*/
public void sendRPC(RPCMessage message) {
- lifecycleManager.sendRPC(message);
+ _internalInterface.sendRPC(message);
}
/**
@@ -420,7 +419,7 @@ public class SdlManager extends BaseSdlManager{
}
if (rpcRequestList.size() > 0) {
- lifecycleManager.sendSequentialRPCs(rpcRequestList, listener);
+ _internalInterface.sendSequentialRPCs(rpcRequestList, listener);
}
}
@@ -445,7 +444,7 @@ public class SdlManager extends BaseSdlManager{
}
if (rpcRequestList.size() > 0) {
- lifecycleManager.sendRPCs(rpcRequestList, listener);
+ _internalInterface.sendRequests(rpcRequestList,listener);
}
}
@@ -454,7 +453,7 @@ public class SdlManager extends BaseSdlManager{
* @param listener listener that will be called when a notification is received
*/
public void addOnRPCNotificationListener(FunctionID notificationId, OnRPCNotificationListener listener){
- lifecycleManager.addOnRPCNotificationListener(notificationId,listener);
+ _internalInterface.addOnRPCNotificationListener(notificationId,listener);
}
/**
@@ -462,7 +461,7 @@ public class SdlManager extends BaseSdlManager{
* @param listener listener that was previously added
*/
public void removeOnRPCNotificationListener(FunctionID notificationId, OnRPCNotificationListener listener){
- lifecycleManager.removeOnRPCNotificationListener(notificationId, listener);
+ _internalInterface.removeOnRPCNotificationListener(notificationId, listener);
}
/**
@@ -470,7 +469,7 @@ public class SdlManager extends BaseSdlManager{
* @param listener listener that will be called when a request is received
*/
public void addOnRPCRequestListener(FunctionID requestId, OnRPCRequestListener listener){
- lifecycleManager.addOnRPCRequestListener(requestId,listener);
+ _internalInterface.addOnRPCRequestListener(requestId,listener);
}
/**
@@ -478,7 +477,7 @@ public class SdlManager extends BaseSdlManager{
* @param listener listener that was previously added
*/
public void removeOnRPCRequestListener(FunctionID requestId, OnRPCRequestListener listener){
- lifecycleManager.removeOnRPCRequestListener(requestId, listener);
+ _internalInterface.removeOnRPCRequestListener(requestId, listener);
}
// LIFECYCLE / OTHER
@@ -508,11 +507,12 @@ public class SdlManager extends BaseSdlManager{
appConfig.setDayColorScheme(dayColorScheme);
appConfig.setNightColorScheme(nightColorScheme);
appConfig.setAppID(appId);
-
+ appConfig.setMinimumProtocolVersion(minimumProtocolVersion);
+ appConfig.setMinimumRPCVersion(minimumRPCVersion);
lifecycleManager = new LifecycleManager(appConfig, transport, lifecycleListener);
- lifecycleManager.setMinimumProtocolVersion(minimumProtocolVersion);
- lifecycleManager.setMinimumRPCVersion(minimumRPCVersion);
+ _internalInterface = lifecycleManager.getInternalInterface(SdlManager.this);
+
if (sdlSecList != null && !sdlSecList.isEmpty()) {
lifecycleManager.setSdlSecurityClassList(sdlSecList);
}
@@ -520,12 +520,11 @@ public class SdlManager extends BaseSdlManager{
Set<FunctionID> functionIDSet = onRPCNotificationListeners.keySet();
if (functionIDSet != null && !functionIDSet.isEmpty()) {
for (FunctionID functionID : functionIDSet) {
- lifecycleManager.addOnRPCNotificationListener(functionID, onRPCNotificationListeners.get(functionID));
+ _internalInterface.addOnRPCNotificationListener(functionID, onRPCNotificationListeners.get(functionID));
}
}
}
- _internalInterface = lifecycleManager.getInternalInterface(SdlManager.this);
lifecycleManager.start();
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 6b97a656d..6e02bdb1c 100644
--- a/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java
+++ b/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java
@@ -34,6 +34,7 @@ package com.smartdevicelink.managers.lifecycle;
import android.support.annotation.RestrictTo;
import android.util.Log;
+import com.smartdevicelink.SdlConnection.ISdlConnectionListener;
import com.smartdevicelink.SdlConnection.SdlSession;
import com.smartdevicelink.exception.SdlException;
import com.smartdevicelink.managers.SdlManager;
@@ -122,7 +123,9 @@ public class LifecycleManager extends BaseLifecycleManager {
this.rpcRequestListeners = new HashMap<>();
this.appConfig = appConfig;
- this.session = new SdlSession(this, config);
+ this.minimumProtocolVersion = appConfig.minimumProtocolVersion;
+ this.minimumRPCVersion = appConfig.minimumRPCVersion;
+ this.session = new SdlSession(sdlConnectionListener, config);
this.systemCapabilityManager = new SystemCapabilityManager(internalInterface);
@@ -142,21 +145,14 @@ public class LifecycleManager extends BaseLifecycleManager {
session.close();
}
- public Version getProtocolVersion(){
+ private Version getProtocolVersion(){
if (session != null){
return session.getProtocolVersion();
}
return new Version(1,0,0);
}
- public Version getRpcSpecVersion(){
- return rpcSpecVersion;
- }
-
- public void sendRPC(RPCMessage message){
- this.sendRPCMessagePrivate(message);
- }
- public void sendRPCs(List<? extends RPCMessage> messages, OnMultipleRequestListener listener){
+ private void sendRPCs(List<? extends RPCMessage> messages, OnMultipleRequestListener listener){
if(messages != null ){
for(RPCMessage message : messages){
if(message instanceof RPCRequest){
@@ -175,7 +171,7 @@ public class LifecycleManager extends BaseLifecycleManager {
}
}
- public void sendSequentialRPCs(final List<? extends RPCMessage> messages, final OnMultipleRequestListener listener){
+ private void sendSequentialRPCs(final List<? extends RPCMessage> messages, final OnMultipleRequestListener listener){
if (messages != null){
int requestCount = messages.size();
@@ -218,15 +214,33 @@ public class LifecycleManager extends BaseLifecycleManager {
} else {
// Notifications and Responses
sendRPCMessagePrivate(rpc);
+ if (listener != null) {
+ listener.onUpdate(messages.size());
+ }
+ // recurse after sending a notification or response as there is no response.
+ sendSequentialRPCs(messages, listener);
}
}
}
- public SystemCapabilityManager getSystemCapabilityManager(){
- return systemCapabilityManager;
+ /**
+ * This method is used to ensure all of the methods in this class can remain private and no grantees can be made
+ * to the developer what methods are available or not.
+ *
+ * <b>NOTE: THERE IS NO GURANTEE THIS WILL BE A VALID SYSTEM CAPABILITY MANAGER</b>
+ *
+ * @param sdlManager this must be a working manager instance
+ * @return the system capability manager.
+ */
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ public SystemCapabilityManager getSystemCapabilityManager(SdlManager sdlManager){
+ if(sdlManager != null){
+ return systemCapabilityManager;
+ }
+ return null;
}
- public boolean isConnected(){
+ private boolean isConnected(){
if(session != null){
return session.getIsConnected();
}else{
@@ -262,6 +276,21 @@ public class LifecycleManager extends BaseLifecycleManager {
}
}
+ /**
+ * This method is used to ensure all of the methods in this class can remain private and no grantees can be made
+ * to the developer what methods are available or not.
+ *
+ * @param sdlManager this must be a working manager instance
+ * @return the internal interface that hooks into this manager
+ */
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ public ISdl getInternalInterface(SdlManager sdlManager) {
+ if (sdlManager != null) {
+ return internalInterface;
+ }
+ return null;
+ }
+
/* *******************************************************************************************************
********************************** INTERNAL - RPC LISTENERS !! START !! *********************************
@@ -377,7 +406,7 @@ public class LifecycleManager extends BaseLifecycleManager {
********************************** METHODS - RPC LISTENERS !! START !! **********************************
*********************************************************************************************************/
- public boolean onRPCReceived(final RPCMessage message){
+ private boolean onRPCReceived(final RPCMessage message){
synchronized(RPC_LISTENER_LOCK){
if(message == null || message.getFunctionID() == null){
return false;
@@ -395,8 +424,7 @@ public class LifecycleManager extends BaseLifecycleManager {
}
}
- //FIXME check if we need this to be public
- public void addRpcListener(FunctionID id, OnRPCListener listener){
+ private void addRpcListener(FunctionID id, OnRPCListener listener){
synchronized(RPC_LISTENER_LOCK){
if (id != null && listener != null) {
if (!rpcListeners.containsKey(id.getId())) {
@@ -408,7 +436,7 @@ public class LifecycleManager extends BaseLifecycleManager {
}
}
- public boolean removeOnRPCListener(FunctionID id, OnRPCListener listener){
+ private boolean removeOnRPCListener(FunctionID id, OnRPCListener listener){
synchronized(RPC_LISTENER_LOCK){
if(rpcListeners!= null
&& id != null
@@ -427,7 +455,7 @@ public class LifecycleManager extends BaseLifecycleManager {
* @param totalSize the total size in bytes
*/
@SuppressWarnings("unused")
- public void onPacketProgress(int correlationId, long bytesWritten, long totalSize){
+ private void onPacketProgress(int correlationId, long bytesWritten, long totalSize){
synchronized(ON_UPDATE_LISTENER_LOCK){
if(rpcResponseListeners !=null
&& rpcResponseListeners.containsKey(correlationId)){
@@ -468,7 +496,7 @@ public class LifecycleManager extends BaseLifecycleManager {
* @param correlationId of the RPCRequest that was sent
* @param totalSize only include if this is an OnPutFileUpdateListener. Otherwise it will be ignored.
*/
- public void addOnRPCResponseListener(OnRPCResponseListener listener,int correlationId, int totalSize){
+ private void addOnRPCResponseListener(OnRPCResponseListener listener,int correlationId, int totalSize){
synchronized(ON_UPDATE_LISTENER_LOCK){
if(rpcResponseListeners!=null
&& listener !=null){
@@ -482,7 +510,7 @@ public class LifecycleManager extends BaseLifecycleManager {
}
@SuppressWarnings("unused")
- public HashMap<Integer, OnRPCResponseListener> getResponseListeners(){
+ private HashMap<Integer, OnRPCResponseListener> getResponseListeners(){
synchronized(ON_UPDATE_LISTENER_LOCK){
return this.rpcResponseListeners;
}
@@ -498,7 +526,7 @@ public class LifecycleManager extends BaseLifecycleManager {
}
@SuppressWarnings("UnusedReturnValue")
- public boolean onRPCNotificationReceived(RPCNotification notification){
+ private boolean onRPCNotificationReceived(RPCNotification notification){
if(notification == null){
DebugTool.logError("onRPCNotificationReceived - Notification was null");
return false;
@@ -533,7 +561,7 @@ public class LifecycleManager extends BaseLifecycleManager {
* @param listener The listener that will be called when a notification of the provided type is received
*/
@SuppressWarnings("unused")
- public void addOnRPCNotificationListener(FunctionID notificationId, OnRPCNotificationListener listener){
+ private void addOnRPCNotificationListener(FunctionID notificationId, OnRPCNotificationListener listener){
synchronized(ON_NOTIFICATION_LISTENER_LOCK){
if(notificationId != null && listener != null){
if(!rpcNotificationListeners.containsKey(notificationId.getId())){
@@ -544,20 +572,7 @@ public class LifecycleManager extends BaseLifecycleManager {
}
}
- /**
- * This method is no longer valid and will not remove the listener for the supplied notificaiton id
- * @param notificationId n/a
- * @see #removeOnRPCNotificationListener(FunctionID, OnRPCNotificationListener)
- */
- @SuppressWarnings("unused")
- @Deprecated
- public void removeOnRPCNotificationListener(FunctionID notificationId){
- synchronized(ON_NOTIFICATION_LISTENER_LOCK){
- //rpcNotificationListeners.delete(notificationId.getId());
- }
- }
-
- public boolean removeOnRPCNotificationListener(FunctionID notificationId, OnRPCNotificationListener listener){
+ private boolean removeOnRPCNotificationListener(FunctionID notificationId, OnRPCNotificationListener listener){
synchronized(ON_NOTIFICATION_LISTENER_LOCK){
if(rpcNotificationListeners!= null
&& notificationId != null
@@ -596,7 +611,7 @@ public class LifecycleManager extends BaseLifecycleManager {
* @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){
+ private void addOnRPCRequestListener(FunctionID requestId, OnRPCRequestListener listener){
synchronized(ON_REQUEST_LISTENER_LOCK){
if(requestId != null && listener != null){
if(!rpcRequestListeners.containsKey(requestId.getId())){
@@ -608,7 +623,7 @@ public class LifecycleManager extends BaseLifecycleManager {
}
@SuppressWarnings("UnusedReturnValue")
- public boolean removeOnRPCRequestListener(FunctionID requestId, OnRPCRequestListener listener){
+ private boolean removeOnRPCRequestListener(FunctionID requestId, OnRPCRequestListener listener){
synchronized(ON_REQUEST_LISTENER_LOCK){
if(rpcRequestListeners!= null
&& requestId != null
@@ -688,181 +703,149 @@ public class LifecycleManager extends BaseLifecycleManager {
*************************************** ISdlConnectionListener START ************************************
*********************************************************************************************************/
+ final ISdlConnectionListener sdlConnectionListener = new ISdlConnectionListener() {
+ @Override
+ public void onTransportDisconnected(String info) {
+ onClose(info, null);
- @Override
- public void onTransportDisconnected(String info) {
- onClose(info,null);
+ }
- }
+ @Override
+ public void onTransportDisconnected(String info, boolean availablePrimary, BaseTransportConfig transportConfig) {
+ if (!availablePrimary) {
+ onClose(info, null);
+ }
- @Override
- public void onTransportDisconnected(String info, boolean availablePrimary, BaseTransportConfig transportConfig) {
- if(!availablePrimary){
- onClose(info, null);
}
- }
-
- @Override
- public void onTransportError(String info, Exception e) {
- onClose(info,e);
+ @Override
+ public void onTransportError(String info, Exception e) {
+ onClose(info, e);
- }
+ }
- @Override
- public void onProtocolMessageReceived(ProtocolMessage msg) {
- //Incoming message
- if(SessionType.RPC.equals(msg.getSessionType())
- || SessionType.BULK_DATA.equals(msg.getSessionType()) ){
+ @Override
+ public void onProtocolMessageReceived(ProtocolMessage msg) {
+ //Incoming message
+ if (SessionType.RPC.equals(msg.getSessionType())
+ || SessionType.BULK_DATA.equals(msg.getSessionType())) {
- RPCMessage rpc = RpcConverter.extractRpc(msg,session.getProtocolVersion());
- if(rpc != null){
+ RPCMessage rpc = RpcConverter.extractRpc(msg, session.getProtocolVersion());
+ if (rpc != null) {
String messageType = rpc.getMessageType();
Log.v(TAG, "RPC received - " + messageType);
- rpc.format(rpcSpecVersion,true);
+ rpc.format(rpcSpecVersion, true);
FunctionID functionID = rpc.getFunctionID();
- if (functionID != null && (functionID.equals(FunctionID.ON_BUTTON_PRESS.toString()) || functionID.equals(FunctionID.ON_BUTTON_EVENT.toString())) ) {
+ if (functionID != null && (functionID.equals(FunctionID.ON_BUTTON_PRESS.toString()) || functionID.equals(FunctionID.ON_BUTTON_EVENT.toString()))) {
rpc = handleButtonNotificationFormatting(rpc);
}
onRPCReceived(rpc);
- if(RPCMessage.KEY_RESPONSE.equals(messageType)){
+ if (RPCMessage.KEY_RESPONSE.equals(messageType)) {
- onRPCResponseReceived((RPCResponse)rpc);
+ onRPCResponseReceived((RPCResponse) rpc);
- }else if(RPCMessage.KEY_NOTIFICATION.equals(messageType)){
+ } else if (RPCMessage.KEY_NOTIFICATION.equals(messageType)) {
- onRPCNotificationReceived((RPCNotification)rpc);
+ onRPCNotificationReceived((RPCNotification) rpc);
- } else if (RPCMessage.KEY_REQUEST.equals(messageType)){
+ } else if (RPCMessage.KEY_REQUEST.equals(messageType)) {
onRPCRequestReceived((RPCRequest) rpc);
}
- }else{
+ } else {
Log.w(TAG, "Shouldn't be here");
}
+ }
+
}
- }
+ @Override
+ public void onProtocolSessionStartedNACKed(SessionType sessionType, byte sessionID, byte version, String correlationID, List<String> rejectedParams) {
+ Log.w(TAG, "onProtocolSessionStartedNACKed " + sessionID);
+ }
- @Override
- public void onProtocolSessionStartedNACKed(SessionType sessionType, byte sessionID, byte version, String correlationID, List<String> rejectedParams) {
- Log.w(TAG, "onProtocolSessionStartedNACKed " + sessionID);
- }
+ @Override
+ public void onProtocolSessionStarted(SessionType sessionType, byte sessionID, byte version, String correlationID, int hashID, boolean isEncrypted) {
+
+ Log.i(TAG, "on protocol session started");
+ if (sessionType != null) {
+ if (minimumProtocolVersion != null && minimumProtocolVersion.isNewerThan(getProtocolVersion()) == 1) {
+ Log.w(TAG, String.format("Disconnecting from head unit, the configured minimum protocol version %s is greater than the supported protocol version %s", minimumProtocolVersion, getProtocolVersion()));
+ session.endService(sessionType, session.getSessionId());
+ cleanProxy();
+ return;
+ }
- @Override
- public void onProtocolSessionStarted(SessionType sessionType, byte sessionID, byte version, String correlationID, int hashID, boolean isEncrypted) {
+ if (sessionType.equals(SessionType.RPC)) {
+ if (appConfig != null) {
- Log.i(TAG, "on protocol session started");
- if (sessionType != null) {
- if (minimumProtocolVersion != null && minimumProtocolVersion.isNewerThan(getProtocolVersion()) == 1){
- Log.w(TAG, String.format("Disconnecting from head unit, the configured minimum protocol version %s is greater than the supported protocol version %s", minimumProtocolVersion, getProtocolVersion()));
- session.endService(sessionType, session.getSessionId());
- cleanProxy();
- return;
- }
+ appConfig.prepare();
- if (sessionType.equals(SessionType.RPC)) {
- if(appConfig != null){
+ SdlMsgVersion sdlMsgVersion = new SdlMsgVersion();
+ sdlMsgVersion.setMajorVersion(MAX_SUPPORTED_RPC_VERSION.getMajor());
+ sdlMsgVersion.setMinorVersion(MAX_SUPPORTED_RPC_VERSION.getMinor());
+ sdlMsgVersion.setPatchVersion(MAX_SUPPORTED_RPC_VERSION.getPatch());
- appConfig.prepare();
+ RegisterAppInterface rai = new RegisterAppInterface(sdlMsgVersion,
+ appConfig.getAppName(), appConfig.isMediaApp(), appConfig.getLanguageDesired(),
+ appConfig.getHmiDisplayLanguageDesired(), appConfig.getAppID());
+ rai.setCorrelationID(REGISTER_APP_INTERFACE_CORRELATION_ID);
- SdlMsgVersion sdlMsgVersion = new SdlMsgVersion();
- sdlMsgVersion.setMajorVersion(MAX_SUPPORTED_RPC_VERSION.getMajor());
- sdlMsgVersion.setMinorVersion(MAX_SUPPORTED_RPC_VERSION.getMinor());
- sdlMsgVersion.setPatchVersion(MAX_SUPPORTED_RPC_VERSION.getPatch());
+ rai.setTtsName(appConfig.getTtsName());
+ rai.setNgnMediaScreenAppName(appConfig.getNgnMediaScreenAppName());
+ rai.setVrSynonyms(appConfig.getVrSynonyms());
+ rai.setAppHMIType(appConfig.getAppType());
+ rai.setDayColorScheme(appConfig.getDayColorScheme());
+ rai.setNightColorScheme(appConfig.getNightColorScheme());
- RegisterAppInterface rai = new RegisterAppInterface(sdlMsgVersion,
- appConfig.getAppName(), appConfig.isMediaApp(), appConfig.getLanguageDesired(),
- appConfig.getHmiDisplayLanguageDesired(), appConfig.getAppID());
- rai.setCorrelationID(REGISTER_APP_INTERFACE_CORRELATION_ID);
+ //Add device/system info in the future
+ //TODO attach previous hash id
- rai.setTtsName(appConfig.getTtsName());
- rai.setNgnMediaScreenAppName(appConfig.getNgnMediaScreenAppName());
- rai.setVrSynonyms(appConfig.getVrSynonyms());
- rai.setAppHMIType(appConfig.getAppType());
- rai.setDayColorScheme(appConfig.getDayColorScheme());
- rai.setNightColorScheme(appConfig.getNightColorScheme());
+ sendRPCMessagePrivate(rai);
+ } else {
+ Log.e(TAG, "App config was null, soo...");
+ }
- //Add device/system info in the future
- //TODO attach previous hash id
- sendRPCMessagePrivate(rai);
- }else{
- Log.e(TAG, "App config was null, soo...");
+ } else {
+ lifecycleListener.onServiceStarted(sessionType);
}
-
-
- } else {
- lifecycleListener.onServiceStarted(sessionType);
}
}
- }
-
- @Override
- public void onProtocolSessionEnded(SessionType sessionType, byte sessionID, String correlationID) {
- }
-
- @Override
- public void onProtocolSessionEndedNACKed(SessionType sessionType, byte sessionID, String correlationID) {
-
- }
+ @Override
+ public void onProtocolSessionEnded(SessionType sessionType, byte sessionID, String correlationID) {
- @Override
- public void onProtocolError(String info, Exception e) {
- DebugTool.logError("Protocol Error - " + info, e);
- }
+ }
- @Override
- public void onHeartbeatTimedOut(byte sessionID) { /* Deprecated */ }
+ @Override
+ public void onProtocolSessionEndedNACKed(SessionType sessionType, byte sessionID, String correlationID) {
- @Override
- public void onProtocolServiceDataACK(SessionType sessionType, int dataSize, byte sessionID) {/* Unused */ }
+ }
+ @Override
+ public void onProtocolError(String info, Exception e) {
+ DebugTool.logError("Protocol Error - " + info, e);
+ }
- @Override
- public void onAuthTokenReceived(String token, byte sessionID) {
- this.authToken = token;
- }
+ @Override
+ public void onHeartbeatTimedOut(byte sessionID) { /* Deprecated */ }
- /**
- * Sets the minimum protocol version that will be permitted to connect.
- * If the protocol version of the head unit connected is below this version,
- * the app will disconnect with an EndService protocol message and will not register.
- * @param minimumProtocolVersion
- */
- public void setMinimumProtocolVersion(Version minimumProtocolVersion){
- this.minimumProtocolVersion = minimumProtocolVersion;
- }
+ @Override
+ public void onProtocolServiceDataACK(SessionType sessionType, int dataSize, byte sessionID) {/* Unused */ }
- /**
- * The minimum RPC version that will be permitted to connect.
- * If the RPC version of the head unit connected is below this version, an UnregisterAppInterface will be sent.
- * @param minimumRPCVersion
- */
- public void setMinimumRPCVersion(Version minimumRPCVersion){
- this.minimumRPCVersion = minimumRPCVersion;
- }
- /**
- * This method is used to ensure all of the methods in this class can remain private and no grantees can be made
- * to the developer what methods are availalbe or not.
- * @param sdlManager this must be a working manager instance
- * @return the internal interface that hooks into this manager
- */
- @RestrictTo(RestrictTo.Scope.LIBRARY)
- public ISdl getInternalInterface(SdlManager sdlManager){
- if(sdlManager != null){
- return internalInterface;
+ @Override
+ public void onAuthTokenReceived(String token, byte sessionID) {
+ LifecycleManager.this.authToken = token;
}
- return null;
- }
+ };
/* *******************************************************************************************************
*************************************** ISdlConnectionListener END ************************************
*********************************************************************************************************/
@@ -958,6 +941,11 @@ public class LifecycleManager extends BaseLifecycleManager {
}
@Override
+ public void sendSequentialRPCs(List<? extends RPCMessage> rpcs, OnMultipleRequestListener listener) {
+ LifecycleManager.this.sendSequentialRPCs(rpcs,listener);
+ }
+
+ @Override
public void addOnRPCNotificationListener(FunctionID notificationId, OnRPCNotificationListener listener) {
LifecycleManager.this.addOnRPCNotificationListener(notificationId,listener);
}
@@ -968,6 +956,16 @@ public class LifecycleManager extends BaseLifecycleManager {
}
@Override
+ public void addOnRPCRequestListener(FunctionID notificationId, OnRPCRequestListener listener) {
+ LifecycleManager.this.addOnRPCRequestListener(notificationId, listener);
+ }
+
+ @Override
+ public boolean removeOnRPCRequestListener(FunctionID notificationId, OnRPCRequestListener listener) {
+ return LifecycleManager.this.removeOnRPCRequestListener(notificationId, listener);
+ }
+
+ @Override
public void addOnRPCListener(FunctionID responseId, OnRPCListener listener) {
LifecycleManager.this.addRpcListener(responseId,listener);
}
@@ -1042,6 +1040,8 @@ public class LifecycleManager extends BaseLifecycleManager {
private Language languageDesired, hmiDisplayLanguageDesired;
private Vector<AppHMIType> appType;
private TemplateColorScheme dayColorScheme, nightColorScheme;
+ private Version minimumProtocolVersion;
+ private Version minimumRPCVersion;
private void prepare(){
if (getNgnMediaScreenAppName() == null) {
@@ -1149,6 +1149,35 @@ public class LifecycleManager extends BaseLifecycleManager {
public void setNightColorScheme(TemplateColorScheme nightColorScheme) {
this.nightColorScheme = nightColorScheme;
}
+
+ public Version getMinimumProtocolVersion() {
+ return minimumProtocolVersion;
+ }
+
+ /**
+ * Sets the minimum protocol version that will be permitted to connect.
+ * If the protocol version of the head unit connected is below this version,
+ * the app will disconnect with an EndService protocol message and will not register.
+ *
+ * @param minimumProtocolVersion
+ */
+ public void setMinimumProtocolVersion(Version minimumProtocolVersion) {
+ this.minimumProtocolVersion = minimumProtocolVersion;
+ }
+
+ public Version getMinimumRPCVersion() {
+ return minimumRPCVersion;
+ }
+
+ /**
+ * The minimum RPC version that will be permitted to connect.
+ * If the RPC version of the head unit connected is below this version, an UnregisterAppInterface will be sent.
+ *
+ * @param minimumRPCVersion
+ */
+ public void setMinimumRPCVersion(Version minimumRPCVersion) {
+ this.minimumRPCVersion = minimumRPCVersion;
+ }
}