diff options
author | Bretty White <geekman3454@protonmail.com> | 2018-05-16 13:50:53 -0400 |
---|---|---|
committer | Bretty White <geekman3454@protonmail.com> | 2018-05-16 13:50:53 -0400 |
commit | 26c686cd9ac5d7015b7d29dbc11b6f896da3bb74 (patch) | |
tree | 03c8713f8e700a085f5ed1be0b52cb16243dbec7 | |
parent | 7830315a5469a7ed99ce6587e6ed253ce680fdba (diff) | |
download | sdl_android-26c686cd9ac5d7015b7d29dbc11b6f896da3bb74.tar.gz |
start of sdlmanager, adding base classes
4 files changed, 980 insertions, 72 deletions
diff --git a/sdl_android/src/main/java/com/smartdevicelink/api/CompletionListener.java b/sdl_android/src/main/java/com/smartdevicelink/api/CompletionListener.java new file mode 100644 index 000000000..631a39fa8 --- /dev/null +++ b/sdl_android/src/main/java/com/smartdevicelink/api/CompletionListener.java @@ -0,0 +1,10 @@ +package com.smartdevicelink.api; + +public interface CompletionListener { + + /** + * Returns whether a specific operation was successful or not + * @param success - success or fail + */ + void onComplete(boolean success); +} diff --git a/sdl_android/src/main/java/com/smartdevicelink/api/ProxyBridge.java b/sdl_android/src/main/java/com/smartdevicelink/api/ProxyBridge.java new file mode 100644 index 000000000..4dadad170 --- /dev/null +++ b/sdl_android/src/main/java/com/smartdevicelink/api/ProxyBridge.java @@ -0,0 +1,532 @@ +package com.smartdevicelink.api; + +import android.util.SparseArray; + +import com.smartdevicelink.protocol.enums.FunctionID; +import com.smartdevicelink.proxy.RPCMessage; +import com.smartdevicelink.proxy.callbacks.OnServiceEnded; +import com.smartdevicelink.proxy.callbacks.OnServiceNACKed; +import com.smartdevicelink.proxy.interfaces.IProxyListenerBase; +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.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; + +import java.util.concurrent.CopyOnWriteArrayList; + +public class ProxyBridge implements IProxyListenerBase{ + private final Object RPC_LISTENER_LOCK = new Object(); + protected SparseArray<CopyOnWriteArrayList<OnRPCListener>> rpcListeners = null; + final LifecycleListener lifecycleListener; + + public interface OnRPCListener { + void onRpcReceived(int functionID, RPCMessage message); + } + + protected interface LifecycleListener{ + void onProxyClosed(String info, Exception e, SdlDisconnectedReason reason); + void onServiceEnded(OnServiceEnded serviceEnded); + void onServiceNACKed(OnServiceNACKed serviceNACKed); + void onError(String info, Exception e); + } + + public ProxyBridge( LifecycleListener lifecycleListener){ + this.lifecycleListener = lifecycleListener; + rpcListeners = new SparseArray<>(); + } + + public boolean onRPCReceived(final RPCMessage message){ + synchronized(RPC_LISTENER_LOCK){ + final int id = FunctionID.getFunctionId(message.getFunctionName()); + CopyOnWriteArrayList<OnRPCListener> listeners = rpcListeners.get(id); + if(listeners!=null && listeners.size()>0) { + for (OnRPCListener listener : listeners) { + listener.onRpcReceived(id,message); + } + return true; + } + return false; + } + } + + protected void addRpcListener(FunctionID id, OnRPCListener listener){ + synchronized(RPC_LISTENER_LOCK){ + if (id != null && listener != null) { + if (rpcListeners.indexOfKey(id.getId()) < 0) { + rpcListeners.put(id.getId(), new CopyOnWriteArrayList<OnRPCListener>()); + } + rpcListeners.get(id.getId()).add(listener); + } + } + } + + public boolean removeOnRPCListener(FunctionID id, OnRPCListener listener){ + synchronized(RPC_LISTENER_LOCK){ + if(rpcListeners!= null + && id != null + && listener != null + && rpcListeners.indexOfKey(id.getId()) >= 0){ + return rpcListeners.get(id.getId()).remove(listener); + } + } + return false; + } + + @Override + public void onProxyClosed(String info, Exception e, SdlDisconnectedReason reason) { + lifecycleListener.onProxyClosed(info,e,reason); + } + + @Override + public void onServiceEnded(OnServiceEnded serviceEnded) { + lifecycleListener.onServiceEnded(serviceEnded); + + } + + @Override + public void onServiceNACKed(OnServiceNACKed serviceNACKed) { + lifecycleListener.onServiceNACKed(serviceNACKed); + + } + @Override + public void onError(String info, Exception e) { + lifecycleListener.onError(info, e); + } + + @Override + public void onOnStreamRPC(OnStreamRPC notification) { + onRPCReceived(notification); + + } + + @Override + public void onStreamRPCResponse(StreamRPCResponse response) { + onRPCReceived(response); + } + + @Override + public void onOnHMIStatus(OnHMIStatus notification) { + onRPCReceived(notification); + } + + @Override + public void onGenericResponse(GenericResponse response) { + onRPCReceived(response); + + } + + @Override + public void onOnCommand(OnCommand notification) { + onRPCReceived(notification); + } + + @Override + public void onAddCommandResponse(AddCommandResponse response) { + onRPCReceived(response); + } + + @Override + public void onAddSubMenuResponse(AddSubMenuResponse response) { + onRPCReceived(response); + + } + + @Override + public void onCreateInteractionChoiceSetResponse(CreateInteractionChoiceSetResponse response) { + onRPCReceived(response); + + } + + @Override + public void onAlertResponse(AlertResponse response) { + onRPCReceived(response); + + } + + @Override + public void onDeleteCommandResponse(DeleteCommandResponse response) { + onRPCReceived(response); + + } + + @Override + public void onDeleteInteractionChoiceSetResponse(DeleteInteractionChoiceSetResponse response) { + onRPCReceived(response); + + } + + @Override + public void onDeleteSubMenuResponse(DeleteSubMenuResponse response) { + onRPCReceived(response); + + } + + @Override + public void onPerformInteractionResponse(PerformInteractionResponse response) { + onRPCReceived(response); + + } + + @Override + public void onResetGlobalPropertiesResponse(ResetGlobalPropertiesResponse response) { + onRPCReceived(response); + + } + + @Override + public void onSetGlobalPropertiesResponse(SetGlobalPropertiesResponse response) { + onRPCReceived(response); + + } + + @Override + public void onSetMediaClockTimerResponse(SetMediaClockTimerResponse response) { + onRPCReceived(response); + + } + + @Override + public void onShowResponse(ShowResponse response) { + onRPCReceived(response); + + } + + @Override + public void onSpeakResponse(SpeakResponse response) { + onRPCReceived(response); + + } + + @Override + public void onOnButtonEvent(OnButtonEvent notification) { + onRPCReceived(notification); + } + + @Override + public void onOnButtonPress(OnButtonPress notification) { + onRPCReceived(notification); + } + + @Override + public void onSubscribeButtonResponse(SubscribeButtonResponse response) { + onRPCReceived(response); + + } + + @Override + public void onUnsubscribeButtonResponse(UnsubscribeButtonResponse response) { + onRPCReceived(response); + + } + + @Override + public void onOnPermissionsChange(OnPermissionsChange notification) { + onRPCReceived(notification); + } + + @Override + public void onSubscribeVehicleDataResponse(SubscribeVehicleDataResponse response) { + onRPCReceived(response); + + } + + @Override + public void onUnsubscribeVehicleDataResponse(UnsubscribeVehicleDataResponse response) { + onRPCReceived(response); + + } + + @Override + public void onGetVehicleDataResponse(GetVehicleDataResponse response) { + onRPCReceived(response); + + } + + @Override + public void onOnVehicleData(OnVehicleData notification) { + onRPCReceived(notification); + } + + @Override + public void onPerformAudioPassThruResponse(PerformAudioPassThruResponse response) { + onRPCReceived(response); + + } + + @Override + public void onEndAudioPassThruResponse(EndAudioPassThruResponse response) { + onRPCReceived(response); + + } + + @Override + public void onOnAudioPassThru(OnAudioPassThru notification) { + onRPCReceived(notification); + } + + @Override + public void onPutFileResponse(PutFileResponse response) { + onRPCReceived(response); + + } + + @Override + public void onDeleteFileResponse(DeleteFileResponse response) { + onRPCReceived(response); + + } + + @Override + public void onListFilesResponse(ListFilesResponse response) { + onRPCReceived(response); + + } + + @Override + public void onSetAppIconResponse(SetAppIconResponse response) { + onRPCReceived(response); + + } + + @Override + public void onScrollableMessageResponse(ScrollableMessageResponse response) { + onRPCReceived(response); + + } + + @Override + public void onChangeRegistrationResponse(ChangeRegistrationResponse response) { + onRPCReceived(response); + + } + + @Override + public void onSetDisplayLayoutResponse(SetDisplayLayoutResponse response) { + onRPCReceived(response); + + } + + @Override + public void onOnLanguageChange(OnLanguageChange notification) { + onRPCReceived(notification); + } + + @Override + public void onOnHashChange(OnHashChange notification) { + onRPCReceived(notification); + } + + @Override + public void onSliderResponse(SliderResponse response) { + onRPCReceived(response); + + } + + @Override + public void onOnDriverDistraction(OnDriverDistraction notification) { + onRPCReceived(notification); + } + + @Override + public void onOnTBTClientState(OnTBTClientState notification) { + onRPCReceived(notification); + } + + @Override + public void onOnSystemRequest(OnSystemRequest notification) { + onRPCReceived(notification); + } + + @Override + public void onSystemRequestResponse(SystemRequestResponse response) { + onRPCReceived(response); + + } + + @Override + public void onOnKeyboardInput(OnKeyboardInput notification) { + onRPCReceived(notification); + } + + @Override + public void onOnTouchEvent(OnTouchEvent notification) { + onRPCReceived(notification); + } + + @Override + public void onDiagnosticMessageResponse(DiagnosticMessageResponse response) { + onRPCReceived(response); + + } + + @Override + public void onReadDIDResponse(ReadDIDResponse response) { + onRPCReceived(response); + + } + + @Override + public void onGetDTCsResponse(GetDTCsResponse response) { + onRPCReceived(response); + + } + + @Override + public void onOnLockScreenNotification(OnLockScreenStatus notification) { + onRPCReceived(notification); + } + + @Override + public void onDialNumberResponse(DialNumberResponse response) { + onRPCReceived(response); + + } + + @Override + public void onSendLocationResponse(SendLocationResponse response) { + onRPCReceived(response); + + } + + @Override + public void onShowConstantTbtResponse(ShowConstantTbtResponse response) { + onRPCReceived(response); + + } + + @Override + public void onAlertManeuverResponse(AlertManeuverResponse response) { + onRPCReceived(response); + + } + + @Override + public void onUpdateTurnListResponse(UpdateTurnListResponse response) { + onRPCReceived(response); + + } + + @Override + public void onServiceDataACK(int dataSize) { + + } + + @Override + public void onGetWayPointsResponse(GetWayPointsResponse response) { + onRPCReceived(response); + + } + + @Override + public void onSubscribeWayPointsResponse(SubscribeWayPointsResponse response) { + onRPCReceived(response); + + } + + @Override + public void onUnsubscribeWayPointsResponse(UnsubscribeWayPointsResponse response) { + onRPCReceived(response); + + } + + @Override + public void onOnWayPointChange(OnWayPointChange notification) { + onRPCReceived(notification); + } + + @Override + public void onGetSystemCapabilityResponse(GetSystemCapabilityResponse response) { + onRPCReceived(response); + + } + + @Override + public void onGetInteriorVehicleDataResponse(GetInteriorVehicleDataResponse response) { + onRPCReceived(response); + + } + + @Override + public void onButtonPressResponse(ButtonPressResponse response) { + onRPCReceived(response); + + } + + @Override + public void onSetInteriorVehicleDataResponse(SetInteriorVehicleDataResponse response) { + onRPCReceived(response); + + } + + @Override + public void onOnInteriorVehicleData(OnInteriorVehicleData notification) { + onRPCReceived(notification); + } + + @Override + public void onSendHapticDataResponse(SendHapticDataResponse response) { + onRPCReceived(response); + } +} diff --git a/sdl_android/src/main/java/com/smartdevicelink/api/SdlManager.java b/sdl_android/src/main/java/com/smartdevicelink/api/SdlManager.java new file mode 100644 index 000000000..2f2957096 --- /dev/null +++ b/sdl_android/src/main/java/com/smartdevicelink/api/SdlManager.java @@ -0,0 +1,340 @@ +package com.smartdevicelink.api; + +import android.content.Context; + +import com.smartdevicelink.exception.SdlException; +import com.smartdevicelink.protocol.enums.FunctionID; +import com.smartdevicelink.protocol.enums.SessionType; +import com.smartdevicelink.proxy.RPCRequest; +import com.smartdevicelink.proxy.SdlProxyBase; +import com.smartdevicelink.proxy.callbacks.OnServiceEnded; +import com.smartdevicelink.proxy.callbacks.OnServiceNACKed; +import com.smartdevicelink.proxy.interfaces.IAudioStreamListener; +import com.smartdevicelink.proxy.interfaces.ISdl; +import com.smartdevicelink.proxy.interfaces.ISdlServiceListener; +import com.smartdevicelink.proxy.interfaces.IVideoStreamListener; +import com.smartdevicelink.proxy.interfaces.OnSystemCapabilityListener; +import com.smartdevicelink.proxy.rpc.SdlMsgVersion; +import com.smartdevicelink.proxy.rpc.enums.AppHMIType; +import com.smartdevicelink.proxy.rpc.enums.Language; +import com.smartdevicelink.proxy.rpc.enums.SdlDisconnectedReason; +import com.smartdevicelink.proxy.rpc.enums.SystemCapabilityType; +import com.smartdevicelink.proxy.rpc.listeners.OnMultipleRequestListener; +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 com.smartdevicelink.transport.BaseTransportConfig; + +import java.util.List; +import java.util.Vector; + +/** + * <strong>SDLManager</strong> <br> + * + * This is the main point of contact between an application and SDL <br> + * + * It is broken down to these areas: <br> + * + * 1. SDLManagerBuilder <br> + * 2. ISdl Interface along with its overridden methods - This can be passed into attached managers <br> + * 3. Sending Requests <br> + * 4. Helper methods + */ +public class SdlManager implements ProxyBridge.LifecycleListener { + + private static String TAG = "Sdl Manager"; + private SdlProxyBase proxy; + + // Required parameters for builder + private String appId, appName; + private boolean isMediaApp; + private Language hmiLanguage; + private Vector<AppHMIType> hmiTypes; + private BaseTransportConfig transport; + private Context context; + + private ProxyBridge proxyBridge; + //public LockScreenConfig lockScreenConfig; + + // Managers + /* + private FileManager fileManager; + private VideoStreamingManager videoStreamingManager; + private AudioStreamManager audioStreamManager; + private LockscreenManager lockscreenManager; + private ScreenManager screenManager; + private PermissionManager permissionManager; + */ + + private SdlManager() {} + + private void initialize(){ + // proxy bridge + this.proxyBridge = new ProxyBridge(this); + // instantiate managers + /* + this.fileManager = new FileManager(_internalInterface, context); + this.lockscreenManager = new LockscreenManager(lockScreenConfig, context, _internalInterface); + this.screenManager = new ScreenManager(_internalInterface, this.fileManager); + this.permissionManager = new PermissionManager(_internalInterface); + this.videoStreamingManager = new VideoStreamingManager(context, _internalInterface); + this.audioStreamManager = new AudioStreamManager(_internalInterface); + */ + } + + private void dispose() { + /* + this.fileManager.dispose(); + this.lockscreenManager.dispose(); + this.audioStreamManager.dispose(); + this.screenManager.dispose(); + this.permissionManager.dispose(); + this.videoStreamingManager.dispose(); + this.audioStreamManager.dispose(); + */ + } + + // BUILDER + + public static class Builder { + SdlManager sdlManager; + + public Builder(){ + sdlManager = new SdlManager(); + } + + public Builder setAppId(final String appId){ + sdlManager.appId = appId; + return this; + } + + public Builder setAppName(final String appName){ + sdlManager.appName = appName; + return this; + } + + public Builder setIsMediaApp(final Boolean isMediaApp){ + sdlManager.isMediaApp = isMediaApp; + return this; + } + + public Builder setLanguage(final Language hmiLanguage){ + sdlManager.hmiLanguage = hmiLanguage; + return this; + } + + /*public Builder setLockScreenConfig (final LockScreenConfig lockScreenConfig){ + sdlManager.lockScreenConfig = lockScreenConfig; + return this; + }*/ + + public Builder setHMITypes(final Vector<AppHMIType> hmiTypes){ + sdlManager.hmiTypes = hmiTypes; + return this; + } + + /** + * This Object type may change with the transport refactor + */ + public Builder setTransportType(BaseTransportConfig transport){ + sdlManager.transport = transport; + return this; + } + + public Builder setContext(Context context){ + sdlManager.context = context; + return this; + } + + @SuppressWarnings("unchecked") + public SdlManager build() { + try { + sdlManager.initialize(); + sdlManager.proxy = new SdlProxyBase(sdlManager.proxyBridge, sdlManager.appName, sdlManager.isMediaApp, sdlManager.hmiLanguage, sdlManager.hmiLanguage, sdlManager.hmiTypes, sdlManager.appId, sdlManager.transport ) {}; + } catch (SdlException e) { + e.printStackTrace(); + } + return sdlManager; + } + } + + // MANAGER GETTERS + + /*public FileManager getFileManager() { + return fileManager; + } + + public VideoStreamingManager getVideoStreamingManager() { + return videoStreamingManager; + } + + public AudioStreamManager getAudioStreamManager() { + return audioStreamManager; + } + + public ScreenManager getScreenManager() { + return screenManager; + } + + public LockscreenManager getLockscreenManager() { + return lockscreenManager; + } + + public PermissionManager getPermissionManager() { + return permissionManager; + }*/ + + // SENDING REQUESTS + + public void sendRPCRequest(RPCRequest request) throws SdlException { + proxy.sendRPCRequest(request); + } + + public void sendSequentialRequests(final List<? extends RPCRequest> rpcs, final OnMultipleRequestListener listener) throws SdlException { + proxy.sendSequentialRequests(rpcs, listener); + } + + public void sendRequests(List<? extends RPCRequest> rpcs, final OnMultipleRequestListener listener) throws SdlException { + proxy.sendRequests(rpcs, listener); + } + + // LIFECYCLE / OTHER + + @Override + public void onProxyClosed(String info, Exception e, SdlDisconnectedReason reason){ + this.dispose(); + } + + @Override + public void onServiceEnded(OnServiceEnded serviceEnded){ + + } + + @Override + public void onServiceNACKed(OnServiceNACKed serviceNACKed){ + + } + + @Override + public void onError(String info, Exception e){ + + } + + // INTERNAL INTERFACE + + private ISdl _internalInterface = new ISdl() { + @Override + public void start() { + try{ + proxy.initializeProxy(); + }catch (SdlException e){ + e.printStackTrace(); + } + } + + @Override + public void stop() { + try{ + proxy.dispose(); + }catch (SdlException e){ + e.printStackTrace(); + } + } + + @Override + public boolean isConnected() { + return proxy.getIsConnected(); + } + + @Override + public void addServiceListener(SessionType serviceType, ISdlServiceListener sdlServiceListener) { + proxy.addServiceListener(serviceType,sdlServiceListener); + } + + @Override + public void removeServiceListener(SessionType serviceType, ISdlServiceListener sdlServiceListener) { + proxy.removeServiceListener(serviceType,sdlServiceListener); + } + + @Override + public void startVideoService(VideoStreamingParameters parameters, boolean encrypted) { + if(proxy.getIsConnected()){ + proxy.startVideoStream(encrypted,parameters); + } + } + + @Override + public IVideoStreamListener startVideoStream(boolean isEncrypted, VideoStreamingParameters parameters){ + return proxy.startVideoStream(isEncrypted, parameters); + } + + @Override + public void stopVideoService() { + if(proxy.getIsConnected()){ + proxy.endVideoStream(); + } + } + + @Override + public void startAudioService(boolean isEncrypted, AudioStreamingCodec codec, + AudioStreamingParams params) { + if(proxy.getIsConnected()){ + proxy.startAudioStream(isEncrypted, codec, params); + } + } + + @Override + public IAudioStreamListener startAudioStream(boolean isEncrypted, AudioStreamingCodec codec, + AudioStreamingParams params) { + return proxy.startAudioStream(isEncrypted, codec, params); + } + + @Override + public void stopAudioService() { + if(proxy.getIsConnected()){ + proxy.endAudioStream(); + } + } + + @Override + public void sendRPCRequest(RPCRequest message){ + try { + proxy.sendRPCRequest(message); + } catch (SdlException e) { + e.printStackTrace(); + } + } + + @Override + public void addOnRPCNotificationListener(FunctionID notificationId, OnRPCNotificationListener listener) { + proxy.addOnRPCNotificationListener(notificationId,listener); + } + + @Override + public boolean removeOnRPCNotificationListener(FunctionID notificationId, OnRPCNotificationListener listener) { + return proxy.removeOnRPCNotificationListener(notificationId,listener); + } + + @Override + public Object getCapability(SystemCapabilityType systemCapabilityType){ + return proxy.getCapability(systemCapabilityType); + } + + @Override + public void getCapability(SystemCapabilityType systemCapabilityType, OnSystemCapabilityListener scListener) { + proxy.getCapability(systemCapabilityType, scListener); + } + + @Override + public boolean isCapabilitySupported(SystemCapabilityType systemCapabilityType){ + return proxy.isCapabilitySupported(systemCapabilityType); + } + + @Override + public SdlMsgVersion getSdlMsgVersion(){ + return proxy.getSdlMsgVersion(); + } + }; + +} diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/ISdl.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/ISdl.java index 9177a146b..a414e8111 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/ISdl.java +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/ISdl.java @@ -1,9 +1,15 @@ package com.smartdevicelink.proxy.interfaces; +import android.content.Context; + import com.smartdevicelink.protocol.enums.FunctionID; import com.smartdevicelink.protocol.enums.SessionType; import com.smartdevicelink.proxy.RPCRequest; +import com.smartdevicelink.proxy.rpc.SdlMsgVersion; +import com.smartdevicelink.proxy.rpc.enums.SystemCapabilityType; 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; /* @@ -40,77 +46,97 @@ import com.smartdevicelink.streaming.video.VideoStreamingParameters; @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 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(); - - /** - * 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); - - /** - * 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); + /** + * 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 + */ + @Deprecated + void startVideoService(VideoStreamingParameters parameters, boolean encrypted); + + /** + * 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); + + /** + * Stops the video service if open + */ + void stopVideoService(); + + /** + * Starts the Audio streaming service + * @param encrypted flag to start this service with encryption or not + */ + void startAudioService(boolean encrypted, AudioStreamingCodec codec, + AudioStreamingParams params); + + IAudioStreamListener startAudioStream(boolean isEncrypted, AudioStreamingCodec codec, + AudioStreamingParams params); + + /** + * Stops the audio service if open + */ + void stopAudioService(); + + /** + * 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); + + /** + * 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); + + + Object getCapability(SystemCapabilityType systemCapabilityType); + + void getCapability(SystemCapabilityType systemCapabilityType, OnSystemCapabilityListener scListener); + + boolean isCapabilitySupported(SystemCapabilityType systemCapabilityType); + SdlMsgVersion getSdlMsgVersion(); } |