summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java19
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/SystemCapabilityManager.java83
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/IProxyListenerBase.java5
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SystemCapability.java28
4 files changed, 132 insertions, 3 deletions
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java
index 59a44a27b..1205827e4 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java
@@ -2831,8 +2831,23 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_proxyListener.onUpdateTurnListResponse(msg);
onRPCResponseReceived(msg);
}
- }
- else {
+ } else if (functionName.equals(FunctionID.GET_SYSTEM_CAPABILITY.toString())) {
+ // GetSystemCapabilityResponse
+ final GetSystemCapabilityResponse msg = new GetSystemCapabilityResponse(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onGetSystemCapabilityResponse(msg);
+ onRPCResponseReceived(msg);
+ }
+ });
+ } else {
+ _proxyListener.onGetSystemCapabilityResponse(msg);
+ onRPCResponseReceived(msg);
+ }
+ } else {
if (_sdlMsgVersion != null) {
DebugTool.logError("Unrecognized response Message: " + functionName.toString() +
"SDL Message Version = " + _sdlMsgVersion);
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/SystemCapabilityManager.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/SystemCapabilityManager.java
new file mode 100644
index 000000000..0a03d0b56
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/SystemCapabilityManager.java
@@ -0,0 +1,83 @@
+package com.smartdevicelink.proxy;
+
+import com.smartdevicelink.exception.SdlException;
+import com.smartdevicelink.proxy.rpc.GetSystemCapability;
+import com.smartdevicelink.proxy.rpc.GetSystemCapabilityResponse;
+import com.smartdevicelink.proxy.rpc.SystemCapability;
+import com.smartdevicelink.proxy.rpc.enums.SystemCapabilityType;
+import com.smartdevicelink.proxy.rpc.listeners.OnRPCResponseListener;
+import com.smartdevicelink.util.CorrelationIdGenerator;
+
+import java.util.HashMap;
+
+/**
+ * Created by austinkirk on 6/12/17.
+ */
+
+public class SystemCapabilityManager {
+ HashMap<String, Object> cachedSystemCapabilities = new HashMap<>();
+ SdlProxyALM proxy = null;
+ final Object SYS_CAP_LOCK = new Object();
+
+ public SystemCapabilityManager(SdlProxyALM proxyALM){
+ proxy = proxyALM;
+ }
+
+ public Object getSystemCapability(final SystemCapabilityType systemCapabilityType) throws SdlException {
+ Object obj = cachedSystemCapabilities.get(systemCapabilityType.toString());
+ if(obj != null){
+ return obj;
+ }
+
+ if(systemCapabilityType.equals(SystemCapabilityType.NAVIGATION)){
+ if(!proxy.getHmiCapabilities().isNavigationAvailable()){
+ return null;
+ }
+ }else if(systemCapabilityType.equals(SystemCapabilityType.PHONE_CALL)){
+ if(!proxy.getHmiCapabilities().isPhoneCallAvailable()){
+ return null;
+ }
+ }else if(systemCapabilityType.equals(SystemCapabilityType.VIDEO_STREAMING)){
+ if(!proxy.getHmiCapabilities().isVideoStreamingAvailable()){
+ return null;
+ }
+ }else if(systemCapabilityType.equals(SystemCapabilityType.AUDIO_STREAMING)){
+ if(!proxy.getHmiCapabilities().isAudioStreamingAvailable()){
+ return null;
+ }
+ }
+
+ final GetSystemCapability request = new GetSystemCapability();
+ request.setSystemCapabilityType(systemCapabilityType);
+ request.setOnRPCResponseListener(new OnRPCResponseListener() {
+ @Override
+ public void onResponse(int correlationId, RPCResponse response) {
+ if(response.getSuccess()){
+ SystemCapability systemCapability = ((GetSystemCapabilityResponse) response).getSystemCapability();
+ Object capability = systemCapability.getCapabilityForType(systemCapabilityType);
+ if(capability != null) {
+ synchronized(SYS_CAP_LOCK){
+ SYS_CAP_LOCK.notify();
+ }
+ cachedSystemCapabilities.put(systemCapabilityType.toString(), capability);
+ }
+ }
+ }
+ });
+ request.setCorrelationID(CorrelationIdGenerator.generateId());
+ proxy.sendRPCRequest(request);
+
+ synchronized(SYS_CAP_LOCK) {
+ try {
+ SYS_CAP_LOCK.wait();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ obj = cachedSystemCapabilities.get(systemCapabilityType.toString());
+ return obj;
+ }
+
+}
+
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/IProxyListenerBase.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/IProxyListenerBase.java
index 8b437e05e..62ddbc1e0 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/IProxyListenerBase.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/IProxyListenerBase.java
@@ -17,6 +17,7 @@ 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.GetSystemCapabilityResponse;
import com.smartdevicelink.proxy.rpc.GetVehicleDataResponse;
import com.smartdevicelink.proxy.rpc.GetWayPointsResponse;
import com.smartdevicelink.proxy.rpc.ListFilesResponse;
@@ -31,9 +32,9 @@ 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.OnStreamRPC;
import com.smartdevicelink.proxy.rpc.OnSystemRequest;
import com.smartdevicelink.proxy.rpc.OnTBTClientState;
-import com.smartdevicelink.proxy.rpc.OnStreamRPC;
import com.smartdevicelink.proxy.rpc.OnTouchEvent;
import com.smartdevicelink.proxy.rpc.OnVehicleData;
import com.smartdevicelink.proxy.rpc.OnWayPointChange;
@@ -335,4 +336,6 @@ public interface IProxyListenerBase {
public void onUnsubscribeWayPointsResponse(UnsubscribeWayPointsResponse response);
public void onOnWayPointChange(OnWayPointChange notification);
+
+ public void onGetSystemCapabilityResponse(GetSystemCapabilityResponse response);
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SystemCapability.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SystemCapability.java
index d60d72445..65bad1204 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SystemCapability.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SystemCapability.java
@@ -38,4 +38,32 @@ public class SystemCapability extends RPCStruct {
}
// TODO: Implement individual capability methods
+
+ public Object getCapabilityForType(SystemCapabilityType type){
+ if(type.equals(SystemCapabilityType.NAVIGATION)){
+ return getObject(Object.class, KEY_NAVIGATION_CAPABILITY);
+ }else if(type.equals(SystemCapabilityType.PHONE_CALL)){
+ return getObject(Object.class, KEY_PHONE_CAPABILITY);
+ }else if(type.equals(SystemCapabilityType.VIDEO_STREAMING)){
+ return getObject(Object.class, KEY_VIDEO_STREAMING_CAPABILITY);
+ }else if(type.equals(SystemCapabilityType.AUDIO_STREAMING)){
+ return getObject(Object.class, KEY_AUDIO_STREAMING_CAPABILITY);
+ }else{
+ return null;
+ }
+ }
+
+ public void setCapabilityForType(SystemCapabilityType type, Object capability){
+ if(type.equals(SystemCapabilityType.NAVIGATION)){
+ setValue(KEY_NAVIGATION_CAPABILITY, (Object) capability);
+ }else if(type.equals(SystemCapabilityType.PHONE_CALL)){
+ setValue(KEY_PHONE_CAPABILITY, (Object) capability);
+ }else if(type.equals(SystemCapabilityType.VIDEO_STREAMING)){
+ setValue(KEY_VIDEO_STREAMING_CAPABILITY, (Object) capability);
+ }else if(type.equals(SystemCapabilityType.AUDIO_STREAMING)){
+ setValue(KEY_AUDIO_STREAMING_CAPABILITY, (Object) capability);
+ }else{
+ return;
+ }
+ }
}