diff options
author | Bilal Alsharifi <bilal.alsharifi@gmail.com> | 2019-03-07 11:24:17 -0500 |
---|---|---|
committer | Bilal Alsharifi <bilal.alsharifi@gmail.com> | 2019-03-07 11:24:17 -0500 |
commit | c9fa91f2b964b4974fdb8a725f3fb3b90551dd46 (patch) | |
tree | e6f9d9968e7dc3f7442eff3f49f2836a7af0f6a0 | |
parent | c7c696fd04e1ed2cb7ac40a3f5eb5805b0cbdca4 (diff) | |
download | sdl_android-c9fa91f2b964b4974fdb8a725f3fb3b90551dd46.tar.gz |
git rm proxy files
8 files changed, 40 insertions, 1352 deletions
diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCMessage.java b/android/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCMessage.java index ad7b8c68e..f4beb9d38 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCMessage.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCMessage.java @@ -1,5 +1,7 @@ package com.smartdevicelink.proxy;
+import com.smartdevicelink.protocol.enums.FunctionID;
+
import java.util.Hashtable;
public class RPCMessage extends RPCStruct {
@@ -50,6 +52,13 @@ public class RPCMessage extends RPCStruct { }
}
+ public FunctionID getFunctionID(){
+ if(function.containsKey(KEY_FUNCTION_NAME)){
+ return FunctionID.getEnumForString((String)function.get(KEY_FUNCTION_NAME));
+ }
+ return null;
+ }
+
protected String messageType;
protected Hashtable<String, Object> parameters;
protected Hashtable<String, Object> function;
diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/proxy/SystemCapabilityManager.java b/android/sdl_android/src/main/java/com/smartdevicelink/proxy/SystemCapabilityManager.java index 5020e4123..5cb798869 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/proxy/SystemCapabilityManager.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/proxy/SystemCapabilityManager.java @@ -1,13 +1,12 @@ package com.smartdevicelink.proxy; +import com.smartdevicelink.protocol.enums.FunctionID; import com.smartdevicelink.proxy.interfaces.ISdl; import com.smartdevicelink.proxy.interfaces.OnSystemCapabilityListener; -import com.smartdevicelink.proxy.rpc.GetSystemCapability; -import com.smartdevicelink.proxy.rpc.GetSystemCapabilityResponse; -import com.smartdevicelink.proxy.rpc.HMICapabilities; -import com.smartdevicelink.proxy.rpc.RegisterAppInterfaceResponse; +import com.smartdevicelink.proxy.rpc.*; import com.smartdevicelink.proxy.rpc.enums.Result; import com.smartdevicelink.proxy.rpc.enums.SystemCapabilityType; +import com.smartdevicelink.proxy.rpc.listeners.OnRPCListener; import com.smartdevicelink.proxy.rpc.listeners.OnRPCResponseListener; import com.smartdevicelink.util.CorrelationIdGenerator; import com.smartdevicelink.util.DebugTool; @@ -17,17 +16,22 @@ 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; private final Object LISTENER_LOCK; private final ISdl callback; + private OnRPCListener rpcListener; public SystemCapabilityManager(ISdl callback){ this.callback = callback; this.LISTENER_LOCK = new Object(); this.onSystemCapabilityListeners = new HashMap<>(); this.cachedSystemCapabilities = new HashMap<>(); + + setupRpcListeners(); } public void parseRAIResponse(RegisterAppInterfaceResponse response){ @@ -45,6 +49,29 @@ public class SystemCapabilityManager { } } + private void setupRpcListeners(){ + rpcListener = new OnRPCListener() { + @Override + public void onReceived(RPCMessage message) { + if (message != null && RPCMessage.KEY_RESPONSE.equals(message.getMessageType())) { + switch (message.getFunctionID()) { + case SET_DISPLAY_LAYOUT: + SetDisplayLayoutResponse response = (SetDisplayLayoutResponse)message; + setCapability(SystemCapabilityType.DISPLAY, response.getDisplayCapabilities()); + setCapability(SystemCapabilityType.BUTTON, response.getButtonCapabilities()); + setCapability(SystemCapabilityType.PRESET_BANK, response.getPresetBankCapabilities()); + setCapability(SystemCapabilityType.SOFTBUTTON, response.getSoftButtonCapabilities()); + break; + } + } + } + }; + + if(callback != null){ + callback.addOnRPCListener(FunctionID.SET_DISPLAY_LAYOUT, rpcListener); + } + } + /** * Sets a capability in the cached map. This should only be done when an RPC is received and contains updates to the capability * that is being cached in the SystemCapabilityManager. diff --git a/base/src/main/java/com/smartdevicelink/proxy/RPCMessage.java b/base/src/main/java/com/smartdevicelink/proxy/RPCMessage.java deleted file mode 100644 index 8135424fc..000000000 --- a/base/src/main/java/com/smartdevicelink/proxy/RPCMessage.java +++ /dev/null @@ -1,138 +0,0 @@ -package com.smartdevicelink.proxy; - -import com.smartdevicelink.protocol.enums.FunctionID; - -import java.util.Hashtable; - -public class RPCMessage extends RPCStruct { - public static final String KEY_REQUEST = "request"; - public static final String KEY_RESPONSE = "response"; - public static final String KEY_NOTIFICATION = "notification"; - public static final String KEY_FUNCTION_NAME = "name"; - public static final String KEY_PARAMETERS = "parameters"; - public static final String KEY_CORRELATION_ID = "correlationID"; - - public RPCMessage(String functionName) { - this(functionName, "request"); - } - - protected RPCMessage(RPCMessage rpcm) { - this(rpcm.store); - } - - protected RPCMessage(RPCStruct rpcs) { - this("", ""); - this.parameters = rpcs.store; - } - - public RPCMessage(String functionName, String messageType) { - function = new Hashtable<String, Object>(); - parameters = new Hashtable<String, Object>(); - - this.messageType = messageType; - function.put(KEY_PARAMETERS, parameters); - - if (messageType != null) - store.put(messageType, function); - if (functionName != null) - function.put(KEY_FUNCTION_NAME, functionName); - } - - @SuppressWarnings("unchecked") - public RPCMessage(Hashtable<String, Object> hash) { - store = hash; - messageType = getMessageTypeName(hash.keySet()); - function = (Hashtable<String, Object>) hash.get(messageType); - parameters = (Hashtable<String, Object>) function.get(KEY_PARAMETERS); - if (hasKey(hash.keySet(), RPCStruct.KEY_BULK_DATA)) { - setBulkData((byte[]) hash.get(RPCStruct.KEY_BULK_DATA)); - } - if (hasKey(hash.keySet(), RPCStruct.KEY_PROTECTED)) { - setPayloadProtected((Boolean) hash.get(RPCStruct.KEY_PROTECTED)); - } - } - - public FunctionID getFunctionID(){ - if(function.containsKey(KEY_FUNCTION_NAME)){ - return FunctionID.getEnumForString((String)function.get(KEY_FUNCTION_NAME)); - } - return null; - } - - protected String messageType; - protected Hashtable<String, Object> parameters; - protected Hashtable<String, Object> function; - - public String getFunctionName() { - return (String)function.get(KEY_FUNCTION_NAME); - } - - protected void setFunctionName(String functionName) { - function.put(KEY_FUNCTION_NAME, functionName); - } - - public String getMessageType() { - if (messageType.equals(KEY_REQUEST) || - messageType.equals(KEY_RESPONSE) || - messageType.equals(KEY_NOTIFICATION)) { - return messageType; - } - return null; - } - - // Generalized Getters and Setters - - public void setParameters(String key, Object value) { - if (value != null) { - parameters.put(key, value); - } else { - parameters.remove(key); - } - } - - public Object getParameters(String key) { - return parameters.get(key); - } - - @Override - public Object getObject(Class tClass, String key) { - Object obj = parameters.get(key); - return formatObject(tClass, obj); - } - - // Common Object Getters - - @Override - public String getString(String key) { - return (String) parameters.get(key); - } - - @Override - public Integer getInteger(String key) { - return (Integer) parameters.get(key); - } - - @Override - public Float getFloat(String key) { - return (Float) parameters.get(key); - } - - @Override - public Double getDouble(String key) { - return (Double) parameters.get(key); - } - - @Override - public Boolean getBoolean(String key) { return (Boolean) parameters.get(key); } - - @Override - public Long getLong(String key){ - Object result = parameters.get(key); - if (result instanceof Integer) { - return ((Integer) result).longValue(); - }else if(result instanceof Long){ - return (Long) result; - } - return null; - } -} diff --git a/base/src/main/java/com/smartdevicelink/proxy/RPCRequest.java b/base/src/main/java/com/smartdevicelink/proxy/RPCRequest.java deleted file mode 100644 index fa4700a81..000000000 --- a/base/src/main/java/com/smartdevicelink/proxy/RPCRequest.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * - */ -package com.smartdevicelink.proxy; - -import java.util.Hashtable; - -import com.smartdevicelink.proxy.rpc.listeners.OnRPCResponseListener; -import com.smartdevicelink.util.CorrelationIdGenerator; - -public class RPCRequest extends RPCMessage { - - protected OnRPCResponseListener onResponseListener; - - public RPCRequest(String functionName) { - super(functionName, RPCMessage.KEY_REQUEST); - messageType = RPCMessage.KEY_REQUEST; - } - - public RPCRequest(Hashtable<String, Object> hash) { - super(hash); - } - - public RPCRequest(RPCRequest request){ - super(request); - setCorrelationID(CorrelationIdGenerator.generateId()); - } - public Integer getCorrelationID() { - //First we check to see if a correlation ID is set. If not, create one. - if(!function.containsKey(RPCMessage.KEY_CORRELATION_ID)){ - setCorrelationID(CorrelationIdGenerator.generateId()); - } - return (Integer)function.get(RPCMessage.KEY_CORRELATION_ID); - } - - public void setCorrelationID(Integer correlationID) { - if (correlationID != null) { - function.put(RPCMessage.KEY_CORRELATION_ID, correlationID ); - } else { - function.remove(RPCMessage.KEY_CORRELATION_ID); - } - } - public void setOnRPCResponseListener(OnRPCResponseListener listener){ - onResponseListener = listener; - } - - public OnRPCResponseListener getOnRPCResponseListener(){ - return this.onResponseListener; - } -} diff --git a/base/src/main/java/com/smartdevicelink/proxy/RPCStruct.java b/base/src/main/java/com/smartdevicelink/proxy/RPCStruct.java deleted file mode 100644 index 2d8c8ce3b..000000000 --- a/base/src/main/java/com/smartdevicelink/proxy/RPCStruct.java +++ /dev/null @@ -1,322 +0,0 @@ -package com.smartdevicelink.proxy; - -import android.util.Log; - -import com.smartdevicelink.marshal.JsonRPCMarshaller; -import com.smartdevicelink.util.Version; - -import org.json.JSONException; -import org.json.JSONObject; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Hashtable; -import java.util.List; -import java.util.Set; - -public class RPCStruct { - public static final String KEY_BULK_DATA = "bulkData"; - public static final String KEY_PROTECTED = "protected"; - - private byte[] _bulkData = null; - private Boolean protectedPayload = false; - - private boolean formatRequested = false; - private Version rpcSpecVersion = null; - - - protected Hashtable<String, Object> store = null; - - public boolean getStoreValue(String key) { // for unit testing - return store.contains(key); - } - - public Hashtable<String,Object> getStore () { // for unit testing - return store; - } - - public RPCStruct() { - store = new Hashtable<String, Object>(); - } - - protected RPCStruct(RPCStruct rpcs) { - this.store = rpcs.store; - } - - public RPCStruct(Hashtable<String, Object> hashtable) { - store = hashtable; - //store = (Hashtable<String, Object>) ObjectCopier.copy(hashtable); - } - - public void deserializeJSON(JSONObject jsonObject) throws JSONException { - store = JsonRPCMarshaller.deserializeJSONObject(jsonObject); - - } - - // deserializeJSONObject method moved to JsonRPCMarshaller for consistency - // Keep reference here for backwards compatibility - @Deprecated - public static Hashtable<String, Object> deserializeJSONObject(JSONObject jsonObject) - throws JSONException { - return JsonRPCMarshaller.deserializeJSONObject(jsonObject); - } - - public JSONObject serializeJSON() throws JSONException { - return JsonRPCMarshaller.serializeHashtable(store); - } - - @SuppressWarnings("unchecked") - public JSONObject serializeJSON(byte protocolVersion) throws JSONException { - if (protocolVersion > 1) { - String messageType = getMessageTypeName(store.keySet()); - Hashtable<String, Object> function = (Hashtable<String, Object>) store.get(messageType); - Hashtable<String, Object> parameters = (Hashtable<String, Object>) function.get(RPCMessage.KEY_PARAMETERS); - return JsonRPCMarshaller.serializeHashtable(parameters); - } else return JsonRPCMarshaller.serializeHashtable(store); - } - - /** - * This method should clean the the RPC to make sure it is compliant with the spec. - * <br><br><b> NOTE:</b> Super needs to be called at the END of the method - * - * @param rpcVersion the rpc spec version that has been negotiated. If value is null the - * the max value of RPC spec version this library supports should be used. - * @param formatParams if true, the format method will be called on subsequent params - */ - public void format(Version rpcVersion, boolean formatParams){ - formatRequested = true; - rpcSpecVersion = rpcVersion; - //Should override this method when breaking changes are made to the RPC spec - if(formatParams && store != null){ - Hashtable<String, Object> parameters; - - if(this instanceof RPCMessage) { - //If this is a message (request, response, notification) the parameters have to be - //retrieved from the store object. - String messageType = getMessageTypeName(store.keySet()); - Hashtable<String, Object> function = (Hashtable<String, Object>) store.get(messageType); - parameters = (Hashtable<String, Object>) function.get(RPCMessage.KEY_PARAMETERS); - } else { - //If this is just an RPC struct the store itself should be used - parameters = store; - } - - if (parameters != null) { - for(Object value:parameters.values()){ - internalFormat(rpcVersion, value); - } - } - } - } - - /** - * Cycles through parameters in this RPC to ensure they all get formated - * @param rpcVersion version of the rpc spec that should be used to format this rpc - * @param value the object to investigate if it needs to be formated - */ - private void internalFormat(Version rpcVersion, Object value) { - if(value instanceof RPCStruct) { - ((RPCStruct)value).format(rpcVersion,true); - } else if(value instanceof List<?>) { - List<?> list = (List<?>)value; - if(list != null && list.size() > 0) { - for(Object listItem: list){ - internalFormat(rpcVersion, listItem); - } - } - } - } - - - public byte[] getBulkData() { - return this._bulkData; - } - - public void setBulkData(byte[] bulkData) { - if (bulkData != null) { - this._bulkData = new byte[bulkData.length]; - System.arraycopy(bulkData, 0, _bulkData, 0, bulkData.length); - } - else{ - this._bulkData = null; - } - } - - public void setPayloadProtected(Boolean bVal) { - protectedPayload = bVal; - } - - public Boolean isPayloadProtected() { - return protectedPayload; - } - - protected String getMessageTypeName(Set<String> keys) { - for (String key : keys) { - if (key == null) { - continue; - } - if (key.equals(RPCMessage.KEY_REQUEST) || key.equals(RPCMessage.KEY_RESPONSE) || - key.equals(RPCMessage.KEY_NOTIFICATION)) { - return key; - } - } - return null; - } - - protected boolean hasKey(Set<String> keys, String keyName) { - for (String key : keys) { - if (key == null) { - continue; - } - if (key.equals(keyName)) { - return true; - } - } - return false; - } - - // Generalized Getters and Setters - - public void setValue(String key, Object value){ - if (value != null) { - store.put(key, value); - } else { - store.remove(key); - } - } - - public Object getValue(String key) { - return store.get(key); - } - - public Object getObject(Class tClass, String key) { - Object obj = store.get(key); - return formatObject(tClass, obj); - } - - // Helper methods - - /** - * @param tClass a Class to cast Objects to - * @param obj Object returned from a stored hashtable - * @return A null object if obj is null or if none of the following is true: - * a) obj is an instance of tClass - * b) obj is an instance of String and it tClass has a valid `valueForString` method - * c) obj is an instance of a Hashtable - * d) obj is an instance of a List - */ - protected Object formatObject(Class tClass, Object obj){ - if(obj == null){ - return null; - } else if (tClass.isInstance(obj)) { - return obj; - } else if (obj instanceof String) { - return getValueForString(tClass, (String) obj); - } else if (obj instanceof Hashtable) { - try { - Constructor constructor = tClass.getConstructor(Hashtable.class); - Object customObject = constructor.newInstance((Hashtable<String, Object>) obj); - if(formatRequested && customObject instanceof RPCStruct){ - ((RPCStruct)customObject).format(rpcSpecVersion,true); - } - - return customObject; - } catch (Exception e) { - e.printStackTrace(); - } - } else if (obj instanceof List<?>) { - List<?> list = (List<?>) obj; - if (list != null && list.size() > 0) { - Object item = list.get(0); - if (tClass.isInstance(item)) { - return list; - } else if (item instanceof Hashtable) { - List<Object> newList = new ArrayList<Object>(); - Object customObject; - for (Object hashObj : list) { - try { - Constructor constructor = tClass.getConstructor(Hashtable.class); - customObject = constructor.newInstance((Hashtable<String, Object>) hashObj); - if(formatRequested - && customObject != null - && customObject instanceof RPCStruct){ - ((RPCStruct)customObject).format(rpcSpecVersion,true); - } - newList.add(customObject); - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } - return newList; - } else if (item instanceof String){ - List<Object> newList = new ArrayList<Object>(); - for (Object hashObj : list) { - Object toAdd = getValueForString(tClass, (String) hashObj); - if (toAdd != null) { - newList.add(toAdd); - } - } - return newList; - } - } - } - return null; - } - - /** - * @param tClass - a Class with a `valueForString(String s)` method that returns an Object for a given String - * @param s - a String to be converted to an Object using a `valueForString(String s)` method - * @return An Object converted using a `valueForString(String s)` method in the Class passed in, or a null object if such method does not exist - */ - protected Object getValueForString(Class tClass, String s){ - Method valueForString = null; - try { - valueForString = tClass.getDeclaredMethod("valueForString", String.class); - } catch (NoSuchMethodException e) { - e.printStackTrace(); - } - if(valueForString != null){ - try { - Object value = valueForString.invoke(null, (String) s); - return value; - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } - } - return null; - } - - // Common Object Getters - public String getString(String key) { - return (String) store.get(key); - } - - public Integer getInteger(String key) { - return (Integer) store.get(key); - } - - public Double getDouble(String key) { - return (Double) store.get(key); - } - - public Float getFloat(String key) { - return (Float) store.get(key); - } - - public Boolean getBoolean(String key) { return (Boolean) store.get(key); } - - public Long getLong(String key){ - Object result = store.get(key); - if (result instanceof Integer) { - return ((Integer) result).longValue(); - }else if(result instanceof Long){ - return (Long) result; - } - return null; - } -} diff --git a/base/src/main/java/com/smartdevicelink/proxy/SystemCapabilityManager.java b/base/src/main/java/com/smartdevicelink/proxy/SystemCapabilityManager.java deleted file mode 100644 index 6cf2d496c..000000000 --- a/base/src/main/java/com/smartdevicelink/proxy/SystemCapabilityManager.java +++ /dev/null @@ -1,250 +0,0 @@ -package com.smartdevicelink.proxy; - -import com.smartdevicelink.protocol.enums.FunctionID; -import com.smartdevicelink.proxy.interfaces.ISdl; -import com.smartdevicelink.proxy.interfaces.OnSystemCapabilityListener; -import com.smartdevicelink.proxy.rpc.*; -import com.smartdevicelink.proxy.rpc.enums.Result; -import com.smartdevicelink.proxy.rpc.enums.SystemCapabilityType; -import com.smartdevicelink.proxy.rpc.listeners.OnRPCListener; -import com.smartdevicelink.proxy.rpc.listeners.OnRPCResponseListener; -import com.smartdevicelink.util.CorrelationIdGenerator; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; - -public class SystemCapabilityManager { - private final HashMap<SystemCapabilityType, Object> cachedSystemCapabilities; - private final HashMap<SystemCapabilityType, CopyOnWriteArrayList<OnSystemCapabilityListener>> onSystemCapabilityListeners; - private final Object LISTENER_LOCK; - private final ISdl callback; - private OnRPCListener rpcListener; - - public SystemCapabilityManager(ISdl callback){ - this.callback = callback; - this.LISTENER_LOCK = new Object(); - this.onSystemCapabilityListeners = new HashMap<>(); - this.cachedSystemCapabilities = new HashMap<>(); - - setupRpcListeners(); - } - - public void parseRAIResponse(RegisterAppInterfaceResponse response){ - if(response!=null && response.getSuccess()) { - setCapability(SystemCapabilityType.HMI, response.getHmiCapabilities()); - setCapability(SystemCapabilityType.DISPLAY, response.getDisplayCapabilities()); - setCapability(SystemCapabilityType.AUDIO_PASSTHROUGH, response.getAudioPassThruCapabilities()); - setCapability(SystemCapabilityType.PCM_STREAMING, response.getPcmStreamingCapabilities()); - setCapability(SystemCapabilityType.BUTTON, response.getButtonCapabilities()); - setCapability(SystemCapabilityType.HMI_ZONE, response.getHmiZoneCapabilities()); - setCapability(SystemCapabilityType.PRESET_BANK, response.getPresetBankCapabilities()); - setCapability(SystemCapabilityType.SOFTBUTTON, response.getSoftButtonCapabilities()); - setCapability(SystemCapabilityType.SPEECH, response.getSpeechCapabilities()); - setCapability(SystemCapabilityType.VOICE_RECOGNITION, response.getVrCapabilities()); - } - } - - private void setupRpcListeners(){ - rpcListener = new OnRPCListener() { - @Override - public void onReceived(RPCMessage message) { - if (message != null && RPCMessage.KEY_RESPONSE.equals(message.getMessageType())) { - switch (message.getFunctionID()) { - case SET_DISPLAY_LAYOUT: - SetDisplayLayoutResponse response = (SetDisplayLayoutResponse)message; - setCapability(SystemCapabilityType.DISPLAY, response.getDisplayCapabilities()); - setCapability(SystemCapabilityType.BUTTON, response.getButtonCapabilities()); - setCapability(SystemCapabilityType.PRESET_BANK, response.getPresetBankCapabilities()); - setCapability(SystemCapabilityType.SOFTBUTTON, response.getSoftButtonCapabilities()); - break; - } - } - } - }; - - if(callback != null){ - callback.addOnRPCListener(FunctionID.SET_DISPLAY_LAYOUT, rpcListener); - } - } - - /** - * Sets a capability in the cached map. This should only be done when an RPC is received and contains updates to the capability - * that is being cached in the SystemCapabilityManager. - * @param systemCapabilityType - * @param capability - */ - public synchronized void setCapability(SystemCapabilityType systemCapabilityType, Object capability){ - cachedSystemCapabilities.put(systemCapabilityType, capability); - notifyListeners(systemCapabilityType, capability); - } - - /** - * Notify listners in the list about the new retrieved capability - * @param systemCapabilityType - * @param capability - */ - private void notifyListeners(SystemCapabilityType systemCapabilityType, Object capability) { - synchronized(LISTENER_LOCK){ - CopyOnWriteArrayList<OnSystemCapabilityListener> listeners = onSystemCapabilityListeners.get(systemCapabilityType); - if(listeners != null && listeners.size() > 0) { - for (OnSystemCapabilityListener listener : listeners) { - listener.onCapabilityRetrieved(capability); - } - } - } - } - - /** - * Ability to see if the connected module supports the given capability. Useful to check before - * attempting to query for capabilities that require asynchronous calls to initialize. - * @param type the SystemCapabilityType that is to be checked - * @return if that capability is supported with the current, connected module - */ - public boolean isCapabilitySupported(SystemCapabilityType type){ - if(cachedSystemCapabilities.get(type) != null){ - //The capability exists in the map and is not null - return true; - }else if(cachedSystemCapabilities.containsKey(SystemCapabilityType.HMI)){ - HMICapabilities hmiCapabilities = ((HMICapabilities)cachedSystemCapabilities.get(SystemCapabilityType.HMI)); - switch (type) { - case NAVIGATION: - return hmiCapabilities.isNavigationAvailable(); - case PHONE_CALL: - return hmiCapabilities.isPhoneCallAvailable(); - case VIDEO_STREAMING: - return hmiCapabilities.isVideoStreamingAvailable(); - case REMOTE_CONTROL: - return hmiCapabilities.isRemoteControlAvailable(); - default: - return false; - } - }else{ - return false; - } - } - /** - * @param systemCapabilityType Type of capability desired - * @param scListener callback to execute upon retrieving capability - */ - public void getCapability(final SystemCapabilityType systemCapabilityType, final OnSystemCapabilityListener scListener){ - Object capability = cachedSystemCapabilities.get(systemCapabilityType); - if(capability != null){ - scListener.onCapabilityRetrieved(capability); - return; - }else if(scListener == null){ - return; - } - - retrieveCapability(systemCapabilityType, scListener); - } - - /** - * @param systemCapabilityType Type of capability desired - * @return Desired capability if it is cached in the manager, otherwise returns a null object - * and works in the background to retrieve the capability for the next call - */ - public Object getCapability(final SystemCapabilityType systemCapabilityType){ - Object capability = cachedSystemCapabilities.get(systemCapabilityType); - if(capability != null){ - return capability; - } - - retrieveCapability(systemCapabilityType, null); - return null; - } - - /** - * Add a listener to be called whenever a new capability is retrieved - * @param systemCapabilityType Type of capability desired - * @param listener callback to execute upon retrieving capability - */ - public void addOnSystemCapabilityListener(final SystemCapabilityType systemCapabilityType, final OnSystemCapabilityListener listener){ - getCapability(systemCapabilityType, listener); - synchronized(LISTENER_LOCK){ - if (systemCapabilityType != null && listener != null) { - if (onSystemCapabilityListeners.get(systemCapabilityType) == null) { - onSystemCapabilityListeners.put(systemCapabilityType, new CopyOnWriteArrayList<OnSystemCapabilityListener>()); - } - onSystemCapabilityListeners.get(systemCapabilityType).add(listener); - } - } - } - - /** - * Remove an OnSystemCapabilityListener that was previously added - * @param systemCapabilityType Type of capability - * @param listener the listener that should be removed - */ - public boolean removeOnSystemCapabilityListener(final SystemCapabilityType systemCapabilityType, final OnSystemCapabilityListener listener){ - synchronized(LISTENER_LOCK){ - if(onSystemCapabilityListeners!= null - && systemCapabilityType != null - && listener != null - && onSystemCapabilityListeners.get(systemCapabilityType) != null){ - return onSystemCapabilityListeners.get(systemCapabilityType).remove(listener); - } - } - return false; - } - - /** - * @param systemCapabilityType Type of capability desired - * passes GetSystemCapabilityType request to `callback` to be sent by proxy - */ - private void retrieveCapability(final SystemCapabilityType systemCapabilityType, final OnSystemCapabilityListener scListener){ - final GetSystemCapability request = new GetSystemCapability(); - request.setSystemCapabilityType(systemCapabilityType); - request.setOnRPCResponseListener(new OnRPCResponseListener() { - @Override - public void onResponse(int correlationId, RPCResponse response) { - if(response.getSuccess()){ - Object retrievedCapability = ((GetSystemCapabilityResponse) response).getSystemCapability().getCapabilityForType(systemCapabilityType); - cachedSystemCapabilities.put(systemCapabilityType, retrievedCapability); - if(scListener!=null){scListener.onCapabilityRetrieved(retrievedCapability); } - }else{ - if(scListener!=null){scListener.onError(response.getInfo());} - } - } - - @Override - public void onError(int correlationId, Result resultCode, String info) { - if(scListener!=null){scListener.onError(info);} - } - }); - request.setCorrelationID(CorrelationIdGenerator.generateId()); - - if(callback!=null){ - callback.sendRPCRequest(request); - } - } - - /** - * Converts a capability object into a list. - * @param object the capability that needs to be converted - * @param classType The class type of that should be contained in the list - * @return a List of capabilities if object is instance of List, otherwise it will return null. - */ - @SuppressWarnings({"unchecked"}) - public static <T> List<T> convertToList(Object object, Class<T> classType){ - if(classType!=null && object!=null && object instanceof List ){ - List list = (List)object; - if(!list.isEmpty()){ - if(classType.isInstance(list.get(0))){ - return (List<T>)object; - }else{ - //The list is not of the correct list type - return null; - } - }else { - //We return a new list of type T instead of null because while we don't know if - //the original list was of type T we want to ensure that we don't throw a cast class exception - //but still - return new ArrayList<T>(); - } - }else{ - return null; - } - } -} diff --git a/base/src/main/java/com/smartdevicelink/proxy/interfaces/IProxyListenerBase.java b/base/src/main/java/com/smartdevicelink/proxy/interfaces/IProxyListenerBase.java deleted file mode 100644 index f5bfeaf57..000000000 --- a/base/src/main/java/com/smartdevicelink/proxy/interfaces/IProxyListenerBase.java +++ /dev/null @@ -1,359 +0,0 @@ -package com.smartdevicelink.proxy.interfaces; - -import com.smartdevicelink.proxy.callbacks.OnServiceEnded; -import com.smartdevicelink.proxy.callbacks.OnServiceNACKed; -import com.smartdevicelink.proxy.rpc.AddCommandResponse; -import com.smartdevicelink.proxy.rpc.AddSubMenuResponse; -import com.smartdevicelink.proxy.rpc.AlertManeuverResponse; -import com.smartdevicelink.proxy.rpc.AlertResponse; -import com.smartdevicelink.proxy.rpc.ButtonPressResponse; -import com.smartdevicelink.proxy.rpc.ChangeRegistrationResponse; -import com.smartdevicelink.proxy.rpc.CreateInteractionChoiceSetResponse; -import com.smartdevicelink.proxy.rpc.DeleteCommandResponse; -import com.smartdevicelink.proxy.rpc.DeleteFileResponse; -import com.smartdevicelink.proxy.rpc.DeleteInteractionChoiceSetResponse; -import com.smartdevicelink.proxy.rpc.DeleteSubMenuResponse; -import com.smartdevicelink.proxy.rpc.DiagnosticMessageResponse; -import com.smartdevicelink.proxy.rpc.DialNumberResponse; -import com.smartdevicelink.proxy.rpc.EndAudioPassThruResponse; -import com.smartdevicelink.proxy.rpc.GenericResponse; -import com.smartdevicelink.proxy.rpc.GetDTCsResponse; -import com.smartdevicelink.proxy.rpc.GetInteriorVehicleDataResponse; -import com.smartdevicelink.proxy.rpc.GetSystemCapabilityResponse; -import com.smartdevicelink.proxy.rpc.GetVehicleDataResponse; -import com.smartdevicelink.proxy.rpc.GetWayPointsResponse; -import com.smartdevicelink.proxy.rpc.ListFilesResponse; -import com.smartdevicelink.proxy.rpc.OnAudioPassThru; -import com.smartdevicelink.proxy.rpc.OnButtonEvent; -import com.smartdevicelink.proxy.rpc.OnButtonPress; -import com.smartdevicelink.proxy.rpc.OnCommand; -import com.smartdevicelink.proxy.rpc.OnDriverDistraction; -import com.smartdevicelink.proxy.rpc.OnHMIStatus; -import com.smartdevicelink.proxy.rpc.OnHashChange; -import com.smartdevicelink.proxy.rpc.OnInteriorVehicleData; -import com.smartdevicelink.proxy.rpc.OnKeyboardInput; -import com.smartdevicelink.proxy.rpc.OnLanguageChange; -import com.smartdevicelink.proxy.rpc.OnLockScreenStatus; -import com.smartdevicelink.proxy.rpc.OnPermissionsChange; -import com.smartdevicelink.proxy.rpc.OnRCStatus; -import com.smartdevicelink.proxy.rpc.OnStreamRPC; -import com.smartdevicelink.proxy.rpc.OnSystemRequest; -import com.smartdevicelink.proxy.rpc.OnTBTClientState; -import com.smartdevicelink.proxy.rpc.OnTouchEvent; -import com.smartdevicelink.proxy.rpc.OnVehicleData; -import com.smartdevicelink.proxy.rpc.OnWayPointChange; -import com.smartdevicelink.proxy.rpc.PerformAudioPassThruResponse; -import com.smartdevicelink.proxy.rpc.PerformInteractionResponse; -import com.smartdevicelink.proxy.rpc.PutFileResponse; -import com.smartdevicelink.proxy.rpc.ReadDIDResponse; -import com.smartdevicelink.proxy.rpc.ResetGlobalPropertiesResponse; -import com.smartdevicelink.proxy.rpc.ScrollableMessageResponse; -import com.smartdevicelink.proxy.rpc.SendHapticDataResponse; -import com.smartdevicelink.proxy.rpc.SendLocationResponse; -import com.smartdevicelink.proxy.rpc.SetAppIconResponse; -import com.smartdevicelink.proxy.rpc.SetDisplayLayoutResponse; -import com.smartdevicelink.proxy.rpc.SetGlobalPropertiesResponse; -import com.smartdevicelink.proxy.rpc.SetInteriorVehicleDataResponse; -import com.smartdevicelink.proxy.rpc.SetMediaClockTimerResponse; -import com.smartdevicelink.proxy.rpc.ShowConstantTbtResponse; -import com.smartdevicelink.proxy.rpc.ShowResponse; -import com.smartdevicelink.proxy.rpc.SliderResponse; -import com.smartdevicelink.proxy.rpc.SpeakResponse; -import com.smartdevicelink.proxy.rpc.StreamRPCResponse; -import com.smartdevicelink.proxy.rpc.SubscribeButtonResponse; -import com.smartdevicelink.proxy.rpc.SubscribeVehicleDataResponse; -import com.smartdevicelink.proxy.rpc.SubscribeWayPointsResponse; -import com.smartdevicelink.proxy.rpc.SystemRequestResponse; -import com.smartdevicelink.proxy.rpc.UnsubscribeButtonResponse; -import com.smartdevicelink.proxy.rpc.UnsubscribeVehicleDataResponse; -import com.smartdevicelink.proxy.rpc.UnsubscribeWayPointsResponse; -import com.smartdevicelink.proxy.rpc.UpdateTurnListResponse; -import com.smartdevicelink.proxy.rpc.enums.SdlDisconnectedReason; - - -public interface IProxyListenerBase { - - /** - * onOnHMIStatus being called indicates that there has been an HMI Level change, - * system context change or audio streaming state change. - * - * @param notification - Contains information about the HMI Level, - * system context and audio streaming state. - */ - public void onOnHMIStatus(OnHMIStatus notification); - - /** - * onProxyClosed has different functionality for the different models. - * In the non-ALM model this indicates that the proxy has experienced an unrecoverable error. - * A new proxy object must be initiated to reestablish connection with SDL. - * In the ALM model this indicates that the app is no longer registered with SDL - * All resources on SDL (addCommands and ChoiceSets) have been deleted and will have to be - * recreated upon the next onReadyForInitialization() call-back. - * - * @param info - Includes information about the reason the proxy has been closed. - * @param e - The exception that occurred. - */ - public void onProxyClosed(String info, Exception e, SdlDisconnectedReason reason); - - public void onServiceEnded(OnServiceEnded serviceEnded); - - public void onServiceNACKed(OnServiceNACKed serviceNACKed); - - public void onOnStreamRPC(OnStreamRPC notification); - - public void onStreamRPCResponse(StreamRPCResponse response); - - /** - * onProxyError() being called indicates that the SDL Proxy experenced an error. - * - * @param info - Includes information about the Exception that occurred. - * @param e - The exception that occurred. - */ - public void onError(String info, Exception e); - - /** - * onGenericResponse() being called indicates that SDL could not determine the - * type of request it is responding to. This is usually result of an unknown RPC Request - * being sent. - * - * @param response - Includes detailed information about the response. - */ - public void onGenericResponse(GenericResponse response); - - /** - * onOnCommand() being called indicates that the user selected a command on SDL. - * - * @param notification - Contains information about the command chosen. - */ - public void onOnCommand(OnCommand notification); - - /** - * onAddCommandResponse() being called indicates that SDL has responded to - * a request to add a command. - * - * @param response - Contains information about the response sent from SDL. - */ - public void onAddCommandResponse(AddCommandResponse response); - - /** - * onAddSubMenuResponse() being called indicates that SDL has responded to - * a request to add a command. - * - * @param response - Contains information about the response sent from SDL. - */ - public void onAddSubMenuResponse(AddSubMenuResponse response); - - /** - * onCreateInteractionChoiceSetResponse() being called indicates that SDL has - * responded to a request to add an interactionChoiceSet. - * - * @param response - Contains information about the response sent from SDL. - */ - public void onCreateInteractionChoiceSetResponse(CreateInteractionChoiceSetResponse response); - - /** - * onAlertResponse being called indicates that SDL has - * responded to a request to alert the user. - * - * @param response - Contains information about the response sent from SDL. - */ - public void onAlertResponse(AlertResponse response); - - /** - * onDeleteCommandResponse being called indicates that SDL has - * responded to a request to delete a command. - * - * @param response - Contains information about the response sent from SDL. - */ - public void onDeleteCommandResponse(DeleteCommandResponse response); - - /** - * onDeleteCommandResponse being called indicates that SDL has - * responded to a request to delete an interaction choice set. - * - * @param response - Contains information about the response sent from SDL. - */ - public void onDeleteInteractionChoiceSetResponse(DeleteInteractionChoiceSetResponse response); - - /** - * onDeleteCommandResponse being called indicates that SDL has - * responded to a request to delete a submenu. - * - * @param response - Contains information about the response sent from SDL. - */ - public void onDeleteSubMenuResponse(DeleteSubMenuResponse response); - - /** - * onPerformInteractionResponse being called indicates that SDL has - * responded to a request to perform an interaction. - * - * @param response - Contains information about the response sent from SDL. - */ - public void onPerformInteractionResponse(PerformInteractionResponse response); - - /** - * onResetGlobalPropertiesResponse being called indicates that SDL has - * responded to a request to reset global properties. - * - * @param response - Contains information about the response sent from SDL. - */ - public void onResetGlobalPropertiesResponse(ResetGlobalPropertiesResponse response); - - /** - * onSetGlobalPropertiesResponse being called indicates that SDL has - * responded to a request to set global properties. - * - * @param response - Contains information about the response sent from SDL. - */ - public void onSetGlobalPropertiesResponse(SetGlobalPropertiesResponse response); - - /** - * onSetMediaClockTimerResponse being called indicates that SDL has - * responded to a request to set the media clock timer. - * - * @param response - Contains information about the response sent from SDL. - */ - public void onSetMediaClockTimerResponse(SetMediaClockTimerResponse response); - - /** - * onShowResponse being called indicates that SDL has - * responded to a request to display information to the user. - * - * @param response - Contains information about the response sent from SDL. - */ - public void onShowResponse(ShowResponse response); - - /** - * onSpeakResponse being called indicates that SDL has - * responded to a request to speak information to the user. - * - * @param response - Contains information about the response sent from SDL. - */ - public void onSpeakResponse(SpeakResponse response); - - /** - * onButtonEvent being called indicates that a button event has occurred. - * - * @param notification - Contains information about the notification sent from SDL. - */ - public void onOnButtonEvent(OnButtonEvent notification); - - /** - * onButtonPress being called indicates that SDL has a button has - * been pressed by the user. - * - * @param notification - Contains information about the notification sent from SDL. - */ - public void onOnButtonPress(OnButtonPress notification); - - /** - * onSubscribeButtonResponse being called indicates that SDL has - * responded to a request to subscribe to button events and button presses. - * - * @param response - Contains information about the response sent from SDL. - */ - public void onSubscribeButtonResponse(SubscribeButtonResponse response); - - /** - * onUnsubscribeButtonResponse being called indicates that SDL has - * responded to a request to unsubscribe from button events and button presses. - * - * @param response - Contains information about the response sent from SDL. - */ - public void onUnsubscribeButtonResponse(UnsubscribeButtonResponse response); - - /** - * onOnPermissionsChange being called indicates that your app permissions have - * changed due to a policy table change. This can mean your app has received additional - * permissions OR lost permissions. - * - * @param notification - Contains information about the changed permissions. - */ - public void onOnPermissionsChange(OnPermissionsChange notification); - - public void onSubscribeVehicleDataResponse(SubscribeVehicleDataResponse response); - - public void onUnsubscribeVehicleDataResponse(UnsubscribeVehicleDataResponse response); - - public void onGetVehicleDataResponse(GetVehicleDataResponse response); - - public void onOnVehicleData(OnVehicleData notification); - - public void onPerformAudioPassThruResponse(PerformAudioPassThruResponse response); - - public void onEndAudioPassThruResponse(EndAudioPassThruResponse response); - - public void onOnAudioPassThru(OnAudioPassThru notification); - - public void onPutFileResponse(PutFileResponse response); - - public void onDeleteFileResponse(DeleteFileResponse response); - - public void onListFilesResponse(ListFilesResponse response); - - public void onSetAppIconResponse(SetAppIconResponse response); - - public void onScrollableMessageResponse(ScrollableMessageResponse response); - - public void onChangeRegistrationResponse(ChangeRegistrationResponse response); - - public void onSetDisplayLayoutResponse(SetDisplayLayoutResponse response); - - public void onOnLanguageChange(OnLanguageChange notification); - - public void onOnHashChange(OnHashChange notification); - - public void onSliderResponse(SliderResponse response); - - public void onOnDriverDistraction(OnDriverDistraction notification); - - public void onOnTBTClientState(OnTBTClientState notification); - - public void onOnSystemRequest(OnSystemRequest notification); - - public void onSystemRequestResponse(SystemRequestResponse response); - - public void onOnKeyboardInput(OnKeyboardInput notification); - - public void onOnTouchEvent(OnTouchEvent notification); - - public void onDiagnosticMessageResponse(DiagnosticMessageResponse response); - - public void onReadDIDResponse(ReadDIDResponse response); - - public void onGetDTCsResponse(GetDTCsResponse response); - - public void onOnLockScreenNotification(OnLockScreenStatus notification); - - public void onDialNumberResponse(DialNumberResponse response); - - public void onSendLocationResponse(SendLocationResponse response); - - public void onShowConstantTbtResponse(ShowConstantTbtResponse response); - - public void onAlertManeuverResponse(AlertManeuverResponse response); - - public void onUpdateTurnListResponse(UpdateTurnListResponse response); - - public void onServiceDataACK(int dataSize); - public void onGetWayPointsResponse(GetWayPointsResponse response); - - public void onSubscribeWayPointsResponse(SubscribeWayPointsResponse response); - - public void onUnsubscribeWayPointsResponse(UnsubscribeWayPointsResponse response); - public void onOnWayPointChange(OnWayPointChange notification); - - public void onGetSystemCapabilityResponse(GetSystemCapabilityResponse response); - - public void onGetInteriorVehicleDataResponse(GetInteriorVehicleDataResponse response); - - public void onButtonPressResponse(ButtonPressResponse response); - - public void onSetInteriorVehicleDataResponse(SetInteriorVehicleDataResponse response); - - public void onOnInteriorVehicleData(OnInteriorVehicleData notification); - - public void onSendHapticDataResponse(SendHapticDataResponse response); - - public void onOnRCStatus(OnRCStatus notification); -} diff --git a/base/src/main/java/com/smartdevicelink/proxy/interfaces/ISdl.java b/base/src/main/java/com/smartdevicelink/proxy/interfaces/ISdl.java deleted file mode 100644 index 5eb8ff36a..000000000 --- a/base/src/main/java/com/smartdevicelink/proxy/interfaces/ISdl.java +++ /dev/null @@ -1,229 +0,0 @@ -package com.smartdevicelink.proxy.interfaces; - -import android.support.annotation.NonNull; - -import com.smartdevicelink.protocol.enums.FunctionID; -import com.smartdevicelink.protocol.enums.SessionType; -import com.smartdevicelink.proxy.RPCRequest; -import com.smartdevicelink.util.Version; -import com.smartdevicelink.proxy.rpc.SdlMsgVersion; -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.streaming.audio.AudioStreamingCodec; -import com.smartdevicelink.streaming.audio.AudioStreamingParams; -import com.smartdevicelink.streaming.video.VideoStreamingParameters; - -import java.util.List; - -/* - * Copyright (c) 2017 Livio, 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 Livio 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. - */ -@SuppressWarnings("unused") -public interface ISdl { - - /** - * Starts the connection with the module - */ - void start(); - - /** - * Ends connection with the module - */ - void stop(); - - /** - * Method to check if the session is connected - * @return if there is a connected session - */ - boolean isConnected(); - - /** - * Add a service listener for a specific service type - * @param serviceType service type that the listener will be attached to - * @param sdlServiceListener listener for events that happen to the service - */ - void addServiceListener(SessionType serviceType, ISdlServiceListener sdlServiceListener); - - /** - * Remote a service listener for a specific service type - * @param serviceType service type that the listener was attached to - * @param sdlServiceListener service listener that was previously added for the service type - */ - void removeServiceListener(SessionType serviceType, ISdlServiceListener sdlServiceListener); - - /** - * Starts the video streaming service - * @param parameters desired video streaming params for this sevice to be started with - * @param encrypted flag to start this service with encryption or not - */ - void startVideoService(VideoStreamingParameters parameters, boolean encrypted); - - /** - * Stops the video service if open - */ - void stopVideoService(); - - /** - * Starts the video streaming service - * @param isEncrypted flag to start this service with encryption or not - * @param parameters desired video streaming params for this sevice to be started with - */ - IVideoStreamListener startVideoStream(boolean isEncrypted, VideoStreamingParameters parameters); - - /** - * Starts the Audio streaming service - * @param encrypted flag to start this service with encryption or not - */ - void startAudioService(boolean encrypted, AudioStreamingCodec codec, AudioStreamingParams params); - - /** - * Starts the Audio streaming service - * @param encrypted flag to start this service with encryption or not - */ - void startAudioService(boolean encrypted); - - /** - * Stops the audio service if open - */ - void stopAudioService(); - - /** - * Start Audio Stream and return IAudioStreamListener - * @param isEncrypted - * @param codec - * @param params - * @return IAudioStreamListener - */ - IAudioStreamListener startAudioStream(boolean isEncrypted, AudioStreamingCodec codec, AudioStreamingParams params); - - /** - * Pass an RPC message through the proxy to be sent to the connected module - * @param message RPCRequest that should be sent to the module - */ - void sendRPCRequest(RPCRequest message); - - /** - * Pass a list of RPC requests through the proxy to be sent to core - * @param rpcs List of RPC requests - * @param listener OnMultipleRequestListener that is called between requests and after all are processed - */ - 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 - */ - void addOnRPCNotificationListener(FunctionID notificationId, OnRPCNotificationListener listener); - - /** - * Removes an OnRPCNotificationListener for specified notification - * @param notificationId FunctionID of the notification that was to be listened for - * @param listener listener that was previously added for the notification ID - */ - boolean removeOnRPCNotificationListener(FunctionID notificationId, OnRPCNotificationListener 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 - */ - void addOnRPCListener(FunctionID responseId, OnRPCListener listener); - - /** - * Removes an OnRPCResponseListener for specified response - * @param responseId FunctionID of the response that was to be listened for - * @param listener listener that was previously added for the response ID - */ - boolean removeOnRPCListener(FunctionID responseId, OnRPCListener listener); - - /** - * Get SystemCapability Object - * @param systemCapabilityType - * @return Object - */ - Object getCapability(SystemCapabilityType systemCapabilityType); - - /** - * Get Capability - * @param systemCapabilityType - * @param scListener - */ - void getCapability(SystemCapabilityType systemCapabilityType, OnSystemCapabilityListener scListener); - - /** - * Check if capability is supported - * @param systemCapabilityType - * @return Boolean - */ - boolean isCapabilitySupported(SystemCapabilityType systemCapabilityType); - - /** - * Add a listener to be called whenever a new capability is retrieved - * @param systemCapabilityType Type of capability desired - * @param listener callback to execute upon retrieving capability - */ - void addOnSystemCapabilityListener(SystemCapabilityType systemCapabilityType, OnSystemCapabilityListener listener); - - /** - * Remove an OnSystemCapabilityListener that was previously added - * @param systemCapabilityType Type of capability - * @param listener the listener that should be removed - */ - boolean removeOnSystemCapabilityListener(SystemCapabilityType systemCapabilityType, OnSystemCapabilityListener listener); - - /** - * Check to see if a transport is available to start/use the supplied service. - * @param serviceType the session that should be checked for transport availability - * @return true if there is either a supported - * transport currently connected or a transport is - * available to connect with for the supplied service type. - * <br>false if there is no - * transport connected to support the service type in question and - * no possibility in the foreseeable future. - */ - boolean isTransportForServiceAvailable(SessionType serviceType); - - /** - * Get the RPC specification version currently being used for the SDL messages - * @return SdlMsgVersion the current RPC specification version - */ - @NonNull SdlMsgVersion getSdlMsgVersion(); - - /** - * Get the protocol version of this session - * @return byte value representing WiPro version - */ - @NonNull Version getProtocolVersion(); - -} |