From e18faa8780084db2f7aeb02c3fb2286fd67c6ab9 Mon Sep 17 00:00:00 2001 From: RHenigan Date: Thu, 6 Aug 2020 14:19:30 -0400 Subject: Add Reason Param to Protocol NAK Base --- .../main/java/com/smartdevicelink/protocol/enums/ControlFrameTags.java | 1 + 1 file changed, 1 insertion(+) diff --git a/base/src/main/java/com/smartdevicelink/protocol/enums/ControlFrameTags.java b/base/src/main/java/com/smartdevicelink/protocol/enums/ControlFrameTags.java index f5ea6836a..b2c27d10c 100644 --- a/base/src/main/java/com/smartdevicelink/protocol/enums/ControlFrameTags.java +++ b/base/src/main/java/com/smartdevicelink/protocol/enums/ControlFrameTags.java @@ -44,6 +44,7 @@ public class ControlFrameTags { private static class NAKBase{ /** An array of rejected parameters related to the corresponding request*/ public static final String REJECTED_PARAMS = "rejectedParams"; + public static final String REASON = "reason"; } /** -- cgit v1.2.1 From 02c14daeca152b97a1237f294ae3c0a5990b1eae Mon Sep 17 00:00:00 2001 From: Bilal Alsharifi Date: Tue, 18 Aug 2020 11:12:41 -0400 Subject: Fix potential race condition in ProtocolBase --- .../smartdevicelink/protocol/SdlProtocolBase.java | 170 ++++++++++++--------- 1 file changed, 96 insertions(+), 74 deletions(-) diff --git a/base/src/main/java/com/smartdevicelink/protocol/SdlProtocolBase.java b/base/src/main/java/com/smartdevicelink/protocol/SdlProtocolBase.java index 18eebbbbc..d54f2de3a 100644 --- a/base/src/main/java/com/smartdevicelink/protocol/SdlProtocolBase.java +++ b/base/src/main/java/com/smartdevicelink/protocol/SdlProtocolBase.java @@ -94,6 +94,8 @@ public class SdlProtocolBase { // Lock to ensure all frames are sent uninterrupted private final Object FRAME_LOCK = new Object(); + private final Object TRANSPORT_MANAGER_LOCK = new Object(); + private final ISdlProtocol iSdlProtocol; private final Hashtable _assemblerForMessageID = new Hashtable<>(); private final Hashtable _messageLocks = new Hashtable<>(); @@ -155,16 +157,20 @@ public class SdlProtocolBase { } // end-ctor void setTransportManager(TransportManagerBase transportManager){ - this.transportManager = transportManager; + synchronized (TRANSPORT_MANAGER_LOCK) { + this.transportManager = transportManager; + } } - public void start(){ - if(transportManager == null){ - throw new IllegalStateException("Attempting to start without setting a transport manager."); + public void start() { + synchronized (TRANSPORT_MANAGER_LOCK) { + if (transportManager == null) { + throw new IllegalStateException("Attempting to start without setting a transport manager."); + } + transportManager.start(); } - transportManager.start(); - } + /** * Retrieves the max payload size for a packet to be sent to the module * @return the max transfer unit @@ -185,14 +191,18 @@ public class SdlProtocolBase { } public void resetSession (){ - if(transportManager == null){ - throw new IllegalStateException("Attempting to reset session without setting a transport manager."); + synchronized (TRANSPORT_MANAGER_LOCK) { + if (transportManager == null) { + throw new IllegalStateException("Attempting to reset session without setting a transport manager."); + } + transportManager.resetSession(); } - transportManager.resetSession(); } public boolean isConnected(){ - return transportManager != null && transportManager.isConnected(null,null); + synchronized (TRANSPORT_MANAGER_LOCK) { + return transportManager != null && transportManager.isConnected(null, null); + } } /** @@ -449,12 +459,14 @@ public class SdlProtocolBase { if (supportedSecondaryTransports != null) { for (TransportType supportedSecondary : supportedSecondaryTransports) { if(!onlyHighBandwidth || supportedSecondary == TransportType.USB || supportedSecondary == TransportType.TCP) { - if (transportManager != null && transportManager.isConnected(supportedSecondary, null)) { - //A supported secondary transport is already connected - return true; - } else if (secondaryTransportParams != null && secondaryTransportParams.containsKey(supportedSecondary)) { - //A secondary transport is available to connect to - return true; + synchronized (TRANSPORT_MANAGER_LOCK) { + if (transportManager != null && transportManager.isConnected(supportedSecondary, null)) { + //A supported secondary transport is already connected + return true; + } else if (secondaryTransportParams != null && secondaryTransportParams.containsKey(supportedSecondary)) { + //A secondary transport is available to connect to + return true; + } } } } @@ -534,10 +546,11 @@ public class SdlProtocolBase { public void endSession(byte sessionID) { SdlPacket header = SdlPacketFactory.createEndSession(SessionType.RPC, sessionID, hashID, (byte)protocolVersion.getMajor(), hashID); handlePacketToSend(header); - if(transportManager != null) { - transportManager.close(sessionID); + synchronized (TRANSPORT_MANAGER_LOCK) { + if (transportManager != null) { + transportManager.close(sessionID); + } } - } // end-method public void sendMessage(ProtocolMessage protocolMsg) { @@ -781,26 +794,27 @@ public class SdlProtocolBase { } }; - if (transportManager != null) { - if (transportManager.isConnected(secondaryTransportType, null)) { - //The transport is actually connected, however no service has been registered - listenerList.add(secondaryListener); - registerSecondaryTransport(sessionID, transportManager.getTransportRecord(secondaryTransportType, null)); - } else if (secondaryTransportParams != null && secondaryTransportParams.containsKey(secondaryTransportType)) { - //No acceptable secondary transport is connected, so first one must be connected - header.setTransportRecord(new TransportRecord(secondaryTransportType, "")); - listenerList.add(secondaryListener); - transportManager.requestSecondaryTransportConnection(sessionID, secondaryTransportParams.get(secondaryTransportType)); + synchronized (TRANSPORT_MANAGER_LOCK) { + if (transportManager != null) { + if (transportManager.isConnected(secondaryTransportType, null)) { + //The transport is actually connected, however no service has been registered + listenerList.add(secondaryListener); + registerSecondaryTransport(sessionID, transportManager.getTransportRecord(secondaryTransportType, null)); + } else if (secondaryTransportParams != null && secondaryTransportParams.containsKey(secondaryTransportType)) { + //No acceptable secondary transport is connected, so first one must be connected + header.setTransportRecord(new TransportRecord(secondaryTransportType, "")); + listenerList.add(secondaryListener); + transportManager.requestSecondaryTransportConnection(sessionID, secondaryTransportParams.get(secondaryTransportType)); + } else { + DebugTool.logWarning(TAG, "No params to connect to secondary transport"); + //Unable to register or start a secondary connection. Use the callback in case + //there is a chance to use the primary transport for this service. + secondaryListener.onConnectionFailure(); + } } else { - DebugTool.logWarning(TAG, "No params to connect to secondary transport"); - //Unable to register or start a secondary connection. Use the callback in case - //there is a chance to use the primary transport for this service. - secondaryListener.onConnectionFailure(); + DebugTool.logError(TAG, "transportManager is null"); } - } else { - DebugTool.logError(TAG, "transportManager is null"); } - } } } @@ -836,11 +850,11 @@ public class SdlProtocolBase { */ protected void handlePacketToSend(SdlPacket packet) { synchronized(FRAME_LOCK) { - - if(packet!=null && transportManager != null) { - transportManager.sendPacket(packet); + synchronized (TRANSPORT_MANAGER_LOCK) { + if (packet != null && transportManager != null) { + transportManager.sendPacket(packet); + } } - } } @@ -1142,8 +1156,10 @@ public class SdlProtocolBase { TransportRecord transportRecord = getTransportForSession(SessionType.RPC); if(transportRecord == null && !requestedSession){ //There is currently no transport registered requestedSession = true; - if (transportManager != null) { - transportManager.requestNewSession(getPreferredTransport(requestedPrimaryTransports, connectedTransports)); + synchronized (TRANSPORT_MANAGER_LOCK) { + if (transportManager != null) { + transportManager.requestNewSession(getPreferredTransport(requestedPrimaryTransports, connectedTransports)); + } } } onTransportsConnectedUpdate(connectedTransports); @@ -1156,8 +1172,10 @@ public class SdlProtocolBase { public void onTransportDisconnected(String info, TransportRecord disconnectedTransport, List connectedTransports) { if (disconnectedTransport == null) { DebugTool.logInfo(TAG, "onTransportDisconnected"); - if (transportManager != null) { - transportManager.close(iSdlProtocol.getSessionId()); + synchronized (TRANSPORT_MANAGER_LOCK) { + if (transportManager != null) { + transportManager.close(iSdlProtocol.getSessionId()); + } } iSdlProtocol.shutdown("No transports left connected"); return; @@ -1185,45 +1203,49 @@ public class SdlProtocolBase { for (TransportType transportType: requestedPrimaryTransports){ DebugTool.logInfo(TAG, "Checking " + transportType.name()); - if(!disconnectedTransport.getType().equals(transportType) - && transportManager != null - && transportManager.isConnected(transportType,null)){ - - //There is currently a supported primary transport - - //See if any high bandwidth transport is available currently - boolean highBandwidthAvailable = transportManager.isHighBandwidthAvailable(); - - if (requiresHighBandwidth) { - if (!highBandwidthAvailable) { - if (TransportType.BLUETOOTH.equals(transportType) - && requestedSecondaryTransports != null - && supportedSecondaryTransports != null) { - for (TransportType secondaryTransport : requestedSecondaryTransports) { - DebugTool.logInfo(TAG, "Checking secondary " + secondaryTransport.name()); - if (supportedSecondaryTransports.contains(secondaryTransport)) { - //Should only be USB or TCP - highBandwidthAvailable = true; - break; + synchronized (TRANSPORT_MANAGER_LOCK) { + if (!disconnectedTransport.getType().equals(transportType) + && transportManager != null + && transportManager.isConnected(transportType, null)) { + + //There is currently a supported primary transport + + //See if any high bandwidth transport is available currently + boolean highBandwidthAvailable = transportManager.isHighBandwidthAvailable(); + + if (requiresHighBandwidth) { + if (!highBandwidthAvailable) { + if (TransportType.BLUETOOTH.equals(transportType) + && requestedSecondaryTransports != null + && supportedSecondaryTransports != null) { + for (TransportType secondaryTransport : requestedSecondaryTransports) { + DebugTool.logInfo(TAG, "Checking secondary " + secondaryTransport.name()); + if (supportedSecondaryTransports.contains(secondaryTransport)) { + //Should only be USB or TCP + highBandwidthAvailable = true; + break; + } } } - } - } // High bandwidth already available - } + } // High bandwidth already available + } - if(!requiresHighBandwidth || (requiresHighBandwidth && highBandwidthAvailable )) { - primaryTransportAvailable = true; - transportManager.updateTransportConfig(transportConfig); - break; + if (!requiresHighBandwidth || (requiresHighBandwidth && highBandwidthAvailable)) { + primaryTransportAvailable = true; + transportManager.updateTransportConfig(transportConfig); + break; + } } } } } connectedPrimaryTransport = null; - if (transportManager != null) { - transportManager.close(iSdlProtocol.getSessionId()); + synchronized (TRANSPORT_MANAGER_LOCK) { + if (transportManager != null) { + transportManager.close(iSdlProtocol.getSessionId()); + } + transportManager = null; } - transportManager = null; requestedSession = false; activeTransports.clear(); -- cgit v1.2.1 From d1ade9d639958a5a9eca69488d62a0ef7d196f40 Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Tue, 18 Aug 2020 16:10:19 -0400 Subject: Very rough draft, Added two classes TextAndGraphicUpdateOperation and TextAndGraphicsState. Refactored BaseT&Gmanager --- .../managers/screen/BaseTextAndGraphicManager.java | 686 ++++----------------- .../screen/TextAndGraphicUpdateOperation.java | 654 ++++++++++++++++++++ .../managers/screen/TextsAndGraphicsState.java | 150 +++++ 3 files changed, 918 insertions(+), 572 deletions(-) create mode 100644 base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java create mode 100644 base/src/main/java/com/smartdevicelink/managers/screen/TextsAndGraphicsState.java diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java index 654d03f2f..b5ee13f11 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java @@ -33,6 +33,8 @@ package com.smartdevicelink.managers.screen; import androidx.annotation.NonNull; +import com.livio.taskmaster.Queue; +import com.livio.taskmaster.Task; import com.smartdevicelink.managers.BaseSubManager; import com.smartdevicelink.managers.CompletionListener; import com.smartdevicelink.managers.ManagerUtility; @@ -80,15 +82,15 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { private static final String TAG = "TextAndGraphicManager"; - boolean isDirty, hasQueuedUpdate; - volatile Show inProgressUpdate; - Show currentScreenData, queuedImageUpdate; + boolean isDirty; + //volatile Show inProgressUpdate; + Show currentScreenData; HMILevel currentHMILevel; WindowCapability defaultMainWindowCapability; private boolean pendingHMIFull, batchingUpdates; private final WeakReference fileManager; private final WeakReference softButtonManager; - private CompletionListener queuedUpdateListener, inProgressListener, pendingHMIListener; + private CompletionListener pendingHMIListener; SdlArtwork blankArtwork; private OnRPCNotificationListener hmiListener; private OnSystemCapabilityListener onDisplaysCapabilityListener; @@ -96,6 +98,12 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { private TextAlignment textAlignment; private String textField1, textField2, textField3, textField4, mediaTrackTextField, title; private MetadataType textField1Type, textField2Type, textField3Type, textField4Type; + private TextAndGraphicUpdateOperation updateOperation; + + + private Queue transactionQueue; + + private TextsAndGraphicsState textsAndGraphicsState; //Constructors @@ -112,6 +120,10 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { currentScreenData = new Show(); addListeners(); getBlankArtwork(); + //TODO added + this.transactionQueue = newTransactionQueue(); + // this.batchQueue = new ArrayList<>(); + textsAndGraphicsState = new TextsAndGraphicsState(); } @Override @@ -138,13 +150,8 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { secondaryGraphic = null; blankArtwork = null; defaultMainWindowCapability = null; - inProgressUpdate = null; - queuedImageUpdate = null; currentScreenData = null; - queuedUpdateListener = null; pendingHMIListener = null; - inProgressListener = null; - hasQueuedUpdate = false; isDirty = false; pendingHMIFull = false; @@ -155,75 +162,32 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { super.dispose(); } - private void addListeners() { - // add listener - hmiListener = new OnRPCNotificationListener() { - @Override - public void onNotified(RPCNotification notification) { - OnHMIStatus onHMIStatus = (OnHMIStatus)notification; - if (onHMIStatus.getWindowID() != null && onHMIStatus.getWindowID() != PredefinedWindows.DEFAULT_WINDOW.getValue()) { - return; - } - currentHMILevel = onHMIStatus.getHmiLevel(); - if (currentHMILevel == HMILevel.HMI_FULL){ - if (pendingHMIFull){ - DebugTool.logInfo(TAG, "Acquired HMI_FULL with pending update. Sending now"); - pendingHMIFull = false; - sdlUpdate(pendingHMIListener); - pendingHMIListener = null; - } - } - } - }; - internalInterface.addOnRPCNotificationListener(FunctionID.ON_HMI_STATUS, hmiListener); + //TODO temp location Also what do I set the ID to? + private Queue newTransactionQueue() { + Queue queue = internalInterface.getTaskmaster().createQueue("TextAndGraphicManager", 9, false); + //queue.pause(); + return queue; + } + //TODO fix for T&G Manager + // Suspend the queue if the soft button capabilities are null (we assume that soft buttons are not supported) + // OR if the HMI level is NONE since we want to delay sending RPCs until we're in non-NONE + private void updateTransactionQueueSuspended() { + if (defaultMainWindowCapability == null || HMILevel.HMI_NONE.equals(currentHMILevel)) { + DebugTool.logInfo(TAG, String.format("Suspending the transaction queue. Current HMI level is NONE: %b, window capabilities are null: %b", HMILevel.HMI_NONE.equals(currentHMILevel), defaultMainWindowCapability == null)); + transactionQueue.pause(); + } else { + DebugTool.logInfo(TAG, "Starting the transaction queue"); + transactionQueue.resume(); + } + } + //TODO not in IOS - onDisplaysCapabilityListener = new OnSystemCapabilityListener() { - @Override - public void onCapabilityRetrieved(Object capability) { - // instead of using the parameter it's more safe to use the convenience method - List capabilities = SystemCapabilityManager.convertToList(capability, DisplayCapability.class); - if (capabilities == null || capabilities.size() == 0) { - DebugTool.logError(TAG, "TextAndGraphic Manager - Capabilities sent here are null or empty"); - }else { - DisplayCapability display = capabilities.get(0); - for (WindowCapability windowCapability : display.getWindowCapabilities()) { - int currentWindowID = windowCapability.getWindowID() != null ? windowCapability.getWindowID() : PredefinedWindows.DEFAULT_WINDOW.getValue(); - if (currentWindowID == PredefinedWindows.DEFAULT_WINDOW.getValue()) { - defaultMainWindowCapability = windowCapability; - } - } - } - } - - @Override - public void onError(String info) { - DebugTool.logError(TAG, "Display Capability cannot be retrieved"); - defaultMainWindowCapability = null; - } - }; - this.internalInterface.addOnSystemCapabilityListener(SystemCapabilityType.DISPLAYS, onDisplaysCapabilityListener); - } // Upload / Send protected void update(CompletionListener listener) { - // check if is batch update - if (batchingUpdates) { - return; - } - - if (isDirty){ - isDirty = false; - sdlUpdate(listener); - } else if (listener != null) { - listener.onComplete(true); - } - } - - private synchronized void sdlUpdate(CompletionListener listener){ - // make sure hmi is not none if (currentHMILevel == null || currentHMILevel == HMILevel.HMI_NONE){ //Trying to send show on HMI_NONE, waiting for full @@ -234,415 +198,51 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { return; } - //Updating Text and Graphics - if (inProgressUpdate != null){ - - //In progress update exists, queueing update - if (queuedUpdateListener != null){ - - //Queued update already exists, superseding previous queued update - queuedUpdateListener.onComplete(false); - queuedUpdateListener = null; - } - - if (listener != null){ - queuedUpdateListener = listener; - } - - hasQueuedUpdate = true; - + // check if is batch update + if (batchingUpdates) { return; } - Show fullShow = new Show(); - fullShow.setAlignment(textAlignment); - fullShow = assembleShowText(fullShow); - fullShow = assembleShowImages(fullShow); - - inProgressListener = listener; - - if (!shouldUpdatePrimaryImage() && !shouldUpdateSecondaryImage()){ - - //No Images to send, only sending text - inProgressUpdate = extractTextFromShow(fullShow); - sendShow(); - - }else if (!sdlArtworkNeedsUpload(primaryGraphic) && (secondaryGraphic == blankArtwork || !sdlArtworkNeedsUpload(secondaryGraphic))){ - - //Images already uploaded, sending full update - // The files to be updated are already uploaded, send the full show immediately - inProgressUpdate = fullShow; - sendShow(); - } else{ - - // Images need to be uploaded, sending text and uploading images - inProgressUpdate = fullShow; - final Show thisUpdate = fullShow; - - uploadImages(new CompletionListener() { - @Override - public void onComplete(boolean success) { - if (!success){ - DebugTool.logError(TAG, "Error uploading image"); - inProgressUpdate = extractTextFromShow(inProgressUpdate); - sendShow(); - } - // Check if queued image update still matches our images (there could have been a new Show in the meantime) - // and send a new update if it does. Since the images will already be on the head unit, the whole show will be sent - if (thisUpdate.getGraphic() != null && thisUpdate.getGraphic().equals(queuedImageUpdate.getGraphic()) || - (thisUpdate.getSecondaryGraphic() != null && queuedImageUpdate.getSecondaryGraphic() != null) && thisUpdate.getSecondaryGraphic().equals(queuedImageUpdate.getSecondaryGraphic())){ - // Queued image update matches the images we need, sending update - sendShow(); - } - // Else, Queued image update does not match the images we need, skipping update - } - }); - queuedImageUpdate = fullShow; - } - } - - private void sendShow(){ - inProgressUpdate.setOnRPCResponseListener(new OnRPCResponseListener() { - @Override - public void onResponse(int correlationId, RPCResponse response) { - handleResponse(response.getSuccess()); - } - - @Override - public void onError(int correlationId, Result resultCode, String info) { - handleResponse(false); - } - - private void handleResponse(boolean success){ - if (success){ - updateCurrentScreenDataState(inProgressUpdate); - } - - inProgressUpdate = null; - if (inProgressListener != null){ - inProgressListener.onComplete(success); - inProgressListener = null; - } - - if (hasQueuedUpdate){ - //Queued update exists, sending another update - hasQueuedUpdate = false; - CompletionListener temp = queuedUpdateListener; - queuedUpdateListener = null; - sdlUpdate(temp); - } - } - }); - - if (this.softButtonManager.get() != null) { - this.softButtonManager.get().setCurrentMainField1(inProgressUpdate.getMainField1()); - } - internalInterface.sendRPC(inProgressUpdate); - } - - // Images - - private void uploadImages(final CompletionListener listener) { - - List artworksToUpload = new ArrayList<>(); - - // add primary image - if (shouldUpdatePrimaryImage() && !primaryGraphic.isStaticIcon()){ - artworksToUpload.add(primaryGraphic); - } - - // add secondary image - if (shouldUpdateSecondaryImage() && !secondaryGraphic.isStaticIcon()){ - artworksToUpload.add(secondaryGraphic); - } - - if (artworksToUpload.size() == 0 && (primaryGraphic.isStaticIcon() || secondaryGraphic.isStaticIcon())){ - DebugTool.logInfo(TAG, "Upload attempted on static icons, sending them without upload instead"); + if (isDirty){ + isDirty = false; + sdlUpdate(listener); + } else if (listener != null) { listener.onComplete(true); } - - // use file manager to upload art - if (fileManager.get() != null) { - fileManager.get().uploadArtworks(artworksToUpload, new MultipleFileCompletionListener() { - @Override - public void onComplete(Map errors) { - if (errors != null) { - DebugTool.logError(TAG, "Error Uploading Artworks. Error: " + errors.toString()); - listener.onComplete(false); - } else { - listener.onComplete(true); - } - } - }); - } - } - - private Show assembleShowImages(Show show){ - - if (shouldUpdatePrimaryImage()){ - show.setGraphic(primaryGraphic.getImageRPC()); - } - - if (shouldUpdateSecondaryImage()){ - show.setSecondaryGraphic(secondaryGraphic.getImageRPC()); - } - - return show; - } - - // Text - - Show assembleShowText(Show show){ - - show = setBlankTextFields(show); - - if (mediaTrackTextField != null && shouldUpdateMediaTrackField()) { - show.setMediaTrack(mediaTrackTextField); - } - - if (title != null && shouldUpdateTitleField()) { - show.setTemplateTitle(title); - } - - List nonNullFields = findValidMainTextFields(); - if (nonNullFields.isEmpty()){ - return show; - } - - int numberOfLines = defaultMainWindowCapability != null ? ManagerUtility.WindowCapabilityUtility.getMaxNumberOfMainFieldLines(defaultMainWindowCapability) : 4; - - switch (numberOfLines) { - case 1: show = assembleOneLineShowText(show, nonNullFields); - break; - case 2: show = assembleTwoLineShowText(show); - break; - case 3: show = assembleThreeLineShowText(show); - break; - case 4: show = assembleFourLineShowText(show); - break; - } - - return show; - } - - private Show assembleOneLineShowText(Show show, List showFields){ - - StringBuilder showString1 = new StringBuilder(); - for (int i = 0; i < showFields.size(); i++) { - if (i > 0) { - showString1.append(" - ").append(showFields.get(i)); - }else{ - showString1.append(showFields.get(i)); - } - } - show.setMainField1(showString1.toString()); - - MetadataTags tags = new MetadataTags(); - tags.setMainField1(findNonNullMetadataFields()); - - show.setMetadataTags(tags); - - return show; - } - - private Show assembleTwoLineShowText(Show show){ - - StringBuilder tempString = new StringBuilder(); - MetadataTags tags = new MetadataTags(); - - if (textField1 != null && textField1.length() > 0) { - tempString.append(textField1); - if (textField1Type != null){ - tags.setMainField1(textField1Type); - } - } - - if (textField2 != null && textField2.length() > 0) { - if (( textField3 == null || !(textField3.length() > 0)) && (textField4 == null || !(textField4.length() > 0))){ - // text does not exist in slots 3 or 4, put text2 in slot 2 - show.setMainField2(textField2); - if (textField2Type != null){ - tags.setMainField2(textField2Type); - } - } else if (textField1 != null && textField1.length() > 0) { - // If text 1 exists, put it in slot 1 formatted - tempString.append(" - ").append(textField2); - if (textField2Type != null){ - List typeList = new ArrayList<>(); - typeList.add(textField2Type); - if (textField1Type != null){ - typeList.add(textField1Type); - } - tags.setMainField1(typeList); - } - }else { - // If text 1 does not exist, put it in slot 1 unformatted - tempString.append(textField2); - if (textField2Type != null){ - tags.setMainField1(textField2Type); - } - } - } - - // set mainfield 1 - show.setMainField1(tempString.toString()); - - // new stringbuilder object - tempString = new StringBuilder(); - - if (textField3 != null && textField3.length() > 0){ - // If text 3 exists, put it in slot 2 - tempString.append(textField3); - if (textField3Type != null){ - List typeList = new ArrayList<>(); - typeList.add(textField3Type); - tags.setMainField2(typeList); - } - } - - if (textField4 != null && textField4.length() > 0){ - if (textField3 != null && textField3.length() > 0){ - // If text 3 exists, put it in slot 2 formatted - tempString.append(" - ").append(textField4); - if (textField4Type != null){ - List typeList = new ArrayList<>(); - typeList.add(textField4Type); - if (textField3Type != null){ - typeList.add(textField3Type); - } - tags.setMainField2(typeList); - } - } else { - // If text 3 does not exist, put it in slot 3 unformatted - tempString.append(textField4); - if (textField4Type != null){ - tags.setMainField2(textField4Type); - } - } - } - - if (tempString.toString().length() > 0){ - show.setMainField2(tempString.toString()); - } - - show.setMetadataTags(tags); - return show; } - private Show assembleThreeLineShowText(Show show){ - - MetadataTags tags = new MetadataTags(); + private synchronized void sdlUpdate(final CompletionListener listener){ - if (textField1 != null && textField1.length() > 0) { - show.setMainField1(textField1); - if (textField1Type != null){ - tags.setMainField1(textField1Type); - } - } - - if (textField2 != null && textField2.length() > 0) { - show.setMainField2(textField2); - if (textField2Type != null){ - tags.setMainField2(textField2Type); - } - } - - StringBuilder tempString = new StringBuilder(); - - if (textField3 != null && textField3.length() > 0){ - tempString.append(textField3); - if (textField3Type != null){ - tags.setMainField3(textField3Type); - } + if(transactionQueue.getTasksAsList().size() > 0) { + //Transactions already exist, cancelling them + transactionQueue.clear(); } + updateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager.get(), defaultMainWindowCapability, currentScreenData, currentState(), new CompletionListener() { + @Override + public void onComplete(boolean success) { - if (textField4 != null && textField4.length() > 0) { - if (textField3 != null && textField3.length() > 0) { - // If text 3 exists, put it in slot 3 formatted - tempString.append(" - ").append(textField4); - if (textField4Type != null){ - List tags4 = new ArrayList<>(); - if (textField3Type != null){ - tags4.add(textField3Type); - } - tags4.add(textField4Type); - tags.setMainField3(tags4); + if (updateOperation.getSentShow() != null) { + currentScreenData = updateOperation.getSentShow(); } - } else { - // If text 3 does not exist, put it in slot 3 formatted - tempString.append(textField4); - if (textField4Type != null){ - tags.setMainField3(textField4Type); + if (listener != null) { //IOS diff here + listener.onComplete(success); } } - } - - show.setMainField3(tempString.toString()); - show.setMetadataTags(tags); - return show; + }); + transactionQueue.add(updateOperation, false); } - private Show assembleFourLineShowText(Show show){ - - MetadataTags tags = new MetadataTags(); - - if (textField1 != null && textField1.length() > 0) { - show.setMainField1(textField1); - if (textField1Type != null){ - tags.setMainField1(textField1Type); - } - } - - if (textField2 != null && textField2.length() > 0) { - show.setMainField2(textField2); - if (textField2Type != null){ - tags.setMainField2(textField2Type); - } - } - - if (textField3 != null && textField3.length() > 0) { - show.setMainField3(textField3); - if (textField3Type != null){ - tags.setMainField3(textField3Type); - } - } - - if (textField4 != null && textField4.length() > 0) { - show.setMainField4(textField4); - if (textField4Type != null){ - tags.setMainField4(textField4Type); - } - } - - show.setMetadataTags(tags); - return show; + // Convert to State + private TextsAndGraphicsState currentState() { + return new TextsAndGraphicsState(textField1, textField2, textField3, textField4, mediaTrackTextField, + title, primaryGraphic, secondaryGraphic, blankArtwork, textAlignment, textField1Type, textField2Type, textField3Type, textField4Type); } // Extraction - Show extractTextFromShow(Show show){ + //IOS has sdl_extractImageFromShow - Show newShow = new Show(); - newShow.setMainField1(show.getMainField1()); - newShow.setMainField2(show.getMainField2()); - newShow.setMainField3(show.getMainField3()); - newShow.setMainField4(show.getMainField4()); - newShow.setTemplateTitle(show.getTemplateTitle()); - - return newShow; - } - - private Show setBlankTextFields(Show newShow){ - - newShow.setMainField1(""); - newShow.setMainField2(""); - newShow.setMainField3(""); - newShow.setMainField4(""); - newShow.setMediaTrack(""); - newShow.setTemplateTitle(""); - - return newShow; - } + //IOS has sdl_createImageOnlyShowWithPrimaryArtwork private void updateCurrentScreenDataState(Show show){ @@ -686,122 +286,14 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { // Helpers - private List findValidMainTextFields(){ - List array = new ArrayList<>(); - - if (textField1 != null && textField1.length() > 0) { - array.add(textField1); - } - - if (textField2 != null && textField2.length() > 0) { - array.add(textField2); - } - - if (textField3 != null && textField3.length() > 0) { - array.add(textField3); - } + // IOS has sdl_hasData - if (textField4 != null && textField4.length() > 0) { - array.add(textField4); - } - - return array; - } - - - private List findNonNullMetadataFields(){ - List array = new ArrayList<>(); - - if (textField1Type != null) { - array.add(textField1Type); - } - - if (textField2Type != null) { - array.add(textField2Type); - } - - if (textField3Type != null) { - array.add(textField3Type); - } - - if (textField4Type != null) { - array.add(textField4Type); - } - - return array; - } + //Equality IOS has this section with: + // sdl_showImages abstract SdlArtwork getBlankArtwork(); - @SuppressWarnings("BooleanMethodIsAlwaysInverted") - private boolean sdlArtworkNeedsUpload(SdlArtwork artwork){ - if (fileManager.get() != null) { - return artwork != null && !fileManager.get().hasUploadedFile(artwork) && !artwork.isStaticIcon(); - } - return false; - } - - /** - * Check to see if primaryGraphic should be updated - * @return true if primaryGraphic should be updated, false if not - */ - private boolean shouldUpdatePrimaryImage() { - boolean templateSupportsPrimaryArtwork = templateSupportsImageField(ImageFieldName.graphic); - - String currentScreenDataPrimaryGraphicName = (currentScreenData != null && currentScreenData.getGraphic() != null) ? currentScreenData.getGraphic().getValue() : null; - String primaryGraphicName = primaryGraphic != null ? primaryGraphic.getName() : null; - return templateSupportsPrimaryArtwork - && !CompareUtils.areStringsEqual(currentScreenDataPrimaryGraphicName, primaryGraphicName, true, true) - && primaryGraphic != null; - } - - /** - * Check to see if secondaryGraphic should be updated - * @return true if secondaryGraphic should be updated, false if not - */ - private boolean shouldUpdateSecondaryImage() { - boolean templateSupportsSecondaryArtwork = (templateSupportsImageField(ImageFieldName.graphic) || templateSupportsImageField(ImageFieldName.secondaryGraphic)); - - String currentScreenDataSecondaryGraphicName = (currentScreenData != null && currentScreenData.getSecondaryGraphic() != null) ? currentScreenData.getSecondaryGraphic().getValue() : null; - String secondaryGraphicName = secondaryGraphic != null ? secondaryGraphic.getName() : null; - return templateSupportsSecondaryArtwork - && !CompareUtils.areStringsEqual(currentScreenDataSecondaryGraphicName, secondaryGraphicName, true, true) - && secondaryGraphic != null; - } - - /** - * Check to see if template supports the specified image field - * @return true if image field is supported, false if not - */ - private boolean templateSupportsImageField(ImageFieldName name) { - return defaultMainWindowCapability == null || ManagerUtility.WindowCapabilityUtility.hasImageFieldOfName(defaultMainWindowCapability, name); - } - - /** - * Check to see if mediaTrackTextField should be updated - * @return true if mediaTrackTextField should be updated, false if not - */ - private boolean shouldUpdateMediaTrackField() { - return templateSupportsTextField(TextFieldName.mediaTrack); - } - - /** - * Check to see if title should be updated - * @return true if title should be updated, false if not - */ - private boolean shouldUpdateTitleField() { - return templateSupportsTextField(TextFieldName.templateTitle); - } - - /** - * Check to see if field should be updated - * @return true if field should be updated, false if not - */ - private boolean templateSupportsTextField(TextFieldName name) { - return defaultMainWindowCapability == null || ManagerUtility.WindowCapabilityUtility.hasTextFieldOfName(defaultMainWindowCapability, name); - } - - // SCREEN ITEM SETTERS AND GETTERS + // Getters / Setters void setTextAlignment(TextAlignment textAlignment){ this.textAlignment = textAlignment; @@ -977,4 +469,54 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { this.batchingUpdates = batching; } + private void addListeners() { + // add listener + hmiListener = new OnRPCNotificationListener() { + @Override + public void onNotified(RPCNotification notification) { + OnHMIStatus onHMIStatus = (OnHMIStatus)notification; + if (onHMIStatus.getWindowID() != null && onHMIStatus.getWindowID() != PredefinedWindows.DEFAULT_WINDOW.getValue()) { + return; + } + // updateTransactionQueueSuspended(); + currentHMILevel = onHMIStatus.getHmiLevel(); + if (currentHMILevel == HMILevel.HMI_FULL){ + if (pendingHMIFull){ + DebugTool.logInfo(TAG, "Acquired HMI_FULL with pending update. Sending now"); + pendingHMIFull = false; + sdlUpdate(pendingHMIListener); + pendingHMIListener = null; + } + } + } + }; + internalInterface.addOnRPCNotificationListener(FunctionID.ON_HMI_STATUS, hmiListener); + + + onDisplaysCapabilityListener = new OnSystemCapabilityListener() { + @Override + public void onCapabilityRetrieved(Object capability) { + // instead of using the parameter it's more safe to use the convenience method + List capabilities = SystemCapabilityManager.convertToList(capability, DisplayCapability.class); + if (capabilities == null || capabilities.size() == 0) { + DebugTool.logError(TAG, "TextAndGraphic Manager - Capabilities sent here are null or empty"); + }else { + DisplayCapability display = capabilities.get(0); + for (WindowCapability windowCapability : display.getWindowCapabilities()) { + int currentWindowID = windowCapability.getWindowID() != null ? windowCapability.getWindowID() : PredefinedWindows.DEFAULT_WINDOW.getValue(); + if (currentWindowID == PredefinedWindows.DEFAULT_WINDOW.getValue()) { + defaultMainWindowCapability = windowCapability; + } + } + } + } + + @Override + public void onError(String info) { + DebugTool.logError(TAG, "Display Capability cannot be retrieved"); + defaultMainWindowCapability = null; + } + }; + this.internalInterface.addOnSystemCapabilityListener(SystemCapabilityType.DISPLAYS, onDisplaysCapabilityListener); + } } diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java new file mode 100644 index 000000000..70e2cf8dd --- /dev/null +++ b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java @@ -0,0 +1,654 @@ +package com.smartdevicelink.managers.screen; + +import com.livio.taskmaster.Task; +import com.smartdevicelink.managers.CompletionListener; +import com.smartdevicelink.managers.ManagerUtility; +import com.smartdevicelink.managers.file.FileManager; +import com.smartdevicelink.managers.file.MultipleFileCompletionListener; +import com.smartdevicelink.managers.file.filetypes.SdlArtwork; +import com.smartdevicelink.proxy.RPCResponse; +import com.smartdevicelink.proxy.interfaces.ISdl; +import com.smartdevicelink.proxy.rpc.MetadataTags; +import com.smartdevicelink.proxy.rpc.Show; +import com.smartdevicelink.proxy.rpc.WindowCapability; +import com.smartdevicelink.proxy.rpc.enums.ImageFieldName; +import com.smartdevicelink.proxy.rpc.enums.MetadataType; +import com.smartdevicelink.proxy.rpc.enums.Result; +import com.smartdevicelink.proxy.rpc.enums.TextFieldName; +import com.smartdevicelink.proxy.rpc.listeners.OnRPCResponseListener; +import com.smartdevicelink.util.CompareUtils; +import com.smartdevicelink.util.DebugTool; + +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class TextAndGraphicUpdateOperation extends Task { + + private static final String TAG = "TextAndGraphicUpdateOperation"; + private final WeakReference internalInterface; + private final WeakReference fileManager; + private WindowCapability currentCapabilities; + private Show currentScreenData, sentShow; + private TextsAndGraphicsState updatedState; + private CompletionListener listener; + + + /** + * @param internalInterface + * @param fileManager + * @param currentCapabilities + * @param currentScreenData + * @param newState + * @param listener + */ + public TextAndGraphicUpdateOperation(ISdl internalInterface, FileManager fileManager, WindowCapability currentCapabilities, + Show currentScreenData, TextsAndGraphicsState newState, CompletionListener listener) { + + super("TextAndGraphicUpdateOperation"); + this.internalInterface = new WeakReference<>(internalInterface); + this.fileManager = new WeakReference<>(fileManager); + this.currentCapabilities = currentCapabilities; + this.currentScreenData = currentScreenData; + this.updatedState = newState; + this.listener = listener; + + } + + @Override + public void onExecute() { + start(); + } + + private void start() { + if (getState() == Task.CANCELED) { + return; + } + + Show fullShow = new Show(); + fullShow.setAlignment(updatedState.getTextAlignment()); + fullShow = assembleShowText(fullShow); + fullShow = assembleShowImages(fullShow); + + + if (!shouldUpdatePrimaryImage() && !shouldUpdateSecondaryImage()){ + //No Images to send, only sending text + sendShow(extractTextFromShow(fullShow), new CompletionListener() { + @Override + public void onComplete(boolean success) { + listener.onComplete(success); + } + }); + + } else if (!sdlArtworkNeedsUpload(updatedState.getPrimaryGraphic()) && (updatedState.getSecondaryGraphic() == updatedState.getBlankArtwork() || !sdlArtworkNeedsUpload(updatedState.getSecondaryGraphic()))){ + //Images already uploaded, sending full update + // The files to be updated are already uploaded, send the full show immediately + sendShow(fullShow, new CompletionListener() { + @Override + public void onComplete(boolean success) { + listener.onComplete(success); + } + }); + } else { + //Images need to be uploaded + + sendShow(extractTextFromShow(fullShow), new CompletionListener() { + @Override + public void onComplete(boolean success) { + //TODO fix +/* if(self.cancelled){ + listener.onComplete(success); + }*/ + uploadImagesAndSendWhenDone(new CompletionListener() { + @Override + public void onComplete(boolean success) { + listener.onComplete(success); + } + }); + + } + }); + } + } + + void sendShow(final Show show, final CompletionListener listener){ + show.setOnRPCResponseListener(new OnRPCResponseListener() { + @Override + public void onResponse(int correlationId, RPCResponse response) { + handleResponse(response.getSuccess()); + + } + + @Override + public void onError(int correlationId, Result resultCode, String info) { + handleResponse(false); + } + + private void handleResponse(boolean success){ + if (success){ + updateCurrentScreenDataState(show); + } + listener.onComplete(success); + } + }); + internalInterface.get().sendRPC(show); + } + + + void uploadImagesAndSendWhenDone(final CompletionListener listener) { + + uploadImages(new CompletionListener() { + @Override + public void onComplete(boolean success) { + Show showWithGraphics = createImageOnlyShowWithPrimaryArtwork(updatedState.getPrimaryGraphic(), updatedState.getSecondaryGraphic()); + if (showWithGraphics != null) { + sendShow(showWithGraphics, new CompletionListener() { + @Override + public void onComplete(boolean success) { + listener.onComplete(success); + } + }); + } else { + listener.onComplete(success); + } + } + }); + } + + private void uploadImages(final CompletionListener listener) { + + List artworksToUpload = new ArrayList<>(); + + // add primary image + if (shouldUpdatePrimaryImage() && !updatedState.getPrimaryGraphic().isStaticIcon()){ + artworksToUpload.add(updatedState.getPrimaryGraphic()); + } + + // add secondary image + if (shouldUpdateSecondaryImage() && !updatedState.getSecondaryGraphic().isStaticIcon()){ + artworksToUpload.add(updatedState.getSecondaryGraphic()); + } + + if (artworksToUpload.size() == 0 && (updatedState.getPrimaryGraphic().isStaticIcon() || updatedState.getSecondaryGraphic().isStaticIcon())){ + DebugTool.logInfo(TAG, "Upload attempted on static icons, sending them without upload instead"); + listener.onComplete(true); + } + + // use file manager to upload art + if (fileManager.get() != null) { + fileManager.get().uploadArtworks(artworksToUpload, new MultipleFileCompletionListener() { + @Override + public void onComplete(Map errors) { + if (errors != null) { + DebugTool.logError(TAG, "Error Uploading Artworks. Error: " + errors.toString()); + listener.onComplete(false); + } else { + listener.onComplete(true); + } + } + }); + } + } + + private Show assembleShowImages(Show show){ + + if (shouldUpdatePrimaryImage()){ + show.setGraphic(updatedState.getPrimaryGraphic().getImageRPC()); + } + + if (shouldUpdateSecondaryImage()){ + show.setSecondaryGraphic(updatedState.getSecondaryGraphic().getImageRPC()); + } + + return show; + } + + private Show createImageOnlyShowWithPrimaryArtwork(SdlArtwork primaryArtwork, SdlArtwork secondaryArtwork){ + Show newShow = new Show(); + //TODO double check logic here + newShow.setGraphic(!(sdlArtworkNeedsUpload(primaryArtwork)) ? primaryArtwork.getImageRPC() : null); + newShow.setSecondaryGraphic(!(sdlArtworkNeedsUpload(secondaryArtwork)) ? secondaryArtwork.getImageRPC() : null); + if(newShow.getGraphic() == null && newShow.getSecondaryGraphic() == null){ + //log no graphic to upload + return null; + } + return newShow; + } + + Show assembleShowText(Show show) { + + show = setBlankTextFields(show); + + if (updatedState.getMediaTrackTextField() != null && shouldUpdateMediaTrackField()) { + show.setMediaTrack(updatedState.getMediaTrackTextField()); + } + + if (updatedState.getTitle() != null && shouldUpdateTitleField()) { + show.setTemplateTitle(updatedState.getTitle()); + } + + List nonNullFields = findValidMainTextFields(); + if (nonNullFields.isEmpty()) { + return show; + } + + int numberOfLines = currentCapabilities != null ? ManagerUtility.WindowCapabilityUtility.getMaxNumberOfMainFieldLines(currentCapabilities) : 4; + + switch (numberOfLines) { + case 1: + show = assembleOneLineShowText(show, nonNullFields); + break; + case 2: + show = assembleTwoLineShowText(show); + break; + case 3: + show = assembleThreeLineShowText(show); + break; + case 4: + show = assembleFourLineShowText(show); + break; + } + + return show; + } + + private Show assembleOneLineShowText(Show show, List showFields) { + + StringBuilder showString1 = new StringBuilder(); + for (int i = 0; i < showFields.size(); i++) { + if (i > 0) { + showString1.append(" - ").append(showFields.get(i)); + } else { + showString1.append(showFields.get(i)); + } + } + show.setMainField1(showString1.toString()); + + MetadataTags tags = new MetadataTags(); + tags.setMainField1(findNonNullMetadataFields()); + + show.setMetadataTags(tags); + + return show; + } + + private Show assembleTwoLineShowText(Show show) { + + StringBuilder tempString = new StringBuilder(); + MetadataTags tags = new MetadataTags(); + + if (updatedState.getTextField1() != null && updatedState.getTextField1().length() > 0) { + tempString.append(updatedState.getTextField1()); + if (updatedState.getTextField1() != null) { + tags.setMainField1(updatedState.getTextField1Type()); + } + } + + if (updatedState.getTextField2() != null && updatedState.getTextField2().length() > 0) { + if ((updatedState.getTextField3() == null || !(updatedState.getTextField3().length() > 0)) && (updatedState.getTextField4() == null || !(updatedState.getTextField4().length() > 0))) { + // text does not exist in slots 3 or 4, put text2 in slot 2 + show.setMainField2(updatedState.getTextField2()); + if (updatedState.getTextField2Type() != null) { + tags.setMainField2(updatedState.getTextField2Type()); + } + } else if (updatedState.getTextField1() != null && updatedState.getTextField1().length() > 0) { + // If text 1 exists, put it in slot 1 formatted + tempString.append(" - ").append(updatedState.getTextField2()); + if (updatedState.getTextField2Type() != null) { + List typeList = new ArrayList<>(); + typeList.add(updatedState.getTextField2Type()); + if (updatedState.getTextField1Type() != null) { + typeList.add(updatedState.getTextField1Type()); + } + tags.setMainField1(typeList); + } + } else { + // If text 1 does not exist, put it in slot 1 unformatted + tempString.append(updatedState.getTextField2()); + if (updatedState.getTextField2Type() != null) { + tags.setMainField1(updatedState.getTextField2Type()); + } + } + } + + // set mainfield 1 + show.setMainField1(tempString.toString()); + + // new stringbuilder object + tempString = new StringBuilder(); + + if (updatedState.getTextField3() != null && updatedState.getTextField3().length() > 0) { + // If text 3 exists, put it in slot 2 + tempString.append(updatedState.getTextField3()); + if (updatedState.getTextField3Type() != null) { + List typeList = new ArrayList<>(); + typeList.add(updatedState.getTextField3Type()); + tags.setMainField2(typeList); + } + } + + if (updatedState.getTextField4() != null && updatedState.getTextField4().length() > 0) { + if (updatedState.getTextField3() != null && updatedState.getTextField3().length() > 0) { + // If text 3 exists, put it in slot 2 formatted + tempString.append(" - ").append(updatedState.getTextField4()); + if (updatedState.getTextField4Type() != null) { + List typeList = new ArrayList<>(); + typeList.add(updatedState.getTextField4Type()); + if (updatedState.getTextField3Type() != null) { + typeList.add(updatedState.getTextField3Type()); + } + tags.setMainField2(typeList); + } + } else { + // If text 3 does not exist, put it in slot 3 unformatted + tempString.append(updatedState.getTextField4()); + if (updatedState.getTextField4Type() != null) { + tags.setMainField2(updatedState.getTextField4Type()); + } + } + } + + if (tempString.toString().length() > 0) { + show.setMainField2(tempString.toString()); + } + + show.setMetadataTags(tags); + return show; + } + + private Show assembleThreeLineShowText(Show show) { + + MetadataTags tags = new MetadataTags(); + + if (updatedState.getTextField1() != null && updatedState.getTextField1().length() > 0) { + show.setMainField1(updatedState.getTextField1()); + if (updatedState.getTextField1Type() != null) { + tags.setMainField1(updatedState.getTextField1Type()); + } + } + + if (updatedState.getTextField2() != null && updatedState.getTextField2().length() > 0) { + show.setMainField2(updatedState.getTextField2()); + if (updatedState.getTextField2Type() != null) { + tags.setMainField2(updatedState.getTextField2Type()); + } + } + + StringBuilder tempString = new StringBuilder(); + + if (updatedState.getTextField3() != null && updatedState.getTextField3().length() > 0) { + tempString.append(updatedState.getTextField3()); + if (updatedState.getTextField3Type() != null) { + tags.setMainField3(updatedState.getTextField3Type()); + } + } + + if (updatedState.getTextField4() != null && updatedState.getTextField4().length() > 0) { + if (updatedState.getTextField3() != null && updatedState.getTextField3().length() > 0) { + // If text 3 exists, put it in slot 3 formatted + tempString.append(" - ").append(updatedState.getTextField4()); + if (updatedState.getTextField4Type() != null) { + List tags4 = new ArrayList<>(); + if (updatedState.getTextField3Type() != null) { + tags4.add(updatedState.getTextField3Type()); + } + tags4.add(updatedState.getTextField4Type()); + tags.setMainField3(tags4); + } + } else { + // If text 3 does not exist, put it in slot 3 formatted + tempString.append(updatedState.getTextField4()); + if (updatedState.getTextField4Type() != null) { + tags.setMainField3(updatedState.getTextField4Type()); + } + } + } + + show.setMainField3(tempString.toString()); + show.setMetadataTags(tags); + return show; + } + + private Show assembleFourLineShowText(Show show) { + + MetadataTags tags = new MetadataTags(); + + if (updatedState.getTextField1() != null && updatedState.getTextField1().length() > 0) { + show.setMainField1(updatedState.getTextField1()); + if (updatedState.getTextField1Type() != null) { + tags.setMainField1(updatedState.getTextField1Type()); + } + } + + if (updatedState.getTextField2() != null && updatedState.getTextField2().length() > 0) { + show.setMainField2(updatedState.getTextField2()); + if (updatedState.getTextField2Type() != null) { + tags.setMainField2(updatedState.getTextField2Type()); + } + } + + if (updatedState.getTextField3() != null && updatedState.getTextField3().length() > 0) { + show.setMainField3(updatedState.getTextField3()); + if (updatedState.getTextField3Type() != null) { + tags.setMainField3(updatedState.getTextField3Type()); + } + } + + if (updatedState.getTextField4() != null && updatedState.getTextField4().length() > 0) { + show.setMainField4(updatedState.getTextField4()); + if (updatedState.getTextField4Type() != null) { + tags.setMainField4(updatedState.getTextField4Type()); + } + } + + show.setMetadataTags(tags); + return show; + } + + // Extraction + + Show extractTextFromShow(Show show) { + + Show newShow = new Show(); + newShow.setMainField1(show.getMainField1()); + newShow.setMainField2(show.getMainField2()); + newShow.setMainField3(show.getMainField3()); + newShow.setMainField4(show.getMainField4()); + newShow.setTemplateTitle(show.getTemplateTitle()); + + return newShow; + } + + private Show setBlankTextFields(Show newShow) { + + newShow.setMainField1(""); + newShow.setMainField2(""); + newShow.setMainField3(""); + newShow.setMainField4(""); + newShow.setMediaTrack(""); + newShow.setTemplateTitle(""); + + return newShow; + } + + private void updateCurrentScreenDataState(Show show) { + + if (show == null) { + DebugTool.logError(TAG, "can not updateCurrentScreenDataFromShow from null show"); + return; + } + + // If the items are null, they were not updated, so we can't just set it directly + if (show.getMainField1() != null) { + currentScreenData.setMainField1(show.getMainField1()); + } + if (show.getMainField2() != null) { + currentScreenData.setMainField2(show.getMainField2()); + } + if (show.getMainField3() != null) { + currentScreenData.setMainField3(show.getMainField3()); + } + if (show.getMainField4() != null) { + currentScreenData.setMainField4(show.getMainField4()); + } + if (show.getTemplateTitle() != null) { + currentScreenData.setTemplateTitle(show.getTemplateTitle()); + } + if (show.getMediaTrack() != null) { + currentScreenData.setMediaTrack(show.getMediaTrack()); + } + if (show.getMetadataTags() != null) { + currentScreenData.setMetadataTags(show.getMetadataTags()); + } + if (show.getAlignment() != null) { + currentScreenData.setAlignment(show.getAlignment()); + } + if (show.getGraphic() != null) { + currentScreenData.setGraphic(show.getGraphic()); + } + if (show.getSecondaryGraphic() != null) { + currentScreenData.setSecondaryGraphic(show.getSecondaryGraphic()); + } + } + + // Helpers + + private List findValidMainTextFields() { + List array = new ArrayList<>(); + + if (updatedState.getTextField1() != null && updatedState.getTextField1().length() > 0) { + array.add(updatedState.getTextField1()); + } + + if (updatedState.getTextField2() != null && updatedState.getTextField2().length() > 0) { + array.add(updatedState.getTextField2()); + } + + if (updatedState.getTextField3() != null && updatedState.getTextField3().length() > 0) { + array.add(updatedState.getTextField3()); + } + + if (updatedState.getTextField4() != null && updatedState.getTextField4().length() > 0) { + array.add(updatedState.getTextField4()); + } + + return array; + } + + + private List findNonNullMetadataFields() { + List array = new ArrayList<>(); + + if (updatedState.getTextField1Type() != null) { + array.add(updatedState.getTextField1Type()); + } + + if (updatedState.getTextField2Type() != null) { + array.add(updatedState.getTextField2Type()); + } + + if (updatedState.getTextField3Type() != null) { + array.add(updatedState.getTextField3Type()); + } + + if (updatedState.getTextField4Type() != null) { + array.add(updatedState.getTextField4Type()); + } + + return array; + } + + // abstract SdlArtwork getBlankArtwork(); + + @SuppressWarnings("BooleanMethodIsAlwaysInverted") + private boolean sdlArtworkNeedsUpload(SdlArtwork artwork) { + if (fileManager.get() != null) { + return artwork != null && !fileManager.get().hasUploadedFile(artwork) && !artwork.isStaticIcon(); + } + return false; + } + + /** + * Check to see if primaryGraphic should be updated + * + * @return true if primaryGraphic should be updated, false if not + */ + private boolean shouldUpdatePrimaryImage() { + boolean templateSupportsPrimaryArtwork = templateSupportsImageField(ImageFieldName.graphic); + + String currentScreenDataPrimaryGraphicName = (currentScreenData != null && currentScreenData.getGraphic() != null) ? currentScreenData.getGraphic().getValue() : null; + String primaryGraphicName = updatedState.getPrimaryGraphic() != null ? updatedState.getPrimaryGraphic().getName() : null; + return templateSupportsPrimaryArtwork + && !CompareUtils.areStringsEqual(currentScreenDataPrimaryGraphicName, primaryGraphicName, true, true) + && updatedState.getPrimaryGraphic() != null; + } + + /** + * Check to see if secondaryGraphic should be updated + * + * @return true if secondaryGraphic should be updated, false if not + */ + private boolean shouldUpdateSecondaryImage() { + boolean templateSupportsSecondaryArtwork = (templateSupportsImageField(ImageFieldName.graphic) || templateSupportsImageField(ImageFieldName.secondaryGraphic)); + + String currentScreenDataSecondaryGraphicName = (currentScreenData != null && currentScreenData.getSecondaryGraphic() != null) ? currentScreenData.getSecondaryGraphic().getValue() : null; + String secondaryGraphicName = updatedState.getSecondaryGraphic() != null ? updatedState.getSecondaryGraphic().getName() : null; + return templateSupportsSecondaryArtwork + && !CompareUtils.areStringsEqual(currentScreenDataSecondaryGraphicName, secondaryGraphicName, true, true) + && updatedState.getSecondaryGraphic() != null; + } + + /** + * Check to see if template supports the specified image field + * + * @return true if image field is supported, false if not + */ + private boolean templateSupportsImageField(ImageFieldName name) { + return currentCapabilities == null || ManagerUtility.WindowCapabilityUtility.hasImageFieldOfName(currentCapabilities, name); + } + + /** + * Check to see if mediaTrackTextField should be updated + * + * @return true if mediaTrackTextField should be updated, false if not + */ + private boolean shouldUpdateMediaTrackField() { + return templateSupportsTextField(TextFieldName.mediaTrack); + } + + /** + * Check to see if title should be updated + * + * @return true if title should be updated, false if not + */ + private boolean shouldUpdateTitleField() { + return templateSupportsTextField(TextFieldName.templateTitle); + } + + /** + * Check to see if field should be updated + * + * @return true if field should be updated, false if not + */ + private boolean templateSupportsTextField(TextFieldName name) { + return currentCapabilities == null || ManagerUtility.WindowCapabilityUtility.hasTextFieldOfName(currentCapabilities, name); + } + + public Show getSentShow() { + return sentShow; + } + + public void setSentShow(Show sentShow) { + this.sentShow = sentShow; + } + + + public Show getCurrentScreenData() { + return currentScreenData; + } + + public void setCurrentScreenData(Show currentScreenData2) { + this.currentScreenData = currentScreenData2; + } +} diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/TextsAndGraphicsState.java b/base/src/main/java/com/smartdevicelink/managers/screen/TextsAndGraphicsState.java new file mode 100644 index 000000000..b82285237 --- /dev/null +++ b/base/src/main/java/com/smartdevicelink/managers/screen/TextsAndGraphicsState.java @@ -0,0 +1,150 @@ +package com.smartdevicelink.managers.screen; + + + +import com.smartdevicelink.managers.file.filetypes.SdlArtwork; +import com.smartdevicelink.proxy.rpc.enums.MetadataType; +import com.smartdevicelink.proxy.rpc.enums.TextAlignment; + +public class TextsAndGraphicsState { + private String textField1, textField2, textField3, textField4, mediaTrackTextField, title; + private MetadataType textField1Type, textField2Type, textField3Type, textField4Type; + private TextAlignment textAlignment; + //TODO need better solution for BlankArtwork + private SdlArtwork primaryGraphic, secondaryGraphic, blankArtwork; + + public TextsAndGraphicsState(){} + + public TextsAndGraphicsState(String textField1, String textField2, String textField3, String textField4, String mediaTrackTextField, + String title, SdlArtwork primaryGraphic, SdlArtwork secondaryGraphic, SdlArtwork blankArtwork, TextAlignment textAlignment, + MetadataType textField1Type, MetadataType textField2Type, MetadataType textField3Type, MetadataType textField4Type) { + this.textField1 = textField1; + this.textField2 = textField2; + this.textField3 = textField3; + this.textField4 = textField4; + this.mediaTrackTextField = mediaTrackTextField; + this.title = title; + this.primaryGraphic = primaryGraphic; + this.secondaryGraphic = secondaryGraphic; + + this.blankArtwork = blankArtwork; + + this.textAlignment = textAlignment; + this.textField1Type = textField1Type; + this.textField2Type = textField2Type; + this.textField3Type = textField3Type; + this.textField4Type = textField4Type; + } + + public String getTextField1() { + return textField1; + } + + public void setTextField1(String textField1) { + this.textField1 = textField1; + } + + public String getTextField2() { + return textField2; + } + + public void setTextField2(String textField2) { + this.textField2 = textField2; + } + + public String getTextField3() { + return textField3; + } + + public void setTextField3(String textField3) { + this.textField3 = textField3; + } + + public String getTextField4() { + return textField4; + } + + public void setTextField4(String textField4) { + this.textField4 = textField4; + } + + public String getMediaTrackTextField() { + return mediaTrackTextField; + } + + public void setMediaTrackTextField(String mediaTrackTextField) { + this.mediaTrackTextField = mediaTrackTextField; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public MetadataType getTextField1Type() { + return textField1Type; + } + + public void setTextField1Type(MetadataType textField1Type) { + this.textField1Type = textField1Type; + } + + public MetadataType getTextField2Type() { + return textField2Type; + } + + public void setTextField2Type(MetadataType textField2Type) { + this.textField2Type = textField2Type; + } + + public MetadataType getTextField3Type() { + return textField3Type; + } + + public void setTextField3Type(MetadataType textField3Type) { + this.textField3Type = textField3Type; + } + + public MetadataType getTextField4Type() { + return textField4Type; + } + + public void setTextField4Type(MetadataType textField4Type) { + this.textField4Type = textField4Type; + } + + public TextAlignment getTextAlignment() { + return textAlignment; + } + + public void setTextAlignment(TextAlignment textAlignment) { + this.textAlignment = textAlignment; + } + + public SdlArtwork getPrimaryGraphic() { + return primaryGraphic; + } + + public void setPrimaryGraphic(SdlArtwork primaryGraphic) { + this.primaryGraphic = primaryGraphic; + } + + public SdlArtwork getSecondaryGraphic() { + return secondaryGraphic; + } + + public void setSecondaryGraphic(SdlArtwork secondaryGraphic) { + this.secondaryGraphic = secondaryGraphic; + } + + public SdlArtwork getBlankArtwork() { + return blankArtwork; + } + + public void setBlankArtwork(SdlArtwork blankArtwork) { + this.blankArtwork = blankArtwork; + } +} -- cgit v1.2.1 From afd900229c8e4bea0c1062a858acc8c8e2ffaea2 Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Tue, 18 Aug 2020 16:32:55 -0400 Subject: Added call to updateTransactionQueueSuspended in hmiListener and fixed some formatting --- .../managers/screen/BaseTextAndGraphicManager.java | 158 +++++++++++---------- 1 file changed, 80 insertions(+), 78 deletions(-) diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java index b5ee13f11..371c49a98 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java @@ -122,7 +122,7 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { getBlankArtwork(); //TODO added this.transactionQueue = newTransactionQueue(); - // this.batchQueue = new ArrayList<>(); + // this.batchQueue = new ArrayList<>(); textsAndGraphicsState = new TextsAndGraphicsState(); } @@ -133,7 +133,7 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { } @Override - public void dispose(){ + public void dispose() { textField1 = null; textField1Type = null; @@ -165,9 +165,10 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { //TODO temp location Also what do I set the ID to? private Queue newTransactionQueue() { Queue queue = internalInterface.getTaskmaster().createQueue("TextAndGraphicManager", 9, false); - //queue.pause(); + queue.pause(); return queue; } + //TODO fix for T&G Manager // Suspend the queue if the soft button capabilities are null (we assume that soft buttons are not supported) // OR if the HMI level is NONE since we want to delay sending RPCs until we're in non-NONE @@ -189,10 +190,10 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { protected void update(CompletionListener listener) { // make sure hmi is not none - if (currentHMILevel == null || currentHMILevel == HMILevel.HMI_NONE){ + if (currentHMILevel == null || currentHMILevel == HMILevel.HMI_NONE) { //Trying to send show on HMI_NONE, waiting for full pendingHMIFull = true; - if (listener != null){ + if (listener != null) { pendingHMIListener = listener; } return; @@ -203,7 +204,7 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { return; } - if (isDirty){ + if (isDirty) { isDirty = false; sdlUpdate(listener); } else if (listener != null) { @@ -211,9 +212,9 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { } } - private synchronized void sdlUpdate(final CompletionListener listener){ + private synchronized void sdlUpdate(final CompletionListener listener) { - if(transactionQueue.getTasksAsList().size() > 0) { + if (transactionQueue.getTasksAsList().size() > 0) { //Transactions already exist, cancelling them transactionQueue.clear(); } @@ -244,42 +245,42 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { //IOS has sdl_createImageOnlyShowWithPrimaryArtwork - private void updateCurrentScreenDataState(Show show){ + private void updateCurrentScreenDataState(Show show) { - if (show == null){ + if (show == null) { DebugTool.logError(TAG, "can not updateCurrentScreenDataFromShow from null show"); return; } // If the items are null, they were not updated, so we can't just set it directly - if (show.getMainField1() != null){ + if (show.getMainField1() != null) { currentScreenData.setMainField1(show.getMainField1()); } - if (show.getMainField2() != null){ + if (show.getMainField2() != null) { currentScreenData.setMainField2(show.getMainField2()); } - if (show.getMainField3() != null){ + if (show.getMainField3() != null) { currentScreenData.setMainField3(show.getMainField3()); } - if (show.getMainField4() != null){ + if (show.getMainField4() != null) { currentScreenData.setMainField4(show.getMainField4()); } - if (show.getTemplateTitle() != null){ + if (show.getTemplateTitle() != null) { currentScreenData.setTemplateTitle(show.getTemplateTitle()); } - if (show.getMediaTrack() != null){ + if (show.getMediaTrack() != null) { currentScreenData.setMediaTrack(show.getMediaTrack()); } - if (show.getMetadataTags() != null){ + if (show.getMetadataTags() != null) { currentScreenData.setMetadataTags(show.getMetadataTags()); } - if (show.getAlignment() != null){ + if (show.getAlignment() != null) { currentScreenData.setAlignment(show.getAlignment()); } - if (show.getGraphic() != null){ + if (show.getGraphic() != null) { currentScreenData.setGraphic(show.getGraphic()); } - if (show.getSecondaryGraphic() != null){ + if (show.getSecondaryGraphic() != null) { currentScreenData.setSecondaryGraphic(show.getSecondaryGraphic()); } } @@ -295,177 +296,177 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { // Getters / Setters - void setTextAlignment(TextAlignment textAlignment){ + void setTextAlignment(TextAlignment textAlignment) { this.textAlignment = textAlignment; // If we aren't batching, send the update immediately, if we are, set ourselves as dirty (so we know we should send an update after the batch ends) - if (!batchingUpdates){ + if (!batchingUpdates) { sdlUpdate(null); - }else{ + } else { isDirty = true; } } - TextAlignment getTextAlignment(){ + TextAlignment getTextAlignment() { return textAlignment; } - void setMediaTrackTextField(String mediaTrackTextField){ + void setMediaTrackTextField(String mediaTrackTextField) { this.mediaTrackTextField = mediaTrackTextField; - if (!batchingUpdates){ + if (!batchingUpdates) { sdlUpdate(null); - }else{ + } else { isDirty = true; } } - String getMediaTrackTextField(){ + String getMediaTrackTextField() { return mediaTrackTextField; } - void setTextField1(String textField1){ + void setTextField1(String textField1) { this.textField1 = textField1; - if (!batchingUpdates){ + if (!batchingUpdates) { sdlUpdate(null); - }else{ + } else { isDirty = true; } } - String getTextField1(){ + String getTextField1() { return textField1; } - void setTextField2(String textField2){ + void setTextField2(String textField2) { this.textField2 = textField2; - if (!batchingUpdates){ + if (!batchingUpdates) { sdlUpdate(null); - }else{ + } else { isDirty = true; } } - String getTextField2(){ + String getTextField2() { return textField2; } - void setTextField3(String textField3){ + void setTextField3(String textField3) { this.textField3 = textField3; - if (!batchingUpdates){ + if (!batchingUpdates) { sdlUpdate(null); - }else{ + } else { isDirty = true; } } - String getTextField3(){ + String getTextField3() { return textField3; } - void setTextField4(String textField4){ + void setTextField4(String textField4) { this.textField4 = textField4; - if (!batchingUpdates){ + if (!batchingUpdates) { sdlUpdate(null); - }else{ + } else { isDirty = true; } } - String getTextField4(){ + String getTextField4() { return textField4; } - void setTextField1Type(MetadataType textField1Type){ + void setTextField1Type(MetadataType textField1Type) { this.textField1Type = textField1Type; - if (!batchingUpdates){ + if (!batchingUpdates) { sdlUpdate(null); - }else{ + } else { isDirty = true; } } - MetadataType getTextField1Type(){ + MetadataType getTextField1Type() { return textField1Type; } - void setTextField2Type(MetadataType textField2Type){ + void setTextField2Type(MetadataType textField2Type) { this.textField2Type = textField2Type; - if (!batchingUpdates){ + if (!batchingUpdates) { sdlUpdate(null); - }else{ + } else { isDirty = true; } } - MetadataType getTextField2Type(){ + MetadataType getTextField2Type() { return textField2Type; } - void setTextField3Type(MetadataType textField3Type){ + void setTextField3Type(MetadataType textField3Type) { this.textField3Type = textField3Type; - if (!batchingUpdates){ + if (!batchingUpdates) { sdlUpdate(null); - }else{ + } else { isDirty = true; } } - MetadataType getTextField3Type(){ + MetadataType getTextField3Type() { return textField3Type; } - void setTextField4Type(MetadataType textField4Type){ + void setTextField4Type(MetadataType textField4Type) { this.textField4Type = textField4Type; - if (!batchingUpdates){ + if (!batchingUpdates) { sdlUpdate(null); - }else{ + } else { isDirty = true; } } - MetadataType getTextField4Type(){ + MetadataType getTextField4Type() { return textField4Type; } - void setTitle(String title){ + void setTitle(String title) { this.title = title; - if (!batchingUpdates){ + if (!batchingUpdates) { sdlUpdate(null); - }else{ + } else { isDirty = true; } } - String getTitle(){ + String getTitle() { return title; } - void setPrimaryGraphic(SdlArtwork primaryGraphic){ + void setPrimaryGraphic(SdlArtwork primaryGraphic) { this.primaryGraphic = primaryGraphic; - if (!batchingUpdates){ + if (!batchingUpdates) { sdlUpdate(null); - }else{ + } else { isDirty = true; } } - SdlArtwork getPrimaryGraphic(){ + SdlArtwork getPrimaryGraphic() { return primaryGraphic; } - void setSecondaryGraphic(SdlArtwork secondaryGraphic){ + void setSecondaryGraphic(SdlArtwork secondaryGraphic) { this.secondaryGraphic = secondaryGraphic; - if (!batchingUpdates){ + if (!batchingUpdates) { sdlUpdate(null); - }else{ + } else { isDirty = true; } } - SdlArtwork getSecondaryGraphic(){ + SdlArtwork getSecondaryGraphic() { return secondaryGraphic; } - void setBatchUpdates(boolean batching){ + void setBatchUpdates(boolean batching) { this.batchingUpdates = batching; } @@ -474,14 +475,15 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { hmiListener = new OnRPCNotificationListener() { @Override public void onNotified(RPCNotification notification) { - OnHMIStatus onHMIStatus = (OnHMIStatus)notification; + OnHMIStatus onHMIStatus = (OnHMIStatus) notification; if (onHMIStatus.getWindowID() != null && onHMIStatus.getWindowID() != PredefinedWindows.DEFAULT_WINDOW.getValue()) { return; } - // updateTransactionQueueSuspended(); + currentHMILevel = onHMIStatus.getHmiLevel(); - if (currentHMILevel == HMILevel.HMI_FULL){ - if (pendingHMIFull){ + updateTransactionQueueSuspended(); + if (currentHMILevel == HMILevel.HMI_FULL) { + if (pendingHMIFull) { DebugTool.logInfo(TAG, "Acquired HMI_FULL with pending update. Sending now"); pendingHMIFull = false; sdlUpdate(pendingHMIListener); @@ -500,7 +502,7 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { List capabilities = SystemCapabilityManager.convertToList(capability, DisplayCapability.class); if (capabilities == null || capabilities.size() == 0) { DebugTool.logError(TAG, "TextAndGraphic Manager - Capabilities sent here are null or empty"); - }else { + } else { DisplayCapability display = capabilities.get(0); for (WindowCapability windowCapability : display.getWindowCapabilities()) { int currentWindowID = windowCapability.getWindowID() != null ? windowCapability.getWindowID() : PredefinedWindows.DEFAULT_WINDOW.getValue(); -- cgit v1.2.1 From be1956908cf446b7ae84f91fabbf43a6d248af97 Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Wed, 19 Aug 2020 10:58:47 -0400 Subject: Align blankArtwork logic with IOS --- .../com/smartdevicelink/managers/screen/BaseScreenManager.java | 6 ++++++ .../managers/screen/BaseTextAndGraphicManager.java | 5 ++--- .../managers/screen/TextAndGraphicUpdateOperation.java | 2 +- .../smartdevicelink/managers/screen/TextsAndGraphicsState.java | 8 ++------ 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java index 80daf4d2e..a1b156085 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java @@ -248,6 +248,9 @@ abstract class BaseScreenManager extends BaseSubManager { * @return an SdlArtwork object represents the current primaryGraphic */ public SdlArtwork getPrimaryGraphic() { + if(this.textAndGraphicManager.getPrimaryGraphic().getName().equals(this.textAndGraphicManager.blankArtwork)){ + return null; + } return this.textAndGraphicManager.getPrimaryGraphic(); } @@ -267,6 +270,9 @@ abstract class BaseScreenManager extends BaseSubManager { * @return an SdlArtwork object represents the current secondaryGraphic */ public SdlArtwork getSecondaryGraphic() { + if(this.textAndGraphicManager.getSecondaryGraphic().getName().equals(this.textAndGraphicManager.blankArtwork)){ + return null; + } return this.textAndGraphicManager.getSecondaryGraphic(); } diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java index 371c49a98..1604edc7f 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java @@ -119,7 +119,6 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { currentHMILevel = HMILevel.HMI_NONE; currentScreenData = new Show(); addListeners(); - getBlankArtwork(); //TODO added this.transactionQueue = newTransactionQueue(); // this.batchQueue = new ArrayList<>(); @@ -234,9 +233,10 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { } // Convert to State + private TextsAndGraphicsState currentState() { return new TextsAndGraphicsState(textField1, textField2, textField3, textField4, mediaTrackTextField, - title, primaryGraphic, secondaryGraphic, blankArtwork, textAlignment, textField1Type, textField2Type, textField3Type, textField4Type); + title, primaryGraphic, secondaryGraphic, textAlignment, textField1Type, textField2Type, textField3Type, textField4Type); } // Extraction @@ -292,7 +292,6 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { //Equality IOS has this section with: // sdl_showImages - abstract SdlArtwork getBlankArtwork(); // Getters / Setters diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java index 70e2cf8dd..a4d45195f 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java @@ -81,7 +81,7 @@ public class TextAndGraphicUpdateOperation extends Task { } }); - } else if (!sdlArtworkNeedsUpload(updatedState.getPrimaryGraphic()) && (updatedState.getSecondaryGraphic() == updatedState.getBlankArtwork() || !sdlArtworkNeedsUpload(updatedState.getSecondaryGraphic()))){ + } else if (!sdlArtworkNeedsUpload(updatedState.getPrimaryGraphic()) && !sdlArtworkNeedsUpload(updatedState.getSecondaryGraphic())){ //Images already uploaded, sending full update // The files to be updated are already uploaded, send the full show immediately sendShow(fullShow, new CompletionListener() { diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/TextsAndGraphicsState.java b/base/src/main/java/com/smartdevicelink/managers/screen/TextsAndGraphicsState.java index b82285237..64ac0eda4 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/TextsAndGraphicsState.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/TextsAndGraphicsState.java @@ -10,13 +10,12 @@ public class TextsAndGraphicsState { private String textField1, textField2, textField3, textField4, mediaTrackTextField, title; private MetadataType textField1Type, textField2Type, textField3Type, textField4Type; private TextAlignment textAlignment; - //TODO need better solution for BlankArtwork - private SdlArtwork primaryGraphic, secondaryGraphic, blankArtwork; + private SdlArtwork primaryGraphic, secondaryGraphic; public TextsAndGraphicsState(){} public TextsAndGraphicsState(String textField1, String textField2, String textField3, String textField4, String mediaTrackTextField, - String title, SdlArtwork primaryGraphic, SdlArtwork secondaryGraphic, SdlArtwork blankArtwork, TextAlignment textAlignment, + String title, SdlArtwork primaryGraphic, SdlArtwork secondaryGraphic, TextAlignment textAlignment, MetadataType textField1Type, MetadataType textField2Type, MetadataType textField3Type, MetadataType textField4Type) { this.textField1 = textField1; this.textField2 = textField2; @@ -26,9 +25,6 @@ public class TextsAndGraphicsState { this.title = title; this.primaryGraphic = primaryGraphic; this.secondaryGraphic = secondaryGraphic; - - this.blankArtwork = blankArtwork; - this.textAlignment = textAlignment; this.textField1Type = textField1Type; this.textField2Type = textField2Type; -- cgit v1.2.1 From 1993768ddb2378eab0d0960f8946d8aec21f83c0 Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Wed, 19 Aug 2020 11:02:05 -0400 Subject: Remove blankArtwork from T&GState to align with IOS --- .../smartdevicelink/managers/screen/TextsAndGraphicsState.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/TextsAndGraphicsState.java b/base/src/main/java/com/smartdevicelink/managers/screen/TextsAndGraphicsState.java index 64ac0eda4..55f572905 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/TextsAndGraphicsState.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/TextsAndGraphicsState.java @@ -135,12 +135,4 @@ public class TextsAndGraphicsState { public void setSecondaryGraphic(SdlArtwork secondaryGraphic) { this.secondaryGraphic = secondaryGraphic; } - - public SdlArtwork getBlankArtwork() { - return blankArtwork; - } - - public void setBlankArtwork(SdlArtwork blankArtwork) { - this.blankArtwork = blankArtwork; - } } -- cgit v1.2.1 From b6500bb2b0d8df4cbe1eb75eff141545171ecaf4 Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Wed, 19 Aug 2020 11:17:59 -0400 Subject: Fix logic to match IOS in screenManager --- .../java/com/smartdevicelink/managers/screen/BaseScreenManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java index a1b156085..7a08ff95b 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java @@ -248,7 +248,7 @@ abstract class BaseScreenManager extends BaseSubManager { * @return an SdlArtwork object represents the current primaryGraphic */ public SdlArtwork getPrimaryGraphic() { - if(this.textAndGraphicManager.getPrimaryGraphic().getName().equals(this.textAndGraphicManager.blankArtwork)){ + if (this.textAndGraphicManager.getPrimaryGraphic().getName().equals(textAndGraphicManager.getBlankArtwork().getName())) { return null; } return this.textAndGraphicManager.getPrimaryGraphic(); @@ -270,7 +270,7 @@ abstract class BaseScreenManager extends BaseSubManager { * @return an SdlArtwork object represents the current secondaryGraphic */ public SdlArtwork getSecondaryGraphic() { - if(this.textAndGraphicManager.getSecondaryGraphic().getName().equals(this.textAndGraphicManager.blankArtwork)){ + if (this.textAndGraphicManager.getSecondaryGraphic().getName().equals(textAndGraphicManager.getBlankArtwork().getName())) { return null; } return this.textAndGraphicManager.getSecondaryGraphic(); -- cgit v1.2.1 From d10a5525520ba077ac2f1f841e6bb9653880263f Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Wed, 19 Aug 2020 16:26:07 -0400 Subject: Fixed formatting and Aligned logic with IOS --- .../managers/screen/TextAndGraphicManager.java | 9 +- .../managers/screen/BaseScreenManager.java | 3 +- .../managers/screen/BaseTextAndGraphicManager.java | 108 ++++----------------- .../screen/TextAndGraphicUpdateOperation.java | 91 +++++++++-------- 4 files changed, 75 insertions(+), 136 deletions(-) diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicManager.java b/android/sdl_android/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicManager.java index 82e9a5e01..89e6a0b52 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicManager.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicManager.java @@ -48,13 +48,12 @@ import com.smartdevicelink.proxy.rpc.enums.FileType; */ class TextAndGraphicManager extends BaseTextAndGraphicManager { - TextAndGraphicManager(@NonNull ISdl internalInterface, @NonNull FileManager fileManager, @NonNull SoftButtonManager softButtonManager) { - super(internalInterface, fileManager, softButtonManager); + TextAndGraphicManager(@NonNull ISdl internalInterface, @NonNull FileManager fileManager) { + super(internalInterface, fileManager); } - @Override - SdlArtwork getBlankArtwork(){ - if (blankArtwork == null){ + SdlArtwork getBlankArtwork() { + if (blankArtwork == null) { blankArtwork = new SdlArtwork(); blankArtwork.setType(FileType.GRAPHIC_PNG); blankArtwork.setName("blankArtwork"); diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java index 7a08ff95b..f00696b91 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java @@ -78,6 +78,7 @@ abstract class BaseScreenManager extends BaseSubManager { // Sub manager listener private final CompletionListener subManagerListener = new CompletionListener() { + @Override public synchronized void onComplete(boolean success) { if (softButtonManager != null && textAndGraphicManager != null && voiceCommandManager != null && menuManager != null && choiceSetManager != null && subscribeButtonManager != null) { @@ -125,7 +126,7 @@ abstract class BaseScreenManager extends BaseSubManager { private void initialize(){ if (fileManager.get() != null) { this.softButtonManager = new SoftButtonManager(internalInterface, fileManager.get()); - this.textAndGraphicManager = new TextAndGraphicManager(internalInterface, fileManager.get(), softButtonManager); + this.textAndGraphicManager = new TextAndGraphicManager(internalInterface, fileManager.get()); this.menuManager = new MenuManager(internalInterface, fileManager.get()); this.choiceSetManager = new ChoiceSetManager(internalInterface, fileManager.get()); } diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java index 1604edc7f..9a298e87b 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java @@ -34,62 +34,47 @@ package com.smartdevicelink.managers.screen; import androidx.annotation.NonNull; import com.livio.taskmaster.Queue; -import com.livio.taskmaster.Task; import com.smartdevicelink.managers.BaseSubManager; import com.smartdevicelink.managers.CompletionListener; -import com.smartdevicelink.managers.ManagerUtility; import com.smartdevicelink.managers.file.FileManager; -import com.smartdevicelink.managers.file.MultipleFileCompletionListener; import com.smartdevicelink.managers.file.filetypes.SdlArtwork; import com.smartdevicelink.protocol.enums.FunctionID; import com.smartdevicelink.proxy.RPCNotification; -import com.smartdevicelink.proxy.RPCResponse; import com.smartdevicelink.managers.lifecycle.SystemCapabilityManager; import com.smartdevicelink.proxy.interfaces.ISdl; import com.smartdevicelink.proxy.interfaces.OnSystemCapabilityListener; import com.smartdevicelink.proxy.rpc.DisplayCapability; -import com.smartdevicelink.proxy.rpc.MetadataTags; import com.smartdevicelink.proxy.rpc.OnHMIStatus; import com.smartdevicelink.proxy.rpc.Show; import com.smartdevicelink.proxy.rpc.WindowCapability; import com.smartdevicelink.proxy.rpc.enums.HMILevel; -import com.smartdevicelink.proxy.rpc.enums.ImageFieldName; import com.smartdevicelink.proxy.rpc.enums.MetadataType; import com.smartdevicelink.proxy.rpc.enums.PredefinedWindows; -import com.smartdevicelink.proxy.rpc.enums.Result; import com.smartdevicelink.proxy.rpc.enums.SystemCapabilityType; import com.smartdevicelink.proxy.rpc.enums.TextAlignment; -import com.smartdevicelink.proxy.rpc.enums.TextFieldName; import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener; -import com.smartdevicelink.proxy.rpc.listeners.OnRPCResponseListener; -import com.smartdevicelink.util.CompareUtils; import com.smartdevicelink.util.DebugTool; import java.lang.ref.WeakReference; -import java.util.ArrayList; import java.util.List; -import java.util.Map; import static com.smartdevicelink.proxy.rpc.enums.TextAlignment.CENTERED; /** * TextAndGraphicManager
- * + *

* Note: This class must be accessed through the SdlManager. Do not instantiate it by itself.
- * */ abstract class BaseTextAndGraphicManager extends BaseSubManager { private static final String TAG = "TextAndGraphicManager"; boolean isDirty; - //volatile Show inProgressUpdate; Show currentScreenData; HMILevel currentHMILevel; WindowCapability defaultMainWindowCapability; private boolean pendingHMIFull, batchingUpdates; private final WeakReference fileManager; - private final WeakReference softButtonManager; private CompletionListener pendingHMIListener; SdlArtwork blankArtwork; private OnRPCNotificationListener hmiListener; @@ -107,11 +92,10 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { //Constructors - BaseTextAndGraphicManager(@NonNull ISdl internalInterface, @NonNull FileManager fileManager, @NonNull SoftButtonManager softButtonManager) { + BaseTextAndGraphicManager(@NonNull ISdl internalInterface, @NonNull FileManager fileManager) { // set class vars super(internalInterface); this.fileManager = new WeakReference<>(fileManager); - this.softButtonManager = new WeakReference<>(softButtonManager); batchingUpdates = false; isDirty = false; pendingHMIFull = false; @@ -119,10 +103,7 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { currentHMILevel = HMILevel.HMI_NONE; currentScreenData = new Show(); addListeners(); - //TODO added this.transactionQueue = newTransactionQueue(); - // this.batchQueue = new ArrayList<>(); - textsAndGraphicsState = new TextsAndGraphicsState(); } @Override @@ -133,7 +114,6 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { @Override public void dispose() { - textField1 = null; textField1Type = null; textField2 = null; @@ -153,6 +133,13 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { pendingHMIListener = null; isDirty = false; pendingHMIFull = false; + updateOperation = null; + + // Cancel the operations + if (transactionQueue != null) { + transactionQueue.close(); + transactionQueue = null; + } // remove listeners internalInterface.removeOnRPCNotificationListener(FunctionID.ON_HMI_STATUS, hmiListener); @@ -161,15 +148,13 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { super.dispose(); } - //TODO temp location Also what do I set the ID to? private Queue newTransactionQueue() { - Queue queue = internalInterface.getTaskmaster().createQueue("TextAndGraphicManager", 9, false); + Queue queue = internalInterface.getTaskmaster().createQueue("TextAndGraphicManager", 3, false); queue.pause(); return queue; } - //TODO fix for T&G Manager - // Suspend the queue if the soft button capabilities are null (we assume that soft buttons are not supported) + // Suspend the queue if the WindowCapabilities are null // OR if the HMI level is NONE since we want to delay sending RPCs until we're in non-NONE private void updateTransactionQueueSuspended() { if (defaultMainWindowCapability == null || HMILevel.HMI_NONE.equals(currentHMILevel)) { @@ -181,13 +166,15 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { } } - //TODO not in IOS - - // Upload / Send protected void update(CompletionListener listener) { + // check if is batch update + if (batchingUpdates) { + return; + } + // make sure hmi is not none if (currentHMILevel == null || currentHMILevel == HMILevel.HMI_NONE) { //Trying to send show on HMI_NONE, waiting for full @@ -198,11 +185,6 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { return; } - // check if is batch update - if (batchingUpdates) { - return; - } - if (isDirty) { isDirty = false; sdlUpdate(listener); @@ -216,6 +198,8 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { if (transactionQueue.getTasksAsList().size() > 0) { //Transactions already exist, cancelling them transactionQueue.clear(); + listener.onComplete(false); + return; } updateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager.get(), defaultMainWindowCapability, currentScreenData, currentState(), new CompletionListener() { @Override @@ -224,7 +208,7 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { if (updateOperation.getSentShow() != null) { currentScreenData = updateOperation.getSentShow(); } - if (listener != null) { //IOS diff here + if (listener != null) { listener.onComplete(success); } } @@ -239,60 +223,6 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { title, primaryGraphic, secondaryGraphic, textAlignment, textField1Type, textField2Type, textField3Type, textField4Type); } - // Extraction - - //IOS has sdl_extractImageFromShow - - //IOS has sdl_createImageOnlyShowWithPrimaryArtwork - - private void updateCurrentScreenDataState(Show show) { - - if (show == null) { - DebugTool.logError(TAG, "can not updateCurrentScreenDataFromShow from null show"); - return; - } - - // If the items are null, they were not updated, so we can't just set it directly - if (show.getMainField1() != null) { - currentScreenData.setMainField1(show.getMainField1()); - } - if (show.getMainField2() != null) { - currentScreenData.setMainField2(show.getMainField2()); - } - if (show.getMainField3() != null) { - currentScreenData.setMainField3(show.getMainField3()); - } - if (show.getMainField4() != null) { - currentScreenData.setMainField4(show.getMainField4()); - } - if (show.getTemplateTitle() != null) { - currentScreenData.setTemplateTitle(show.getTemplateTitle()); - } - if (show.getMediaTrack() != null) { - currentScreenData.setMediaTrack(show.getMediaTrack()); - } - if (show.getMetadataTags() != null) { - currentScreenData.setMetadataTags(show.getMetadataTags()); - } - if (show.getAlignment() != null) { - currentScreenData.setAlignment(show.getAlignment()); - } - if (show.getGraphic() != null) { - currentScreenData.setGraphic(show.getGraphic()); - } - if (show.getSecondaryGraphic() != null) { - currentScreenData.setSecondaryGraphic(show.getSecondaryGraphic()); - } - } - - // Helpers - - // IOS has sdl_hasData - - //Equality IOS has this section with: - // sdl_showImages - - // Getters / Setters void setTextAlignment(TextAlignment textAlignment) { diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java index a4d45195f..befe34a8c 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java @@ -45,7 +45,6 @@ public class TextAndGraphicUpdateOperation extends Task { */ public TextAndGraphicUpdateOperation(ISdl internalInterface, FileManager fileManager, WindowCapability currentCapabilities, Show currentScreenData, TextsAndGraphicsState newState, CompletionListener listener) { - super("TextAndGraphicUpdateOperation"); this.internalInterface = new WeakReference<>(internalInterface); this.fileManager = new WeakReference<>(fileManager); @@ -53,7 +52,6 @@ public class TextAndGraphicUpdateOperation extends Task { this.currentScreenData = currentScreenData; this.updatedState = newState; this.listener = listener; - } @Override @@ -63,47 +61,52 @@ public class TextAndGraphicUpdateOperation extends Task { private void start() { if (getState() == Task.CANCELED) { + finishOperation(false); return; } + // Build a show with everything from `self.newState`, we'll pull things out later if we can. Show fullShow = new Show(); fullShow.setAlignment(updatedState.getTextAlignment()); fullShow = assembleShowText(fullShow); fullShow = assembleShowImages(fullShow); + if (!shouldUpdatePrimaryImage() && !shouldUpdateSecondaryImage()) { + DebugTool.logInfo(TAG, "No images to send, sending text"); + // If there are no images to update, just send the text + sendShow(extractTextFromShow(fullShow), new CompletionListener() { + @Override + public void onComplete(boolean success) { + finishOperation(success); + return; + } + }); - if (!shouldUpdatePrimaryImage() && !shouldUpdateSecondaryImage()){ - //No Images to send, only sending text - sendShow(extractTextFromShow(fullShow), new CompletionListener() { - @Override - public void onComplete(boolean success) { - listener.onComplete(success); - } - }); - - } else if (!sdlArtworkNeedsUpload(updatedState.getPrimaryGraphic()) && !sdlArtworkNeedsUpload(updatedState.getSecondaryGraphic())){ - //Images already uploaded, sending full update + } else if (!sdlArtworkNeedsUpload(updatedState.getPrimaryGraphic()) && !sdlArtworkNeedsUpload(updatedState.getSecondaryGraphic())) { + DebugTool.logInfo(TAG, "Images already uploaded, sending full update"); // The files to be updated are already uploaded, send the full show immediately sendShow(fullShow, new CompletionListener() { @Override public void onComplete(boolean success) { - listener.onComplete(success); + finishOperation(success); + return; } }); } else { - //Images need to be uploaded + DebugTool.logInfo(TAG, "Images need to be uploaded, sending text and uploading images"); sendShow(extractTextFromShow(fullShow), new CompletionListener() { @Override public void onComplete(boolean success) { - //TODO fix -/* if(self.cancelled){ - listener.onComplete(success); - }*/ + if (getState() == Task.CANCELED) { + finishOperation(success); + return; + } uploadImagesAndSendWhenDone(new CompletionListener() { @Override public void onComplete(boolean success) { - listener.onComplete(success); + finishOperation(success); + return; } }); @@ -112,7 +115,7 @@ public class TextAndGraphicUpdateOperation extends Task { } } - void sendShow(final Show show, final CompletionListener listener){ + void sendShow(final Show show, final CompletionListener listener) { show.setOnRPCResponseListener(new OnRPCResponseListener() { @Override public void onResponse(int correlationId, RPCResponse response) { @@ -125,8 +128,9 @@ public class TextAndGraphicUpdateOperation extends Task { handleResponse(false); } - private void handleResponse(boolean success){ - if (success){ + private void handleResponse(boolean success) { + DebugTool.logInfo(TAG, "Text and Graphic update completed"); + if (success) { updateCurrentScreenDataState(show); } listener.onComplete(success); @@ -137,12 +141,12 @@ public class TextAndGraphicUpdateOperation extends Task { void uploadImagesAndSendWhenDone(final CompletionListener listener) { - uploadImages(new CompletionListener() { @Override public void onComplete(boolean success) { Show showWithGraphics = createImageOnlyShowWithPrimaryArtwork(updatedState.getPrimaryGraphic(), updatedState.getSecondaryGraphic()); if (showWithGraphics != null) { + DebugTool.logInfo(TAG, "Sending update with the successfully uploaded images"); sendShow(showWithGraphics, new CompletionListener() { @Override public void onComplete(boolean success) { @@ -150,6 +154,7 @@ public class TextAndGraphicUpdateOperation extends Task { } }); } else { + DebugTool.logWarning(TAG, "All images failed to upload. No graphics to show, skipping update."); listener.onComplete(success); } } @@ -161,17 +166,17 @@ public class TextAndGraphicUpdateOperation extends Task { List artworksToUpload = new ArrayList<>(); // add primary image - if (shouldUpdatePrimaryImage() && !updatedState.getPrimaryGraphic().isStaticIcon()){ + if (shouldUpdatePrimaryImage() && !updatedState.getPrimaryGraphic().isStaticIcon()) { artworksToUpload.add(updatedState.getPrimaryGraphic()); } // add secondary image - if (shouldUpdateSecondaryImage() && !updatedState.getSecondaryGraphic().isStaticIcon()){ + if (shouldUpdateSecondaryImage() && !updatedState.getSecondaryGraphic().isStaticIcon()) { artworksToUpload.add(updatedState.getSecondaryGraphic()); } - if (artworksToUpload.size() == 0 && (updatedState.getPrimaryGraphic().isStaticIcon() || updatedState.getSecondaryGraphic().isStaticIcon())){ - DebugTool.logInfo(TAG, "Upload attempted on static icons, sending them without upload instead"); + if (artworksToUpload.size() == 0) { + DebugTool.logInfo(TAG, "No artworks need an upload, sending them without upload instead"); listener.onComplete(true); } @@ -181,7 +186,7 @@ public class TextAndGraphicUpdateOperation extends Task { @Override public void onComplete(Map errors) { if (errors != null) { - DebugTool.logError(TAG, "Error Uploading Artworks. Error: " + errors.toString()); + DebugTool.logError(TAG, "Text and graphic manager artwork failed to upload with error: " + errors.toString()); listener.onComplete(false); } else { listener.onComplete(true); @@ -191,32 +196,31 @@ public class TextAndGraphicUpdateOperation extends Task { } } - private Show assembleShowImages(Show show){ + private Show assembleShowImages(Show show) { - if (shouldUpdatePrimaryImage()){ + if (shouldUpdatePrimaryImage()) { show.setGraphic(updatedState.getPrimaryGraphic().getImageRPC()); } - if (shouldUpdateSecondaryImage()){ + if (shouldUpdateSecondaryImage()) { show.setSecondaryGraphic(updatedState.getSecondaryGraphic().getImageRPC()); } return show; } - private Show createImageOnlyShowWithPrimaryArtwork(SdlArtwork primaryArtwork, SdlArtwork secondaryArtwork){ + private Show createImageOnlyShowWithPrimaryArtwork(SdlArtwork primaryArtwork, SdlArtwork secondaryArtwork) { Show newShow = new Show(); - //TODO double check logic here newShow.setGraphic(!(sdlArtworkNeedsUpload(primaryArtwork)) ? primaryArtwork.getImageRPC() : null); newShow.setSecondaryGraphic(!(sdlArtworkNeedsUpload(secondaryArtwork)) ? secondaryArtwork.getImageRPC() : null); - if(newShow.getGraphic() == null && newShow.getSecondaryGraphic() == null){ - //log no graphic to upload + if (newShow.getGraphic() == null && newShow.getSecondaryGraphic() == null) { + DebugTool.logInfo(TAG, "No graphics to upload"); return null; } return newShow; } - Show assembleShowText(Show show) { + Show assembleShowText(Show show) { show = setBlankTextFields(show); @@ -559,7 +563,7 @@ public class TextAndGraphicUpdateOperation extends Task { return array; } - // abstract SdlArtwork getBlankArtwork(); + // abstract SdlArtwork getBlankArtwork(); @SuppressWarnings("BooleanMethodIsAlwaysInverted") private boolean sdlArtworkNeedsUpload(SdlArtwork artwork) { @@ -643,12 +647,17 @@ public class TextAndGraphicUpdateOperation extends Task { this.sentShow = sentShow; } - public Show getCurrentScreenData() { return currentScreenData; } - public void setCurrentScreenData(Show currentScreenData2) { - this.currentScreenData = currentScreenData2; + public void setCurrentScreenData(Show currentScreenData) { + this.currentScreenData = currentScreenData; + } + + void finishOperation(boolean success) { + DebugTool.logInfo(TAG, "Finishing text and graphic update operation"); + listener.onComplete(success); + onFinished(); } } -- cgit v1.2.1 From a9c2176eaedd702b795144a5d70d22cb4f724602 Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Thu, 20 Aug 2020 12:22:11 -0400 Subject: Added TextAndGraphicUpdateOperationTest. Checking codcov for it, TextAndGraphicManagerTest need work still --- .../screen/TextAndGraphicManagerTests.java | 22 +-- .../screen/TextAndGraphicUpdateOperationTest.java | 210 +++++++++++++++++++++ .../screen/TextAndGraphicUpdateOperation.java | 12 +- 3 files changed, 225 insertions(+), 19 deletions(-) create mode 100644 android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java index 439b7ebe9..67f5a0647 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java @@ -42,7 +42,7 @@ import static org.mockito.Mockito.mock; @RunWith(AndroidJUnit4.class) public class TextAndGraphicManagerTests { - // SETUP / HELPERS +/* // SETUP / HELPERS private TextAndGraphicManager textAndGraphicManager; private SdlArtwork testArtwork; @@ -60,7 +60,7 @@ public class TextAndGraphicManagerTests { testArtwork.setUri(uri); testArtwork.setType(FileType.GRAPHIC_PNG); - textAndGraphicManager = new TextAndGraphicManager(internalInterface, fileManager, softButtonManager); + textAndGraphicManager = new TextAndGraphicManager(internalInterface, fileManager); } @@ -96,10 +96,10 @@ public class TextAndGraphicManagerTests { return windowCapability; } - /** + *//** * Used to simulate WindowCapability having no capabilities set * @return windowCapability that has no capabilities set - */ + *//* private WindowCapability getNullVarWindowCapability() { WindowCapability windowCapability = new WindowCapability(); @@ -122,11 +122,7 @@ public class TextAndGraphicManagerTests { assertNull(textAndGraphicManager.getTextField2Type()); assertNull(textAndGraphicManager.getTextField3Type()); assertNull(textAndGraphicManager.getTextField4Type()); - assertNotNull(textAndGraphicManager.currentScreenData); - assertNull(textAndGraphicManager.inProgressUpdate); - assertNull(textAndGraphicManager.queuedImageUpdate); - assertFalse(textAndGraphicManager.hasQueuedUpdate); assertNull(textAndGraphicManager.defaultMainWindowCapability); assertEquals(textAndGraphicManager.currentHMILevel, HMILevel.HMI_NONE); assertFalse(textAndGraphicManager.isDirty); @@ -134,9 +130,9 @@ public class TextAndGraphicManagerTests { assertNotNull(textAndGraphicManager.getBlankArtwork()); } - /** + *//** * Test getting number of lines available to be set based off of windowCapability - */ + *//* @Test public void testGetMainLines(){ @@ -526,9 +522,9 @@ public class TextAndGraphicManagerTests { assertEquals(tags.getMainField4(), tagsList4); } - /** + *//** * Testing if WindowCapability is null, TextFields should still update. - */ + *//* @Test public void testAssemble4LinesNullWindowCapability() { @@ -720,5 +716,5 @@ public class TextAndGraphicManagerTests { assertNull(textAndGraphicManager.defaultMainWindowCapability); assertFalse(textAndGraphicManager.isDirty); assertEquals(textAndGraphicManager.getState(), BaseSubManager.SHUTDOWN); - } + }*/ } diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java new file mode 100644 index 000000000..c1c241c99 --- /dev/null +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java @@ -0,0 +1,210 @@ +package com.smartdevicelink.managers.screen; + +import android.content.Context; +import android.net.Uri; + +import androidx.test.ext.junit.runners.AndroidJUnit4; + +import com.smartdevicelink.managers.CompletionListener; +import com.smartdevicelink.managers.ManagerUtility; +import com.smartdevicelink.managers.file.FileManager; +import com.smartdevicelink.managers.file.filetypes.SdlArtwork; +import com.smartdevicelink.proxy.RPCRequest; +import com.smartdevicelink.proxy.interfaces.ISdl; +import com.smartdevicelink.proxy.rpc.Show; +import com.smartdevicelink.proxy.rpc.ShowResponse; +import com.smartdevicelink.proxy.rpc.TextField; +import com.smartdevicelink.proxy.rpc.WindowCapability; +import com.smartdevicelink.proxy.rpc.enums.FileType; +import com.smartdevicelink.proxy.rpc.enums.MetadataType; +import com.smartdevicelink.proxy.rpc.enums.TextAlignment; +import com.smartdevicelink.proxy.rpc.enums.TextFieldName; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; + +import java.util.ArrayList; +import java.util.List; + +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; +import static junit.framework.TestCase.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.mock; + +@RunWith(AndroidJUnit4.class) +public class TextAndGraphicUpdateOperationTest { + + private TextAndGraphicUpdateOperation textAndGraphicUpdateOperation; + private TextAndGraphicUpdateOperation textAndGraphicUpdateOperationNullCapability; + private TextAndGraphicUpdateOperation textAndGraphicUpdateOperationEmptyCapability; + private String textField1, textField2, textField3, textField4, mediaTrackField, title; + private MetadataType textField1Type, textField2Type, textField3Type, textField4Type; + private SdlArtwork testArtwork1, testArtwork2, testArtwork3, testArtwork4; + private TextAlignment textAlignment; + private WindowCapability defaultMainWindowCapability; + private Show currentScreenData; + private CompletionListener listener; + ISdl internalInterface; + + private Answer onShowSuccess = new Answer() { + @Override + public Void answer(InvocationOnMock invocation) { + Object[] args = invocation.getArguments(); + RPCRequest message = (RPCRequest) args[0]; + if (message instanceof Show) { + int correlationId = message.getCorrelationID(); + ShowResponse showResponse = new ShowResponse(); + showResponse.setSuccess(true); + message.getOnRPCResponseListener().onResponse(correlationId, showResponse); + } + return null; + } + }; + + + @Before + public void setUp() throws Exception { + Context mTestContext = getInstrumentation().getContext(); + // mock things + internalInterface = mock(ISdl.class); + FileManager fileManager = mock(FileManager.class); + setUpCompletionListener(); + textField1 = "It is"; + textField2 = "wednesday"; + textField3 = "my"; + textField4 = "dudes"; + mediaTrackField = "dudes"; + title = "dudes"; + + textField1Type = MetadataType.MEDIA_TITLE; + textField2Type = MetadataType.MEDIA_TITLE; + textField3Type = MetadataType.MEDIA_TITLE; + textField4Type = MetadataType.MEDIA_TITLE; + + + textAlignment = TextAlignment.CENTERED; + testArtwork1 = new SdlArtwork(); + testArtwork1.setName("testFile"); + Uri uri1 = Uri.parse("android.resource://" + mTestContext.getPackageName() + "/drawable/ic_sdl"); + testArtwork1.setUri(uri1); + testArtwork1.setType(FileType.GRAPHIC_PNG); + + testArtwork2 = new SdlArtwork(); + testArtwork2.setName("testFile"); + Uri uri2 = Uri.parse("android.resource://" + mTestContext.getPackageName() + "/drawable/ic_sdl"); + testArtwork2.setUri(uri2); + testArtwork2.setType(FileType.GRAPHIC_PNG); + + testArtwork3 = new SdlArtwork(); + testArtwork3.setName("testFile"); + Uri uri3 = Uri.parse("android.resource://" + mTestContext.getPackageName() + "/drawable/ic_sdl"); + testArtwork3.setUri(uri3); + testArtwork3.setType(FileType.GRAPHIC_PNG); + + testArtwork4 = new SdlArtwork(); + testArtwork4.setName("testFile"); + Uri uri4 = Uri.parse("android.resource://" + mTestContext.getPackageName() + "/drawable/ic_sdl"); + testArtwork4.setUri(uri4); + testArtwork4.setType(FileType.GRAPHIC_PNG); + + currentScreenData = new Show(); + currentScreenData.setMainField1("Old"); + currentScreenData.setMainField2("Text"); + currentScreenData.setMainField3("Not"); + currentScreenData.setMainField4("Important"); + + currentScreenData.setGraphic(testArtwork1.getImageRPC()); + currentScreenData.setSecondaryGraphic(testArtwork2.getImageRPC()); + + defaultMainWindowCapability = getWindowCapability(4); + + TextsAndGraphicsState textsAndGraphicsState = new TextsAndGraphicsState(textField1, textField2, textField3, textField4, + mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, textField1Type, textField2Type, textField3Type, textField4Type); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener); + } + + + private void setUpCompletionListener() { + listener = new CompletionListener() { + @Override + public void onComplete(boolean success) { + + } + }; + + } + + private WindowCapability getWindowCapability(int numberOfMainFields) { + + TextField mainField1 = new TextField(); + mainField1.setName(TextFieldName.mainField1); + TextField mainField2 = new TextField(); + mainField2.setName(TextFieldName.mainField2); + TextField mainField3 = new TextField(); + mainField3.setName(TextFieldName.mainField3); + TextField mainField4 = new TextField(); + mainField4.setName(TextFieldName.mainField4); + + List textFieldList = new ArrayList<>(); + + textFieldList.add(mainField1); + textFieldList.add(mainField2); + textFieldList.add(mainField3); + textFieldList.add(mainField4); + + List returnList = new ArrayList<>(); + + if (numberOfMainFields > 0) { + for (int i = 0; i < numberOfMainFields; i++) { + returnList.add(textFieldList.get(i)); + } + } + + WindowCapability windowCapability = new WindowCapability(); + windowCapability.setTextFields(returnList); + + return windowCapability; + } + + /** + * Used to simulate WindowCapability having no capabilities set + * + * @return windowCapability that has no capabilities set + */ + private WindowCapability getNullVarWindowCapability() { + + WindowCapability windowCapability = new WindowCapability(); + return windowCapability; + } + + @Test + public void testOnExecute() { + doAnswer(onShowSuccess).when(internalInterface).sendRPC(any(Show.class)); + + textAndGraphicUpdateOperation.onExecute(); + assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getMainField1(), textField1); + } + + /** + * Test getting number of lines available to be set based off of windowCapability + */ + @Test + public void testGetMainLines() { + + // We want to test that the looping works. By default, it will return 4 if display cap is null + textAndGraphicUpdateOperation.defaultMainWindowCapability = getNullVarWindowCapability(); + + // Null test + assertEquals(0, ManagerUtility.WindowCapabilityUtility.getMaxNumberOfMainFieldLines(textAndGraphicUpdateOperation.defaultMainWindowCapability)); + + // The tests.java class has an example of this, but we must build it to do what + // we need it to do. Build display cap w/ 3 main fields and test that it returns 3 + textAndGraphicUpdateOperation.defaultMainWindowCapability = getWindowCapability(3); + assertEquals(ManagerUtility.WindowCapabilityUtility.getMaxNumberOfMainFieldLines(textAndGraphicUpdateOperation.defaultMainWindowCapability), 3); + } + +} diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java index befe34a8c..a801faa75 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java @@ -29,7 +29,7 @@ public class TextAndGraphicUpdateOperation extends Task { private static final String TAG = "TextAndGraphicUpdateOperation"; private final WeakReference internalInterface; private final WeakReference fileManager; - private WindowCapability currentCapabilities; + WindowCapability defaultMainWindowCapability; private Show currentScreenData, sentShow; private TextsAndGraphicsState updatedState; private CompletionListener listener; @@ -48,7 +48,7 @@ public class TextAndGraphicUpdateOperation extends Task { super("TextAndGraphicUpdateOperation"); this.internalInterface = new WeakReference<>(internalInterface); this.fileManager = new WeakReference<>(fileManager); - this.currentCapabilities = currentCapabilities; + this.defaultMainWindowCapability = currentCapabilities; this.currentScreenData = currentScreenData; this.updatedState = newState; this.listener = listener; @@ -59,7 +59,7 @@ public class TextAndGraphicUpdateOperation extends Task { start(); } - private void start() { + void start() { if (getState() == Task.CANCELED) { finishOperation(false); return; @@ -237,7 +237,7 @@ public class TextAndGraphicUpdateOperation extends Task { return show; } - int numberOfLines = currentCapabilities != null ? ManagerUtility.WindowCapabilityUtility.getMaxNumberOfMainFieldLines(currentCapabilities) : 4; + int numberOfLines = defaultMainWindowCapability != null ? ManagerUtility.WindowCapabilityUtility.getMaxNumberOfMainFieldLines(defaultMainWindowCapability) : 4; switch (numberOfLines) { case 1: @@ -609,7 +609,7 @@ public class TextAndGraphicUpdateOperation extends Task { * @return true if image field is supported, false if not */ private boolean templateSupportsImageField(ImageFieldName name) { - return currentCapabilities == null || ManagerUtility.WindowCapabilityUtility.hasImageFieldOfName(currentCapabilities, name); + return defaultMainWindowCapability == null || ManagerUtility.WindowCapabilityUtility.hasImageFieldOfName(defaultMainWindowCapability, name); } /** @@ -636,7 +636,7 @@ public class TextAndGraphicUpdateOperation extends Task { * @return true if field should be updated, false if not */ private boolean templateSupportsTextField(TextFieldName name) { - return currentCapabilities == null || ManagerUtility.WindowCapabilityUtility.hasTextFieldOfName(currentCapabilities, name); + return defaultMainWindowCapability == null || ManagerUtility.WindowCapabilityUtility.hasTextFieldOfName(defaultMainWindowCapability, name); } public Show getSentShow() { -- cgit v1.2.1 From 8551fdfd5a2244c82b843cadbe2ddd1455574800 Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Thu, 20 Aug 2020 13:20:02 -0400 Subject: Removed test from screenManager because behavior was changed to align with IOS --- .../managers/screen/ScreenManagerTests.java | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/ScreenManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/ScreenManagerTests.java index f1e68e9b3..33d164740 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/ScreenManagerTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/ScreenManagerTests.java @@ -100,26 +100,12 @@ public class ScreenManagerTests { assertEquals(screenManager.getPrimaryGraphic(), testArtwork); } - @Test - public void testSetPrimaryGraphicWithBlankImage() { - screenManager.setPrimaryGraphic(null); - assertNotNull(screenManager.getPrimaryGraphic()); - assertEquals(screenManager.getPrimaryGraphic().getName(), "blankArtwork"); - } - @Test public void testSetSecondaryGraphic() { screenManager.setSecondaryGraphic(testArtwork); assertEquals(screenManager.getSecondaryGraphic(), testArtwork); } - @Test - public void testSetSecondaryGraphicWithBlankImage() { - screenManager.setSecondaryGraphic(null); - assertNotNull(screenManager.getSecondaryGraphic()); - assertEquals(screenManager.getSecondaryGraphic().getName(), "blankArtwork"); - } - @Test public void testAlignment() { screenManager.setTextAlignment(TextAlignment.LEFT_ALIGNED); -- cgit v1.2.1 From 5335b51118303d5db5fbabd3e8835376a0fefb3b Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Thu, 20 Aug 2020 13:20:20 -0400 Subject: Fixed null error in ScreenManager --- .../java/com/smartdevicelink/managers/screen/BaseScreenManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java index f00696b91..7935406dc 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java @@ -249,7 +249,7 @@ abstract class BaseScreenManager extends BaseSubManager { * @return an SdlArtwork object represents the current primaryGraphic */ public SdlArtwork getPrimaryGraphic() { - if (this.textAndGraphicManager.getPrimaryGraphic().getName().equals(textAndGraphicManager.getBlankArtwork().getName())) { + if (this.textAndGraphicManager.getPrimaryGraphic() == null || this.textAndGraphicManager.getPrimaryGraphic().getName().equals(textAndGraphicManager.getBlankArtwork().getName())) { return null; } return this.textAndGraphicManager.getPrimaryGraphic(); @@ -271,7 +271,7 @@ abstract class BaseScreenManager extends BaseSubManager { * @return an SdlArtwork object represents the current secondaryGraphic */ public SdlArtwork getSecondaryGraphic() { - if (this.textAndGraphicManager.getSecondaryGraphic().getName().equals(textAndGraphicManager.getBlankArtwork().getName())) { + if (this.textAndGraphicManager.getSecondaryGraphic() == null || this.textAndGraphicManager.getSecondaryGraphic().getName().equals(textAndGraphicManager.getBlankArtwork().getName())) { return null; } return this.textAndGraphicManager.getSecondaryGraphic(); -- cgit v1.2.1 From 09cfdefd37f14f684f34417b19351d10bfb9a389 Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Thu, 20 Aug 2020 13:25:33 -0400 Subject: Added null check for listener --- .../smartdevicelink/managers/screen/BaseTextAndGraphicManager.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java index 9a298e87b..437aecb06 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java @@ -198,7 +198,9 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { if (transactionQueue.getTasksAsList().size() > 0) { //Transactions already exist, cancelling them transactionQueue.clear(); - listener.onComplete(false); + if (listener != null) { + listener.onComplete(false); + } return; } updateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager.get(), defaultMainWindowCapability, currentScreenData, currentState(), new CompletionListener() { -- cgit v1.2.1 From 38955c79319c9f535a83fa96ffc30184aa79a76a Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Thu, 20 Aug 2020 13:25:52 -0400 Subject: Fixed javaSE project T&G manager --- .../com/smartdevicelink/managers/screen/TextAndGraphicManager.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/javaSE/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicManager.java b/javaSE/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicManager.java index 961e9e196..bc206c76f 100644 --- a/javaSE/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicManager.java +++ b/javaSE/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicManager.java @@ -46,10 +46,9 @@ import com.smartdevicelink.proxy.rpc.enums.FileType; class TextAndGraphicManager extends BaseTextAndGraphicManager { TextAndGraphicManager(@NonNull ISdl internalInterface, @NonNull FileManager fileManager, @NonNull SoftButtonManager softButtonManager) { - super(internalInterface, fileManager, softButtonManager); + super(internalInterface, fileManager); } - - @Override + SdlArtwork getBlankArtwork(){ if (blankArtwork == null){ blankArtwork = new SdlArtwork(); -- cgit v1.2.1 From b515f8658df5a56fb7081c9dda1f2cbdca23983b Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Thu, 20 Aug 2020 13:26:18 -0400 Subject: Testing codcov of test --- .../screen/TextAndGraphicManagerTests.java | 29 ++++++++++++---------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java index 67f5a0647..cd302daa4 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java @@ -4,6 +4,7 @@ import android.content.Context; import android.net.Uri; import androidx.test.ext.junit.runners.AndroidJUnit4; +import com.livio.taskmaster.Taskmaster; import com.smartdevicelink.managers.BaseSubManager; import com.smartdevicelink.managers.ManagerUtility; import com.smartdevicelink.managers.file.FileManager; @@ -34,6 +35,7 @@ import static junit.framework.TestCase.assertFalse; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; /** * This is a unit test class for the SmartDeviceLink library manager class : @@ -42,17 +44,21 @@ import static org.mockito.Mockito.mock; @RunWith(AndroidJUnit4.class) public class TextAndGraphicManagerTests { -/* // SETUP / HELPERS + // SETUP / HELPERS private TextAndGraphicManager textAndGraphicManager; private SdlArtwork testArtwork; + Taskmaster taskmaster; @Before public void setUp() throws Exception{ Context mTestContext = getInstrumentation().getContext(); + // mock things ISdl internalInterface = mock(ISdl.class); FileManager fileManager = mock(FileManager.class); SoftButtonManager softButtonManager = mock(SoftButtonManager.class); + taskmaster = new Taskmaster.Builder().build(); + when(internalInterface.getTaskmaster()).thenReturn(taskmaster); testArtwork = new SdlArtwork(); testArtwork.setName("testFile"); @@ -96,10 +102,10 @@ public class TextAndGraphicManagerTests { return windowCapability; } - *//** + /** * Used to simulate WindowCapability having no capabilities set * @return windowCapability that has no capabilities set - *//* + */ private WindowCapability getNullVarWindowCapability() { WindowCapability windowCapability = new WindowCapability(); @@ -130,9 +136,9 @@ public class TextAndGraphicManagerTests { assertNotNull(textAndGraphicManager.getBlankArtwork()); } - *//** + /** * Test getting number of lines available to be set based off of windowCapability - *//* + */ @Test public void testGetMainLines(){ @@ -148,7 +154,7 @@ public class TextAndGraphicManagerTests { assertEquals(ManagerUtility.WindowCapabilityUtility.getMaxNumberOfMainFieldLines(textAndGraphicManager.defaultMainWindowCapability), 3); } - @Test +/* @Test public void testAssemble1Line(){ Show inputShow = new Show(); @@ -634,7 +640,7 @@ public class TextAndGraphicManagerTests { tagsList4.add(MetadataType.MEDIA_STATION); assertEquals(tags.getMainField1(), tagsList); assertEquals(tags.getMainField4(), tagsList4); - } + }*/ @Test public void testMediaTrackTextField() { @@ -659,7 +665,7 @@ public class TextAndGraphicManagerTests { assertEquals(textAndGraphicManager.getTextAlignment(), TextAlignment.LEFT_ALIGNED); } - @Test +/* @Test public void testExtractTextFromShow(){ Show mainShow = new Show(); @@ -673,7 +679,7 @@ public class TextAndGraphicManagerTests { assertEquals(newShow.getMainField3(), "Sauce"); assertEquals(newShow.getMainField4(), ""); assertNull(newShow.getMainField2()); - } + }*/ // TEST IMAGES @@ -710,11 +716,8 @@ public class TextAndGraphicManagerTests { assertNull(textAndGraphicManager.getTitle()); assertNotNull(textAndGraphicManager.getBlankArtwork()); assertNull(textAndGraphicManager.currentScreenData); - assertNull(textAndGraphicManager.inProgressUpdate); - assertNull(textAndGraphicManager.queuedImageUpdate); - assertFalse(textAndGraphicManager.hasQueuedUpdate); assertNull(textAndGraphicManager.defaultMainWindowCapability); assertFalse(textAndGraphicManager.isDirty); assertEquals(textAndGraphicManager.getState(), BaseSubManager.SHUTDOWN); - }*/ + } } -- cgit v1.2.1 From a1d63cd537f714401b16eb9340d91b2885bbbcd2 Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Thu, 20 Aug 2020 13:53:15 -0400 Subject: Fixed JavaSE Project --- .../com/smartdevicelink/managers/screen/TextAndGraphicManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/javaSE/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicManager.java b/javaSE/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicManager.java index bc206c76f..ed2e93067 100644 --- a/javaSE/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicManager.java +++ b/javaSE/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicManager.java @@ -45,10 +45,10 @@ import com.smartdevicelink.proxy.rpc.enums.FileType; */ class TextAndGraphicManager extends BaseTextAndGraphicManager { - TextAndGraphicManager(@NonNull ISdl internalInterface, @NonNull FileManager fileManager, @NonNull SoftButtonManager softButtonManager) { + TextAndGraphicManager(@NonNull ISdl internalInterface, @NonNull FileManager fileManager) { super(internalInterface, fileManager); } - + SdlArtwork getBlankArtwork(){ if (blankArtwork == null){ blankArtwork = new SdlArtwork(); -- cgit v1.2.1 From 9fd2effd9fb94feb32f23d0a57ca93a2f98adcae Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Thu, 20 Aug 2020 18:02:28 -0400 Subject: Fixed Logic with canceling task and setting currentScreenData --- .../managers/screen/TextAndGraphicUpdateOperation.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java index a801faa75..259d5debc 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java @@ -99,7 +99,7 @@ public class TextAndGraphicUpdateOperation extends Task { @Override public void onComplete(boolean success) { if (getState() == Task.CANCELED) { - finishOperation(success); + finishOperation(false); return; } uploadImagesAndSendWhenDone(new CompletionListener() { @@ -147,6 +147,7 @@ public class TextAndGraphicUpdateOperation extends Task { Show showWithGraphics = createImageOnlyShowWithPrimaryArtwork(updatedState.getPrimaryGraphic(), updatedState.getSecondaryGraphic()); if (showWithGraphics != null) { DebugTool.logInfo(TAG, "Sending update with the successfully uploaded images"); + //Check for cancel sendShow(showWithGraphics, new CompletionListener() { @Override public void onComplete(boolean success) { @@ -185,6 +186,10 @@ public class TextAndGraphicUpdateOperation extends Task { fileManager.get().uploadArtworks(artworksToUpload, new MultipleFileCompletionListener() { @Override public void onComplete(Map errors) { + if (getState() == Task.CANCELED) { + finishOperation(false); + return; + } if (errors != null) { DebugTool.logError(TAG, "Text and graphic manager artwork failed to upload with error: " + errors.toString()); listener.onComplete(false); @@ -460,6 +465,8 @@ public class TextAndGraphicUpdateOperation extends Task { newShow.setMainField3(show.getMainField3()); newShow.setMainField4(show.getMainField4()); newShow.setTemplateTitle(show.getTemplateTitle()); + newShow.setMetadataTags(show.getMetadataTags()); + newShow.setAlignment(show.getAlignment()); return newShow; } -- cgit v1.2.1 From d567337df1f59bd9148616eee909e9840324a0f1 Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Thu, 20 Aug 2020 18:02:40 -0400 Subject: Added test for operation --- .../screen/TextAndGraphicUpdateOperationTest.java | 117 +++++++++++++++++++-- 1 file changed, 111 insertions(+), 6 deletions(-) diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java index c1c241c99..0973a98f2 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java @@ -8,14 +8,18 @@ import androidx.test.ext.junit.runners.AndroidJUnit4; import com.smartdevicelink.managers.CompletionListener; import com.smartdevicelink.managers.ManagerUtility; import com.smartdevicelink.managers.file.FileManager; +import com.smartdevicelink.managers.file.MultipleFileCompletionListener; import com.smartdevicelink.managers.file.filetypes.SdlArtwork; +import com.smartdevicelink.managers.file.filetypes.SdlFile; import com.smartdevicelink.proxy.RPCRequest; import com.smartdevicelink.proxy.interfaces.ISdl; +import com.smartdevicelink.proxy.rpc.ImageField; import com.smartdevicelink.proxy.rpc.Show; import com.smartdevicelink.proxy.rpc.ShowResponse; import com.smartdevicelink.proxy.rpc.TextField; import com.smartdevicelink.proxy.rpc.WindowCapability; import com.smartdevicelink.proxy.rpc.enums.FileType; +import com.smartdevicelink.proxy.rpc.enums.ImageFieldName; import com.smartdevicelink.proxy.rpc.enums.MetadataType; import com.smartdevicelink.proxy.rpc.enums.TextAlignment; import com.smartdevicelink.proxy.rpc.enums.TextFieldName; @@ -34,6 +38,9 @@ import static junit.framework.TestCase.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; @RunWith(AndroidJUnit4.class) public class TextAndGraphicUpdateOperationTest { @@ -49,6 +56,7 @@ public class TextAndGraphicUpdateOperationTest { private Show currentScreenData; private CompletionListener listener; ISdl internalInterface; + FileManager fileManager; private Answer onShowSuccess = new Answer() { @Override @@ -65,13 +73,40 @@ public class TextAndGraphicUpdateOperationTest { } }; + private Answer onShowSuccessCanceled = new Answer() { + @Override + public Void answer(InvocationOnMock invocation) { + Object[] args = invocation.getArguments(); + RPCRequest message = (RPCRequest) args[0]; + if (message instanceof Show) { + int correlationId = message.getCorrelationID(); + ShowResponse showResponse = new ShowResponse(); + showResponse.setSuccess(true); + message.getOnRPCResponseListener().onResponse(correlationId, showResponse); + } + return null; + } + }; + + + private Answer onImageUploadSuccessTaskCanceled = new Answer() { + @Override + public Void answer(InvocationOnMock invocation) throws Throwable { + Object[] args = invocation.getArguments(); + MultipleFileCompletionListener listener = (MultipleFileCompletionListener) args[1]; + textAndGraphicUpdateOperation.cancelTask(); + listener.onComplete(null); + return null; + } + }; + @Before public void setUp() throws Exception { Context mTestContext = getInstrumentation().getContext(); // mock things internalInterface = mock(ISdl.class); - FileManager fileManager = mock(FileManager.class); + fileManager = mock(FileManager.class); setUpCompletionListener(); textField1 = "It is"; textField2 = "wednesday"; @@ -87,26 +122,27 @@ public class TextAndGraphicUpdateOperationTest { textAlignment = TextAlignment.CENTERED; + testArtwork1 = new SdlArtwork(); - testArtwork1.setName("testFile"); + testArtwork1.setName("testFile1"); Uri uri1 = Uri.parse("android.resource://" + mTestContext.getPackageName() + "/drawable/ic_sdl"); testArtwork1.setUri(uri1); testArtwork1.setType(FileType.GRAPHIC_PNG); testArtwork2 = new SdlArtwork(); - testArtwork2.setName("testFile"); + testArtwork2.setName("testFile2"); Uri uri2 = Uri.parse("android.resource://" + mTestContext.getPackageName() + "/drawable/ic_sdl"); testArtwork2.setUri(uri2); testArtwork2.setType(FileType.GRAPHIC_PNG); testArtwork3 = new SdlArtwork(); - testArtwork3.setName("testFile"); + testArtwork3.setName("testFile3"); Uri uri3 = Uri.parse("android.resource://" + mTestContext.getPackageName() + "/drawable/ic_sdl"); testArtwork3.setUri(uri3); testArtwork3.setType(FileType.GRAPHIC_PNG); testArtwork4 = new SdlArtwork(); - testArtwork4.setName("testFile"); + testArtwork4.setName("testFile4"); Uri uri4 = Uri.parse("android.resource://" + mTestContext.getPackageName() + "/drawable/ic_sdl"); testArtwork4.setUri(uri4); testArtwork4.setType(FileType.GRAPHIC_PNG); @@ -167,6 +203,17 @@ public class TextAndGraphicUpdateOperationTest { WindowCapability windowCapability = new WindowCapability(); windowCapability.setTextFields(returnList); + ImageField imageField = new ImageField(); + imageField.setName(ImageFieldName.graphic); + ImageField imageField2 = new ImageField(); + imageField2.setName(ImageFieldName.secondaryGraphic); + List imageFieldList = new ArrayList<>(); + imageFieldList.add(imageField); + imageFieldList.add(imageField2); + windowCapability.setImageFields(imageFieldList); + + windowCapability.setImageFields(imageFieldList); + return windowCapability; } @@ -182,11 +229,69 @@ public class TextAndGraphicUpdateOperationTest { } @Test - public void testOnExecute() { + public void testUpload() { doAnswer(onShowSuccess).when(internalInterface).sendRPC(any(Show.class)); + // doAnswer(onImageUploadSuccess).when(fileManager).uploadArtworks(any(List.class), any(MultipleFileCompletionListener.class)); + // doAnswer(onHasUploadedFile).when(fileManager).hasUploadedFile(any(SdlFile.class)); + + // when(fileManager.hasUploadedFile(any(SdlFile.class))).thenReturn(true); + // verify(fileManager.uploadArtwork(any(List.class), any(MultipleFileCompletionListener.class)),1) +// assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getMetadataTags().getMainField1(), textField1Type); + + // Test Images need to be uploaded, sending text and uploading images + textAndGraphicUpdateOperation.onExecute(); + assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getMainField1(), textField1); + assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getMainField2(), textField2); + assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getMainField3(), textField3); + assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getMainField4(), textField4); + assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getAlignment(), textAlignment); + + // Test The files to be updated are already uploaded, send the full show immediately + String textField11 = "It's not"; + when(fileManager.hasUploadedFile(any(SdlFile.class))).thenReturn(true); + TextsAndGraphicsState textsAndGraphicsState = new TextsAndGraphicsState(textField11, textField2, textField3, textField4, + mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, textField1Type, textField2Type, textField3Type, textField4Type); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener); + textAndGraphicUpdateOperation.onExecute(); + assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getMainField1(), textField11); + + //Test: If there are no images to update, just send the text + TextsAndGraphicsState textsAndGraphicsStateNullImages = new TextsAndGraphicsState(textField1, textField2, textField3, textField4, + mediaTrackField, title, null, null, textAlignment, textField1Type, textField2Type, textField3Type, textField4Type); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsStateNullImages, listener); textAndGraphicUpdateOperation.onExecute(); assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getMainField1(), textField1); + + // Verifies that uploadArtworks gets called only with the fist textAndGraphicsUpdateOperation.onExecute call + verify(fileManager, times(1)).uploadArtworks(any(List.class),any(MultipleFileCompletionListener.class)); + + } + + @Test + public void testCanceledRightAway() { + textAndGraphicUpdateOperation.cancelTask(); + textAndGraphicUpdateOperation.onExecute(); + assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getMainField1(),"Old"); + } + + @Test + public void testTaskCanceledAfterImageUpload() { + doAnswer(onShowSuccess).when(internalInterface).sendRPC(any(Show.class)); + doAnswer(onImageUploadSuccessTaskCanceled).when(fileManager).uploadArtworks(any(List.class), any(MultipleFileCompletionListener.class)); + + // Test Canceled after Image upload + textAndGraphicUpdateOperation.onExecute(); + verify(internalInterface, times(1)).sendRPC(any(Show.class)); + assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getMainField1(),textField1); + + } + + public void testTaskCanceledAfterTextSent() { + doAnswer(onShowSuccessCanceled).when(internalInterface).sendRPC(any(Show.class)); + textAndGraphicUpdateOperation.onExecute(); + verify(fileManager, times(0)).uploadArtworks(any(List.class),any(MultipleFileCompletionListener.class)); + } /** -- cgit v1.2.1 From 4f36ce5242d4c89d09d1cd342f90a9be64259cf2 Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Thu, 20 Aug 2020 20:09:21 -0400 Subject: Converted Test from TextAndGrpahicsManagerTest to TextAndGraphicUpdateOperationTest --- .../screen/TextAndGraphicManagerTests.java | 504 ------------------- .../screen/TextAndGraphicUpdateOperationTest.java | 551 ++++++++++++++++++++- 2 files changed, 541 insertions(+), 514 deletions(-) diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java index cd302daa4..a3a9fbe22 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java @@ -154,494 +154,6 @@ public class TextAndGraphicManagerTests { assertEquals(ManagerUtility.WindowCapabilityUtility.getMaxNumberOfMainFieldLines(textAndGraphicManager.defaultMainWindowCapability), 3); } -/* @Test - public void testAssemble1Line(){ - - Show inputShow = new Show(); - - // Force it to return display with support for only 1 line of text - textAndGraphicManager.defaultMainWindowCapability = getWindowCapability(1); - - textAndGraphicManager.setTextField1("It is"); - textAndGraphicManager.setTextField1Type(MetadataType.HUMIDITY); - - Show assembledShow = textAndGraphicManager.assembleShowText(inputShow); - assertEquals(assembledShow.getMainField1(), "It is"); - - // test tags (just 1) - MetadataTags tags = assembledShow.getMetadataTags(); - List tagsList = new ArrayList<>(); - tagsList.add(MetadataType.HUMIDITY); - assertEquals(tags.getMainField1(), tagsList); - - textAndGraphicManager.setTextField2("Wednesday"); - - assembledShow = textAndGraphicManager.assembleShowText(inputShow); - assertEquals(assembledShow.getMainField1(), "It is - Wednesday"); - - textAndGraphicManager.setTextField3("My"); - - assembledShow = textAndGraphicManager.assembleShowText(inputShow); - assertEquals(assembledShow.getMainField1(), "It is - Wednesday - My"); - - textAndGraphicManager.setTextField4("Dudes"); - textAndGraphicManager.setTextField4Type(MetadataType.CURRENT_TEMPERATURE); - - assembledShow = textAndGraphicManager.assembleShowText(inputShow); - assertEquals(assembledShow.getMainField1(), "It is - Wednesday - My - Dudes"); - - // test tags - tags = assembledShow.getMetadataTags(); - tagsList = new ArrayList<>(); - tagsList.add(MetadataType.HUMIDITY); - tagsList.add(MetadataType.CURRENT_TEMPERATURE); - assertEquals(tags.getMainField1(), tagsList); - - // For some obscurity, lets try setting just fields 2 and 4 for a 1 line display - textAndGraphicManager.setTextField1(null); - textAndGraphicManager.setTextField3(null); - - assembledShow = textAndGraphicManager.assembleShowText(inputShow); - assertEquals(assembledShow.getMainField1(), "Wednesday - Dudes"); - } - - @Test - public void testAssemble2Lines() { - - Show inputShow = new Show(); - - // Force it to return display with support for only 2 lines of text - textAndGraphicManager.defaultMainWindowCapability = getWindowCapability(2); - - textAndGraphicManager.setTextField1("It is"); - textAndGraphicManager.setTextField1Type(MetadataType.HUMIDITY); - - Show assembledShow = textAndGraphicManager.assembleShowText(inputShow); - assertEquals(assembledShow.getMainField1(), "It is"); - - // test tags - MetadataTags tags = assembledShow.getMetadataTags(); - List tagsList = new ArrayList<>(); - tagsList.add(MetadataType.HUMIDITY); - assertEquals(tags.getMainField1(), tagsList); - - textAndGraphicManager.setTextField2("Wednesday"); - textAndGraphicManager.setTextField2Type(MetadataType.CURRENT_TEMPERATURE); - - assembledShow = textAndGraphicManager.assembleShowText(inputShow); - assertEquals(assembledShow.getMainField1(), "It is"); - assertEquals(assembledShow.getMainField2(), "Wednesday"); - - // test tags - tags = assembledShow.getMetadataTags(); - tagsList = new ArrayList<>(); - List tagsList2 = new ArrayList<>(); - tagsList.add(MetadataType.HUMIDITY); - tagsList2.add(MetadataType.CURRENT_TEMPERATURE); - assertEquals(tags.getMainField1(), tagsList); - assertEquals(tags.getMainField2(), tagsList2); - - textAndGraphicManager.setTextField3("My"); - textAndGraphicManager.setTextField3Type(MetadataType.MEDIA_ALBUM); - - assembledShow = textAndGraphicManager.assembleShowText(inputShow); - assertEquals(assembledShow.getMainField1(), "It is - Wednesday"); - assertEquals(assembledShow.getMainField2(), "My"); - - // test tags - tags = assembledShow.getMetadataTags(); - tagsList = new ArrayList<>(); - tagsList2 = new ArrayList<>(); - tagsList.add(MetadataType.CURRENT_TEMPERATURE); - tagsList.add(MetadataType.HUMIDITY); - tagsList2.add(MetadataType.MEDIA_ALBUM); - assertEquals(tags.getMainField1(), tagsList); - assertEquals(tags.getMainField2(), tagsList2); - - textAndGraphicManager.setTextField4("Dudes"); - textAndGraphicManager.setTextField4Type(MetadataType.MEDIA_STATION); - - assembledShow = textAndGraphicManager.assembleShowText(inputShow); - assertEquals(assembledShow.getMainField1(), "It is - Wednesday"); - assertEquals(assembledShow.getMainField2(), "My - Dudes"); - - // test tags - tags = assembledShow.getMetadataTags(); - tagsList = new ArrayList<>(); - tagsList2 = new ArrayList<>(); - tagsList.add(MetadataType.CURRENT_TEMPERATURE); - tagsList.add(MetadataType.HUMIDITY); - tagsList2.add(MetadataType.MEDIA_STATION); - tagsList2.add(MetadataType.MEDIA_ALBUM); - assertEquals(tags.getMainField1(), tagsList); - assertEquals(tags.getMainField2(), tagsList2); - - // For some obscurity, lets try setting just fields 2 and 4 for a 2 line display - textAndGraphicManager.setTextField1(null); - textAndGraphicManager.setTextField3(null); - textAndGraphicManager.setTextField1Type(null); - textAndGraphicManager.setTextField3Type(null); - - assembledShow = textAndGraphicManager.assembleShowText(inputShow); - assertEquals(assembledShow.getMainField1(), "Wednesday"); - assertEquals(assembledShow.getMainField2(), "Dudes"); - - // And 3 fields without setting 1 - textAndGraphicManager.setTextField3("My"); - - assembledShow = textAndGraphicManager.assembleShowText(inputShow); - assertEquals(assembledShow.getMainField1(), "Wednesday"); - assertEquals(assembledShow.getMainField2(), "My - Dudes"); - - // test tags - tags = assembledShow.getMetadataTags(); - tagsList = new ArrayList<>(); - tagsList2 = new ArrayList<>(); - tagsList.add(MetadataType.CURRENT_TEMPERATURE); - tagsList2.add(MetadataType.MEDIA_STATION); - assertEquals(tags.getMainField1(), tagsList); - assertEquals(tags.getMainField2(), tagsList2); - } - - @Test - public void testAssemble3Lines() { - - Show inputShow = new Show(); - - // Force it to return display with support for only 3 lines of text - textAndGraphicManager.defaultMainWindowCapability = getWindowCapability(3); - - textAndGraphicManager.setTextField1("It is"); - textAndGraphicManager.setTextField1Type(MetadataType.HUMIDITY); - - Show assembledShow = textAndGraphicManager.assembleShowText(inputShow); - assertEquals(assembledShow.getMainField1(), "It is"); - assertEquals(assembledShow.getMainField2(), ""); - assertEquals(assembledShow.getMainField3(), ""); - - // test tags - MetadataTags tags = assembledShow.getMetadataTags(); - List tagsList = new ArrayList<>(); - tagsList.add(MetadataType.HUMIDITY); - assertEquals(tags.getMainField1(), tagsList); - - textAndGraphicManager.setTextField2("Wednesday"); - textAndGraphicManager.setTextField2Type(MetadataType.CURRENT_TEMPERATURE); - - assembledShow = textAndGraphicManager.assembleShowText(inputShow); - assertEquals(assembledShow.getMainField1(), "It is"); - assertEquals(assembledShow.getMainField2(), "Wednesday"); - assertEquals(assembledShow.getMainField3(), ""); - - // test tags - tags = assembledShow.getMetadataTags(); - tagsList = new ArrayList<>(); - List tagsList2 = new ArrayList<>(); - tagsList.add(MetadataType.HUMIDITY); - tagsList2.add(MetadataType.CURRENT_TEMPERATURE); - assertEquals(tags.getMainField1(), tagsList); - assertEquals(tags.getMainField2(), tagsList2); - - textAndGraphicManager.setTextField3("My"); - textAndGraphicManager.setTextField3Type(MetadataType.MEDIA_ALBUM); - - assembledShow = textAndGraphicManager.assembleShowText(inputShow); - assertEquals(assembledShow.getMainField1(), "It is"); - assertEquals(assembledShow.getMainField2(), "Wednesday"); - assertEquals(assembledShow.getMainField3(), "My"); - - // test tags - tags = assembledShow.getMetadataTags(); - tagsList = new ArrayList<>(); - tagsList2 = new ArrayList<>(); - List tagsList3 = new ArrayList<>(); - tagsList.add(MetadataType.HUMIDITY); - tagsList2.add(MetadataType.CURRENT_TEMPERATURE); - tagsList3.add(MetadataType.MEDIA_ALBUM); - assertEquals(tags.getMainField1(), tagsList); - assertEquals(tags.getMainField2(), tagsList2); - assertEquals(tags.getMainField3(), tagsList3); - - textAndGraphicManager.setTextField4("Dudes"); - textAndGraphicManager.setTextField4Type(MetadataType.MEDIA_STATION); - - assembledShow = textAndGraphicManager.assembleShowText(inputShow); - assertEquals(assembledShow.getMainField1(), "It is"); - assertEquals(assembledShow.getMainField2(), "Wednesday"); - assertEquals(assembledShow.getMainField3(), "My - Dudes"); - - // test tags - tags = assembledShow.getMetadataTags(); - tagsList = new ArrayList<>(); - tagsList2 = new ArrayList<>(); - tagsList3 = new ArrayList<>(); - tagsList.add(MetadataType.HUMIDITY); - tagsList2.add(MetadataType.CURRENT_TEMPERATURE); - tagsList3.add(MetadataType.MEDIA_ALBUM); - tagsList3.add(MetadataType.MEDIA_STATION); - assertEquals(tags.getMainField1(), tagsList); - assertEquals(tags.getMainField2(), tagsList2); - assertEquals(tags.getMainField3(), tagsList3); - - // Someone might not want to set the fields in order? We should handle that - textAndGraphicManager.setTextField1(null); - - assembledShow = textAndGraphicManager.assembleShowText(inputShow); - try { - System.out.println(assembledShow.serializeJSON().toString()); - } catch (JSONException e) { - e.printStackTrace(); - } - - assertEquals(assembledShow.getMainField2(), "Wednesday"); - assertEquals(assembledShow.getMainField3(), "My - Dudes"); - } - - @Test - public void testAssemble4Lines() { - - Show inputShow = new Show(); - - textAndGraphicManager.defaultMainWindowCapability = getWindowCapability(4); - TextField tx1 = new TextField(); - TextField tx2 = new TextField(); - TextField tx3 = new TextField(); - TextField tx4 = new TextField(); - TextField tx5 = new TextField(); - TextField tx6 = new TextField(); - - tx1.setName(TextFieldName.mainField1); - tx2.setName(TextFieldName.mainField2); - tx3.setName(TextFieldName.mainField3); - tx4.setName(TextFieldName.mainField4); - tx5.setName(TextFieldName.mediaTrack); - tx6.setName(TextFieldName.templateTitle); - - List textFieldNames = Arrays.asList(tx1,tx2,tx3,tx4,tx5,tx6); - textAndGraphicManager.defaultMainWindowCapability.setTextFields(textFieldNames); - - textAndGraphicManager.setMediaTrackTextField("HI"); - textAndGraphicManager.setTitle("bye"); - - // Force it to return display with support for only 4 lines of text - - textAndGraphicManager.setTextField1("It is"); - textAndGraphicManager.setTextField1Type(MetadataType.HUMIDITY); - - Show assembledShow = textAndGraphicManager.assembleShowText(inputShow); - - assertEquals(assembledShow.getMainField1(), "It is"); - assertEquals(assembledShow.getMainField2(), ""); - assertEquals(assembledShow.getMainField3(), ""); - assertEquals(assembledShow.getMainField4(), ""); - assertEquals(assembledShow.getMediaTrack(), "HI"); - assertEquals(assembledShow.getTemplateTitle(), "bye"); - - // test tags - MetadataTags tags = assembledShow.getMetadataTags(); - List tagsList = new ArrayList<>(); - tagsList.add(MetadataType.HUMIDITY); - assertEquals(tags.getMainField1(), tagsList); - - textAndGraphicManager.setTextField2("Wednesday"); - textAndGraphicManager.setTextField2Type(MetadataType.CURRENT_TEMPERATURE); - - assembledShow = textAndGraphicManager.assembleShowText(inputShow); - assertEquals(assembledShow.getMainField1(), "It is"); - assertEquals(assembledShow.getMainField2(), "Wednesday"); - assertEquals(assembledShow.getMainField3(), ""); - assertEquals(assembledShow.getMainField4(), ""); - - // test tags - tags = assembledShow.getMetadataTags(); - tagsList = new ArrayList<>(); - List tagsList2 = new ArrayList<>(); - tagsList.add(MetadataType.HUMIDITY); - tagsList2.add(MetadataType.CURRENT_TEMPERATURE); - assertEquals(tags.getMainField1(), tagsList); - assertEquals(tags.getMainField2(), tagsList2); - - textAndGraphicManager.setTextField3("My"); - textAndGraphicManager.setTextField3Type(MetadataType.MEDIA_ALBUM); - - assembledShow = textAndGraphicManager.assembleShowText(inputShow); - assertEquals(assembledShow.getMainField1(), "It is"); - assertEquals(assembledShow.getMainField2(), "Wednesday"); - assertEquals(assembledShow.getMainField3(), "My"); - assertEquals(assembledShow.getMainField4(), ""); - - // test tags - tags = assembledShow.getMetadataTags(); - tagsList = new ArrayList<>(); - tagsList2 = new ArrayList<>(); - List tagsList3 = new ArrayList<>(); - tagsList.add(MetadataType.HUMIDITY); - tagsList2.add(MetadataType.CURRENT_TEMPERATURE); - tagsList3.add(MetadataType.MEDIA_ALBUM); - assertEquals(tags.getMainField1(), tagsList); - assertEquals(tags.getMainField2(), tagsList2); - assertEquals(tags.getMainField3(), tagsList3); - - textAndGraphicManager.setTextField4("Dudes"); - textAndGraphicManager.setTextField4Type(MetadataType.MEDIA_STATION); - - assembledShow = textAndGraphicManager.assembleShowText(inputShow); - assertEquals(assembledShow.getMainField1(), "It is"); - assertEquals(assembledShow.getMainField2(), "Wednesday"); - assertEquals(assembledShow.getMainField3(), "My"); - assertEquals(assembledShow.getMainField4(), "Dudes"); - - // test tags - tags = assembledShow.getMetadataTags(); - tagsList = new ArrayList<>(); - tagsList2 = new ArrayList<>(); - tagsList3 = new ArrayList<>(); - List tagsList4 = new ArrayList<>(); - tagsList.add(MetadataType.HUMIDITY); - tagsList2.add(MetadataType.CURRENT_TEMPERATURE); - tagsList3.add(MetadataType.MEDIA_ALBUM); - tagsList4.add(MetadataType.MEDIA_STATION); - assertEquals(tags.getMainField1(), tagsList); - assertEquals(tags.getMainField2(), tagsList2); - assertEquals(tags.getMainField3(), tagsList3); - assertEquals(tags.getMainField4(), tagsList4); - - // try just setting line 1 and 4 - textAndGraphicManager.setTextField2(null); - textAndGraphicManager.setTextField3(null); - textAndGraphicManager.setTextField2Type(null); - textAndGraphicManager.setTextField3Type(null); - - assembledShow = textAndGraphicManager.assembleShowText(inputShow); - assertEquals(assembledShow.getMainField1(), "It is"); - assertEquals(assembledShow.getMainField2(), ""); - assertEquals(assembledShow.getMainField3(), ""); - assertEquals(assembledShow.getMainField4(), "Dudes"); - - // test tags - tags = assembledShow.getMetadataTags(); - tagsList = new ArrayList<>(); - tagsList4 = new ArrayList<>(); - tagsList.add(MetadataType.HUMIDITY); - tagsList4.add(MetadataType.MEDIA_STATION); - assertEquals(tags.getMainField1(), tagsList); - assertEquals(tags.getMainField4(), tagsList4); - } - - *//** - * Testing if WindowCapability is null, TextFields should still update. - *//* - @Test - public void testAssemble4LinesNullWindowCapability() { - - Show inputShow = new Show(); - - textAndGraphicManager.setMediaTrackTextField("HI"); - textAndGraphicManager.setTitle("bye"); - - textAndGraphicManager.setTextField1("It is"); - textAndGraphicManager.setTextField1Type(MetadataType.HUMIDITY); - - Show assembledShow = textAndGraphicManager.assembleShowText(inputShow); - - assertEquals(assembledShow.getMainField1(), "It is"); - assertEquals(assembledShow.getMainField2(), ""); - assertEquals(assembledShow.getMainField3(), ""); - assertEquals(assembledShow.getMainField4(), ""); - assertEquals(assembledShow.getMediaTrack(), "HI"); - assertEquals(assembledShow.getTemplateTitle(), "bye"); - - // test tags - MetadataTags tags = assembledShow.getMetadataTags(); - List tagsList = new ArrayList<>(); - tagsList.add(MetadataType.HUMIDITY); - assertEquals(tags.getMainField1(), tagsList); - - textAndGraphicManager.setTextField2("Wednesday"); - textAndGraphicManager.setTextField2Type(MetadataType.CURRENT_TEMPERATURE); - - assembledShow = textAndGraphicManager.assembleShowText(inputShow); - assertEquals(assembledShow.getMainField1(), "It is"); - assertEquals(assembledShow.getMainField2(), "Wednesday"); - assertEquals(assembledShow.getMainField3(), ""); - assertEquals(assembledShow.getMainField4(), ""); - - // test tags - tags = assembledShow.getMetadataTags(); - tagsList = new ArrayList<>(); - List tagsList2 = new ArrayList<>(); - tagsList.add(MetadataType.HUMIDITY); - tagsList2.add(MetadataType.CURRENT_TEMPERATURE); - assertEquals(tags.getMainField1(), tagsList); - assertEquals(tags.getMainField2(), tagsList2); - - textAndGraphicManager.setTextField3("My"); - textAndGraphicManager.setTextField3Type(MetadataType.MEDIA_ALBUM); - - assembledShow = textAndGraphicManager.assembleShowText(inputShow); - assertEquals(assembledShow.getMainField1(), "It is"); - assertEquals(assembledShow.getMainField2(), "Wednesday"); - assertEquals(assembledShow.getMainField3(), "My"); - assertEquals(assembledShow.getMainField4(), ""); - - // test tags - tags = assembledShow.getMetadataTags(); - tagsList = new ArrayList<>(); - tagsList2 = new ArrayList<>(); - List tagsList3 = new ArrayList<>(); - tagsList.add(MetadataType.HUMIDITY); - tagsList2.add(MetadataType.CURRENT_TEMPERATURE); - tagsList3.add(MetadataType.MEDIA_ALBUM); - assertEquals(tags.getMainField1(), tagsList); - assertEquals(tags.getMainField2(), tagsList2); - assertEquals(tags.getMainField3(), tagsList3); - - textAndGraphicManager.setTextField4("Dudes"); - textAndGraphicManager.setTextField4Type(MetadataType.MEDIA_STATION); - - assembledShow = textAndGraphicManager.assembleShowText(inputShow); - assertEquals(assembledShow.getMainField1(), "It is"); - assertEquals(assembledShow.getMainField2(), "Wednesday"); - assertEquals(assembledShow.getMainField3(), "My"); - assertEquals(assembledShow.getMainField4(), "Dudes"); - - // test tags - tags = assembledShow.getMetadataTags(); - tagsList = new ArrayList<>(); - tagsList2 = new ArrayList<>(); - tagsList3 = new ArrayList<>(); - List tagsList4 = new ArrayList<>(); - tagsList.add(MetadataType.HUMIDITY); - tagsList2.add(MetadataType.CURRENT_TEMPERATURE); - tagsList3.add(MetadataType.MEDIA_ALBUM); - tagsList4.add(MetadataType.MEDIA_STATION); - assertEquals(tags.getMainField1(), tagsList); - assertEquals(tags.getMainField2(), tagsList2); - assertEquals(tags.getMainField3(), tagsList3); - assertEquals(tags.getMainField4(), tagsList4); - - // try just setting line 1 and 4 - textAndGraphicManager.setTextField2(null); - textAndGraphicManager.setTextField3(null); - textAndGraphicManager.setTextField2Type(null); - textAndGraphicManager.setTextField3Type(null); - - assembledShow = textAndGraphicManager.assembleShowText(inputShow); - assertEquals(assembledShow.getMainField1(), "It is"); - assertEquals(assembledShow.getMainField2(), ""); - assertEquals(assembledShow.getMainField3(), ""); - assertEquals(assembledShow.getMainField4(), "Dudes"); - - // test tags - tags = assembledShow.getMetadataTags(); - tagsList = new ArrayList<>(); - tagsList4 = new ArrayList<>(); - tagsList.add(MetadataType.HUMIDITY); - tagsList4.add(MetadataType.MEDIA_STATION); - assertEquals(tags.getMainField1(), tagsList); - assertEquals(tags.getMainField4(), tagsList4); - }*/ - @Test public void testMediaTrackTextField() { @@ -665,22 +177,6 @@ public class TextAndGraphicManagerTests { assertEquals(textAndGraphicManager.getTextAlignment(), TextAlignment.LEFT_ALIGNED); } -/* @Test - public void testExtractTextFromShow(){ - - Show mainShow = new Show(); - mainShow.setMainField1("test"); - mainShow.setMainField3("Sauce"); - mainShow.setMainField4(""); - - Show newShow = textAndGraphicManager.extractTextFromShow(mainShow); - - assertEquals(newShow.getMainField1(), "test"); - assertEquals(newShow.getMainField3(), "Sauce"); - assertEquals(newShow.getMainField4(), ""); - assertNull(newShow.getMainField2()); - }*/ - // TEST IMAGES @Test diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java index 0973a98f2..c62104f5f 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java @@ -14,6 +14,7 @@ import com.smartdevicelink.managers.file.filetypes.SdlFile; import com.smartdevicelink.proxy.RPCRequest; import com.smartdevicelink.proxy.interfaces.ISdl; import com.smartdevicelink.proxy.rpc.ImageField; +import com.smartdevicelink.proxy.rpc.MetadataTags; import com.smartdevicelink.proxy.rpc.Show; import com.smartdevicelink.proxy.rpc.ShowResponse; import com.smartdevicelink.proxy.rpc.TextField; @@ -24,6 +25,7 @@ import com.smartdevicelink.proxy.rpc.enums.MetadataType; import com.smartdevicelink.proxy.rpc.enums.TextAlignment; import com.smartdevicelink.proxy.rpc.enums.TextFieldName; +import org.json.JSONException; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -31,10 +33,12 @@ import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; +import static org.junit.Assert.assertNull; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; @@ -80,6 +84,7 @@ public class TextAndGraphicUpdateOperationTest { RPCRequest message = (RPCRequest) args[0]; if (message instanceof Show) { int correlationId = message.getCorrelationID(); + textAndGraphicUpdateOperation.cancelTask(); ShowResponse showResponse = new ShowResponse(); showResponse.setSuccess(true); message.getOnRPCResponseListener().onResponse(correlationId, showResponse); @@ -109,9 +114,9 @@ public class TextAndGraphicUpdateOperationTest { fileManager = mock(FileManager.class); setUpCompletionListener(); textField1 = "It is"; - textField2 = "wednesday"; - textField3 = "my"; - textField4 = "dudes"; + textField2 = "Wednesday"; + textField3 = "My"; + textField4 = "Dudes"; mediaTrackField = "dudes"; title = "dudes"; @@ -231,13 +236,6 @@ public class TextAndGraphicUpdateOperationTest { @Test public void testUpload() { doAnswer(onShowSuccess).when(internalInterface).sendRPC(any(Show.class)); - // doAnswer(onImageUploadSuccess).when(fileManager).uploadArtworks(any(List.class), any(MultipleFileCompletionListener.class)); - // doAnswer(onHasUploadedFile).when(fileManager).hasUploadedFile(any(SdlFile.class)); - - // when(fileManager.hasUploadedFile(any(SdlFile.class))).thenReturn(true); - // verify(fileManager.uploadArtwork(any(List.class), any(MultipleFileCompletionListener.class)),1) -// assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getMetadataTags().getMainField1(), textField1Type); - // Test Images need to be uploaded, sending text and uploading images textAndGraphicUpdateOperation.onExecute(); @@ -312,4 +310,537 @@ public class TextAndGraphicUpdateOperationTest { assertEquals(ManagerUtility.WindowCapabilityUtility.getMaxNumberOfMainFieldLines(textAndGraphicUpdateOperation.defaultMainWindowCapability), 3); } + + @Test + public void testAssemble1Line(){ + + Show inputShow = new Show(); + + TextsAndGraphicsState textsAndGraphicsState = new TextsAndGraphicsState(textField1, null, null, null, + mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, MetadataType.HUMIDITY, null, null, null); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, getWindowCapability(1), currentScreenData, textsAndGraphicsState, listener); + + Show assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); + assertEquals(assembledShow.getMainField1(), "It is"); + + // test tags (just 1) + MetadataTags tags = assembledShow.getMetadataTags(); + List tagsList = new ArrayList<>(); + tagsList.add(MetadataType.HUMIDITY); + assertEquals(tags.getMainField1(), tagsList); + + textsAndGraphicsState.setTextField2(textField2); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, getWindowCapability(1), currentScreenData, textsAndGraphicsState, listener); + + assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); + assertEquals(assembledShow.getMainField1(), "It is - Wednesday"); + + textsAndGraphicsState.setTextField3(textField3); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, getWindowCapability(1), currentScreenData, textsAndGraphicsState, listener); + + assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); + assertEquals(assembledShow.getMainField1(), "It is - Wednesday - My"); + + textsAndGraphicsState.setTextField4(textField4); + textsAndGraphicsState.setTextField4Type(MetadataType.CURRENT_TEMPERATURE); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, getWindowCapability(1), currentScreenData, textsAndGraphicsState, listener); + + assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); + assertEquals(assembledShow.getMainField1(), "It is - Wednesday - My - Dudes"); + + // test tags + tags = assembledShow.getMetadataTags(); + tagsList = new ArrayList<>(); + tagsList.add(MetadataType.HUMIDITY); + tagsList.add(MetadataType.CURRENT_TEMPERATURE); + assertEquals(tags.getMainField1(), tagsList); + + // For some obscurity, lets try setting just fields 2 and 4 for a 1 line display + textsAndGraphicsState.setTextField1(null); + textsAndGraphicsState.setTextField3(null); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, getWindowCapability(1), currentScreenData, textsAndGraphicsState, listener); + + + assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); + assertEquals(assembledShow.getMainField1(), "Wednesday - Dudes"); + } + + @Test + public void testAssemble2Lines() { + + Show inputShow = new Show(); + defaultMainWindowCapability = getWindowCapability(2); + + // Force it to return display with support for only 2 lines of text + TextsAndGraphicsState textsAndGraphicsState = new TextsAndGraphicsState(textField1, null, null, null, + mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, MetadataType.HUMIDITY, null, null, null); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener); + + Show assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); + assertEquals(assembledShow.getMainField1(), "It is"); + + // test tags + MetadataTags tags = assembledShow.getMetadataTags(); + List tagsList = new ArrayList<>(); + tagsList.add(MetadataType.HUMIDITY); + assertEquals(tags.getMainField1(), tagsList); + + textsAndGraphicsState.setTextField2(textField2); + textsAndGraphicsState.setTextField2Type(MetadataType.CURRENT_TEMPERATURE); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener); + + assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); + assertEquals(assembledShow.getMainField1(), "It is"); + assertEquals(assembledShow.getMainField2(), "Wednesday"); + + // test tags + tags = assembledShow.getMetadataTags(); + tagsList = new ArrayList<>(); + List tagsList2 = new ArrayList<>(); + tagsList.add(MetadataType.HUMIDITY); + tagsList2.add(MetadataType.CURRENT_TEMPERATURE); + assertEquals(tags.getMainField1(), tagsList); + assertEquals(tags.getMainField2(), tagsList2); + + textsAndGraphicsState.setTextField3(textField3); + textsAndGraphicsState.setTextField3Type(MetadataType.MEDIA_ALBUM); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, getWindowCapability(2), currentScreenData, textsAndGraphicsState, listener); + + assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); + assertEquals(assembledShow.getMainField1(), "It is - Wednesday"); + assertEquals(assembledShow.getMainField2(), "My"); + + // test tags + tags = assembledShow.getMetadataTags(); + tagsList = new ArrayList<>(); + tagsList2 = new ArrayList<>(); + tagsList.add(MetadataType.CURRENT_TEMPERATURE); + tagsList.add(MetadataType.HUMIDITY); + tagsList2.add(MetadataType.MEDIA_ALBUM); + assertEquals(tags.getMainField1(), tagsList); + assertEquals(tags.getMainField2(), tagsList2); + + textsAndGraphicsState.setTextField4(textField4); + textsAndGraphicsState.setTextField4Type(MetadataType.MEDIA_STATION); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, getWindowCapability(2), currentScreenData, textsAndGraphicsState, listener); + + assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); + assertEquals(assembledShow.getMainField1(), "It is - Wednesday"); + assertEquals(assembledShow.getMainField2(), "My - Dudes"); + + // test tags + tags = assembledShow.getMetadataTags(); + tagsList = new ArrayList<>(); + tagsList2 = new ArrayList<>(); + tagsList.add(MetadataType.CURRENT_TEMPERATURE); + tagsList.add(MetadataType.HUMIDITY); + tagsList2.add(MetadataType.MEDIA_STATION); + tagsList2.add(MetadataType.MEDIA_ALBUM); + assertEquals(tags.getMainField1(), tagsList); + assertEquals(tags.getMainField2(), tagsList2); + + // For some obscurity, lets try setting just fields 2 and 4 for a 2 line display + textsAndGraphicsState.setTextField1(null); + textsAndGraphicsState.setTextField3(null); + textsAndGraphicsState.setTextField1Type(null); + textsAndGraphicsState.setTextField3Type(null); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, getWindowCapability(2), currentScreenData, textsAndGraphicsState, listener); + + assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); + assertEquals(assembledShow.getMainField1(), "Wednesday"); + assertEquals(assembledShow.getMainField2(), "Dudes"); + + // And 3 fields without setting 1 + textsAndGraphicsState.setTextField3(textField3); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, getWindowCapability(2), currentScreenData, textsAndGraphicsState, listener); + + assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); + assertEquals(assembledShow.getMainField1(), "Wednesday"); + assertEquals(assembledShow.getMainField2(), "My - Dudes"); + + // test tags + tags = assembledShow.getMetadataTags(); + tagsList = new ArrayList<>(); + tagsList2 = new ArrayList<>(); + tagsList.add(MetadataType.CURRENT_TEMPERATURE); + tagsList2.add(MetadataType.MEDIA_STATION); + assertEquals(tags.getMainField1(), tagsList); + assertEquals(tags.getMainField2(), tagsList2); + } + + @Test + public void testAssemble3Lines() { + + Show inputShow = new Show(); + + // Force it to return display with support for only 3 lines of text + defaultMainWindowCapability = getWindowCapability(3); + TextsAndGraphicsState textsAndGraphicsState = new TextsAndGraphicsState(textField1, null, null, null, + mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, MetadataType.HUMIDITY, null, null, null); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener); + + Show assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); + assertEquals(assembledShow.getMainField1(), "It is"); + assertEquals(assembledShow.getMainField2(), ""); + assertEquals(assembledShow.getMainField3(), ""); + + // test tags + MetadataTags tags = assembledShow.getMetadataTags(); + List tagsList = new ArrayList<>(); + tagsList.add(MetadataType.HUMIDITY); + assertEquals(tags.getMainField1(), tagsList); + + textsAndGraphicsState.setTextField2(textField2); + textsAndGraphicsState.setTextField2Type(MetadataType.CURRENT_TEMPERATURE); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener); + + assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); + assertEquals(assembledShow.getMainField1(), "It is"); + assertEquals(assembledShow.getMainField2(), "Wednesday"); + assertEquals(assembledShow.getMainField3(), ""); + + // test tags + tags = assembledShow.getMetadataTags(); + tagsList = new ArrayList<>(); + List tagsList2 = new ArrayList<>(); + tagsList.add(MetadataType.HUMIDITY); + tagsList2.add(MetadataType.CURRENT_TEMPERATURE); + assertEquals(tags.getMainField1(), tagsList); + assertEquals(tags.getMainField2(), tagsList2); + + textsAndGraphicsState.setTextField3(textField3); + textsAndGraphicsState.setTextField3Type(MetadataType.MEDIA_ALBUM); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener); + + assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); + assertEquals(assembledShow.getMainField1(), "It is"); + assertEquals(assembledShow.getMainField2(), "Wednesday"); + assertEquals(assembledShow.getMainField3(), "My"); + + // test tags + tags = assembledShow.getMetadataTags(); + tagsList = new ArrayList<>(); + tagsList2 = new ArrayList<>(); + List tagsList3 = new ArrayList<>(); + tagsList.add(MetadataType.HUMIDITY); + tagsList2.add(MetadataType.CURRENT_TEMPERATURE); + tagsList3.add(MetadataType.MEDIA_ALBUM); + assertEquals(tags.getMainField1(), tagsList); + assertEquals(tags.getMainField2(), tagsList2); + assertEquals(tags.getMainField3(), tagsList3); + + textsAndGraphicsState.setTextField4(textField4); + textsAndGraphicsState.setTextField4Type(MetadataType.MEDIA_STATION); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager,defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener); + + assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); + assertEquals(assembledShow.getMainField1(), "It is"); + assertEquals(assembledShow.getMainField2(), "Wednesday"); + assertEquals(assembledShow.getMainField3(), "My - Dudes"); + + // test tags + tags = assembledShow.getMetadataTags(); + tagsList = new ArrayList<>(); + tagsList2 = new ArrayList<>(); + tagsList3 = new ArrayList<>(); + tagsList.add(MetadataType.HUMIDITY); + tagsList2.add(MetadataType.CURRENT_TEMPERATURE); + tagsList3.add(MetadataType.MEDIA_ALBUM); + tagsList3.add(MetadataType.MEDIA_STATION); + assertEquals(tags.getMainField1(), tagsList); + assertEquals(tags.getMainField2(), tagsList2); + assertEquals(tags.getMainField3(), tagsList3); + + // Someone might not want to set the fields in order? We should handle that + textsAndGraphicsState.setTextField1(null); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener); + + assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); + try { + System.out.println(assembledShow.serializeJSON().toString()); + } catch (JSONException e) { + e.printStackTrace(); + } + + assertEquals(assembledShow.getMainField2(), "Wednesday"); + assertEquals(assembledShow.getMainField3(), "My - Dudes"); + } + + @Test + public void testAssemble4Lines() { + + Show inputShow = new Show(); + + defaultMainWindowCapability = getWindowCapability(4); + TextField tx1 = new TextField(); + TextField tx2 = new TextField(); + TextField tx3 = new TextField(); + TextField tx4 = new TextField(); + TextField tx5 = new TextField(); + TextField tx6 = new TextField(); + + tx1.setName(TextFieldName.mainField1); + tx2.setName(TextFieldName.mainField2); + tx3.setName(TextFieldName.mainField3); + tx4.setName(TextFieldName.mainField4); + tx5.setName(TextFieldName.mediaTrack); + tx6.setName(TextFieldName.templateTitle); + + List textFieldNames = Arrays.asList(tx1,tx2,tx3,tx4,tx5,tx6); + defaultMainWindowCapability.setTextFields(textFieldNames); + + TextsAndGraphicsState textsAndGraphicsState = new TextsAndGraphicsState(textField1, null, null, null, + mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, MetadataType.HUMIDITY, null, null, null); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener); + textsAndGraphicsState.setMediaTrackTextField("HI"); + textsAndGraphicsState.setTitle("bye"); + + // Force it to return display with support for only 4 lines of text + Show assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); + + assertEquals(assembledShow.getMainField1(), "It is"); + assertEquals(assembledShow.getMainField2(), ""); + assertEquals(assembledShow.getMainField3(), ""); + assertEquals(assembledShow.getMainField4(), ""); + assertEquals(assembledShow.getMediaTrack(), "HI"); + assertEquals(assembledShow.getTemplateTitle(), "bye"); + + // test tags + MetadataTags tags = assembledShow.getMetadataTags(); + List tagsList = new ArrayList<>(); + tagsList.add(MetadataType.HUMIDITY); + assertEquals(tags.getMainField1(), tagsList); + + textsAndGraphicsState.setTextField2("Wednesday"); + textsAndGraphicsState.setTextField2Type(MetadataType.CURRENT_TEMPERATURE); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener); + + + assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); + assertEquals(assembledShow.getMainField1(), "It is"); + assertEquals(assembledShow.getMainField2(), "Wednesday"); + assertEquals(assembledShow.getMainField3(), ""); + assertEquals(assembledShow.getMainField4(), ""); + + // test tags + tags = assembledShow.getMetadataTags(); + tagsList = new ArrayList<>(); + List tagsList2 = new ArrayList<>(); + tagsList.add(MetadataType.HUMIDITY); + tagsList2.add(MetadataType.CURRENT_TEMPERATURE); + assertEquals(tags.getMainField1(), tagsList); + assertEquals(tags.getMainField2(), tagsList2); + + textsAndGraphicsState.setTextField3("My"); + textsAndGraphicsState.setTextField3Type(MetadataType.MEDIA_ALBUM); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener); + + assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); + assertEquals(assembledShow.getMainField1(), "It is"); + assertEquals(assembledShow.getMainField2(), "Wednesday"); + assertEquals(assembledShow.getMainField3(), "My"); + assertEquals(assembledShow.getMainField4(), ""); + + // test tags + tags = assembledShow.getMetadataTags(); + tagsList = new ArrayList<>(); + tagsList2 = new ArrayList<>(); + List tagsList3 = new ArrayList<>(); + tagsList.add(MetadataType.HUMIDITY); + tagsList2.add(MetadataType.CURRENT_TEMPERATURE); + tagsList3.add(MetadataType.MEDIA_ALBUM); + assertEquals(tags.getMainField1(), tagsList); + assertEquals(tags.getMainField2(), tagsList2); + assertEquals(tags.getMainField3(), tagsList3); + + textsAndGraphicsState.setTextField4("Dudes"); + textsAndGraphicsState.setTextField4Type(MetadataType.MEDIA_STATION); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener); + + assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); + assertEquals(assembledShow.getMainField1(), "It is"); + assertEquals(assembledShow.getMainField2(), "Wednesday"); + assertEquals(assembledShow.getMainField3(), "My"); + assertEquals(assembledShow.getMainField4(), "Dudes"); + + // test tags + tags = assembledShow.getMetadataTags(); + tagsList = new ArrayList<>(); + tagsList2 = new ArrayList<>(); + tagsList3 = new ArrayList<>(); + List tagsList4 = new ArrayList<>(); + tagsList.add(MetadataType.HUMIDITY); + tagsList2.add(MetadataType.CURRENT_TEMPERATURE); + tagsList3.add(MetadataType.MEDIA_ALBUM); + tagsList4.add(MetadataType.MEDIA_STATION); + assertEquals(tags.getMainField1(), tagsList); + assertEquals(tags.getMainField2(), tagsList2); + assertEquals(tags.getMainField3(), tagsList3); + assertEquals(tags.getMainField4(), tagsList4); + + // try just setting line 1 and 4 + textsAndGraphicsState.setTextField2(null); + textsAndGraphicsState.setTextField3(null); + textsAndGraphicsState.setTextField2Type(null); + textsAndGraphicsState.setTextField3Type(null); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener); + + assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); + assertEquals(assembledShow.getMainField1(), "It is"); + assertEquals(assembledShow.getMainField2(), ""); + assertEquals(assembledShow.getMainField3(), ""); + assertEquals(assembledShow.getMainField4(), "Dudes"); + + // test tags + tags = assembledShow.getMetadataTags(); + tagsList = new ArrayList<>(); + tagsList4 = new ArrayList<>(); + tagsList.add(MetadataType.HUMIDITY); + tagsList4.add(MetadataType.MEDIA_STATION); + assertEquals(tags.getMainField1(), tagsList); + assertEquals(tags.getMainField4(), tagsList4); + } + + /** + * Testing if WindowCapability is null, TextFields should still update. + */ + @Test + public void testAssemble4LinesNullWindowCapability() { + + Show inputShow = new Show(); + + TextsAndGraphicsState textsAndGraphicsState = new TextsAndGraphicsState(textField1, null, null, null, + mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, MetadataType.HUMIDITY, null, null, null); + + textsAndGraphicsState.setMediaTrackTextField("HI"); + textsAndGraphicsState.setTitle("bye"); + + textsAndGraphicsState.setTextField1("It is"); + textsAndGraphicsState.setTextField1Type(MetadataType.HUMIDITY); + + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, null, currentScreenData, textsAndGraphicsState, listener); + + Show assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); + + assertEquals(assembledShow.getMainField1(), "It is"); + assertEquals(assembledShow.getMainField2(), ""); + assertEquals(assembledShow.getMainField3(), ""); + assertEquals(assembledShow.getMainField4(), ""); + assertEquals(assembledShow.getMediaTrack(), "HI"); + assertEquals(assembledShow.getTemplateTitle(), "bye"); + + // test tags + MetadataTags tags = assembledShow.getMetadataTags(); + List tagsList = new ArrayList<>(); + tagsList.add(MetadataType.HUMIDITY); + assertEquals(tags.getMainField1(), tagsList); + + textsAndGraphicsState.setTextField2("Wednesday"); + textsAndGraphicsState.setTextField2Type(MetadataType.CURRENT_TEMPERATURE); + + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, null, currentScreenData, textsAndGraphicsState, listener); + + assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); + assertEquals(assembledShow.getMainField1(), "It is"); + assertEquals(assembledShow.getMainField2(), "Wednesday"); + assertEquals(assembledShow.getMainField3(), ""); + assertEquals(assembledShow.getMainField4(), ""); + + // test tags + tags = assembledShow.getMetadataTags(); + tagsList = new ArrayList<>(); + List tagsList2 = new ArrayList<>(); + tagsList.add(MetadataType.HUMIDITY); + tagsList2.add(MetadataType.CURRENT_TEMPERATURE); + assertEquals(tags.getMainField1(), tagsList); + assertEquals(tags.getMainField2(), tagsList2); + + textsAndGraphicsState.setTextField3("My"); + textsAndGraphicsState.setTextField3Type(MetadataType.MEDIA_ALBUM); + + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, null, currentScreenData, textsAndGraphicsState, listener); + + assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); + assertEquals(assembledShow.getMainField1(), "It is"); + assertEquals(assembledShow.getMainField2(), "Wednesday"); + assertEquals(assembledShow.getMainField3(), "My"); + assertEquals(assembledShow.getMainField4(), ""); + + // test tags + tags = assembledShow.getMetadataTags(); + tagsList = new ArrayList<>(); + tagsList2 = new ArrayList<>(); + List tagsList3 = new ArrayList<>(); + tagsList.add(MetadataType.HUMIDITY); + tagsList2.add(MetadataType.CURRENT_TEMPERATURE); + tagsList3.add(MetadataType.MEDIA_ALBUM); + assertEquals(tags.getMainField1(), tagsList); + assertEquals(tags.getMainField2(), tagsList2); + assertEquals(tags.getMainField3(), tagsList3); + + textsAndGraphicsState.setTextField4("Dudes"); + textsAndGraphicsState.setTextField4Type(MetadataType.MEDIA_STATION); + + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, null, currentScreenData, textsAndGraphicsState, listener); + + assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); + assertEquals(assembledShow.getMainField1(), "It is"); + assertEquals(assembledShow.getMainField2(), "Wednesday"); + assertEquals(assembledShow.getMainField3(), "My"); + assertEquals(assembledShow.getMainField4(), "Dudes"); + + // test tags + tags = assembledShow.getMetadataTags(); + tagsList = new ArrayList<>(); + tagsList2 = new ArrayList<>(); + tagsList3 = new ArrayList<>(); + List tagsList4 = new ArrayList<>(); + tagsList.add(MetadataType.HUMIDITY); + tagsList2.add(MetadataType.CURRENT_TEMPERATURE); + tagsList3.add(MetadataType.MEDIA_ALBUM); + tagsList4.add(MetadataType.MEDIA_STATION); + assertEquals(tags.getMainField1(), tagsList); + assertEquals(tags.getMainField2(), tagsList2); + assertEquals(tags.getMainField3(), tagsList3); + assertEquals(tags.getMainField4(), tagsList4); + + // try just setting line 1 and 4 + textsAndGraphicsState.setTextField2(null); + textsAndGraphicsState.setTextField3(null); + textsAndGraphicsState.setTextField2Type(null); + textsAndGraphicsState.setTextField3Type(null); + + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, null, currentScreenData, textsAndGraphicsState, listener); + + assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); + assertEquals(assembledShow.getMainField1(), "It is"); + assertEquals(assembledShow.getMainField2(), ""); + assertEquals(assembledShow.getMainField3(), ""); + assertEquals(assembledShow.getMainField4(), "Dudes"); + + // test tags + tags = assembledShow.getMetadataTags(); + tagsList = new ArrayList<>(); + tagsList4 = new ArrayList<>(); + tagsList.add(MetadataType.HUMIDITY); + tagsList4.add(MetadataType.MEDIA_STATION); + assertEquals(tags.getMainField1(), tagsList); + assertEquals(tags.getMainField4(), tagsList4); + } + + @Test + public void testExtractTextFromShow(){ + Show mainShow = new Show(); + mainShow.setMainField1("test"); + mainShow.setMainField3("Sauce"); + mainShow.setMainField4(""); + + Show newShow = textAndGraphicUpdateOperation.extractTextFromShow(mainShow); + + assertEquals(newShow.getMainField1(), "test"); + assertEquals(newShow.getMainField3(), "Sauce"); + assertEquals(newShow.getMainField4(), ""); + assertNull(newShow.getMainField2()); + } + } -- cgit v1.2.1 From 6addbc1143d00c13ff42ebf33fc10db9deb76719 Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Thu, 20 Aug 2020 21:00:06 -0400 Subject: Added test for CreateImageOnlyShowWithPrimaryArtwork() and fixed formatting --- .../screen/TextAndGraphicUpdateOperationTest.java | 66 +++++++++++++++------- 1 file changed, 45 insertions(+), 21 deletions(-) diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java index c62104f5f..3c68fa325 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java @@ -262,7 +262,7 @@ public class TextAndGraphicUpdateOperationTest { assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getMainField1(), textField1); // Verifies that uploadArtworks gets called only with the fist textAndGraphicsUpdateOperation.onExecute call - verify(fileManager, times(1)).uploadArtworks(any(List.class),any(MultipleFileCompletionListener.class)); + verify(fileManager, times(1)).uploadArtworks(any(List.class), any(MultipleFileCompletionListener.class)); } @@ -270,7 +270,7 @@ public class TextAndGraphicUpdateOperationTest { public void testCanceledRightAway() { textAndGraphicUpdateOperation.cancelTask(); textAndGraphicUpdateOperation.onExecute(); - assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getMainField1(),"Old"); + assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getMainField1(), "Old"); } @Test @@ -281,14 +281,14 @@ public class TextAndGraphicUpdateOperationTest { // Test Canceled after Image upload textAndGraphicUpdateOperation.onExecute(); verify(internalInterface, times(1)).sendRPC(any(Show.class)); - assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getMainField1(),textField1); + assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getMainField1(), textField1); } public void testTaskCanceledAfterTextSent() { doAnswer(onShowSuccessCanceled).when(internalInterface).sendRPC(any(Show.class)); textAndGraphicUpdateOperation.onExecute(); - verify(fileManager, times(0)).uploadArtworks(any(List.class),any(MultipleFileCompletionListener.class)); + verify(fileManager, times(0)).uploadArtworks(any(List.class), any(MultipleFileCompletionListener.class)); } @@ -312,7 +312,7 @@ public class TextAndGraphicUpdateOperationTest { @Test - public void testAssemble1Line(){ + public void testAssemble1Line() { Show inputShow = new Show(); @@ -531,7 +531,7 @@ public class TextAndGraphicUpdateOperationTest { textsAndGraphicsState.setTextField4(textField4); textsAndGraphicsState.setTextField4Type(MetadataType.MEDIA_STATION); - textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager,defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener); assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); assertEquals(assembledShow.getMainField1(), "It is"); @@ -586,7 +586,7 @@ public class TextAndGraphicUpdateOperationTest { tx5.setName(TextFieldName.mediaTrack); tx6.setName(TextFieldName.templateTitle); - List textFieldNames = Arrays.asList(tx1,tx2,tx3,tx4,tx5,tx6); + List textFieldNames = Arrays.asList(tx1, tx2, tx3, tx4, tx5, tx6); defaultMainWindowCapability.setTextFields(textFieldNames); TextsAndGraphicsState textsAndGraphicsState = new TextsAndGraphicsState(textField1, null, null, null, @@ -701,7 +701,7 @@ public class TextAndGraphicUpdateOperationTest { assertEquals(tags.getMainField4(), tagsList4); } - /** + /** * Testing if WindowCapability is null, TextFields should still update. */ @Test @@ -829,18 +829,42 @@ public class TextAndGraphicUpdateOperationTest { } @Test - public void testExtractTextFromShow(){ - Show mainShow = new Show(); - mainShow.setMainField1("test"); - mainShow.setMainField3("Sauce"); - mainShow.setMainField4(""); - - Show newShow = textAndGraphicUpdateOperation.extractTextFromShow(mainShow); - - assertEquals(newShow.getMainField1(), "test"); - assertEquals(newShow.getMainField3(), "Sauce"); - assertEquals(newShow.getMainField4(), ""); - assertNull(newShow.getMainField2()); - } + public void testExtractTextFromShow() { + Show mainShow = new Show(); + mainShow.setMainField1("test"); + mainShow.setMainField3("Sauce"); + mainShow.setMainField4(""); + + Show newShow = textAndGraphicUpdateOperation.extractTextFromShow(mainShow); + + assertEquals(newShow.getMainField1(), "test"); + assertEquals(newShow.getMainField3(), "Sauce"); + assertEquals(newShow.getMainField4(), ""); + assertNull(newShow.getMainField2()); + } + + @Test + public void testCreateImageOnlyShowWithPrimaryArtwork() { + // Test null + Show testShow = textAndGraphicUpdateOperation.createImageOnlyShowWithPrimaryArtwork(null, null); + assertNull(testShow); + + // Test when artwork hasn't been uploaded + when(fileManager.hasUploadedFile(any(SdlFile.class))).thenReturn(false); + TextsAndGraphicsState textsAndGraphicsState = new TextsAndGraphicsState(textField1, textField2, textField3, textField4, + mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, textField1Type, textField2Type, textField3Type, textField4Type); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener); + testShow = textAndGraphicUpdateOperation.createImageOnlyShowWithPrimaryArtwork(testArtwork1, testArtwork2); + assertNull(testShow); + + // Test when artwork has been uploaded + when(fileManager.hasUploadedFile(any(SdlFile.class))).thenReturn(true); + textsAndGraphicsState = new TextsAndGraphicsState(textField1, textField2, textField3, textField4, + mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, textField1Type, textField2Type, textField3Type, textField4Type); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener); + testShow = textAndGraphicUpdateOperation.createImageOnlyShowWithPrimaryArtwork(testArtwork1, testArtwork2); + assertEquals(testShow.getGraphic(), testArtwork1.getImageRPC()); + assertEquals(testShow.getSecondaryGraphic(), testArtwork2.getImageRPC()); + } } -- cgit v1.2.1 From 43f81dff43becf0bf6b37f2bbd78736ea189d194 Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Thu, 20 Aug 2020 21:00:43 -0400 Subject: Fixed future potential NPE --- .../managers/screen/TextAndGraphicUpdateOperation.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java index 259d5debc..4028b1a44 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java @@ -214,10 +214,10 @@ public class TextAndGraphicUpdateOperation extends Task { return show; } - private Show createImageOnlyShowWithPrimaryArtwork(SdlArtwork primaryArtwork, SdlArtwork secondaryArtwork) { + Show createImageOnlyShowWithPrimaryArtwork(SdlArtwork primaryArtwork, SdlArtwork secondaryArtwork) { Show newShow = new Show(); - newShow.setGraphic(!(sdlArtworkNeedsUpload(primaryArtwork)) ? primaryArtwork.getImageRPC() : null); - newShow.setSecondaryGraphic(!(sdlArtworkNeedsUpload(secondaryArtwork)) ? secondaryArtwork.getImageRPC() : null); + newShow.setGraphic((primaryArtwork != null && !(sdlArtworkNeedsUpload(primaryArtwork))) ? primaryArtwork.getImageRPC() : null); + newShow.setSecondaryGraphic((secondaryArtwork != null && !(sdlArtworkNeedsUpload(secondaryArtwork))) ? secondaryArtwork.getImageRPC() : null); if (newShow.getGraphic() == null && newShow.getSecondaryGraphic() == null) { DebugTool.logInfo(TAG, "No graphics to upload"); return null; -- cgit v1.2.1 From be7157d524736b19fb9277c5cad3dc0e9bec3935 Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Fri, 21 Aug 2020 16:08:35 -0400 Subject: IOS alignment --- .../managers/screen/BaseTextAndGraphicManager.java | 109 ++++++++++++++------- .../screen/TextAndGraphicUpdateOperation.java | 19 ++-- .../managers/screen/TextsAndGraphicsState.java | 14 --- 3 files changed, 83 insertions(+), 59 deletions(-) diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java index 437aecb06..b8190edaa 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java @@ -34,6 +34,7 @@ package com.smartdevicelink.managers.screen; import androidx.annotation.NonNull; import com.livio.taskmaster.Queue; +import com.livio.taskmaster.Task; import com.smartdevicelink.managers.BaseSubManager; import com.smartdevicelink.managers.CompletionListener; import com.smartdevicelink.managers.file.FileManager; @@ -56,6 +57,7 @@ import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener; import com.smartdevicelink.util.DebugTool; import java.lang.ref.WeakReference; +import java.util.ArrayList; import java.util.List; import static com.smartdevicelink.proxy.rpc.enums.TextAlignment.CENTERED; @@ -73,9 +75,8 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { Show currentScreenData; HMILevel currentHMILevel; WindowCapability defaultMainWindowCapability; - private boolean pendingHMIFull, batchingUpdates; + private boolean batchingUpdates; private final WeakReference fileManager; - private CompletionListener pendingHMIListener; SdlArtwork blankArtwork; private OnRPCNotificationListener hmiListener; private OnSystemCapabilityListener onDisplaysCapabilityListener; @@ -84,12 +85,8 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { private String textField1, textField2, textField3, textField4, mediaTrackTextField, title; private MetadataType textField1Type, textField2Type, textField3Type, textField4Type; private TextAndGraphicUpdateOperation updateOperation; - - private Queue transactionQueue; - private TextsAndGraphicsState textsAndGraphicsState; - //Constructors BaseTextAndGraphicManager(@NonNull ISdl internalInterface, @NonNull FileManager fileManager) { @@ -98,7 +95,6 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { this.fileManager = new WeakReference<>(fileManager); batchingUpdates = false; isDirty = false; - pendingHMIFull = false; textAlignment = CENTERED; currentHMILevel = HMILevel.HMI_NONE; currentScreenData = new Show(); @@ -130,9 +126,7 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { blankArtwork = null; defaultMainWindowCapability = null; currentScreenData = null; - pendingHMIListener = null; isDirty = false; - pendingHMIFull = false; updateOperation = null; // Cancel the operations @@ -169,22 +163,10 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { // Upload / Send protected void update(CompletionListener listener) { - // check if is batch update if (batchingUpdates) { return; } - - // make sure hmi is not none - if (currentHMILevel == null || currentHMILevel == HMILevel.HMI_NONE) { - //Trying to send show on HMI_NONE, waiting for full - pendingHMIFull = true; - if (listener != null) { - pendingHMIListener = listener; - } - return; - } - if (isDirty) { isDirty = false; sdlUpdate(listener); @@ -194,7 +176,6 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { } private synchronized void sdlUpdate(final CompletionListener listener) { - if (transactionQueue.getTasksAsList().size() > 0) { //Transactions already exist, cancelling them transactionQueue.clear(); @@ -203,20 +184,76 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { } return; } - updateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager.get(), defaultMainWindowCapability, currentScreenData, currentState(), new CompletionListener() { + CurrentScreenDataUpdatedListener currentScreenDataUpdateListener = new CurrentScreenDataUpdatedListener() { + @Override + public void onUpdate(Show show) { + updatePendingOperationsWithNewScreenData(show); + } + }; + CompletionListener updateOperationListener = new CompletionListener() { @Override public void onComplete(boolean success) { - - if (updateOperation.getSentShow() != null) { - currentScreenData = updateOperation.getSentShow(); - } if (listener != null) { listener.onComplete(success); } } - }); + }; + + updateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager.get(), defaultMainWindowCapability, currentScreenData, currentState(), updateOperationListener, currentScreenDataUpdateListener); transactionQueue.add(updateOperation, false); } + //Updates pending task with current screen data + void updatePendingOperationsWithNewScreenData(Show newScreenData){ + for(Task task: transactionQueue.getTasksAsList()){ + if(!(task instanceof TextAndGraphicUpdateOperation) || task.getState() == Task.IN_PROGRESS){ + continue; + } + ((TextAndGraphicUpdateOperation) task).setCurrentScreenData(newScreenData); + } + } + + interface CurrentScreenDataUpdatedListener{ + void onUpdate(Show show); + } + + + private List findNonNullTextFields() { + List array = new ArrayList<>(); + + if (textField1 != null) { + array.add(textField1); + } + + if (textField2 != null) { + array.add(textField2); + } + + if (textField3 != null) { + array.add(textField3); + } + + if (textField4 != null) { + array.add(textField4); + } + + if(title != null){ + array.add(title); + } + + if(mediaTrackTextField != null){ + array.add(mediaTrackTextField); + } + + return array; + } + + Boolean hasData() { + boolean hasTextFields = (findNonNullTextFields().size() > 0); + boolean hasImageFields = (primaryGraphic != null) || (secondaryGraphic != null); + + return hasTextFields || hasImageFields; + } + // Convert to State @@ -410,22 +447,12 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { if (onHMIStatus.getWindowID() != null && onHMIStatus.getWindowID() != PredefinedWindows.DEFAULT_WINDOW.getValue()) { return; } - currentHMILevel = onHMIStatus.getHmiLevel(); updateTransactionQueueSuspended(); - if (currentHMILevel == HMILevel.HMI_FULL) { - if (pendingHMIFull) { - DebugTool.logInfo(TAG, "Acquired HMI_FULL with pending update. Sending now"); - pendingHMIFull = false; - sdlUpdate(pendingHMIListener); - pendingHMIListener = null; - } - } } }; internalInterface.addOnRPCNotificationListener(FunctionID.ON_HMI_STATUS, hmiListener); - onDisplaysCapabilityListener = new OnSystemCapabilityListener() { @Override public void onCapabilityRetrieved(Object capability) { @@ -442,12 +469,18 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { } } } + // Update the queue's suspend state + updateTransactionQueueSuspended(); + if (hasData()) { + update(null); + } } @Override public void onError(String info) { DebugTool.logError(TAG, "Display Capability cannot be retrieved"); defaultMainWindowCapability = null; + updateTransactionQueueSuspended(); } }; this.internalInterface.addOnSystemCapabilityListener(SystemCapabilityType.DISPLAYS, onDisplaysCapabilityListener); diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java index 4028b1a44..f6e79391f 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java @@ -33,6 +33,7 @@ public class TextAndGraphicUpdateOperation extends Task { private Show currentScreenData, sentShow; private TextsAndGraphicsState updatedState; private CompletionListener listener; + private TextAndGraphicManager.CurrentScreenDataUpdatedListener currentScreenDataUpdateListener; /** @@ -44,7 +45,7 @@ public class TextAndGraphicUpdateOperation extends Task { * @param listener */ public TextAndGraphicUpdateOperation(ISdl internalInterface, FileManager fileManager, WindowCapability currentCapabilities, - Show currentScreenData, TextsAndGraphicsState newState, CompletionListener listener) { + Show currentScreenData, TextsAndGraphicsState newState, CompletionListener listener, TextAndGraphicManager.CurrentScreenDataUpdatedListener currentScreenDataUpdateListener) { super("TextAndGraphicUpdateOperation"); this.internalInterface = new WeakReference<>(internalInterface); this.fileManager = new WeakReference<>(fileManager); @@ -52,6 +53,7 @@ public class TextAndGraphicUpdateOperation extends Task { this.currentScreenData = currentScreenData; this.updatedState = newState; this.listener = listener; + this.currentScreenDataUpdateListener = currentScreenDataUpdateListener; } @Override @@ -68,6 +70,8 @@ public class TextAndGraphicUpdateOperation extends Task { // Build a show with everything from `self.newState`, we'll pull things out later if we can. Show fullShow = new Show(); fullShow.setAlignment(updatedState.getTextAlignment()); + //TODO IOS ask about tages, Dont they just get set when we assembleShowText + // fullShow.setMetadataTags(updatedState.getM); fullShow = assembleShowText(fullShow); fullShow = assembleShowImages(fullShow); @@ -78,7 +82,6 @@ public class TextAndGraphicUpdateOperation extends Task { @Override public void onComplete(boolean success) { finishOperation(success); - return; } }); @@ -89,7 +92,6 @@ public class TextAndGraphicUpdateOperation extends Task { @Override public void onComplete(boolean success) { finishOperation(success); - return; } }); } else { @@ -106,7 +108,6 @@ public class TextAndGraphicUpdateOperation extends Task { @Override public void onComplete(boolean success) { finishOperation(success); - return; } }); @@ -131,7 +132,7 @@ public class TextAndGraphicUpdateOperation extends Task { private void handleResponse(boolean success) { DebugTool.logInfo(TAG, "Text and Graphic update completed"); if (success) { - updateCurrentScreenDataState(show); + updateCurrentScreenDataFromShow(show); } listener.onComplete(success); } @@ -145,9 +146,9 @@ public class TextAndGraphicUpdateOperation extends Task { @Override public void onComplete(boolean success) { Show showWithGraphics = createImageOnlyShowWithPrimaryArtwork(updatedState.getPrimaryGraphic(), updatedState.getSecondaryGraphic()); + //TODO Ask about logic here, Should we do if(success) then create and sendShow with Graphic or return false if (showWithGraphics != null) { DebugTool.logInfo(TAG, "Sending update with the successfully uploaded images"); - //Check for cancel sendShow(showWithGraphics, new CompletionListener() { @Override public void onComplete(boolean success) { @@ -483,7 +484,8 @@ public class TextAndGraphicUpdateOperation extends Task { return newShow; } - private void updateCurrentScreenDataState(Show show) { + //TODO IOS different by maybe same + private void updateCurrentScreenDataFromShow(Show show) { if (show == null) { DebugTool.logError(TAG, "can not updateCurrentScreenDataFromShow from null show"); @@ -521,6 +523,9 @@ public class TextAndGraphicUpdateOperation extends Task { if (show.getSecondaryGraphic() != null) { currentScreenData.setSecondaryGraphic(show.getSecondaryGraphic()); } + if (currentScreenDataUpdateListener != null) { + currentScreenDataUpdateListener.onUpdate(show); + } } // Helpers diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/TextsAndGraphicsState.java b/base/src/main/java/com/smartdevicelink/managers/screen/TextsAndGraphicsState.java index 55f572905..ce0d473cc 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/TextsAndGraphicsState.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/TextsAndGraphicsState.java @@ -12,8 +12,6 @@ public class TextsAndGraphicsState { private TextAlignment textAlignment; private SdlArtwork primaryGraphic, secondaryGraphic; - public TextsAndGraphicsState(){} - public TextsAndGraphicsState(String textField1, String textField2, String textField3, String textField4, String mediaTrackTextField, String title, SdlArtwork primaryGraphic, SdlArtwork secondaryGraphic, TextAlignment textAlignment, MetadataType textField1Type, MetadataType textField2Type, MetadataType textField3Type, MetadataType textField4Type) { @@ -116,23 +114,11 @@ public class TextsAndGraphicsState { return textAlignment; } - public void setTextAlignment(TextAlignment textAlignment) { - this.textAlignment = textAlignment; - } - public SdlArtwork getPrimaryGraphic() { return primaryGraphic; } - public void setPrimaryGraphic(SdlArtwork primaryGraphic) { - this.primaryGraphic = primaryGraphic; - } - public SdlArtwork getSecondaryGraphic() { return secondaryGraphic; } - - public void setSecondaryGraphic(SdlArtwork secondaryGraphic) { - this.secondaryGraphic = secondaryGraphic; - } } -- cgit v1.2.1 From cbcb3d440bd8bdb9e8921288ed345c754697a603 Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Fri, 21 Aug 2020 16:16:26 -0400 Subject: Fixed unit test --- .../screen/TextAndGraphicUpdateOperationTest.java | 70 ++++++++++++---------- 1 file changed, 39 insertions(+), 31 deletions(-) diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java index 3c68fa325..49ff4648f 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java @@ -59,6 +59,7 @@ public class TextAndGraphicUpdateOperationTest { private WindowCapability defaultMainWindowCapability; private Show currentScreenData; private CompletionListener listener; + private TextAndGraphicManager.CurrentScreenDataUpdatedListener currentScreenDataUpdatedListener; ISdl internalInterface; FileManager fileManager; @@ -161,11 +162,18 @@ public class TextAndGraphicUpdateOperationTest { currentScreenData.setGraphic(testArtwork1.getImageRPC()); currentScreenData.setSecondaryGraphic(testArtwork2.getImageRPC()); + currentScreenDataUpdatedListener = new TextAndGraphicManager.CurrentScreenDataUpdatedListener() { + @Override + public void onUpdate(Show show) { + + } + }; + defaultMainWindowCapability = getWindowCapability(4); TextsAndGraphicsState textsAndGraphicsState = new TextsAndGraphicsState(textField1, textField2, textField3, textField4, mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, textField1Type, textField2Type, textField3Type, textField4Type); - textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener); } @@ -250,14 +258,14 @@ public class TextAndGraphicUpdateOperationTest { when(fileManager.hasUploadedFile(any(SdlFile.class))).thenReturn(true); TextsAndGraphicsState textsAndGraphicsState = new TextsAndGraphicsState(textField11, textField2, textField3, textField4, mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, textField1Type, textField2Type, textField3Type, textField4Type); - textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener); textAndGraphicUpdateOperation.onExecute(); assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getMainField1(), textField11); //Test: If there are no images to update, just send the text TextsAndGraphicsState textsAndGraphicsStateNullImages = new TextsAndGraphicsState(textField1, textField2, textField3, textField4, mediaTrackField, title, null, null, textAlignment, textField1Type, textField2Type, textField3Type, textField4Type); - textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsStateNullImages, listener); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsStateNullImages, listener, currentScreenDataUpdatedListener); textAndGraphicUpdateOperation.onExecute(); assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getMainField1(), textField1); @@ -318,7 +326,7 @@ public class TextAndGraphicUpdateOperationTest { TextsAndGraphicsState textsAndGraphicsState = new TextsAndGraphicsState(textField1, null, null, null, mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, MetadataType.HUMIDITY, null, null, null); - textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, getWindowCapability(1), currentScreenData, textsAndGraphicsState, listener); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, getWindowCapability(1), currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener); Show assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); assertEquals(assembledShow.getMainField1(), "It is"); @@ -330,20 +338,20 @@ public class TextAndGraphicUpdateOperationTest { assertEquals(tags.getMainField1(), tagsList); textsAndGraphicsState.setTextField2(textField2); - textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, getWindowCapability(1), currentScreenData, textsAndGraphicsState, listener); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, getWindowCapability(1), currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener); assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); assertEquals(assembledShow.getMainField1(), "It is - Wednesday"); textsAndGraphicsState.setTextField3(textField3); - textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, getWindowCapability(1), currentScreenData, textsAndGraphicsState, listener); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, getWindowCapability(1), currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener); assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); assertEquals(assembledShow.getMainField1(), "It is - Wednesday - My"); textsAndGraphicsState.setTextField4(textField4); textsAndGraphicsState.setTextField4Type(MetadataType.CURRENT_TEMPERATURE); - textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, getWindowCapability(1), currentScreenData, textsAndGraphicsState, listener); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, getWindowCapability(1), currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener); assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); assertEquals(assembledShow.getMainField1(), "It is - Wednesday - My - Dudes"); @@ -358,7 +366,7 @@ public class TextAndGraphicUpdateOperationTest { // For some obscurity, lets try setting just fields 2 and 4 for a 1 line display textsAndGraphicsState.setTextField1(null); textsAndGraphicsState.setTextField3(null); - textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, getWindowCapability(1), currentScreenData, textsAndGraphicsState, listener); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, getWindowCapability(1), currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener); assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); @@ -374,7 +382,7 @@ public class TextAndGraphicUpdateOperationTest { // Force it to return display with support for only 2 lines of text TextsAndGraphicsState textsAndGraphicsState = new TextsAndGraphicsState(textField1, null, null, null, mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, MetadataType.HUMIDITY, null, null, null); - textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener); Show assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); assertEquals(assembledShow.getMainField1(), "It is"); @@ -387,7 +395,7 @@ public class TextAndGraphicUpdateOperationTest { textsAndGraphicsState.setTextField2(textField2); textsAndGraphicsState.setTextField2Type(MetadataType.CURRENT_TEMPERATURE); - textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener); assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); assertEquals(assembledShow.getMainField1(), "It is"); @@ -404,7 +412,7 @@ public class TextAndGraphicUpdateOperationTest { textsAndGraphicsState.setTextField3(textField3); textsAndGraphicsState.setTextField3Type(MetadataType.MEDIA_ALBUM); - textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, getWindowCapability(2), currentScreenData, textsAndGraphicsState, listener); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, getWindowCapability(2), currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener); assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); assertEquals(assembledShow.getMainField1(), "It is - Wednesday"); @@ -422,7 +430,7 @@ public class TextAndGraphicUpdateOperationTest { textsAndGraphicsState.setTextField4(textField4); textsAndGraphicsState.setTextField4Type(MetadataType.MEDIA_STATION); - textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, getWindowCapability(2), currentScreenData, textsAndGraphicsState, listener); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, getWindowCapability(2), currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener); assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); assertEquals(assembledShow.getMainField1(), "It is - Wednesday"); @@ -444,7 +452,7 @@ public class TextAndGraphicUpdateOperationTest { textsAndGraphicsState.setTextField3(null); textsAndGraphicsState.setTextField1Type(null); textsAndGraphicsState.setTextField3Type(null); - textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, getWindowCapability(2), currentScreenData, textsAndGraphicsState, listener); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, getWindowCapability(2), currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener); assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); assertEquals(assembledShow.getMainField1(), "Wednesday"); @@ -452,7 +460,7 @@ public class TextAndGraphicUpdateOperationTest { // And 3 fields without setting 1 textsAndGraphicsState.setTextField3(textField3); - textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, getWindowCapability(2), currentScreenData, textsAndGraphicsState, listener); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, getWindowCapability(2), currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener); assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); assertEquals(assembledShow.getMainField1(), "Wednesday"); @@ -477,7 +485,7 @@ public class TextAndGraphicUpdateOperationTest { defaultMainWindowCapability = getWindowCapability(3); TextsAndGraphicsState textsAndGraphicsState = new TextsAndGraphicsState(textField1, null, null, null, mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, MetadataType.HUMIDITY, null, null, null); - textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener); Show assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); assertEquals(assembledShow.getMainField1(), "It is"); @@ -492,7 +500,7 @@ public class TextAndGraphicUpdateOperationTest { textsAndGraphicsState.setTextField2(textField2); textsAndGraphicsState.setTextField2Type(MetadataType.CURRENT_TEMPERATURE); - textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener); assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); assertEquals(assembledShow.getMainField1(), "It is"); @@ -510,7 +518,7 @@ public class TextAndGraphicUpdateOperationTest { textsAndGraphicsState.setTextField3(textField3); textsAndGraphicsState.setTextField3Type(MetadataType.MEDIA_ALBUM); - textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener); assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); assertEquals(assembledShow.getMainField1(), "It is"); @@ -531,7 +539,7 @@ public class TextAndGraphicUpdateOperationTest { textsAndGraphicsState.setTextField4(textField4); textsAndGraphicsState.setTextField4Type(MetadataType.MEDIA_STATION); - textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener); assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); assertEquals(assembledShow.getMainField1(), "It is"); @@ -553,7 +561,7 @@ public class TextAndGraphicUpdateOperationTest { // Someone might not want to set the fields in order? We should handle that textsAndGraphicsState.setTextField1(null); - textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener); assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); try { @@ -591,7 +599,7 @@ public class TextAndGraphicUpdateOperationTest { TextsAndGraphicsState textsAndGraphicsState = new TextsAndGraphicsState(textField1, null, null, null, mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, MetadataType.HUMIDITY, null, null, null); - textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener); textsAndGraphicsState.setMediaTrackTextField("HI"); textsAndGraphicsState.setTitle("bye"); @@ -613,7 +621,7 @@ public class TextAndGraphicUpdateOperationTest { textsAndGraphicsState.setTextField2("Wednesday"); textsAndGraphicsState.setTextField2Type(MetadataType.CURRENT_TEMPERATURE); - textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener); assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); @@ -633,7 +641,7 @@ public class TextAndGraphicUpdateOperationTest { textsAndGraphicsState.setTextField3("My"); textsAndGraphicsState.setTextField3Type(MetadataType.MEDIA_ALBUM); - textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener); assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); assertEquals(assembledShow.getMainField1(), "It is"); @@ -655,7 +663,7 @@ public class TextAndGraphicUpdateOperationTest { textsAndGraphicsState.setTextField4("Dudes"); textsAndGraphicsState.setTextField4Type(MetadataType.MEDIA_STATION); - textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener); assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); assertEquals(assembledShow.getMainField1(), "It is"); @@ -683,7 +691,7 @@ public class TextAndGraphicUpdateOperationTest { textsAndGraphicsState.setTextField3(null); textsAndGraphicsState.setTextField2Type(null); textsAndGraphicsState.setTextField3Type(null); - textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener); assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); assertEquals(assembledShow.getMainField1(), "It is"); @@ -718,7 +726,7 @@ public class TextAndGraphicUpdateOperationTest { textsAndGraphicsState.setTextField1("It is"); textsAndGraphicsState.setTextField1Type(MetadataType.HUMIDITY); - textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, null, currentScreenData, textsAndGraphicsState, listener); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, null, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener); Show assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); @@ -738,7 +746,7 @@ public class TextAndGraphicUpdateOperationTest { textsAndGraphicsState.setTextField2("Wednesday"); textsAndGraphicsState.setTextField2Type(MetadataType.CURRENT_TEMPERATURE); - textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, null, currentScreenData, textsAndGraphicsState, listener); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, null, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener); assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); assertEquals(assembledShow.getMainField1(), "It is"); @@ -758,7 +766,7 @@ public class TextAndGraphicUpdateOperationTest { textsAndGraphicsState.setTextField3("My"); textsAndGraphicsState.setTextField3Type(MetadataType.MEDIA_ALBUM); - textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, null, currentScreenData, textsAndGraphicsState, listener); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, null, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener); assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); assertEquals(assembledShow.getMainField1(), "It is"); @@ -781,7 +789,7 @@ public class TextAndGraphicUpdateOperationTest { textsAndGraphicsState.setTextField4("Dudes"); textsAndGraphicsState.setTextField4Type(MetadataType.MEDIA_STATION); - textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, null, currentScreenData, textsAndGraphicsState, listener); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, null, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener); assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); assertEquals(assembledShow.getMainField1(), "It is"); @@ -810,7 +818,7 @@ public class TextAndGraphicUpdateOperationTest { textsAndGraphicsState.setTextField2Type(null); textsAndGraphicsState.setTextField3Type(null); - textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, null, currentScreenData, textsAndGraphicsState, listener); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, null, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener); assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow); assertEquals(assembledShow.getMainField1(), "It is"); @@ -853,7 +861,7 @@ public class TextAndGraphicUpdateOperationTest { when(fileManager.hasUploadedFile(any(SdlFile.class))).thenReturn(false); TextsAndGraphicsState textsAndGraphicsState = new TextsAndGraphicsState(textField1, textField2, textField3, textField4, mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, textField1Type, textField2Type, textField3Type, textField4Type); - textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener); testShow = textAndGraphicUpdateOperation.createImageOnlyShowWithPrimaryArtwork(testArtwork1, testArtwork2); assertNull(testShow); @@ -861,7 +869,7 @@ public class TextAndGraphicUpdateOperationTest { when(fileManager.hasUploadedFile(any(SdlFile.class))).thenReturn(true); textsAndGraphicsState = new TextsAndGraphicsState(textField1, textField2, textField3, textField4, mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, textField1Type, textField2Type, textField3Type, textField4Type); - textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener); + textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener); testShow = textAndGraphicUpdateOperation.createImageOnlyShowWithPrimaryArtwork(testArtwork1, testArtwork2); assertEquals(testShow.getGraphic(), testArtwork1.getImageRPC()); assertEquals(testShow.getSecondaryGraphic(), testArtwork2.getImageRPC()); -- cgit v1.2.1 From 788be099f11fb96e3ebb9a2dce9752fb6c9e3735 Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Sat, 22 Aug 2020 16:14:07 -0400 Subject: Fix OnRPCResponseListener in TextAndGraphicsOperation and remove unused imports --- .../managers/screen/BaseTextAndGraphicManager.java | 1 - .../managers/screen/TextAndGraphicUpdateOperation.java | 16 +++------------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java index 007328c10..817e58de5 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java @@ -43,7 +43,6 @@ import com.smartdevicelink.managers.lifecycle.OnSystemCapabilityListener; import com.smartdevicelink.managers.lifecycle.SystemCapabilityManager; import com.smartdevicelink.protocol.enums.FunctionID; import com.smartdevicelink.proxy.RPCNotification; -import com.smartdevicelink.managers.lifecycle.SystemCapabilityManager; import com.smartdevicelink.proxy.interfaces.ISdl; import com.smartdevicelink.proxy.rpc.DisplayCapability; import com.smartdevicelink.proxy.rpc.OnHMIStatus; diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java index f6e79391f..1c51be9e5 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java @@ -13,7 +13,6 @@ import com.smartdevicelink.proxy.rpc.Show; import com.smartdevicelink.proxy.rpc.WindowCapability; import com.smartdevicelink.proxy.rpc.enums.ImageFieldName; import com.smartdevicelink.proxy.rpc.enums.MetadataType; -import com.smartdevicelink.proxy.rpc.enums.Result; import com.smartdevicelink.proxy.rpc.enums.TextFieldName; import com.smartdevicelink.proxy.rpc.listeners.OnRPCResponseListener; import com.smartdevicelink.util.CompareUtils; @@ -120,21 +119,12 @@ public class TextAndGraphicUpdateOperation extends Task { show.setOnRPCResponseListener(new OnRPCResponseListener() { @Override public void onResponse(int correlationId, RPCResponse response) { - handleResponse(response.getSuccess()); - - } - - @Override - public void onError(int correlationId, Result resultCode, String info) { - handleResponse(false); - } - - private void handleResponse(boolean success) { DebugTool.logInfo(TAG, "Text and Graphic update completed"); - if (success) { + if (response.getSuccess()) { updateCurrentScreenDataFromShow(show); } - listener.onComplete(success); + listener.onComplete(response.getSuccess()); + } }); internalInterface.get().sendRPC(show); -- cgit v1.2.1 From 381094c7666e36dbe4e66da837ed05a1d9c6f093 Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Sat, 22 Aug 2020 16:55:33 -0400 Subject: Added unit test to TextAndGraphicsManager --- .../screen/TextAndGraphicManagerTests.java | 43 ++++++++++++++++++++-- .../managers/screen/BaseTextAndGraphicManager.java | 2 +- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java index a3a9fbe22..f2a731c8d 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java @@ -4,8 +4,10 @@ import android.content.Context; import android.net.Uri; import androidx.test.ext.junit.runners.AndroidJUnit4; +import com.livio.taskmaster.Task; import com.livio.taskmaster.Taskmaster; import com.smartdevicelink.managers.BaseSubManager; +import com.smartdevicelink.managers.CompletionListener; import com.smartdevicelink.managers.ManagerUtility; import com.smartdevicelink.managers.file.FileManager; import com.smartdevicelink.managers.file.filetypes.SdlArtwork; @@ -34,6 +36,9 @@ import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertFalse; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; +import static junit.framework.TestCase.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -47,7 +52,6 @@ public class TextAndGraphicManagerTests { // SETUP / HELPERS private TextAndGraphicManager textAndGraphicManager; private SdlArtwork testArtwork; - Taskmaster taskmaster; @Before public void setUp() throws Exception{ @@ -56,9 +60,6 @@ public class TextAndGraphicManagerTests { // mock things ISdl internalInterface = mock(ISdl.class); FileManager fileManager = mock(FileManager.class); - SoftButtonManager softButtonManager = mock(SoftButtonManager.class); - taskmaster = new Taskmaster.Builder().build(); - when(internalInterface.getTaskmaster()).thenReturn(taskmaster); testArtwork = new SdlArtwork(); testArtwork.setName("testFile"); @@ -66,6 +67,10 @@ public class TextAndGraphicManagerTests { testArtwork.setUri(uri); testArtwork.setType(FileType.GRAPHIC_PNG); + Taskmaster taskmaster = new Taskmaster.Builder().build(); + taskmaster.start(); + when(internalInterface.getTaskmaster()).thenReturn(taskmaster); + textAndGraphicManager = new TextAndGraphicManager(internalInterface, fileManager); } @@ -216,4 +221,34 @@ public class TextAndGraphicManagerTests { assertFalse(textAndGraphicManager.isDirty); assertEquals(textAndGraphicManager.getState(), BaseSubManager.SHUTDOWN); } + + @Test + public void testOperationManagement() { + textAndGraphicManager.isDirty = true; + textAndGraphicManager.update(new CompletionListener() { + @Override + public void onComplete(boolean success) { + assertTrue(success); + } + }); + assertEquals(textAndGraphicManager.transactionQueue.getTasksAsList().size(), 1); + + textAndGraphicManager.transactionQueue.clear(); + + assertEquals(textAndGraphicManager.transactionQueue.getTasksAsList().size(), 0); + + textAndGraphicManager.isDirty = true; + textAndGraphicManager.update(new CompletionListener() { + @Override + public void onComplete(boolean success) { + assertTrue(success); + } + }); + + assertEquals(textAndGraphicManager.transactionQueue.getTasksAsList().size(), 1); + + assertTrue(textAndGraphicManager.transactionQueue.getTasksAsList().get(0).getState() == Task.READY); + + + } } diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java index 817e58de5..995bf6d5f 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java @@ -85,7 +85,7 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { private String textField1, textField2, textField3, textField4, mediaTrackTextField, title; private MetadataType textField1Type, textField2Type, textField3Type, textField4Type; private TextAndGraphicUpdateOperation updateOperation; - private Queue transactionQueue; + Queue transactionQueue; //Constructors -- cgit v1.2.1 From d901d744954337e4baff75334ee0b6c736f54e1e Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Sun, 23 Aug 2020 13:19:02 -0400 Subject: Fixed unit test --- .../screen/TextAndGraphicUpdateOperationTest.java | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java index 49ff4648f..da0269053 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java @@ -50,8 +50,6 @@ import static org.mockito.Mockito.when; public class TextAndGraphicUpdateOperationTest { private TextAndGraphicUpdateOperation textAndGraphicUpdateOperation; - private TextAndGraphicUpdateOperation textAndGraphicUpdateOperationNullCapability; - private TextAndGraphicUpdateOperation textAndGraphicUpdateOperationEmptyCapability; private String textField1, textField2, textField3, textField4, mediaTrackField, title; private MetadataType textField1Type, textField2Type, textField3Type, textField4Type; private SdlArtwork testArtwork1, testArtwork2, testArtwork3, testArtwork4; @@ -106,6 +104,17 @@ public class TextAndGraphicUpdateOperationTest { } }; + private Answer onArtworkUploadSuccess = new Answer() { + @Override + public Void answer(InvocationOnMock invocation) { + Object[] args = invocation.getArguments(); + MultipleFileCompletionListener listener = (MultipleFileCompletionListener) args[1]; + when(fileManager.hasUploadedFile(any(SdlFile.class))).thenReturn(true); + listener.onComplete(null); + return null; + } + }; + @Before public void setUp() throws Exception { @@ -242,8 +251,9 @@ public class TextAndGraphicUpdateOperationTest { } @Test - public void testUpload() { + public void testUploads() { doAnswer(onShowSuccess).when(internalInterface).sendRPC(any(Show.class)); + doAnswer(onArtworkUploadSuccess).when(fileManager).uploadArtworks(any(List.class), any(MultipleFileCompletionListener.class)); // Test Images need to be uploaded, sending text and uploading images textAndGraphicUpdateOperation.onExecute(); @@ -252,10 +262,12 @@ public class TextAndGraphicUpdateOperationTest { assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getMainField3(), textField3); assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getMainField4(), textField4); assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getAlignment(), textAlignment); + assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getGraphic(), testArtwork3.getImageRPC()); + assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getSecondaryGraphic(), testArtwork4.getImageRPC()); + // Test The files to be updated are already uploaded, send the full show immediately String textField11 = "It's not"; - when(fileManager.hasUploadedFile(any(SdlFile.class))).thenReturn(true); TextsAndGraphicsState textsAndGraphicsState = new TextsAndGraphicsState(textField11, textField2, textField3, textField4, mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, textField1Type, textField2Type, textField3Type, textField4Type); textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener); @@ -271,7 +283,6 @@ public class TextAndGraphicUpdateOperationTest { // Verifies that uploadArtworks gets called only with the fist textAndGraphicsUpdateOperation.onExecute call verify(fileManager, times(1)).uploadArtworks(any(List.class), any(MultipleFileCompletionListener.class)); - } @Test -- cgit v1.2.1 From 2ada23f3bd5cb0d35c8dee344a925f39b1e2ff0c Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Sun, 23 Aug 2020 14:20:21 -0400 Subject: Fix unit test --- .../managers/screen/TextAndGraphicUpdateOperationTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java index da0269053..a279e3aec 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java @@ -269,7 +269,7 @@ public class TextAndGraphicUpdateOperationTest { // Test The files to be updated are already uploaded, send the full show immediately String textField11 = "It's not"; TextsAndGraphicsState textsAndGraphicsState = new TextsAndGraphicsState(textField11, textField2, textField3, textField4, - mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, textField1Type, textField2Type, textField3Type, textField4Type); + mediaTrackField, title, testArtwork1, testArtwork2, textAlignment, textField1Type, textField2Type, textField3Type, textField4Type); textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener); textAndGraphicUpdateOperation.onExecute(); assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getMainField1(), textField11); @@ -304,6 +304,7 @@ public class TextAndGraphicUpdateOperationTest { } + @Test public void testTaskCanceledAfterTextSent() { doAnswer(onShowSuccessCanceled).when(internalInterface).sendRPC(any(Show.class)); textAndGraphicUpdateOperation.onExecute(); -- cgit v1.2.1 From f9fa66d9d5f540bbedb98b8377974de4ee2bafad Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Sun, 23 Aug 2020 15:27:41 -0400 Subject: Added test for OnRPCNotificationListener in T&G manager --- .../screen/TextAndGraphicManagerTests.java | 56 +++++++++++++++++++++- .../managers/screen/BaseTextAndGraphicManager.java | 2 +- 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java index f2a731c8d..b0e9f8bbf 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java @@ -11,24 +11,34 @@ import com.smartdevicelink.managers.CompletionListener; import com.smartdevicelink.managers.ManagerUtility; import com.smartdevicelink.managers.file.FileManager; import com.smartdevicelink.managers.file.filetypes.SdlArtwork; +import com.smartdevicelink.managers.lifecycle.OnSystemCapabilityListener; +import com.smartdevicelink.protocol.enums.FunctionID; import com.smartdevicelink.proxy.interfaces.ISdl; +import com.smartdevicelink.proxy.rpc.DisplayCapability; import com.smartdevicelink.proxy.rpc.MetadataTags; +import com.smartdevicelink.proxy.rpc.OnHMIStatus; import com.smartdevicelink.proxy.rpc.Show; +import com.smartdevicelink.proxy.rpc.SoftButtonCapabilities; import com.smartdevicelink.proxy.rpc.TextField; import com.smartdevicelink.proxy.rpc.WindowCapability; import com.smartdevicelink.proxy.rpc.enums.FileType; import com.smartdevicelink.proxy.rpc.enums.HMILevel; import com.smartdevicelink.proxy.rpc.enums.MetadataType; +import com.smartdevicelink.proxy.rpc.enums.SystemCapabilityType; import com.smartdevicelink.proxy.rpc.enums.TextAlignment; import com.smartdevicelink.proxy.rpc.enums.TextFieldName; +import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener; import org.json.JSONException; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; @@ -38,6 +48,7 @@ import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -71,6 +82,37 @@ public class TextAndGraphicManagerTests { taskmaster.start(); when(internalInterface.getTaskmaster()).thenReturn(taskmaster); + Answer onHMIStatusAnswer = new Answer() { + @Override + public Void answer(InvocationOnMock invocation) { + Object[] args = invocation.getArguments(); + OnRPCNotificationListener onHMIStatusListener = (OnRPCNotificationListener) args[1]; + OnHMIStatus onHMIStatusFakeNotification = new OnHMIStatus(); + onHMIStatusFakeNotification.setHmiLevel(HMILevel.HMI_FULL); + onHMIStatusListener.onNotified(onHMIStatusFakeNotification); + return null; + } + }; + doAnswer(onHMIStatusAnswer).when(internalInterface).addOnRPCNotificationListener(eq(FunctionID.ON_HMI_STATUS), any(OnRPCNotificationListener.class)); + + + // When internalInterface.addOnSystemCapabilityListener(SystemCapabilityType.DISPLAYS, onSystemCapabilityListener) is called + // inside SoftButtonManager, respond with a fake response to let the SoftButtonManager continue working. + Answer onSystemCapabilityAnswer = new Answer() { + @Override + public Void answer(InvocationOnMock invocation) { + Object[] args = invocation.getArguments(); + OnSystemCapabilityListener onSystemCapabilityListener = (OnSystemCapabilityListener) args[1]; + WindowCapability windowCapability = getWindowCapability(4); + DisplayCapability displayCapability = new DisplayCapability(); + displayCapability.setWindowCapabilities(Collections.singletonList(windowCapability)); + List capabilities = Collections.singletonList(displayCapability); + onSystemCapabilityListener.onCapabilityRetrieved(capabilities); + return null; + } + }; + doAnswer(onSystemCapabilityAnswer).when(internalInterface).addOnSystemCapabilityListener(eq(SystemCapabilityType.DISPLAYS), any(OnSystemCapabilityListener.class)); + textAndGraphicManager = new TextAndGraphicManager(internalInterface, fileManager); } @@ -134,8 +176,8 @@ public class TextAndGraphicManagerTests { assertNull(textAndGraphicManager.getTextField3Type()); assertNull(textAndGraphicManager.getTextField4Type()); assertNotNull(textAndGraphicManager.currentScreenData); - assertNull(textAndGraphicManager.defaultMainWindowCapability); - assertEquals(textAndGraphicManager.currentHMILevel, HMILevel.HMI_NONE); + assertNotNull(textAndGraphicManager.defaultMainWindowCapability); + assertEquals(textAndGraphicManager.currentHMILevel, HMILevel.HMI_FULL); assertFalse(textAndGraphicManager.isDirty); assertEquals(textAndGraphicManager.getState(), BaseSubManager.SETTING_UP); assertNotNull(textAndGraphicManager.getBlankArtwork()); @@ -248,7 +290,17 @@ public class TextAndGraphicManagerTests { assertEquals(textAndGraphicManager.transactionQueue.getTasksAsList().size(), 1); assertTrue(textAndGraphicManager.transactionQueue.getTasksAsList().get(0).getState() == Task.READY); + } + @Test + public void testHasData() { + assertFalse(textAndGraphicManager.hasData()); + + textAndGraphicManager.setTextField1("HI"); + assertTrue(textAndGraphicManager.hasData()); + textAndGraphicManager.setTextField1(null); + textAndGraphicManager.setPrimaryGraphic(testArtwork); + assertTrue(textAndGraphicManager.hasData()); } } diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java index 995bf6d5f..43520d6f2 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java @@ -98,8 +98,8 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { textAlignment = CENTERED; currentHMILevel = HMILevel.HMI_NONE; currentScreenData = new Show(); - addListeners(); this.transactionQueue = newTransactionQueue(); + addListeners(); } @Override -- cgit v1.2.1 From ec88eaab3e4d130500185f303dea98ebaa04481f Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Sun, 23 Aug 2020 17:50:59 -0400 Subject: Added functionality to cancel task and fix formatting --- .../managers/screen/BaseTextAndGraphicManager.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java index 43520d6f2..e02a03594 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java @@ -178,6 +178,7 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { private synchronized void sdlUpdate(final CompletionListener listener) { if (transactionQueue.getTasksAsList().size() > 0) { //Transactions already exist, cancelling them + transactionQueue.getTasksAsList().get(0).cancelTask(); transactionQueue.clear(); if (listener != null) { listener.onComplete(false); @@ -202,17 +203,18 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { updateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager.get(), defaultMainWindowCapability, currentScreenData, currentState(), updateOperationListener, currentScreenDataUpdateListener); transactionQueue.add(updateOperation, false); } + //Updates pending task with current screen data - void updatePendingOperationsWithNewScreenData(Show newScreenData){ - for(Task task: transactionQueue.getTasksAsList()){ - if(!(task instanceof TextAndGraphicUpdateOperation) || task.getState() == Task.IN_PROGRESS){ + void updatePendingOperationsWithNewScreenData(Show newScreenData) { + for (Task task : transactionQueue.getTasksAsList()) { + if (!(task instanceof TextAndGraphicUpdateOperation) || task.getState() == Task.IN_PROGRESS) { continue; } ((TextAndGraphicUpdateOperation) task).setCurrentScreenData(newScreenData); } } - interface CurrentScreenDataUpdatedListener{ + interface CurrentScreenDataUpdatedListener { void onUpdate(Show show); } @@ -236,11 +238,11 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { array.add(textField4); } - if(title != null){ + if (title != null) { array.add(title); } - if(mediaTrackTextField != null){ + if (mediaTrackTextField != null) { array.add(mediaTrackTextField); } -- cgit v1.2.1 From c0dc0e2cad9ee289153b49010532b90c566bff48 Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Sun, 23 Aug 2020 17:56:47 -0400 Subject: Clean up and formatting fixes --- .../screen/TextAndGraphicUpdateOperation.java | 35 ++-------------------- 1 file changed, 3 insertions(+), 32 deletions(-) diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java index 1c51be9e5..a58d775f7 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java @@ -34,7 +34,6 @@ public class TextAndGraphicUpdateOperation extends Task { private CompletionListener listener; private TextAndGraphicManager.CurrentScreenDataUpdatedListener currentScreenDataUpdateListener; - /** * @param internalInterface * @param fileManager @@ -69,8 +68,6 @@ public class TextAndGraphicUpdateOperation extends Task { // Build a show with everything from `self.newState`, we'll pull things out later if we can. Show fullShow = new Show(); fullShow.setAlignment(updatedState.getTextAlignment()); - //TODO IOS ask about tages, Dont they just get set when we assembleShowText - // fullShow.setMetadataTags(updatedState.getM); fullShow = assembleShowText(fullShow); fullShow = assembleShowImages(fullShow); @@ -136,7 +133,6 @@ public class TextAndGraphicUpdateOperation extends Task { @Override public void onComplete(boolean success) { Show showWithGraphics = createImageOnlyShowWithPrimaryArtwork(updatedState.getPrimaryGraphic(), updatedState.getSecondaryGraphic()); - //TODO Ask about logic here, Should we do if(success) then create and sendShow with Graphic or return false if (showWithGraphics != null) { DebugTool.logInfo(TAG, "Sending update with the successfully uploaded images"); sendShow(showWithGraphics, new CompletionListener() { @@ -154,7 +150,6 @@ public class TextAndGraphicUpdateOperation extends Task { } private void uploadImages(final CompletionListener listener) { - List artworksToUpload = new ArrayList<>(); // add primary image @@ -193,7 +188,6 @@ public class TextAndGraphicUpdateOperation extends Task { } private Show assembleShowImages(Show show) { - if (shouldUpdatePrimaryImage()) { show.setGraphic(updatedState.getPrimaryGraphic().getImageRPC()); } @@ -217,7 +211,6 @@ public class TextAndGraphicUpdateOperation extends Task { } Show assembleShowText(Show show) { - show = setBlankTextFields(show); if (updatedState.getMediaTrackTextField() != null && shouldUpdateMediaTrackField()) { @@ -249,12 +242,10 @@ public class TextAndGraphicUpdateOperation extends Task { show = assembleFourLineShowText(show); break; } - return show; } private Show assembleOneLineShowText(Show show, List showFields) { - StringBuilder showString1 = new StringBuilder(); for (int i = 0; i < showFields.size(); i++) { if (i > 0) { @@ -264,17 +255,14 @@ public class TextAndGraphicUpdateOperation extends Task { } } show.setMainField1(showString1.toString()); - MetadataTags tags = new MetadataTags(); tags.setMainField1(findNonNullMetadataFields()); - show.setMetadataTags(tags); return show; } private Show assembleTwoLineShowText(Show show) { - StringBuilder tempString = new StringBuilder(); MetadataTags tags = new MetadataTags(); @@ -312,10 +300,10 @@ public class TextAndGraphicUpdateOperation extends Task { } } - // set mainfield 1 + // set mainField1 show.setMainField1(tempString.toString()); - // new stringbuilder object + // new stringBuilder object tempString = new StringBuilder(); if (updatedState.getTextField3() != null && updatedState.getTextField3().length() > 0) { @@ -358,7 +346,6 @@ public class TextAndGraphicUpdateOperation extends Task { } private Show assembleThreeLineShowText(Show show) { - MetadataTags tags = new MetadataTags(); if (updatedState.getTextField1() != null && updatedState.getTextField1().length() > 0) { @@ -404,16 +391,13 @@ public class TextAndGraphicUpdateOperation extends Task { } } } - show.setMainField3(tempString.toString()); show.setMetadataTags(tags); return show; } private Show assembleFourLineShowText(Show show) { - MetadataTags tags = new MetadataTags(); - if (updatedState.getTextField1() != null && updatedState.getTextField1().length() > 0) { show.setMainField1(updatedState.getTextField1()); if (updatedState.getTextField1Type() != null) { @@ -443,13 +427,13 @@ public class TextAndGraphicUpdateOperation extends Task { } show.setMetadataTags(tags); + return show; } // Extraction Show extractTextFromShow(Show show) { - Show newShow = new Show(); newShow.setMainField1(show.getMainField1()); newShow.setMainField2(show.getMainField2()); @@ -463,7 +447,6 @@ public class TextAndGraphicUpdateOperation extends Task { } private Show setBlankTextFields(Show newShow) { - newShow.setMainField1(""); newShow.setMainField2(""); newShow.setMainField3(""); @@ -474,9 +457,7 @@ public class TextAndGraphicUpdateOperation extends Task { return newShow; } - //TODO IOS different by maybe same private void updateCurrentScreenDataFromShow(Show show) { - if (show == null) { DebugTool.logError(TAG, "can not updateCurrentScreenDataFromShow from null show"); return; @@ -565,8 +546,6 @@ public class TextAndGraphicUpdateOperation extends Task { return array; } - // abstract SdlArtwork getBlankArtwork(); - @SuppressWarnings("BooleanMethodIsAlwaysInverted") private boolean sdlArtworkNeedsUpload(SdlArtwork artwork) { if (fileManager.get() != null) { @@ -641,14 +620,6 @@ public class TextAndGraphicUpdateOperation extends Task { return defaultMainWindowCapability == null || ManagerUtility.WindowCapabilityUtility.hasTextFieldOfName(defaultMainWindowCapability, name); } - public Show getSentShow() { - return sentShow; - } - - public void setSentShow(Show sentShow) { - this.sentShow = sentShow; - } - public Show getCurrentScreenData() { return currentScreenData; } -- cgit v1.2.1 From 676b3db50a6ef9cb5314dbb89a8b23c4a95f2337 Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Sun, 23 Aug 2020 17:59:45 -0400 Subject: Updated copyright fixed formatting --- .../com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java | 2 +- .../smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java | 3 +++ .../com/smartdevicelink/managers/screen/TextsAndGraphicsState.java | 2 -- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java index e02a03594..7e2c01d56 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Livio, Inc. + * Copyright (c) 2019 - 2020 Livio, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java index a58d775f7..70d35e82d 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java @@ -23,6 +23,9 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +/** + * Created by Julian Kast on 8/23/20. + */ public class TextAndGraphicUpdateOperation extends Task { private static final String TAG = "TextAndGraphicUpdateOperation"; diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/TextsAndGraphicsState.java b/base/src/main/java/com/smartdevicelink/managers/screen/TextsAndGraphicsState.java index ce0d473cc..ca409a4b4 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/TextsAndGraphicsState.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/TextsAndGraphicsState.java @@ -1,7 +1,5 @@ package com.smartdevicelink.managers.screen; - - import com.smartdevicelink.managers.file.filetypes.SdlArtwork; import com.smartdevicelink.proxy.rpc.enums.MetadataType; import com.smartdevicelink.proxy.rpc.enums.TextAlignment; -- cgit v1.2.1 From de3f00e43aa8d61e7cb589c16d4fe57d416abda1 Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Mon, 24 Aug 2020 15:40:07 -0400 Subject: Fixed task executing canceling --- .../managers/screen/BaseTextAndGraphicManager.java | 9 ++++----- .../managers/screen/TextAndGraphicUpdateOperation.java | 11 ++++++++--- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java index 7e2c01d56..b08525f5c 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java @@ -178,12 +178,11 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { private synchronized void sdlUpdate(final CompletionListener listener) { if (transactionQueue.getTasksAsList().size() > 0) { //Transactions already exist, cancelling them - transactionQueue.getTasksAsList().get(0).cancelTask(); - transactionQueue.clear(); - if (listener != null) { - listener.onComplete(false); + for (Task task : transactionQueue.getTasksAsList()) { + if (task instanceof TextAndGraphicUpdateOperation) { + ((TextAndGraphicUpdateOperation) task).setTaskIsCanceled(true); + } } - return; } CurrentScreenDataUpdatedListener currentScreenDataUpdateListener = new CurrentScreenDataUpdatedListener() { @Override diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java index 70d35e82d..986ac42e2 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java @@ -35,6 +35,7 @@ public class TextAndGraphicUpdateOperation extends Task { private Show currentScreenData, sentShow; private TextsAndGraphicsState updatedState; private CompletionListener listener; + private boolean taskIsCanceled; private TextAndGraphicManager.CurrentScreenDataUpdatedListener currentScreenDataUpdateListener; /** @@ -55,6 +56,7 @@ public class TextAndGraphicUpdateOperation extends Task { this.updatedState = newState; this.listener = listener; this.currentScreenDataUpdateListener = currentScreenDataUpdateListener; + this.taskIsCanceled = false; } @Override @@ -63,7 +65,7 @@ public class TextAndGraphicUpdateOperation extends Task { } void start() { - if (getState() == Task.CANCELED) { + if (taskIsCanceled) { finishOperation(false); return; } @@ -99,7 +101,7 @@ public class TextAndGraphicUpdateOperation extends Task { sendShow(extractTextFromShow(fullShow), new CompletionListener() { @Override public void onComplete(boolean success) { - if (getState() == Task.CANCELED) { + if (taskIsCanceled) { finishOperation(false); return; } @@ -175,7 +177,7 @@ public class TextAndGraphicUpdateOperation extends Task { fileManager.get().uploadArtworks(artworksToUpload, new MultipleFileCompletionListener() { @Override public void onComplete(Map errors) { - if (getState() == Task.CANCELED) { + if (taskIsCanceled) { finishOperation(false); return; } @@ -636,4 +638,7 @@ public class TextAndGraphicUpdateOperation extends Task { listener.onComplete(success); onFinished(); } + public void setTaskIsCanceled(boolean taskIsCanceled) { + this.taskIsCanceled = taskIsCanceled; + } } -- cgit v1.2.1 From 54e78d863f1d714f85b1fd03de67842f3199826a Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Mon, 24 Aug 2020 15:56:50 -0400 Subject: Fix canceling logic for operations --- .../smartdevicelink/managers/screen/BaseTextAndGraphicManager.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java index b08525f5c..82f590c55 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java @@ -184,6 +184,11 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { } } } + // transactionQueue.getTaskAsList() will not return a task in progress, so we need to check + if (updateOperation.getState() == Task.IN_PROGRESS) { + updateOperation.setTaskIsCanceled(true); + } + CurrentScreenDataUpdatedListener currentScreenDataUpdateListener = new CurrentScreenDataUpdatedListener() { @Override public void onUpdate(Show show) { @@ -206,7 +211,7 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { //Updates pending task with current screen data void updatePendingOperationsWithNewScreenData(Show newScreenData) { for (Task task : transactionQueue.getTasksAsList()) { - if (!(task instanceof TextAndGraphicUpdateOperation) || task.getState() == Task.IN_PROGRESS) { + if (!(task instanceof TextAndGraphicUpdateOperation)) { continue; } ((TextAndGraphicUpdateOperation) task).setCurrentScreenData(newScreenData); -- cgit v1.2.1 From f0ac42ed59bd8b0a45c7a7c3f1a41f8dae5075c0 Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Mon, 24 Aug 2020 16:00:03 -0400 Subject: Added null check --- .../com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java index 82f590c55..fe2b72e0e 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java @@ -185,7 +185,7 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { } } // transactionQueue.getTaskAsList() will not return a task in progress, so we need to check - if (updateOperation.getState() == Task.IN_PROGRESS) { + if (updateOperation != null && updateOperation.getState() == Task.IN_PROGRESS) { updateOperation.setTaskIsCanceled(true); } -- cgit v1.2.1 From 6f27facda94d94b070386483f26e05a444274f9b Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Mon, 24 Aug 2020 16:00:15 -0400 Subject: Fixed unit test --- .../managers/screen/TextAndGraphicUpdateOperationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java index a279e3aec..0e5b439f5 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java @@ -83,7 +83,7 @@ public class TextAndGraphicUpdateOperationTest { RPCRequest message = (RPCRequest) args[0]; if (message instanceof Show) { int correlationId = message.getCorrelationID(); - textAndGraphicUpdateOperation.cancelTask(); + textAndGraphicUpdateOperation.setTaskIsCanceled(true); ShowResponse showResponse = new ShowResponse(); showResponse.setSuccess(true); message.getOnRPCResponseListener().onResponse(correlationId, showResponse); -- cgit v1.2.1 From 6121537b5e8ebe00c53bda265cd84527beb1cce4 Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Mon, 24 Aug 2020 16:56:08 -0400 Subject: Fixed comments --- .../managers/screen/TextAndGraphicManagerTests.java | 3 --- .../managers/screen/TextAndGraphicUpdateOperation.java | 8 -------- 2 files changed, 11 deletions(-) diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java index b0e9f8bbf..646e26ded 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java @@ -95,9 +95,6 @@ public class TextAndGraphicManagerTests { }; doAnswer(onHMIStatusAnswer).when(internalInterface).addOnRPCNotificationListener(eq(FunctionID.ON_HMI_STATUS), any(OnRPCNotificationListener.class)); - - // When internalInterface.addOnSystemCapabilityListener(SystemCapabilityType.DISPLAYS, onSystemCapabilityListener) is called - // inside SoftButtonManager, respond with a fake response to let the SoftButtonManager continue working. Answer onSystemCapabilityAnswer = new Answer() { @Override public Void answer(InvocationOnMock invocation) { diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java index 986ac42e2..ceea0bca8 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java @@ -38,14 +38,6 @@ public class TextAndGraphicUpdateOperation extends Task { private boolean taskIsCanceled; private TextAndGraphicManager.CurrentScreenDataUpdatedListener currentScreenDataUpdateListener; - /** - * @param internalInterface - * @param fileManager - * @param currentCapabilities - * @param currentScreenData - * @param newState - * @param listener - */ public TextAndGraphicUpdateOperation(ISdl internalInterface, FileManager fileManager, WindowCapability currentCapabilities, Show currentScreenData, TextsAndGraphicsState newState, CompletionListener listener, TextAndGraphicManager.CurrentScreenDataUpdatedListener currentScreenDataUpdateListener) { super("TextAndGraphicUpdateOperation"); -- cgit v1.2.1 From a40e0c5003d9581893847692250fd08e81fefe4a Mon Sep 17 00:00:00 2001 From: Joey Grover Date: Wed, 26 Aug 2020 11:35:49 -0400 Subject: Remove FrameData as it is not used --- .../java/com/smartdevicelink/test/Validator.java | 24 +---- .../test/protocol/enums/FrameDataTests.java | 116 --------------------- .../smartdevicelink/protocol/enums/FrameData.java | 73 ------------- 3 files changed, 1 insertion(+), 212 deletions(-) delete mode 100644 android/sdl_android/src/androidTest/java/com/smartdevicelink/test/protocol/enums/FrameDataTests.java delete mode 100644 base/src/main/java/com/smartdevicelink/protocol/enums/FrameData.java diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/Validator.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/Validator.java index d34bfea07..6de391c41 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/Validator.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/Validator.java @@ -1,7 +1,6 @@ package com.smartdevicelink.test; import com.smartdevicelink.managers.file.filetypes.SdlFile; -import com.smartdevicelink.protocol.enums.FrameData; import com.smartdevicelink.protocol.enums.FrameDataControlFrameType; import com.smartdevicelink.protocol.enums.FrameType; import com.smartdevicelink.protocol.enums.SessionType; @@ -146,28 +145,7 @@ public class Validator{ return true; } - - public static boolean validateFrameDataArray (FrameData[] array1, FrameData[] array2) { - if (array1 == null) { - return (array2 == null); - } - - if (array2 == null) { - return (array1 == null); - } - - if (array1.length != array2.length) { - return false; - } - - for (int i = 0; i < array1.length; i++) { - if (array1[i] != array2[i]) { - return false; - } - } - - return true; - } + public static boolean validateImage(Image image1, Image image2){ if(image1 == null){ diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/protocol/enums/FrameDataTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/protocol/enums/FrameDataTests.java deleted file mode 100644 index e2ad1ea3a..000000000 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/protocol/enums/FrameDataTests.java +++ /dev/null @@ -1,116 +0,0 @@ -package com.smartdevicelink.test.protocol.enums; - -import com.smartdevicelink.protocol.enums.FrameData; -import com.smartdevicelink.test.Validator; - -import junit.framework.TestCase; - -import java.util.Vector; - -public class FrameDataTests extends TestCase { - - private Vector list = FrameData.getList(); - - // Verifies the values are not null upon valid assignment. - // These are not actual enums for packeting reasons so testing is different. - public void testValidEnums () { - - final byte START_SESSION_BYTE = (byte) 0x01; - final String START_SESSION_STRING = "StartSession"; - - final byte START_SESSION_ACK_BYTE = (byte) 0x02; - final String START_SESSION_ACK_STRING = "StartSessionACK"; - - final byte START_SESSION_NACK_BYTE = (byte) 0x03; - final String START_SESSION_NACK_STRING = "StartSessionNACK"; - - final byte END_SESSION_BYTE = (byte) 0x04; - final String END_SESSION_STRING = "EndSession"; - - try { - - assertNotNull("FrameData list returned null", list); - - // Check the byte values - FrameData enumSS = (FrameData) FrameData.get(list, START_SESSION_BYTE); - FrameData enumSSACK = (FrameData) FrameData.get(list, START_SESSION_ACK_BYTE); - FrameData enumSSNACK = (FrameData) FrameData.get(list, START_SESSION_NACK_BYTE); - FrameData enumES = (FrameData) FrameData.get(list, END_SESSION_BYTE); - - assertNotNull("Start session byte match returned null", enumSS); - assertNotNull("Single byte match returned null", enumSSACK); - assertNotNull("First byte match returned null", enumSSNACK); - assertNotNull("Consecutive byte match returned null", enumES); - - // Check the string values - enumSS = (FrameData) FrameData.get(list, START_SESSION_STRING); - enumSSACK = (FrameData) FrameData.get(list, START_SESSION_ACK_STRING); - enumSSNACK = (FrameData) FrameData.get(list, START_SESSION_NACK_STRING); - enumES = (FrameData) FrameData.get(list, END_SESSION_STRING); - - assertNotNull("Start session string match returned null", enumSS); - assertNotNull("Single string match returned null", enumSSACK); - assertNotNull("First string match returned null", enumSSNACK); - assertNotNull("Consecutive string match returned null", enumES); - - } catch (NullPointerException exception) { - fail("Null enum list throws NullPointerException."); - } - } - - // Verifies that an invalid assignment is null. - public void testInvalidEnum () { - - final byte INVALID_BYTE = (byte) 0xAB; - final String INVALID_STRING = "Invalid"; - - try { - - // Check the byte value - FrameData enumInvalid = (FrameData) FrameData.get(list, INVALID_BYTE); - assertNull("Invalid byte match didn't return null", enumInvalid); - - // Check the string value - enumInvalid = (FrameData) FrameData.get(list, INVALID_STRING); - assertNull("Invalid string match didn't return null", enumInvalid); - - } catch (IllegalArgumentException exception) { - fail("Invalid enum throws IllegalArgumentException."); - } - } - - // Verifies that a null assignment is invalid. - public void testNullEnum () { - try { - - // Check null string lookup - FrameData enumNull = (FrameData) FrameData.get(list, null); - assertNull("Null lookup returns a value", enumNull); - - } catch (NullPointerException exception) { - fail("Null string throws NullPointerException."); - } - } - - // Verifies the possible enum values of FrameType. - public void testListEnum () { - // Test Vector - Vector enumTestList = new Vector(); - enumTestList.add(FrameData.StartSession); - enumTestList.add(FrameData.StartSessionACK); - enumTestList.add(FrameData.StartSessionNACK); - enumTestList.add(FrameData.EndSession); - - assertTrue("List does not match enum test list.", - list.containsAll(enumTestList) && - enumTestList.containsAll(list)); - - // Test Array - FrameData[] enumValueArray = FrameData.values(); - FrameData[] enumTestArray = { FrameData.StartSession, FrameData.StartSessionACK, - FrameData.StartSessionNACK, FrameData.EndSession }; - - assertTrue("Array does not match enum values array.", - Validator.validateFrameDataArray(enumValueArray, enumTestArray)); - } -} \ No newline at end of file diff --git a/base/src/main/java/com/smartdevicelink/protocol/enums/FrameData.java b/base/src/main/java/com/smartdevicelink/protocol/enums/FrameData.java deleted file mode 100644 index 745faf5f3..000000000 --- a/base/src/main/java/com/smartdevicelink/protocol/enums/FrameData.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ -package com.smartdevicelink.protocol.enums; - -import com.smartdevicelink.util.ByteEnumer; - -import java.util.Vector; - -public class FrameData extends ByteEnumer { - - private static Vector theList = new Vector(); - public static Vector getList() { return theList; } - - byte i = 0x00; - - protected FrameData(byte value, String name) { - super(value, name); - } - - public final static FrameData StartSession = new FrameData((byte)0x01, "StartSession"); - public final static FrameData StartSessionACK = new FrameData((byte)0x02, "StartSessionACK"); - public final static FrameData StartSessionNACK = new FrameData((byte)0x03, "StartSessionNACK"); - public final static FrameData EndSession = new FrameData((byte)0x04, "EndSession"); - - public final static FrameData SingleFrame = new FrameData((byte)0x00, "SingleFrame"); - public final static FrameData FirstFrame = new FrameData((byte)0x00, "FirstFrame"); - public final static FrameData ConsecutiveFrame = new FrameData((byte)0x00, "ConsecutiveFrame"); - public final static byte LastFrame = (byte)0x00; - - static { - theList.addElement(StartSession); - theList.addElement(StartSessionACK); - theList.addElement(StartSessionNACK); - theList.addElement(EndSession); - } - - public static FrameData valueOf(String passedButton) { - return (FrameData) get(theList, passedButton); - } - - public static FrameData[] values() { - return theList.toArray(new FrameData[theList.size()]); - } -} -- cgit v1.2.1 From 3954d4ea76e35d5fa5bc17ba7eae4e7ae8544a7e Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Wed, 26 Aug 2020 11:38:32 -0400 Subject: Fixed softButton mainField1 issue --- .../com/smartdevicelink/managers/screen/TextAndGraphicManager.java | 4 ++-- .../com/smartdevicelink/managers/screen/BaseScreenManager.java | 2 +- .../smartdevicelink/managers/screen/BaseTextAndGraphicManager.java | 7 ++++++- .../com/smartdevicelink/managers/screen/TextAndGraphicManager.java | 4 ++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicManager.java b/android/sdl_android/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicManager.java index 89e6a0b52..d077f6366 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicManager.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicManager.java @@ -48,8 +48,8 @@ import com.smartdevicelink.proxy.rpc.enums.FileType; */ class TextAndGraphicManager extends BaseTextAndGraphicManager { - TextAndGraphicManager(@NonNull ISdl internalInterface, @NonNull FileManager fileManager) { - super(internalInterface, fileManager); + TextAndGraphicManager(@NonNull ISdl internalInterface, @NonNull FileManager fileManager, @NonNull SoftButtonManager softButtonManager) { + super(internalInterface, fileManager, softButtonManager); } SdlArtwork getBlankArtwork() { diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java index 7935406dc..9ecce1f64 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java @@ -126,7 +126,7 @@ abstract class BaseScreenManager extends BaseSubManager { private void initialize(){ if (fileManager.get() != null) { this.softButtonManager = new SoftButtonManager(internalInterface, fileManager.get()); - this.textAndGraphicManager = new TextAndGraphicManager(internalInterface, fileManager.get()); + this.textAndGraphicManager = new TextAndGraphicManager(internalInterface, fileManager.get(), softButtonManager); this.menuManager = new MenuManager(internalInterface, fileManager.get()); this.choiceSetManager = new ChoiceSetManager(internalInterface, fileManager.get()); } diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java index fe2b72e0e..4a1123bfb 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java @@ -74,6 +74,7 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { boolean isDirty; Show currentScreenData; HMILevel currentHMILevel; + private final WeakReference softButtonManager; WindowCapability defaultMainWindowCapability; private boolean batchingUpdates; private final WeakReference fileManager; @@ -89,10 +90,11 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { //Constructors - BaseTextAndGraphicManager(@NonNull ISdl internalInterface, @NonNull FileManager fileManager) { + BaseTextAndGraphicManager(@NonNull ISdl internalInterface, @NonNull FileManager fileManager, @NonNull SoftButtonManager softButtonManager) { // set class vars super(internalInterface); this.fileManager = new WeakReference<>(fileManager); + this.softButtonManager = new WeakReference<>(softButtonManager); batchingUpdates = false; isDirty = false; textAlignment = CENTERED; @@ -216,6 +218,9 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { } ((TextAndGraphicUpdateOperation) task).setCurrentScreenData(newScreenData); } + if (this.softButtonManager.get() != null && newScreenData.getMainField1() != null) { + this.softButtonManager.get().setCurrentMainField1(currentScreenData.getMainField1()); + } } interface CurrentScreenDataUpdatedListener { diff --git a/javaSE/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicManager.java b/javaSE/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicManager.java index ed2e93067..a561028bd 100644 --- a/javaSE/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicManager.java +++ b/javaSE/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicManager.java @@ -45,8 +45,8 @@ import com.smartdevicelink.proxy.rpc.enums.FileType; */ class TextAndGraphicManager extends BaseTextAndGraphicManager { - TextAndGraphicManager(@NonNull ISdl internalInterface, @NonNull FileManager fileManager) { - super(internalInterface, fileManager); + TextAndGraphicManager(@NonNull ISdl internalInterface, @NonNull FileManager fileManager, @NonNull SoftButtonManager softButtonManager) { + super(internalInterface, fileManager, softButtonManager); } SdlArtwork getBlankArtwork(){ -- cgit v1.2.1 From e91105eb75c8b8972b84d5b7ab4440699194ff52 Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Wed, 26 Aug 2020 13:09:03 -0400 Subject: Fixed issue with setting text when number of lines available is 2 --- .../smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java index ceea0bca8..f0d6ca283 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java @@ -265,7 +265,7 @@ public class TextAndGraphicUpdateOperation extends Task { if (updatedState.getTextField1() != null && updatedState.getTextField1().length() > 0) { tempString.append(updatedState.getTextField1()); - if (updatedState.getTextField1() != null) { + if (updatedState.getTextField1Type() != null) { tags.setMainField1(updatedState.getTextField1Type()); } } -- cgit v1.2.1 From cdaac8e90faf848b22a64aa322af3ca9776af764 Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Wed, 26 Aug 2020 13:42:58 -0400 Subject: Add Override back for blankArtwork --- .../com/smartdevicelink/managers/screen/TextAndGraphicManager.java | 1 + .../com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java | 2 ++ .../com/smartdevicelink/managers/screen/TextAndGraphicManager.java | 3 ++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicManager.java b/android/sdl_android/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicManager.java index d077f6366..3d05bc7cd 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicManager.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicManager.java @@ -52,6 +52,7 @@ class TextAndGraphicManager extends BaseTextAndGraphicManager { super(internalInterface, fileManager, softButtonManager); } + @Override SdlArtwork getBlankArtwork() { if (blankArtwork == null) { blankArtwork = new SdlArtwork(); diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java index 4a1123bfb..58e9d7746 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java @@ -265,6 +265,8 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { return hasTextFields || hasImageFields; } + abstract SdlArtwork getBlankArtwork(); + // Convert to State diff --git a/javaSE/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicManager.java b/javaSE/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicManager.java index a561028bd..b84734a52 100644 --- a/javaSE/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicManager.java +++ b/javaSE/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicManager.java @@ -48,7 +48,8 @@ class TextAndGraphicManager extends BaseTextAndGraphicManager { TextAndGraphicManager(@NonNull ISdl internalInterface, @NonNull FileManager fileManager, @NonNull SoftButtonManager softButtonManager) { super(internalInterface, fileManager, softButtonManager); } - + + @Override SdlArtwork getBlankArtwork(){ if (blankArtwork == null){ blankArtwork = new SdlArtwork(); -- cgit v1.2.1 From 6ebbef6bc7da28e83710dd2e3f955b01ca8ccfc4 Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Wed, 26 Aug 2020 13:44:50 -0400 Subject: Fix potential NPE in ScreenManager --- .../java/com/smartdevicelink/managers/screen/BaseScreenManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java index 9ecce1f64..6d05b93eb 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java @@ -249,7 +249,7 @@ abstract class BaseScreenManager extends BaseSubManager { * @return an SdlArtwork object represents the current primaryGraphic */ public SdlArtwork getPrimaryGraphic() { - if (this.textAndGraphicManager.getPrimaryGraphic() == null || this.textAndGraphicManager.getPrimaryGraphic().getName().equals(textAndGraphicManager.getBlankArtwork().getName())) { + if (this.textAndGraphicManager.getPrimaryGraphic() == null || textAndGraphicManager.getPrimaryGraphic().getName() == null || this.textAndGraphicManager.getPrimaryGraphic().getName().equals(textAndGraphicManager.getBlankArtwork().getName())) { return null; } return this.textAndGraphicManager.getPrimaryGraphic(); @@ -271,7 +271,7 @@ abstract class BaseScreenManager extends BaseSubManager { * @return an SdlArtwork object represents the current secondaryGraphic */ public SdlArtwork getSecondaryGraphic() { - if (this.textAndGraphicManager.getSecondaryGraphic() == null || this.textAndGraphicManager.getSecondaryGraphic().getName().equals(textAndGraphicManager.getBlankArtwork().getName())) { + if (this.textAndGraphicManager.getSecondaryGraphic() == null || textAndGraphicManager.getSecondaryGraphic().getName() == null || this.textAndGraphicManager.getSecondaryGraphic().getName().equals(textAndGraphicManager.getBlankArtwork().getName())) { return null; } return this.textAndGraphicManager.getSecondaryGraphic(); -- cgit v1.2.1 From 7b620f620d3d0d40e31cd693b37824d89ccb7fa5 Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Wed, 26 Aug 2020 14:38:53 -0400 Subject: Make TextAndGraphicsState package private --- .../managers/screen/TextsAndGraphicsState.java | 50 +++++++++++----------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/TextsAndGraphicsState.java b/base/src/main/java/com/smartdevicelink/managers/screen/TextsAndGraphicsState.java index ca409a4b4..bd6f749a3 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/TextsAndGraphicsState.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/TextsAndGraphicsState.java @@ -4,13 +4,13 @@ import com.smartdevicelink.managers.file.filetypes.SdlArtwork; import com.smartdevicelink.proxy.rpc.enums.MetadataType; import com.smartdevicelink.proxy.rpc.enums.TextAlignment; -public class TextsAndGraphicsState { +class TextsAndGraphicsState { private String textField1, textField2, textField3, textField4, mediaTrackTextField, title; private MetadataType textField1Type, textField2Type, textField3Type, textField4Type; private TextAlignment textAlignment; private SdlArtwork primaryGraphic, secondaryGraphic; - public TextsAndGraphicsState(String textField1, String textField2, String textField3, String textField4, String mediaTrackTextField, + TextsAndGraphicsState(String textField1, String textField2, String textField3, String textField4, String mediaTrackTextField, String title, SdlArtwork primaryGraphic, SdlArtwork secondaryGraphic, TextAlignment textAlignment, MetadataType textField1Type, MetadataType textField2Type, MetadataType textField3Type, MetadataType textField4Type) { this.textField1 = textField1; @@ -28,95 +28,95 @@ public class TextsAndGraphicsState { this.textField4Type = textField4Type; } - public String getTextField1() { + String getTextField1() { return textField1; } - public void setTextField1(String textField1) { + void setTextField1(String textField1) { this.textField1 = textField1; } - public String getTextField2() { + String getTextField2() { return textField2; } - public void setTextField2(String textField2) { + void setTextField2(String textField2) { this.textField2 = textField2; } - public String getTextField3() { + String getTextField3() { return textField3; } - public void setTextField3(String textField3) { + void setTextField3(String textField3) { this.textField3 = textField3; } - public String getTextField4() { + String getTextField4() { return textField4; } - public void setTextField4(String textField4) { + void setTextField4(String textField4) { this.textField4 = textField4; } - public String getMediaTrackTextField() { + String getMediaTrackTextField() { return mediaTrackTextField; } - public void setMediaTrackTextField(String mediaTrackTextField) { + void setMediaTrackTextField(String mediaTrackTextField) { this.mediaTrackTextField = mediaTrackTextField; } - public String getTitle() { + String getTitle() { return title; } - public void setTitle(String title) { + void setTitle(String title) { this.title = title; } - public MetadataType getTextField1Type() { + MetadataType getTextField1Type() { return textField1Type; } - public void setTextField1Type(MetadataType textField1Type) { + void setTextField1Type(MetadataType textField1Type) { this.textField1Type = textField1Type; } - public MetadataType getTextField2Type() { + MetadataType getTextField2Type() { return textField2Type; } - public void setTextField2Type(MetadataType textField2Type) { + void setTextField2Type(MetadataType textField2Type) { this.textField2Type = textField2Type; } - public MetadataType getTextField3Type() { + MetadataType getTextField3Type() { return textField3Type; } - public void setTextField3Type(MetadataType textField3Type) { + void setTextField3Type(MetadataType textField3Type) { this.textField3Type = textField3Type; } - public MetadataType getTextField4Type() { + MetadataType getTextField4Type() { return textField4Type; } - public void setTextField4Type(MetadataType textField4Type) { + void setTextField4Type(MetadataType textField4Type) { this.textField4Type = textField4Type; } - public TextAlignment getTextAlignment() { + TextAlignment getTextAlignment() { return textAlignment; } - public SdlArtwork getPrimaryGraphic() { + SdlArtwork getPrimaryGraphic() { return primaryGraphic; } - public SdlArtwork getSecondaryGraphic() { + SdlArtwork getSecondaryGraphic() { return secondaryGraphic; } } -- cgit v1.2.1 From 8d445a8cb181722c74172dae9266458563692c0a Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Wed, 26 Aug 2020 14:43:21 -0400 Subject: Updated CurrentScreenData with onUpdate while updating pending operations, set defadefaultMainWindowCapability to null if no capabilities received --- .../com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java index 58e9d7746..a06b72179 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java @@ -195,6 +195,7 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { @Override public void onUpdate(Show show) { updatePendingOperationsWithNewScreenData(show); + currentScreenData = show; } }; CompletionListener updateOperationListener = new CompletionListener() { @@ -473,6 +474,7 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { List capabilities = SystemCapabilityManager.convertToList(capability, DisplayCapability.class); if (capabilities == null || capabilities.size() == 0) { DebugTool.logError(TAG, "TextAndGraphic Manager - Capabilities sent here are null or empty"); + defaultMainWindowCapability = null; } else { DisplayCapability display = capabilities.get(0); for (WindowCapability windowCapability : display.getWindowCapabilities()) { -- cgit v1.2.1 From cdadb3bf31051787bf48bcb14a0e7da1d4300706 Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Wed, 26 Aug 2020 19:01:18 -0400 Subject: Fixed queue management --- .../managers/screen/BaseTextAndGraphicManager.java | 38 ++++++++++++---------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java index a06b72179..7dba7853e 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java @@ -86,6 +86,7 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { private String textField1, textField2, textField3, textField4, mediaTrackTextField, title; private MetadataType textField1Type, textField2Type, textField3Type, textField4Type; private TextAndGraphicUpdateOperation updateOperation; + private CompletionListener currentOperationListener; Queue transactionQueue; //Constructors @@ -178,19 +179,30 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { } private synchronized void sdlUpdate(final CompletionListener listener) { - if (transactionQueue.getTasksAsList().size() > 0) { - //Transactions already exist, cancelling them - for (Task task : transactionQueue.getTasksAsList()) { - if (task instanceof TextAndGraphicUpdateOperation) { - ((TextAndGraphicUpdateOperation) task).setTaskIsCanceled(true); - } + if (this.transactionQueue.getTasksAsList().size() > 0) { + // Transactions already in queue, we need to clear it out + transactionQueue.clear(); + updateOperation = null; + if (currentOperationListener != null) { + currentOperationListener.onComplete(false); } } - // transactionQueue.getTaskAsList() will not return a task in progress, so we need to check + + // Task can be READY, about to start and popped of the queue, so we have to cancel it, to prevent it from starting + if (updateOperation != null && updateOperation.getState() == Task.READY) { + updateOperation.cancelTask(); + if (currentOperationListener != null) { + currentOperationListener.onComplete(false); + } + } + + // If Task is IN_PROGRESS it's not on the queue, we need to cancel it, operation will take care of stopping it. if (updateOperation != null && updateOperation.getState() == Task.IN_PROGRESS) { - updateOperation.setTaskIsCanceled(true); + updateOperation.cancelTask(); } + currentOperationListener = listener; + CurrentScreenDataUpdatedListener currentScreenDataUpdateListener = new CurrentScreenDataUpdatedListener() { @Override public void onUpdate(Show show) { @@ -198,16 +210,8 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { currentScreenData = show; } }; - CompletionListener updateOperationListener = new CompletionListener() { - @Override - public void onComplete(boolean success) { - if (listener != null) { - listener.onComplete(success); - } - } - }; - updateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager.get(), defaultMainWindowCapability, currentScreenData, currentState(), updateOperationListener, currentScreenDataUpdateListener); + updateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager.get(), defaultMainWindowCapability, currentScreenData, currentState(), currentOperationListener, currentScreenDataUpdateListener); transactionQueue.add(updateOperation, false); } -- cgit v1.2.1 From 9d6b02248ef1aa928fca0297f7ce906bd8c9ba1b Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Wed, 26 Aug 2020 19:12:42 -0400 Subject: Fixed cancel logic and made methods private and package private --- .../screen/TextAndGraphicUpdateOperation.java | 31 ++++++++++------------ 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java index f0d6ca283..54c7d51d6 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java @@ -26,19 +26,18 @@ import java.util.Map; /** * Created by Julian Kast on 8/23/20. */ -public class TextAndGraphicUpdateOperation extends Task { +class TextAndGraphicUpdateOperation extends Task { private static final String TAG = "TextAndGraphicUpdateOperation"; private final WeakReference internalInterface; private final WeakReference fileManager; WindowCapability defaultMainWindowCapability; - private Show currentScreenData, sentShow; + private Show currentScreenData; private TextsAndGraphicsState updatedState; private CompletionListener listener; - private boolean taskIsCanceled; private TextAndGraphicManager.CurrentScreenDataUpdatedListener currentScreenDataUpdateListener; - public TextAndGraphicUpdateOperation(ISdl internalInterface, FileManager fileManager, WindowCapability currentCapabilities, + TextAndGraphicUpdateOperation(ISdl internalInterface, FileManager fileManager, WindowCapability currentCapabilities, Show currentScreenData, TextsAndGraphicsState newState, CompletionListener listener, TextAndGraphicManager.CurrentScreenDataUpdatedListener currentScreenDataUpdateListener) { super("TextAndGraphicUpdateOperation"); this.internalInterface = new WeakReference<>(internalInterface); @@ -48,7 +47,6 @@ public class TextAndGraphicUpdateOperation extends Task { this.updatedState = newState; this.listener = listener; this.currentScreenDataUpdateListener = currentScreenDataUpdateListener; - this.taskIsCanceled = false; } @Override @@ -56,8 +54,8 @@ public class TextAndGraphicUpdateOperation extends Task { start(); } - void start() { - if (taskIsCanceled) { + private void start() { + if (getState() == Task.CANCELED) { finishOperation(false); return; } @@ -93,7 +91,7 @@ public class TextAndGraphicUpdateOperation extends Task { sendShow(extractTextFromShow(fullShow), new CompletionListener() { @Override public void onComplete(boolean success) { - if (taskIsCanceled) { + if (getState() == Task.CANCELED) { finishOperation(false); return; } @@ -109,7 +107,7 @@ public class TextAndGraphicUpdateOperation extends Task { } } - void sendShow(final Show show, final CompletionListener listener) { + private void sendShow(final Show show, final CompletionListener listener) { show.setOnRPCResponseListener(new OnRPCResponseListener() { @Override public void onResponse(int correlationId, RPCResponse response) { @@ -125,7 +123,7 @@ public class TextAndGraphicUpdateOperation extends Task { } - void uploadImagesAndSendWhenDone(final CompletionListener listener) { + private void uploadImagesAndSendWhenDone(final CompletionListener listener) { uploadImages(new CompletionListener() { @Override public void onComplete(boolean success) { @@ -140,7 +138,7 @@ public class TextAndGraphicUpdateOperation extends Task { }); } else { DebugTool.logWarning(TAG, "All images failed to upload. No graphics to show, skipping update."); - listener.onComplete(success); + listener.onComplete(false); } } }); @@ -169,7 +167,7 @@ public class TextAndGraphicUpdateOperation extends Task { fileManager.get().uploadArtworks(artworksToUpload, new MultipleFileCompletionListener() { @Override public void onComplete(Map errors) { - if (taskIsCanceled) { + if (getState() == Task.CANCELED) { finishOperation(false); return; } @@ -625,12 +623,11 @@ public class TextAndGraphicUpdateOperation extends Task { this.currentScreenData = currentScreenData; } - void finishOperation(boolean success) { + private void finishOperation(boolean success) { DebugTool.logInfo(TAG, "Finishing text and graphic update operation"); - listener.onComplete(success); + if(listener != null){ + listener.onComplete(success); + } onFinished(); } - public void setTaskIsCanceled(boolean taskIsCanceled) { - this.taskIsCanceled = taskIsCanceled; - } } -- cgit v1.2.1 From 22fd530fe67f1ea15d732b922a403c8d07600125 Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Wed, 26 Aug 2020 19:26:45 -0400 Subject: Fixed Unit test --- .../managers/screen/ScreenManagerTests.java | 13 +++++++++-- .../screen/TextAndGraphicManagerTests.java | 26 +++++----------------- .../screen/TextAndGraphicUpdateOperationTest.java | 2 +- .../managers/screen/BaseTextAndGraphicManager.java | 2 +- 4 files changed, 19 insertions(+), 24 deletions(-) diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/ScreenManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/ScreenManagerTests.java index 33d164740..11d8472c2 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/ScreenManagerTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/ScreenManagerTests.java @@ -21,7 +21,6 @@ import java.util.Arrays; import java.util.List; import static junit.framework.TestCase.assertEquals; -import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static org.mockito.Mockito.mock; @@ -99,13 +98,23 @@ public class ScreenManagerTests { screenManager.setPrimaryGraphic(testArtwork); assertEquals(screenManager.getPrimaryGraphic(), testArtwork); } - + @Test + public void testSetPrimaryGraphicWithBlankImage() { + screenManager.setPrimaryGraphic(null); + assertNull(screenManager.getPrimaryGraphic()); + } @Test public void testSetSecondaryGraphic() { screenManager.setSecondaryGraphic(testArtwork); assertEquals(screenManager.getSecondaryGraphic(), testArtwork); } + @Test + public void testSetSecondaryGraphicWithBlankImage() { + screenManager.setSecondaryGraphic(null); + assertNull(screenManager.getSecondaryGraphic()); + } + @Test public void testAlignment() { screenManager.setTextAlignment(TextAlignment.LEFT_ALIGNED); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java index 646e26ded..2bb0164fb 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java @@ -7,7 +7,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4; import com.livio.taskmaster.Task; import com.livio.taskmaster.Taskmaster; import com.smartdevicelink.managers.BaseSubManager; -import com.smartdevicelink.managers.CompletionListener; import com.smartdevicelink.managers.ManagerUtility; import com.smartdevicelink.managers.file.FileManager; import com.smartdevicelink.managers.file.filetypes.SdlArtwork; @@ -15,21 +14,16 @@ import com.smartdevicelink.managers.lifecycle.OnSystemCapabilityListener; import com.smartdevicelink.protocol.enums.FunctionID; import com.smartdevicelink.proxy.interfaces.ISdl; import com.smartdevicelink.proxy.rpc.DisplayCapability; -import com.smartdevicelink.proxy.rpc.MetadataTags; import com.smartdevicelink.proxy.rpc.OnHMIStatus; -import com.smartdevicelink.proxy.rpc.Show; -import com.smartdevicelink.proxy.rpc.SoftButtonCapabilities; import com.smartdevicelink.proxy.rpc.TextField; import com.smartdevicelink.proxy.rpc.WindowCapability; import com.smartdevicelink.proxy.rpc.enums.FileType; import com.smartdevicelink.proxy.rpc.enums.HMILevel; -import com.smartdevicelink.proxy.rpc.enums.MetadataType; import com.smartdevicelink.proxy.rpc.enums.SystemCapabilityType; import com.smartdevicelink.proxy.rpc.enums.TextAlignment; import com.smartdevicelink.proxy.rpc.enums.TextFieldName; import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener; -import org.json.JSONException; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -37,7 +31,6 @@ import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -71,6 +64,7 @@ public class TextAndGraphicManagerTests { // mock things ISdl internalInterface = mock(ISdl.class); FileManager fileManager = mock(FileManager.class); + SoftButtonManager softButtonManager = mock(SoftButtonManager.class); testArtwork = new SdlArtwork(); testArtwork.setName("testFile"); @@ -110,7 +104,7 @@ public class TextAndGraphicManagerTests { }; doAnswer(onSystemCapabilityAnswer).when(internalInterface).addOnSystemCapabilityListener(eq(SystemCapabilityType.DISPLAYS), any(OnSystemCapabilityListener.class)); - textAndGraphicManager = new TextAndGraphicManager(internalInterface, fileManager); + textAndGraphicManager = new TextAndGraphicManager(internalInterface, fileManager, softButtonManager); } @@ -264,25 +258,17 @@ public class TextAndGraphicManagerTests { @Test public void testOperationManagement() { textAndGraphicManager.isDirty = true; - textAndGraphicManager.update(new CompletionListener() { - @Override - public void onComplete(boolean success) { - assertTrue(success); - } - }); + textAndGraphicManager.updateOperation = null; + textAndGraphicManager.update(null); assertEquals(textAndGraphicManager.transactionQueue.getTasksAsList().size(), 1); textAndGraphicManager.transactionQueue.clear(); + textAndGraphicManager.updateOperation = null; assertEquals(textAndGraphicManager.transactionQueue.getTasksAsList().size(), 0); textAndGraphicManager.isDirty = true; - textAndGraphicManager.update(new CompletionListener() { - @Override - public void onComplete(boolean success) { - assertTrue(success); - } - }); + textAndGraphicManager.update(null); assertEquals(textAndGraphicManager.transactionQueue.getTasksAsList().size(), 1); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java index 0e5b439f5..a279e3aec 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java @@ -83,7 +83,7 @@ public class TextAndGraphicUpdateOperationTest { RPCRequest message = (RPCRequest) args[0]; if (message instanceof Show) { int correlationId = message.getCorrelationID(); - textAndGraphicUpdateOperation.setTaskIsCanceled(true); + textAndGraphicUpdateOperation.cancelTask(); ShowResponse showResponse = new ShowResponse(); showResponse.setSuccess(true); message.getOnRPCResponseListener().onResponse(correlationId, showResponse); diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java index 7dba7853e..336abf5ba 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java @@ -85,7 +85,7 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { private TextAlignment textAlignment; private String textField1, textField2, textField3, textField4, mediaTrackTextField, title; private MetadataType textField1Type, textField2Type, textField3Type, textField4Type; - private TextAndGraphicUpdateOperation updateOperation; + TextAndGraphicUpdateOperation updateOperation; private CompletionListener currentOperationListener; Queue transactionQueue; -- cgit v1.2.1 From b021ee64d09e4fa843f104c16b55a0e1f1ba3561 Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Wed, 26 Aug 2020 19:32:09 -0400 Subject: removed unnecessary check --- .../managers/screen/TextAndGraphicUpdateOperation.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java index 54c7d51d6..485a54fe6 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java @@ -560,8 +560,7 @@ class TextAndGraphicUpdateOperation extends Task { String currentScreenDataPrimaryGraphicName = (currentScreenData != null && currentScreenData.getGraphic() != null) ? currentScreenData.getGraphic().getValue() : null; String primaryGraphicName = updatedState.getPrimaryGraphic() != null ? updatedState.getPrimaryGraphic().getName() : null; return templateSupportsPrimaryArtwork - && !CompareUtils.areStringsEqual(currentScreenDataPrimaryGraphicName, primaryGraphicName, true, true) - && updatedState.getPrimaryGraphic() != null; + && !CompareUtils.areStringsEqual(currentScreenDataPrimaryGraphicName, primaryGraphicName, true, true); } /** @@ -575,8 +574,7 @@ class TextAndGraphicUpdateOperation extends Task { String currentScreenDataSecondaryGraphicName = (currentScreenData != null && currentScreenData.getSecondaryGraphic() != null) ? currentScreenData.getSecondaryGraphic().getValue() : null; String secondaryGraphicName = updatedState.getSecondaryGraphic() != null ? updatedState.getSecondaryGraphic().getName() : null; return templateSupportsSecondaryArtwork - && !CompareUtils.areStringsEqual(currentScreenDataSecondaryGraphicName, secondaryGraphicName, true, true) - && updatedState.getSecondaryGraphic() != null; + && !CompareUtils.areStringsEqual(currentScreenDataSecondaryGraphicName, secondaryGraphicName, true, true); } /** -- cgit v1.2.1 From 486d2aea3ae8b959bb49a8e01092025d9febb916 Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Wed, 26 Aug 2020 19:49:04 -0400 Subject: Added back null check --- .../managers/screen/TextAndGraphicUpdateOperation.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java index 485a54fe6..54c7d51d6 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java @@ -560,7 +560,8 @@ class TextAndGraphicUpdateOperation extends Task { String currentScreenDataPrimaryGraphicName = (currentScreenData != null && currentScreenData.getGraphic() != null) ? currentScreenData.getGraphic().getValue() : null; String primaryGraphicName = updatedState.getPrimaryGraphic() != null ? updatedState.getPrimaryGraphic().getName() : null; return templateSupportsPrimaryArtwork - && !CompareUtils.areStringsEqual(currentScreenDataPrimaryGraphicName, primaryGraphicName, true, true); + && !CompareUtils.areStringsEqual(currentScreenDataPrimaryGraphicName, primaryGraphicName, true, true) + && updatedState.getPrimaryGraphic() != null; } /** @@ -574,7 +575,8 @@ class TextAndGraphicUpdateOperation extends Task { String currentScreenDataSecondaryGraphicName = (currentScreenData != null && currentScreenData.getSecondaryGraphic() != null) ? currentScreenData.getSecondaryGraphic().getValue() : null; String secondaryGraphicName = updatedState.getSecondaryGraphic() != null ? updatedState.getSecondaryGraphic().getName() : null; return templateSupportsSecondaryArtwork - && !CompareUtils.areStringsEqual(currentScreenDataSecondaryGraphicName, secondaryGraphicName, true, true); + && !CompareUtils.areStringsEqual(currentScreenDataSecondaryGraphicName, secondaryGraphicName, true, true) + && updatedState.getSecondaryGraphic() != null; } /** -- cgit v1.2.1 From 10f5e261c3d089829c7b5dbec66874a57be66d88 Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Wed, 26 Aug 2020 21:20:45 -0400 Subject: Removed unnecessary logic --- .../managers/screen/TextAndGraphicUpdateOperation.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java index 54c7d51d6..485a54fe6 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java @@ -560,8 +560,7 @@ class TextAndGraphicUpdateOperation extends Task { String currentScreenDataPrimaryGraphicName = (currentScreenData != null && currentScreenData.getGraphic() != null) ? currentScreenData.getGraphic().getValue() : null; String primaryGraphicName = updatedState.getPrimaryGraphic() != null ? updatedState.getPrimaryGraphic().getName() : null; return templateSupportsPrimaryArtwork - && !CompareUtils.areStringsEqual(currentScreenDataPrimaryGraphicName, primaryGraphicName, true, true) - && updatedState.getPrimaryGraphic() != null; + && !CompareUtils.areStringsEqual(currentScreenDataPrimaryGraphicName, primaryGraphicName, true, true); } /** @@ -575,8 +574,7 @@ class TextAndGraphicUpdateOperation extends Task { String currentScreenDataSecondaryGraphicName = (currentScreenData != null && currentScreenData.getSecondaryGraphic() != null) ? currentScreenData.getSecondaryGraphic().getValue() : null; String secondaryGraphicName = updatedState.getSecondaryGraphic() != null ? updatedState.getSecondaryGraphic().getName() : null; return templateSupportsSecondaryArtwork - && !CompareUtils.areStringsEqual(currentScreenDataSecondaryGraphicName, secondaryGraphicName, true, true) - && updatedState.getSecondaryGraphic() != null; + && !CompareUtils.areStringsEqual(currentScreenDataSecondaryGraphicName, secondaryGraphicName, true, true); } /** -- cgit v1.2.1 From 6fa2e178b77fc190ff391c49ebe254243e8c45ae Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Wed, 26 Aug 2020 21:21:14 -0400 Subject: Fixed unit test --- .../managers/screen/TextAndGraphicUpdateOperationTest.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java index a279e3aec..292e828fd 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java @@ -5,6 +5,7 @@ import android.net.Uri; import androidx.test.ext.junit.runners.AndroidJUnit4; +import com.smartdevicelink.R; import com.smartdevicelink.managers.CompletionListener; import com.smartdevicelink.managers.ManagerUtility; import com.smartdevicelink.managers.file.FileManager; @@ -58,6 +59,7 @@ public class TextAndGraphicUpdateOperationTest { private Show currentScreenData; private CompletionListener listener; private TextAndGraphicManager.CurrentScreenDataUpdatedListener currentScreenDataUpdatedListener; + private SdlArtwork blankArtwork; ISdl internalInterface; FileManager fileManager; @@ -130,6 +132,11 @@ public class TextAndGraphicUpdateOperationTest { mediaTrackField = "dudes"; title = "dudes"; + blankArtwork = new SdlArtwork(); + blankArtwork.setType(FileType.GRAPHIC_PNG); + blankArtwork.setName("blankArtwork"); + blankArtwork.setResourceId(R.drawable.transparent); + textField1Type = MetadataType.MEDIA_TITLE; textField2Type = MetadataType.MEDIA_TITLE; textField3Type = MetadataType.MEDIA_TITLE; @@ -276,7 +283,7 @@ public class TextAndGraphicUpdateOperationTest { //Test: If there are no images to update, just send the text TextsAndGraphicsState textsAndGraphicsStateNullImages = new TextsAndGraphicsState(textField1, textField2, textField3, textField4, - mediaTrackField, title, null, null, textAlignment, textField1Type, textField2Type, textField3Type, textField4Type); + mediaTrackField, title, blankArtwork, blankArtwork, textAlignment, textField1Type, textField2Type, textField3Type, textField4Type); textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsStateNullImages, listener, currentScreenDataUpdatedListener); textAndGraphicUpdateOperation.onExecute(); assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getMainField1(), textField1); -- cgit v1.2.1 From 8e79cec4d0c43a70f161764a70b66261c62abccb Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Wed, 26 Aug 2020 23:16:23 -0400 Subject: Fixed Error with updating currentScreenData --- .../smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java index 485a54fe6..6252488a9 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java @@ -490,7 +490,7 @@ class TextAndGraphicUpdateOperation extends Task { currentScreenData.setSecondaryGraphic(show.getSecondaryGraphic()); } if (currentScreenDataUpdateListener != null) { - currentScreenDataUpdateListener.onUpdate(show); + currentScreenDataUpdateListener.onUpdate(currentScreenData); } } -- cgit v1.2.1 From 56771c0fe3ea9c8db96fd26f12b95a3694fb5d21 Mon Sep 17 00:00:00 2001 From: Kostiantyn Boskin Date: Thu, 27 Aug 2020 21:59:34 +0300 Subject: [0256] Refactor Fuel Information Related Vehicle Data (#1392) * [0256] - Add CapacityUnit - Refactor Fuel information - Fix tests * [0256] - Update tests data after code review - Add @Deprecated annotation - Fix JavaDoc * [0256] - Update tests after code review - Change since X.x --> since 6.0 * [0256] - Regenerate using Generator * [0256] - Fix tests * [0256] - Rollback formatting changes - Change order of methods to make the diff clear * [0256] - Rollback of UnsubscribeVehicleData && SubscribeVehicleData * [0256] - Rollback of SubscribeVehicleData && SubscribeVehicleDataResponse * [0256] - Rollback of OnVehicleData && GetVehicleData/Response * [0256] - Rollback of VehicleDataType && FuelRange && SubscribeVehicleData * Revert LF to CRLF line separators * Rollback javadoc * [VideoStreaming] - Fix tests, fix compilation errors * [0256] - Remove unused setFuelLevel_State * [0256] - Remove unused setFuelLevel_State * Revert LF to CRLF line separators * Update base/src/main/java/com/smartdevicelink/proxy/rpc/FuelRange.java Co-authored-by: Julian Kast * Update base/src/main/java/com/smartdevicelink/proxy/rpc/FuelRange.java Co-authored-by: Julian Kast * Update base/src/main/java/com/smartdevicelink/proxy/rpc/FuelRange.java Co-authored-by: Julian Kast * Update base/src/main/java/com/smartdevicelink/proxy/rpc/FuelRange.java Co-authored-by: Julian Kast * Update base/src/main/java/com/smartdevicelink/proxy/rpc/FuelRange.java Co-authored-by: Julian Kast * Update base/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleDataResponse.java Co-authored-by: Julian Kast * Update base/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleDataResponse.java Co-authored-by: Julian Kast * Update base/src/main/java/com/smartdevicelink/proxy/rpc/OnVehicleData.java Co-authored-by: Julian Kast * Update base/src/main/java/com/smartdevicelink/proxy/rpc/OnVehicleData.java Co-authored-by: Julian Kast * Update base/src/main/java/com/smartdevicelink/proxy/rpc/OnVehicleData.java Co-authored-by: Julian Kast * [0256] - Fix PR comments Co-authored-by: kboskin Co-authored-by: Vladyslav Mustafin Co-authored-by: Julian Kast --- .../java/com/smartdevicelink/test/TestValues.java | 2 + .../java/com/smartdevicelink/test/Validator.java | 18 ++- .../smartdevicelink/test/VehicleDataHelper.java | 9 ++ .../test/rpc/datatypes/FuelRangeTests.java | 24 +++- .../test/rpc/enums/CapacityUnitTests.java | 71 +++++++++ .../test/rpc/notifications/OnVehicleDataTests.java | 4 + .../rpc/responses/GetVehicleDataResponseTests.java | 4 + .../com/smartdevicelink/proxy/rpc/FuelRange.java | 160 ++++++++++++++++++++- .../smartdevicelink/proxy/rpc/GetVehicleData.java | 77 ++++++---- .../proxy/rpc/GetVehicleDataResponse.java | 72 +++++++--- .../smartdevicelink/proxy/rpc/OnVehicleData.java | 68 +++++++-- .../proxy/rpc/SubscribeVehicleData.java | 63 +++++--- .../proxy/rpc/SubscribeVehicleDataResponse.java | 42 ++++-- .../proxy/rpc/UnsubscribeVehicleData.java | 72 ++++++---- .../proxy/rpc/UnsubscribeVehicleDataResponse.java | 43 ++++-- .../proxy/rpc/enums/CapacityUnit.java | 57 ++++++++ .../proxy/rpc/enums/VehicleDataType.java | 2 + 17 files changed, 661 insertions(+), 127 deletions(-) create mode 100644 android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/CapacityUnitTests.java create mode 100644 base/src/main/java/com/smartdevicelink/proxy/rpc/enums/CapacityUnit.java diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/TestValues.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/TestValues.java index 05d0327a7..caa9f1e7f 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/TestValues.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/TestValues.java @@ -125,6 +125,7 @@ import com.smartdevicelink.proxy.rpc.enums.BitsPerSample; import com.smartdevicelink.proxy.rpc.enums.ButtonEventMode; import com.smartdevicelink.proxy.rpc.enums.ButtonName; import com.smartdevicelink.proxy.rpc.enums.ButtonPressMode; +import com.smartdevicelink.proxy.rpc.enums.CapacityUnit; import com.smartdevicelink.proxy.rpc.enums.CarModeStatus; import com.smartdevicelink.proxy.rpc.enums.CharacterSet; import com.smartdevicelink.proxy.rpc.enums.CompassDirection; @@ -335,6 +336,7 @@ public class TestValues { public static final VehicleDataResultCode GENERAL_VEHICLEDATARESULTCODE = VehicleDataResultCode.IGNORED; public static final ComponentVolumeStatus GENERAL_COMPONENTVOLUMESTATUS = ComponentVolumeStatus.LOW; public static final PresetBankCapabilities GENERAL_PRESETBANKCAPABILITIES = new PresetBankCapabilities(); + public static final CapacityUnit GENERAL_CAPACITYUNIT = CapacityUnit.KILOGRAMS; public static final VehicleDataEventStatus GENERAL_VEHCILEDATAEVENTSTATUS = VehicleDataEventStatus.YES; public static final VehicleDataEventStatus GENERAL_VEHICLEDATAEVENTSTATUS = VehicleDataEventStatus.YES; public static final TouchEventCapabilities GENERAL_TOUCHEVENTCAPABILITIES = new TouchEventCapabilities(); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/Validator.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/Validator.java index 6de391c41..4fa61368f 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/Validator.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/Validator.java @@ -2321,7 +2321,23 @@ public class Validator{ if (item1.get(i).getType() != item2.get(i).getType()) { return false; } - if (item1.get(i).getRange() != item2.get(i).getRange()) { + if (!item1.get(i).getRange().equals(item2.get(i).getRange())) { + return false; + } + + if (!item1.get(i).getCapacity().equals(item2.get(i).getCapacity())) { + return false; + } + + if (!item1.get(i).getCapacityUnit().equals(item2.get(i).getCapacityUnit())) { + return false; + } + + if (!item1.get(i).getLevel().equals(item2.get(i).getLevel())) { + return false; + } + + if (!item1.get(i).getLevelState().equals(item2.get(i).getLevelState())) { return false; } } diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/VehicleDataHelper.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/VehicleDataHelper.java index 542cf28c3..c314c7f9b 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/VehicleDataHelper.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/VehicleDataHelper.java @@ -20,6 +20,7 @@ import com.smartdevicelink.proxy.rpc.TireStatus; import com.smartdevicelink.proxy.rpc.WindowState; import com.smartdevicelink.proxy.rpc.WindowStatus; import com.smartdevicelink.proxy.rpc.enums.AmbientLightStatus; +import com.smartdevicelink.proxy.rpc.enums.CapacityUnit; import com.smartdevicelink.proxy.rpc.enums.CarModeStatus; import com.smartdevicelink.proxy.rpc.enums.CompassDirection; import com.smartdevicelink.proxy.rpc.enums.ComponentVolumeStatus; @@ -197,6 +198,10 @@ public class VehicleDataHelper{ // fuel range public static final FuelType FUEL_RANGE_TYPE = FuelType.GASOLINE; public static final Float FUEL_RANGE_RANGE = TestValues.GENERAL_FLOAT; + public static final Float FUEL_RANGE_CAPACITY = TestValues.GENERAL_FLOAT; + public static final CapacityUnit FUEL_RANGE_CAPACITY_UNIT = TestValues.GENERAL_CAPACITYUNIT; + public static final Float FUEL_RANGE_LEVEL = TestValues.GENERAL_FLOAT; + public static final ComponentVolumeStatus FUEL_RANGE_LEVEL_STATE = TestValues.GENERAL_COMPONENTVOLUMESTATUS; // Gear status public static final GearStatus GEAR_STATUS = new GearStatus(); @@ -336,6 +341,10 @@ public class VehicleDataHelper{ // FUEL_RANGE and FUEL_RANGE_LIST set up FUEL_RANGE.setType(FUEL_RANGE_TYPE); FUEL_RANGE.setRange(FUEL_RANGE_RANGE); + FUEL_RANGE.setCapacity(FUEL_RANGE_CAPACITY); + FUEL_RANGE.setCapacityUnit(FUEL_RANGE_CAPACITY_UNIT); + FUEL_RANGE.setLevel(FUEL_RANGE_LEVEL); + FUEL_RANGE.setLevelState(FUEL_RANGE_LEVEL_STATE); FUEL_RANGE_LIST.add(FUEL_RANGE); //WINDOW_STATUS and WINDOW_STATUS_LIST set up diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/FuelRangeTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/FuelRangeTests.java index f8bb07caf..6e23edc7a 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/FuelRangeTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/FuelRangeTests.java @@ -1,6 +1,8 @@ package com.smartdevicelink.test.rpc.datatypes; import com.smartdevicelink.proxy.rpc.FuelRange; +import com.smartdevicelink.proxy.rpc.enums.CapacityUnit; +import com.smartdevicelink.proxy.rpc.enums.ComponentVolumeStatus; import com.smartdevicelink.proxy.rpc.enums.FuelType; import com.smartdevicelink.test.JsonUtils; import com.smartdevicelink.test.TestValues; @@ -26,6 +28,10 @@ public class FuelRangeTests extends TestCase{ msg.setType(TestValues.GENERAL_FUELTYPE); msg.setRange(TestValues.GENERAL_FLOAT); + msg.setLevel(TestValues.GENERAL_FLOAT); + msg.setLevelState(TestValues.GENERAL_COMPONENTVOLUMESTATUS); + msg.setCapacity(TestValues.GENERAL_FLOAT); + msg.setCapacityUnit(TestValues.GENERAL_CAPACITYUNIT); } /** @@ -35,10 +41,18 @@ public class FuelRangeTests extends TestCase{ // Test Values FuelType fuelType = msg.getType(); float range = msg.getRange(); - + float level = msg.getLevel(); + ComponentVolumeStatus levelState = msg.getLevelState(); + CapacityUnit capacityUnit = msg.getCapacityUnit(); + float capacity = msg.getCapacity(); + // Valid Tests assertEquals(TestValues.MATCH, TestValues.GENERAL_FLOAT, range); assertEquals(TestValues.MATCH, TestValues.GENERAL_FUELTYPE, fuelType); + assertEquals(TestValues.MATCH, TestValues.GENERAL_FLOAT, level); + assertEquals(TestValues.MATCH, TestValues.GENERAL_COMPONENTVOLUMESTATUS, levelState); + assertEquals(TestValues.MATCH, TestValues.GENERAL_CAPACITYUNIT, capacityUnit); + assertEquals(TestValues.MATCH, TestValues.GENERAL_FLOAT, capacity); // Invalid/Null Tests FuelRange msg = new FuelRange(); @@ -46,6 +60,10 @@ public class FuelRangeTests extends TestCase{ assertNull(TestValues.NULL, msg.getType()); assertNull(TestValues.NULL, msg.getRange()); + assertNull(TestValues.NULL, msg.getLevel()); + assertNull(TestValues.NULL, msg.getLevelState()); + assertNull(TestValues.NULL, msg.getCapacityUnit()); + assertNull(TestValues.NULL, msg.getCapacity()); } public void testJson(){ @@ -54,6 +72,10 @@ public class FuelRangeTests extends TestCase{ try{ reference.put(FuelRange.KEY_TYPE, TestValues.GENERAL_FUELTYPE); reference.put(FuelRange.KEY_RANGE, (Float) TestValues.GENERAL_FLOAT); + reference.put(FuelRange.KEY_LEVEL, TestValues.GENERAL_FLOAT); + reference.put(FuelRange.KEY_LEVEL_STATE, TestValues.GENERAL_COMPONENTVOLUMESTATUS); + reference.put(FuelRange.KEY_CAPACITY, TestValues.GENERAL_FLOAT); + reference.put(FuelRange.KEY_CAPACITY_UNIT, TestValues.GENERAL_CAPACITYUNIT); JSONObject underTest = msg.serializeJSON(); assertEquals(TestValues.MATCH, reference.length(), underTest.length()); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/CapacityUnitTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/CapacityUnitTests.java new file mode 100644 index 000000000..4da32bebf --- /dev/null +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/CapacityUnitTests.java @@ -0,0 +1,71 @@ +package com.smartdevicelink.test.rpc.enums; + +import com.smartdevicelink.proxy.rpc.enums.CapacityUnit; + +import junit.framework.TestCase; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class CapacityUnitTests extends TestCase { + + /** + * Verifies that the enum values are not null upon valid assignment. + */ + public void testValidEnums () { + String example = "LITERS"; + CapacityUnit enumLiters = CapacityUnit.valueForString(example); + example = "KILOWATTHOURS"; + CapacityUnit enumKWH = CapacityUnit.valueForString(example); + example = "KILOGRAMS"; + CapacityUnit enumKilograms = CapacityUnit.valueForString(example); + + assertNotNull("LITERS returned null", enumLiters); + assertNotNull("KILOWATTHOURS returned null", enumKWH); + assertNotNull("KILOGRAMS returned null", enumKilograms); + } + + /** + * Verifies that an invalid assignment is null. + */ + public void testInvalidEnum () { + String example = "lONg"; + try { + CapacityUnit temp = CapacityUnit.valueForString(example); + assertNull("Result of valueForString should be null.", temp); + } + catch (IllegalArgumentException exception) { + fail("Invalid enum throws IllegalArgumentException."); + } + } + + /** + * Verifies that a null assignment is invalid. + */ + public void testNullEnum () { + String example = null; + try { + CapacityUnit temp = CapacityUnit.valueForString(example); + assertNull("Result of valueForString should be null.", temp); + } + catch (NullPointerException exception) { + fail("Null string throws NullPointerException."); + } + } + + /** + * Verifies the possible enum values of ButtonPressMode. + */ + public void testListEnum() { + List enumValueList = Arrays.asList(CapacityUnit.values()); + + List enumTestList = new ArrayList(); + enumTestList.add(CapacityUnit.KILOGRAMS); + enumTestList.add(CapacityUnit.KILOWATTHOURS); + enumTestList.add(CapacityUnit.LITERS); + + assertTrue("Enum value list does not match enum class list", + enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList)); + } +} diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnVehicleDataTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnVehicleDataTests.java index d333d3b5a..00718929c 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnVehicleDataTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnVehicleDataTests.java @@ -370,6 +370,10 @@ public class OnVehicleDataTests extends BaseRpcTests{ // FUEL_RANGE fuelRangeObj.put(FuelRange.KEY_TYPE, VehicleDataHelper.FUEL_RANGE_TYPE); fuelRangeObj.put(FuelRange.KEY_RANGE, VehicleDataHelper.FUEL_RANGE_RANGE); + fuelRangeObj.put(FuelRange.KEY_CAPACITY, VehicleDataHelper.FUEL_RANGE_CAPACITY); + fuelRangeObj.put(FuelRange.KEY_CAPACITY_UNIT, VehicleDataHelper.FUEL_RANGE_CAPACITY_UNIT); + fuelRangeObj.put(FuelRange.KEY_LEVEL, VehicleDataHelper.FUEL_RANGE_LEVEL); + fuelRangeObj.put(FuelRange.KEY_LEVEL_STATE, VehicleDataHelper.FUEL_RANGE_LEVEL_STATE); fuelRangeArrayObj.put(fuelRangeObj); // WINDOW_STATUS diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetVehicleDataResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetVehicleDataResponseTests.java index 6ebc03f80..896694f53 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetVehicleDataResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetVehicleDataResponseTests.java @@ -255,6 +255,10 @@ public class GetVehicleDataResponseTests extends BaseRpcTests{ // FUEL_RANGE fuelRangeObj.put(FuelRange.KEY_TYPE, VehicleDataHelper.FUEL_RANGE_TYPE); fuelRangeObj.put(FuelRange.KEY_RANGE, VehicleDataHelper.FUEL_RANGE_RANGE); + fuelRangeObj.put(FuelRange.KEY_CAPACITY, VehicleDataHelper.FUEL_RANGE_CAPACITY); + fuelRangeObj.put(FuelRange.KEY_CAPACITY_UNIT, VehicleDataHelper.FUEL_RANGE_CAPACITY_UNIT); + fuelRangeObj.put(FuelRange.KEY_LEVEL, VehicleDataHelper.FUEL_RANGE_LEVEL); + fuelRangeObj.put(FuelRange.KEY_LEVEL_STATE, VehicleDataHelper.FUEL_RANGE_LEVEL_STATE); fuelRangeArrayObj.put(fuelRangeObj); //GEAR_STATUS diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/FuelRange.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/FuelRange.java index 1457a7459..334f6eb4e 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/FuelRange.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/FuelRange.java @@ -32,14 +32,84 @@ package com.smartdevicelink.proxy.rpc; import com.smartdevicelink.proxy.RPCStruct; +import com.smartdevicelink.proxy.rpc.enums.CapacityUnit; +import com.smartdevicelink.proxy.rpc.enums.ComponentVolumeStatus; import com.smartdevicelink.proxy.rpc.enums.FuelType; import com.smartdevicelink.util.SdlDataTypeConverter; import java.util.Hashtable; -public class FuelRange extends RPCStruct{ +/** + * + *

Parameter List

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Param NameTypeDescriptionRequiredNotesVersion Available
typeFuelTypeN
rangeFloatThe estimate range in KM the vehicle can travel based on fuel level and consumption.N{"num_min_value": 0.0, "num_max_value": 10000.0}
levelFloatThe relative remaining capacity of this fuel type (percentage).N{"num_min_value": -6.0, "num_max_value": 1000000.0}SmartDeviceLink 7.0.0
levelStateComponentVolumeStatusThe fuel level stateNSmartDeviceLink 7.0.0
capacityFloatThe absolute capacity of this fuel type.N{"num_min_value": 0.0, "num_max_value": 1000000.0}SmartDeviceLink 7.0.0
capacityUnitCapacityUnitThe unit of the capacity of this fuel type such as liters for gasoline or kWh forbatteries.NSmartDeviceLink 7.0.0
+ * @since SmartDeviceLink 5.0.0 + */ +public class FuelRange extends RPCStruct { public static final String KEY_TYPE = "type"; public static final String KEY_RANGE = "range"; + public static final String KEY_LEVEL = "level"; + public static final String KEY_LEVEL_STATE = "levelState"; + public static final String KEY_CAPACITY = "capacity"; + public static final String KEY_CAPACITY_UNIT = "capacityUnit"; /** * Constructs a new FuelRange object @@ -96,4 +166,92 @@ public class FuelRange extends RPCStruct{ public void setRange(Float range) { setValue(KEY_RANGE, range); } + + /** + * Sets the level. + * + * @param level The relative remaining capacity of this fuel type (percentage). + * {"num_min_value": -6.0, "num_max_value": 1000000.0} + * @since SmartDeviceLink 7.0.0 + */ + public void setLevel(Float level) { + setValue(KEY_LEVEL, level); + } + + /** + * Gets the level. + * + * @return Float The relative remaining capacity of this fuel type (percentage). + * {"num_min_value": -6.0, "num_max_value": 1000000.0} + * @since SmartDeviceLink 7.0.0 + */ + public Float getLevel() { + Object object = getValue(KEY_LEVEL); + return SdlDataTypeConverter.objectToFloat(object); + } + + /** + * Sets the levelState. + * + * @param levelState The fuel level state + * @since SmartDeviceLink 7.0.0 + */ + public void setLevelState(ComponentVolumeStatus levelState) { + setValue(KEY_LEVEL_STATE, levelState); + } + + /** + * Gets the levelState. + * + * @return ComponentVolumeStatus The fuel level state + * @since SmartDeviceLink 7.0.0 + */ + public ComponentVolumeStatus getLevelState() { + return (ComponentVolumeStatus) getObject(ComponentVolumeStatus.class, KEY_LEVEL_STATE); + } + + /** + * Sets the capacity. + * + * @param capacity The absolute capacity of this fuel type. + * {"num_min_value": 0.0, "num_max_value": 1000000.0} + * @since SmartDeviceLink 7.0.0 + */ + public void setCapacity(Float capacity) { + setValue(KEY_CAPACITY, capacity); + } + + /** + * Gets the capacity. + * + * @return Float The absolute capacity of this fuel type. + * {"num_min_value": 0.0, "num_max_value": 1000000.0} + * @since SmartDeviceLink 7.0.0 + */ + public Float getCapacity() { + Object object = getValue(KEY_CAPACITY); + return SdlDataTypeConverter.objectToFloat(object); + } + + /** + * Sets the capacityUnit. + * + * @param capacityUnit The unit of the capacity of this fuel type such as liters for gasoline or kWh for + * batteries. + * @since SmartDeviceLink 7.0.0 + */ + public void setCapacityUnit(CapacityUnit capacityUnit) { + setValue(KEY_CAPACITY_UNIT, capacityUnit); + } + + /** + * Gets the capacityUnit. + * + * @return CapacityUnit The unit of the capacity of this fuel type such as liters for gasoline or kWh for + * batteries. + * @since SmartDeviceLink 7.0.0 + */ + public CapacityUnit getCapacityUnit() { + return (CapacityUnit) getObject(CapacityUnit.class, KEY_CAPACITY_UNIT); + } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleData.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleData.java index 4699de61f..b08a18e5f 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleData.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleData.java @@ -76,18 +76,26 @@ import java.util.Hashtable; * * fuelLevel * Boolean - * The fuel level in the tank (percentage) + * The fuel level in the tank (percentage). This parameter is deprecated starting RPC Spec7.0, please see fuelRange. * N * Subscribable - * SmartDeviceLink 2.0 + * SmartDeviceLink 7.0.0 * * * fuelLevel_State * Boolean - * The fuel level state + * The fuel level state. This parameter is deprecated starting RPC Spec 7.0, please seefuelRange. * N * Subscribable - * SmartDeviceLink 2.0 + * SmartDeviceLink 7.0.0 + * + * + * fuelRange + * Boolean + * The fuel type, estimated range in KM, fuel level/capacity and fuel level state for thevehicle. See struct FuelRange for details. + * N + * Subscribable + * SmartDeviceLink 5.0.0 * * * instantFuelConsumption @@ -281,7 +289,6 @@ public class GetVehicleData extends RPCRequest { public static final String KEY_SPEED = "speed"; public static final String KEY_RPM = "rpm"; public static final String KEY_EXTERNAL_TEMPERATURE = "externalTemperature"; - public static final String KEY_FUEL_LEVEL = "fuelLevel"; public static final String KEY_VIN = "vin"; public static final String KEY_PRNDL = "prndl"; public static final String KEY_TIRE_PRESSURE = "tirePressure"; @@ -289,7 +296,6 @@ public class GetVehicleData extends RPCRequest { public static final String KEY_ENGINE_OIL_LIFE = "engineOilLife"; public static final String KEY_ODOMETER = "odometer"; public static final String KEY_GPS = "gps"; - public static final String KEY_FUEL_LEVEL_STATE = "fuelLevel_State"; public static final String KEY_INSTANT_FUEL_CONSUMPTION = "instantFuelConsumption"; public static final String KEY_BELT_STATUS = "beltStatus"; public static final String KEY_BODY_INFORMATION = "bodyInformation"; @@ -311,6 +317,17 @@ public class GetVehicleData extends RPCRequest { public static final String KEY_WINDOW_STATUS = "windowStatus"; public static final String KEY_HANDS_OFF_STEERING = "handsOffSteering"; public static final String KEY_GEAR_STATUS = "gearStatus"; + /** + * @deprecated + */ + @Deprecated + public static final String KEY_FUEL_LEVEL = "fuelLevel"; + + /** + * @deprecated + */ + @Deprecated + public static final String KEY_FUEL_LEVEL_STATE = "fuelLevel_State"; /** * Constructs a new GetVehicleData object @@ -350,15 +367,35 @@ public class GetVehicleData extends RPCRequest { public Boolean getRpm() { return getBoolean(KEY_RPM); } + + /** + * Sets the fuelLevel. + * + * @param fuelLevel The fuel level in the tank (percentage). This parameter is deprecated starting RPC Spec + * 7.0, please see fuelRange. + */ + @Deprecated public void setFuelLevel(Boolean fuelLevel) { setParameters(KEY_FUEL_LEVEL, fuelLevel); } + + /** + * Gets the fuelLevel. + * + * @return Boolean The fuel level in the tank (percentage). This parameter is deprecated starting RPC Spec + * 7.0, please see fuelRange. + */ + @Deprecated public Boolean getFuelLevel() { return getBoolean(KEY_FUEL_LEVEL); } + + @Deprecated public void setFuelLevelState(Boolean fuelLevelState) { setParameters(KEY_FUEL_LEVEL_STATE, fuelLevelState); } + + @Deprecated public Boolean getFuelLevelState() { return getBoolean(KEY_FUEL_LEVEL_STATE); } @@ -368,6 +405,15 @@ public class GetVehicleData extends RPCRequest { public Boolean getInstantFuelConsumption() { return getBoolean(KEY_INSTANT_FUEL_CONSUMPTION); } + + public void setFuelRange(Boolean fuelRange) { + setParameters(KEY_FUEL_RANGE, fuelRange); + } + + public Boolean getFuelRange() { + return getBoolean(KEY_FUEL_RANGE); + } + public void setExternalTemperature(Boolean externalTemperature) { setParameters(KEY_EXTERNAL_TEMPERATURE, externalTemperature); } @@ -509,25 +555,6 @@ public class GetVehicleData extends RPCRequest { return getBoolean(KEY_MY_KEY); } - /** - * Sets a boolean value. If true, gets fuelRange data - * @param fuelRange - * a boolean value - */ - public void setFuelRange(Boolean fuelRange) { - setParameters(KEY_FUEL_RANGE, fuelRange); - } - - /** - * Gets a boolean value. - * - * @return Boolean -a Boolean value. - * - */ - public Boolean getFuelRange() { - return getBoolean(KEY_FUEL_RANGE); - } - /** * Sets a boolean value. If true, subscribes turnSignal data * @param turnSignal a boolean value diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleDataResponse.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleDataResponse.java index 1226baa45..6c619c010 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleDataResponse.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleDataResponse.java @@ -54,36 +54,44 @@ import java.util.List; * @since SmartDeviceLink 2.0 */ public class GetVehicleDataResponse extends RPCResponse { + public static final String KEY_GPS = "gps"; public static final String KEY_SPEED = "speed"; public static final String KEY_RPM = "rpm"; - public static final String KEY_EXTERNAL_TEMPERATURE = "externalTemperature"; + /** + * @deprecated + */ + @Deprecated public static final String KEY_FUEL_LEVEL = "fuelLevel"; + /** + * @deprecated + */ + @Deprecated + public static final String KEY_FUEL_LEVEL_STATE = "fuelLevel_State"; + public static final String KEY_INSTANT_FUEL_CONSUMPTION = "instantFuelConsumption"; + public static final String KEY_FUEL_RANGE = "fuelRange"; + public static final String KEY_EXTERNAL_TEMPERATURE = "externalTemperature"; + public static final String KEY_TURN_SIGNAL = "turnSignal"; public static final String KEY_VIN = "vin"; public static final String KEY_PRNDL = "prndl"; public static final String KEY_TIRE_PRESSURE = "tirePressure"; - public static final String KEY_ENGINE_TORQUE = "engineTorque"; - public static final String KEY_ENGINE_OIL_LIFE = "engineOilLife"; public static final String KEY_ODOMETER = "odometer"; - public static final String KEY_GPS = "gps"; - public static final String KEY_FUEL_LEVEL_STATE = "fuelLevel_State"; - public static final String KEY_INSTANT_FUEL_CONSUMPTION = "instantFuelConsumption"; public static final String KEY_BELT_STATUS = "beltStatus"; public static final String KEY_BODY_INFORMATION = "bodyInformation"; public static final String KEY_DEVICE_STATUS = "deviceStatus"; public static final String KEY_DRIVER_BRAKING = "driverBraking"; public static final String KEY_WIPER_STATUS = "wiperStatus"; public static final String KEY_HEAD_LAMP_STATUS = "headLampStatus"; + public static final String KEY_ENGINE_TORQUE = "engineTorque"; public static final String KEY_ACC_PEDAL_POSITION = "accPedalPosition"; public static final String KEY_STEERING_WHEEL_ANGLE = "steeringWheelAngle"; + public static final String KEY_ENGINE_OIL_LIFE = "engineOilLife"; + public static final String KEY_ELECTRONIC_PARK_BRAKE_STATUS = "electronicParkBrakeStatus"; + public static final String KEY_CLOUD_APP_VEHICLE_ID = "cloudAppVehicleID"; public static final String KEY_E_CALL_INFO = "eCallInfo"; public static final String KEY_AIRBAG_STATUS = "airbagStatus"; public static final String KEY_EMERGENCY_EVENT = "emergencyEvent"; public static final String KEY_CLUSTER_MODE_STATUS = "clusterModeStatus"; public static final String KEY_MY_KEY = "myKey"; - public static final String KEY_FUEL_RANGE = "fuelRange"; - public static final String KEY_TURN_SIGNAL = "turnSignal"; - public static final String KEY_ELECTRONIC_PARK_BRAKE_STATUS = "electronicParkBrakeStatus"; - public static final String KEY_CLOUD_APP_VEHICLE_ID = "cloudAppVehicleID"; public static final String KEY_WINDOW_STATUS = "windowStatus"; public static final String KEY_GEAR_STATUS = "gearStatus"; public static final String KEY_HANDS_OFF_STEERING = "handsOffSteering"; @@ -128,19 +136,49 @@ public class GetVehicleDataResponse extends RPCResponse { public Integer getRpm() { return getInteger(KEY_RPM); } - public void setFuelLevel(Double fuelLevel) { - setParameters(KEY_FUEL_LEVEL, fuelLevel); - } - public Double getFuelLevel() { - Object object = getParameters(KEY_FUEL_LEVEL); - return SdlDataTypeConverter.objectToDouble(object); - } + + /** + * Sets Fuel Level State + * @param fuelLevelState a ComponentVolumeStatus related to FuelLevel State + */ + @Deprecated public void setFuelLevelState(ComponentVolumeStatus fuelLevelState) { setParameters(KEY_FUEL_LEVEL_STATE, fuelLevelState); } + /** + * Gets Fuel Level State + * @return a ComponentVolumeStatus related to FuelLevel State + */ + @Deprecated + @SuppressWarnings("unchecked") public ComponentVolumeStatus getFuelLevelState() { return (ComponentVolumeStatus) getObject(ComponentVolumeStatus.class, KEY_FUEL_LEVEL_STATE); } + + /** + * Sets the fuelLevel. + * + * @param fuelLevel The fuel level in the tank (percentage). This parameter is deprecated starting RPC Spec + * 7.0, please see fuelRange. + * @since SmartDeviceLink 7.0.0 + */ + @Deprecated + public void setFuelLevel(Double fuelLevel) { + setParameters(KEY_FUEL_LEVEL, fuelLevel); + } + + /** + * Gets the fuelLevel. + * + * @return Double The fuel level in the tank (percentage). This parameter is deprecated starting RPC Spec + * 7.0, please see fuelRange. + * @since SmartDeviceLink 7.0.0 + */ + @Deprecated + public Double getFuelLevel() { + Object object = getParameters(KEY_FUEL_LEVEL); + return SdlDataTypeConverter.objectToDouble(object); + } public void setInstantFuelConsumption(Double instantFuelConsumption) { setParameters(KEY_INSTANT_FUEL_CONSUMPTION, instantFuelConsumption); } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnVehicleData.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnVehicleData.java index 74fcda171..a54aebdd5 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnVehicleData.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnVehicleData.java @@ -93,19 +93,27 @@ import java.util.List; * * * fuelLevel - * Float - * The fuel level in the tank (percentage) + * Boolean + * The fuel level in the tank (percentage). This parameter is deprecated starting RPC Spec7.0, please see fuelRange. * N * Subscribable - * SmartDeviceLink 2.0 + * SmartDeviceLink 7.0.0 * * * fuelLevel_State - * ComponentVolumeStatus - * The fuel level state (Ok/Low) + * Boolean + * The fuel level state. This parameter is deprecated starting RPC Spec 7.0, please seefuelRange. * N * Subscribable - * SmartDeviceLink 2.0 + * SmartDeviceLink 7.0.0 + * + * + * fuelRange + * Boolean + * The fuel type, estimated range in KM, fuel level/capacity and fuel level state for thevehicle. See struct FuelRange for details. + * N + * {"array_min_size": 0, "array_max_size": 100} + * SmartDeviceLink 5.0.0 * * * instantFuelConsumption @@ -324,7 +332,6 @@ public class OnVehicleData extends RPCNotification { public static final String KEY_SPEED = "speed"; public static final String KEY_RPM = "rpm"; public static final String KEY_EXTERNAL_TEMPERATURE = "externalTemperature"; - public static final String KEY_FUEL_LEVEL = "fuelLevel"; public static final String KEY_VIN = "vin"; public static final String KEY_PRNDL = "prndl"; public static final String KEY_TIRE_PRESSURE = "tirePressure"; @@ -332,7 +339,6 @@ public class OnVehicleData extends RPCNotification { public static final String KEY_ENGINE_OIL_LIFE = "engineOilLife"; public static final String KEY_ODOMETER = "odometer"; public static final String KEY_GPS = "gps"; - public static final String KEY_FUEL_LEVEL_STATE = "fuelLevel_State"; public static final String KEY_INSTANT_FUEL_CONSUMPTION = "instantFuelConsumption"; public static final String KEY_BELT_STATUS = "beltStatus"; public static final String KEY_BODY_INFORMATION = "bodyInformation"; @@ -354,6 +360,16 @@ public class OnVehicleData extends RPCNotification { public static final String KEY_HANDS_OFF_STEERING = "handsOffSteering"; public static final String KEY_WINDOW_STATUS = "windowStatus"; public static final String KEY_GEAR_STATUS = "gearStatus"; + /** + * @deprecated + */ + @Deprecated + public static final String KEY_FUEL_LEVEL = "fuelLevel"; + /** + * @deprecated + */ + @Deprecated + public static final String KEY_FUEL_LEVEL_STATE = "fuelLevel_State"; public OnVehicleData() { @@ -382,16 +398,34 @@ public class OnVehicleData extends RPCNotification { public Integer getRpm() { return getInteger(KEY_RPM); } + + /** + * Sets the fuelLevel. + * + * @param fuelLevel The fuel level in the tank (percentage). This parameter is deprecated starting RPC Spec + * 7.0, please see fuelRange. + */ + @Deprecated public void setFuelLevel(Double fuelLevel) { setParameters(KEY_FUEL_LEVEL, fuelLevel); } + + /** + * Gets the fuelLevel. + * + * @return Float The fuel level in the tank (percentage). This parameter is deprecated starting RPC Spec + * 7.0, please see fuelRange. + */ + @Deprecated public Double getFuelLevel() { Object object = getParameters(KEY_FUEL_LEVEL); return SdlDataTypeConverter.objectToDouble(object); } + @Deprecated public void setFuelLevelState(ComponentVolumeStatus fuelLevelState) { setParameters(KEY_FUEL_LEVEL_STATE, fuelLevelState); } + @Deprecated public ComponentVolumeStatus getFuelLevelState() { return (ComponentVolumeStatus) getObject(ComponentVolumeStatus.class, KEY_FUEL_LEVEL_STATE); } @@ -561,17 +595,25 @@ public class OnVehicleData extends RPCNotification { } /** - * Sets Fuel Range List. Fuel Range - The estimate range in KM the vehicle can travel based on fuel level and consumption. - * @param fuelRange + * Sets the fuelRange. + * + * @param fuelRange The fuel type, estimated range in KM, fuel level/capacity and fuel level state for the + * vehicle. See struct FuelRange for details. + * {"array_min_size": 0, "array_max_size": 100} + * @since SmartDeviceLink 5.0.0 */ public void setFuelRange(List fuelRange) { setParameters(KEY_FUEL_RANGE, fuelRange); } /** - * Gets Fuel Range List. - * @return List - * Fuel Range - The estimate range in KM the vehicle can travel based on fuel level and consumption. + * Gets the fuelRange. + * + * @return List The fuel type, estimated range in KM, fuel level/capacity and fuel level state for the + * vehicle. See struct FuelRange for details. + * {"array_min_size": 0, "array_max_size": 100} + * @since SmartDeviceLink 5.0.0 + */ @SuppressWarnings("unchecked") public List getFuelRange() { diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeVehicleData.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeVehicleData.java index 9b67c145f..89e30c6df 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeVehicleData.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeVehicleData.java @@ -84,18 +84,26 @@ import java.util.Hashtable; * * fuelLevel * Boolean - * The fuel level in the tank (percentage) + * The fuel level in the tank (percentage). This parameter is deprecated starting RPC Spec7.0, please see fuelRange. * N * Subscribable - * SmartDeviceLink 2.0 + * SmartDeviceLink 7.0.0 * * * fuelLevel_State * Boolean - * The fuel level state + * The fuel level state. This parameter is deprecated starting RPC Spec 7.0, please seefuelRange. * N * Subscribable - * SmartDeviceLink 2.0 + * SmartDeviceLink 7.0.0 + * + * + * fuelRange + * Boolean + * The fuel type, estimated range in KM, fuel level/capacity and fuel level state for thevehicle. See struct FuelRange for details. + * N + * Subscribable + * SmartDeviceLink 5.0.0 * * * instantFuelConsumption @@ -315,14 +323,12 @@ import java.util.Hashtable; public class SubscribeVehicleData extends RPCRequest { public static final String KEY_RPM = "rpm"; public static final String KEY_EXTERNAL_TEMPERATURE = "externalTemperature"; - public static final String KEY_FUEL_LEVEL = "fuelLevel"; public static final String KEY_PRNDL = "prndl"; public static final String KEY_TIRE_PRESSURE = "tirePressure"; public static final String KEY_ENGINE_TORQUE = "engineTorque"; public static final String KEY_ENGINE_OIL_LIFE = "engineOilLife"; public static final String KEY_ODOMETER = "odometer"; public static final String KEY_GPS = "gps"; - public static final String KEY_FUEL_LEVEL_STATE = "fuelLevel_State"; public static final String KEY_INSTANT_FUEL_CONSUMPTION = "instantFuelConsumption"; public static final String KEY_BELT_STATUS = "beltStatus"; public static final String KEY_BODY_INFORMATION = "bodyInformation"; @@ -345,6 +351,16 @@ public class SubscribeVehicleData extends RPCRequest { public static final String KEY_HANDS_OFF_STEERING = "handsOffSteering"; public static final String KEY_WINDOW_STATUS = "windowStatus"; public static final String KEY_GEAR_STATUS = "gearStatus"; + /** + * @deprecated + */ + @Deprecated + public static final String KEY_FUEL_LEVEL = "fuelLevel"; + /** + * @deprecated + */ + @Deprecated + public static final String KEY_FUEL_LEVEL_STATE = "fuelLevel_State"; /** * Constructs a new SubscribeVehicleData object @@ -426,22 +442,23 @@ public class SubscribeVehicleData extends RPCRequest { } /** - * Sets a boolean value. If true, subscribes FuelLevel data + * Sets the fuelLevel. * - * @param fuelLevel - * a boolean value + * @param fuelLevel The fuel level in the tank (percentage). This parameter is deprecated starting RPC Spec + * 7.0, please see fuelRange. */ + @Deprecated public void setFuelLevel(Boolean fuelLevel) { setParameters(KEY_FUEL_LEVEL, fuelLevel); } /** - * Gets a boolean value. If true, means the FuelLevel data has been - * subscribed. + * Gets the fuelLevel. * - * @return Boolean -a Boolean value. If true, means the FuelLevel data has - * been subscribed. + * @return Float The fuel level in the tank (percentage). This parameter is deprecated starting RPC Spec + * 7.0, please see fuelRange. */ + @Deprecated public Boolean getFuelLevel() { return getBoolean(KEY_FUEL_LEVEL); } @@ -452,6 +469,7 @@ public class SubscribeVehicleData extends RPCRequest { * @param fuelLevelState * a boolean value */ + @Deprecated public void setFuelLevelState(Boolean fuelLevelState) { setParameters(KEY_FUEL_LEVEL_STATE, fuelLevelState); } @@ -463,7 +481,8 @@ public class SubscribeVehicleData extends RPCRequest { * @return Boolean -a Boolean value. If true, means the fuelLevelState data * has been subscribed. */ - public Boolean getFuelLevelState() { + @Deprecated + public Boolean getFuelLevelState() { return getBoolean(KEY_FUEL_LEVEL_STATE); } @@ -821,22 +840,22 @@ public class SubscribeVehicleData extends RPCRequest { } /** - * Sets a boolean value. If true, subscribes fuelRange data + * Sets the fuelRange. * - * @param fuelRange - * a boolean value + * @param fuelRange The fuel type, estimated range in KM, fuel level/capacity and fuel level state for the + * vehicle. See struct FuelRange for details. + * @since SmartDeviceLink 5.0.0 */ public void setFuelRange(Boolean fuelRange) { setParameters(KEY_FUEL_RANGE, fuelRange); } /** - * Gets a boolean value. If true, means the Fuel Range data has been - * subscribed. - * - * @return Boolean -a Boolean value. If true, means the Fuel Range data - * has been subscribed. + * Gets the fuelRange. * + * @return Boolean The fuel type, estimated range in KM, fuel level/capacity and fuel level state for the + * vehicle. See struct FuelRange for details. + * @since SmartDeviceLink 5.0.0 */ public Boolean getFuelRange() { return getBoolean(KEY_FUEL_RANGE); diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeVehicleDataResponse.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeVehicleDataResponse.java index cb869336a..95609469f 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeVehicleDataResponse.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeVehicleDataResponse.java @@ -47,7 +47,6 @@ import java.util.Hashtable; public class SubscribeVehicleDataResponse extends RPCResponse { public static final String KEY_SPEED = "speed"; public static final String KEY_RPM = "rpm"; - public static final String KEY_FUEL_LEVEL = "fuelLevel"; public static final String KEY_EXTERNAL_TEMPERATURE = "externalTemperature"; public static final String KEY_PRNDL = "prndl"; public static final String KEY_TIRE_PRESSURE = "tirePressure"; @@ -55,7 +54,6 @@ public class SubscribeVehicleDataResponse extends RPCResponse { public static final String KEY_ENGINE_OIL_LIFE = "engineOilLife"; public static final String KEY_ODOMETER = "odometer"; public static final String KEY_GPS = "gps"; - public static final String KEY_FUEL_LEVEL_STATE = "fuelLevel_State"; public static final String KEY_INSTANT_FUEL_CONSUMPTION = "instantFuelConsumption"; public static final String KEY_BELT_STATUS = "beltStatus"; public static final String KEY_BODY_INFORMATION = "bodyInformation"; @@ -77,6 +75,16 @@ public class SubscribeVehicleDataResponse extends RPCResponse { public static final String KEY_GEAR_STATUS = "gearStatus"; public static final String KEY_HANDS_OFF_STEERING = "handsOffSteering"; public static final String KEY_WINDOW_STATUS = "windowStatus"; + /** + * @deprecated + */ + @Deprecated + public static final String KEY_FUEL_LEVEL = "fuelLevel"; + /** + * @deprecated + */ + @Deprecated + public static final String KEY_FUEL_LEVEL_STATE = "fuelLevel_State"; /** * Constructs a new SubscribeVehicleDataResponse object @@ -151,17 +159,23 @@ public class SubscribeVehicleDataResponse extends RPCResponse { return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_RPM); } /** - * Sets Fuel Level - * @param fuelLevel a VehicleDataResult related to Fuel Level + * Sets the fuelLevel. + * + * @param fuelLevel The fuel level in the tank (percentage). This parameter is deprecated starting RPC Spec + * 7.0, please see fuelRange. */ + @Deprecated public void setFuelLevel(VehicleDataResult fuelLevel) { setParameters(KEY_FUEL_LEVEL, fuelLevel); } /** - * Gets Fuel Level - * @return a VehicleDataResult related to FuelLevel + * Gets the fuelLevel. + * + * @return VehicleDataResult The fuel level in the tank (percentage). This parameter is deprecated starting RPC Spec + * 7.0, please see fuelRange. */ @SuppressWarnings("unchecked") + @Deprecated public VehicleDataResult getFuelLevel() { return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_FUEL_LEVEL); } @@ -169,6 +183,7 @@ public class SubscribeVehicleDataResponse extends RPCResponse { * Sets Fuel Level State * @param fuelLevelState a VehicleDataResult related to FuelLevel State */ + @Deprecated public void setFuelLevelState(VehicleDataResult fuelLevelState) { setParameters(KEY_FUEL_LEVEL_STATE, fuelLevelState); } @@ -176,6 +191,7 @@ public class SubscribeVehicleDataResponse extends RPCResponse { * Gets Fuel Level State * @return a VehicleDataResult related to FuelLevel State */ + @Deprecated @SuppressWarnings("unchecked") public VehicleDataResult getFuelLevelState() { return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_FUEL_LEVEL_STATE); @@ -443,16 +459,22 @@ public class SubscribeVehicleDataResponse extends RPCResponse { } /** - * Sets Fuel Range - * @param fuelRange a VehicleDataResult related to the fuel range + * Sets the fuelRange. + * + * @param fuelRange The fuel type, estimated range in KM, fuel level/capacity and fuel level state for the + * vehicle. See struct FuelRange for details. + * @since SmartDeviceLink 5.0.0 */ public void setFuelRange(VehicleDataResult fuelRange) { setParameters(KEY_FUEL_RANGE, fuelRange); } /** - * Gets Fuel Range - * @return a VehicleDataResult related to the fuel range + * Gets the fuelRange. + * + * @return VehicleDataResult The fuel type, estimated range in KM, fuel level/capacity and fuel level state for the + * vehicle. See struct FuelRange for details. + * @since SmartDeviceLink 5.0.0 */ @SuppressWarnings("unchecked") public VehicleDataResult getFuelRange() { diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleData.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleData.java index 5a998a268..ea2822a35 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleData.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleData.java @@ -79,18 +79,26 @@ import java.util.Hashtable; * * fuelLevel * Boolean - * The fuel level in the tank (percentage) + * The fuel level in the tank (percentage). This parameter is deprecated starting RPC Spec7.0, please see fuelRange. * N * Subscribable - * SmartDeviceLink 2.0 + * SmartDeviceLink 7.0.0 * * * fuelLevel_State * Boolean - * The fuel level state + * The fuel level state. This parameter is deprecated starting RPC Spec 7.0, please seefuelRange. * N * Subscribable - * SmartDeviceLink 2.0 + * SmartDeviceLink 7.0.0 + * + * + * fuelRange + * Boolean + * The fuel type, estimated range in KM, fuel level/capacity and fuel level state for thevehicle. See struct FuelRange for details. + * N + * Subscribable + * SmartDeviceLink 5.0.0 * * * instantFuelConsumption @@ -301,14 +309,12 @@ public class UnsubscribeVehicleData extends RPCRequest { public static final String KEY_SPEED = "speed"; public static final String KEY_RPM = "rpm"; public static final String KEY_EXTERNAL_TEMPERATURE = "externalTemperature"; - public static final String KEY_FUEL_LEVEL = "fuelLevel"; public static final String KEY_PRNDL = "prndl"; public static final String KEY_TIRE_PRESSURE = "tirePressure"; public static final String KEY_ENGINE_TORQUE = "engineTorque"; public static final String KEY_ENGINE_OIL_LIFE = "engineOilLife"; public static final String KEY_ODOMETER = "odometer"; public static final String KEY_GPS = "gps"; - public static final String KEY_FUEL_LEVEL_STATE = "fuelLevel_State"; public static final String KEY_INSTANT_FUEL_CONSUMPTION = "instantFuelConsumption"; public static final String KEY_BELT_STATUS = "beltStatus"; public static final String KEY_BODY_INFORMATION = "bodyInformation"; @@ -330,6 +336,16 @@ public class UnsubscribeVehicleData extends RPCRequest { public static final String KEY_HANDS_OFF_STEERING = "handsOffSteering"; public static final String KEY_GEAR_STATUS = "gearStatus"; public static final String KEY_WINDOW_STATUS = "windowStatus"; + /** + * @deprecated + */ + @Deprecated + public static final String KEY_FUEL_LEVEL = "fuelLevel"; + /** + * @deprecated + */ + @Deprecated + public static final String KEY_FUEL_LEVEL_STATE = "fuelLevel_State"; /** * Constructs a new UnsubscribeVehicleData object @@ -411,43 +427,47 @@ public class UnsubscribeVehicleData extends RPCRequest { } /** - * Sets a boolean value. If true, unsubscribes from FuelLevel data + * Sets the fuelLevel. * - * @param fuelLevel - * a boolean value + * @param fuelLevel The fuel level in the tank (percentage). This parameter is deprecated starting RPC Spec + * 7.0, please see fuelRange. */ + @Deprecated public void setFuelLevel(Boolean fuelLevel) { setParameters(KEY_FUEL_LEVEL, fuelLevel); } /** - * Gets a boolean value. If true, means the FuelLevel data has been - * unsubscribed. + * Gets the fuelLevel. * - * @return Boolean -a Boolean value. If true, means the FuelLevel data has - * been unsubscribed. + * @return Boolean The fuel level in the tank (percentage). This parameter is deprecated starting RPC Spec + * 7.0, please see fuelRange. */ + @Deprecated public Boolean getFuelLevel() { return getBoolean(KEY_FUEL_LEVEL); } - /** - * Sets a boolean value. If true, unsubscribes from fuelLevelState data - * - * @param fuelLevelState - * a boolean value - */ + /** + * Sets the fuelRange. + * + * @param fuelLevelState The fuel type, estimated range in KM, fuel level/capacity and fuel level state for the + * vehicle. See struct FuelRange for details. + * @since SmartDeviceLink 5.0.0 + */ + @Deprecated public void setFuelLevelState(Boolean fuelLevelState) { setParameters(KEY_FUEL_LEVEL_STATE, fuelLevelState); } - /** - * Gets a boolean value. If true, means the fuelLevel_State data has been - * unsubscribed. - * - * @return Boolean -a Boolean value. If true, means the fuelLevelState data - * has been unsubscribed. - */ + /** + * Gets the fuelRange. + * + * @return Boolean The fuel type, estimated range in KM, fuel level/capacity and fuel level state for the + * vehicle. See struct FuelRange for details. + * @since SmartDeviceLink 5.0.0 + */ + @Deprecated public Boolean getFuelLevelState() { return getBoolean(KEY_FUEL_LEVEL_STATE); } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleDataResponse.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleDataResponse.java index 37b1f0c51..68def6a87 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleDataResponse.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleDataResponse.java @@ -47,7 +47,6 @@ import java.util.Hashtable; public class UnsubscribeVehicleDataResponse extends RPCResponse { public static final String KEY_SPEED = "speed"; public static final String KEY_RPM = "rpm"; - public static final String KEY_FUEL_LEVEL = "fuelLevel"; public static final String KEY_EXTERNAL_TEMPERATURE = "externalTemperature"; public static final String KEY_PRNDL = "prndl"; public static final String KEY_TIRE_PRESSURE = "tirePressure"; @@ -55,7 +54,6 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse { public static final String KEY_ENGINE_OIL_LIFE = "engineOilLife"; public static final String KEY_ODOMETER = "odometer"; public static final String KEY_GPS = "gps"; - public static final String KEY_FUEL_LEVEL_STATE = "fuelLevel_State"; public static final String KEY_INSTANT_FUEL_CONSUMPTION = "instantFuelConsumption"; public static final String KEY_BELT_STATUS = "beltStatus"; public static final String KEY_BODY_INFORMATION = "bodyInformation"; @@ -77,6 +75,16 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse { public static final String KEY_HANDS_OFF_STEERING = "handsOffSteering"; public static final String KEY_WINDOW_STATUS = "windowStatus"; public static final String KEY_GEAR_STATUS = "gearStatus"; + /** + * @deprecated + */ + @Deprecated + public static final String KEY_FUEL_LEVEL = "fuelLevel"; + /** + * @deprecated + */ + @Deprecated + public static final String KEY_FUEL_LEVEL_STATE = "fuelLevel_State"; /** * Constructs a new UnsubscribeVehicleDataResponse object @@ -153,17 +161,23 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse { return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_RPM); } /** - * Sets Fuel Level - * @param fuelLevel a VehicleDataResult related to Fuel Level + * Sets the fuelLevel. + * + * @param fuelLevel The fuel level in the tank (percentage). This parameter is deprecated starting RPC Spec + * 7.0, please see fuelRange. */ + @Deprecated public void setFuelLevel(VehicleDataResult fuelLevel) { setParameters(KEY_FUEL_LEVEL, fuelLevel); } /** - * Gets Fuel Level - * @return a VehicleDataResult related to FuelLevel + * Gets the fuelLevel. + * + * @return VehicleDataResult The fuel level in the tank (percentage). This parameter is deprecated starting RPC Spec + * 7.0, please see fuelRange. */ @SuppressWarnings("unchecked") + @Deprecated public VehicleDataResult getFuelLevel() { return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_FUEL_LEVEL); } @@ -171,6 +185,7 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse { * Sets Fuel Level State * @param fuelLevelState a VehicleDataResult related to FuelLevel State */ + @Deprecated public void setFuelLevelState(VehicleDataResult fuelLevelState) { setParameters(KEY_FUEL_LEVEL_STATE, fuelLevelState); } @@ -178,6 +193,7 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse { * Gets Fuel Level State * @return a VehicleDataResult related to FuelLevel State */ + @Deprecated @SuppressWarnings("unchecked") public VehicleDataResult getFuelLevelState() { return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_FUEL_LEVEL_STATE); @@ -445,18 +461,23 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse { } /** - * Sets Fuel Range - * @param fuelRange a VehicleDataResult related to the fuel range + * Sets the fuelRange. + * + * @param fuelRange The fuel type, estimated range in KM, fuel level/capacity and fuel level state for the + * vehicle. See struct FuelRange for details. + * @since SmartDeviceLink 5.0.0 */ public void setFuelRange(VehicleDataResult fuelRange) { setParameters(KEY_FUEL_RANGE, fuelRange); } /** - * Gets Fuel Range - * @return a VehicleDataResult related to the fuel range + * Gets the fuelRange. + * + * @return VehicleDataResult The fuel type, estimated range in KM, fuel level/capacity and fuel level state for the + * vehicle. See struct FuelRange for details. + * @since SmartDeviceLink 5.0.0 */ - @SuppressWarnings("unchecked") public VehicleDataResult getFuelRange() { return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_FUEL_RANGE); } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/enums/CapacityUnit.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/enums/CapacityUnit.java new file mode 100644 index 000000000..a8b3c4817 --- /dev/null +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/enums/CapacityUnit.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2017 - 2020, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium 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. + */ +package com.smartdevicelink.proxy.rpc.enums; + +/** + * @since SmartDeviceLink 7.0.0 + */ +public enum CapacityUnit { + LITERS, + + KILOWATTHOURS, + + KILOGRAMS; + + /** + * Convert String to CapacityUnit + * + * @param value String + * @return CapacityUnit + */ + public static CapacityUnit valueForString(String value) { + try{ + return valueOf(value); + }catch(Exception e){ + return null; + } + } +} diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/enums/VehicleDataType.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/enums/VehicleDataType.java index 7682e16f8..5a7155427 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/enums/VehicleDataType.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/enums/VehicleDataType.java @@ -50,10 +50,12 @@ public enum VehicleDataType { VEHICLEDATA_RPM, /** * Notifies FUELLEVELData may be subscribed + * until Smart Device Link 7.0 */ VEHICLEDATA_FUELLEVEL, /** * Notifies FUELLEVEL_STATEData may be subscribed + * until Smart Device Link 7.0 */ VEHICLEDATA_FUELLEVEL_STATE, /** -- cgit v1.2.1 From 2b85be5353b484523ce28f6e8eea8901470e7e14 Mon Sep 17 00:00:00 2001 From: Bilal Alsharifi Date: Thu, 27 Aug 2020 16:49:33 -0400 Subject: Add new SdlFile constructor that takes URI --- .../smartdevicelink/managers/file/FileManager.java | 37 ++++++++++++++ .../managers/file/filetypes/SdlArtwork.java | 13 +++++ .../managers/file/filetypes/SdlFile.java | 57 ++++++++++++++++++++-- 3 files changed, 102 insertions(+), 5 deletions(-) diff --git a/javaSE/src/main/java/com/smartdevicelink/managers/file/FileManager.java b/javaSE/src/main/java/com/smartdevicelink/managers/file/FileManager.java index 959a9ced5..54896f273 100644 --- a/javaSE/src/main/java/com/smartdevicelink/managers/file/FileManager.java +++ b/javaSE/src/main/java/com/smartdevicelink/managers/file/FileManager.java @@ -36,8 +36,13 @@ import androidx.annotation.NonNull; import com.smartdevicelink.managers.file.filetypes.SdlFile; import com.smartdevicelink.proxy.interfaces.ISdl; import com.smartdevicelink.proxy.rpc.PutFile; +import com.smartdevicelink.util.DebugTool; import com.smartdevicelink.util.FileUtls; +import java.io.IOException; +import java.io.InputStream; +import java.net.URI; + /** * FileManager
* @@ -94,6 +99,14 @@ public class FileManager extends BaseFileManager { }else{ throw new IllegalArgumentException("File at path was empty"); } + }else if(file.getURI() != null){ + // Use URI to upload file + byte[] data = contentsOfUri(file.getURI()); + if(data != null){ + putFile.setFileData(data); + }else{ + throw new IllegalArgumentException("Uri was empty"); + } }else if(file.getFileData() != null){ // Use file data (raw bytes) to upload file putFile.setFileData(file.getFileData()); @@ -110,4 +123,28 @@ public class FileManager extends BaseFileManager { return putFile; } + + /** + * Helper method to take Uri and turn it into byte array + * @param uri Uri for desired file + * @return Resulting byte array + */ + private byte[] contentsOfUri(URI uri){ + InputStream is = null; + try{ + is = uri.toURL().openStream(); + return contentsOfInputStream(is); + } catch (IOException e){ + DebugTool.logError(TAG, "Can't read from URI", e); + return null; + } finally { + if (is != null) { + try { + is.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } } diff --git a/javaSE/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlArtwork.java b/javaSE/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlArtwork.java index 69bfb9238..a63c3e27b 100644 --- a/javaSE/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlArtwork.java +++ b/javaSE/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlArtwork.java @@ -38,6 +38,8 @@ import com.smartdevicelink.proxy.rpc.enums.ImageType; import com.smartdevicelink.proxy.rpc.enums.StaticIconName; import com.smartdevicelink.util.DebugTool; +import java.net.URI; + /** * A class that extends SdlFile, representing artwork (JPEG, PNG, or BMP) to be uploaded to core */ @@ -61,6 +63,17 @@ public class SdlArtwork extends SdlFile implements Cloneable{ super(fileName, fileType, filePath, persistentFile); } + /** + * Creates a new instance of SdlArtwork + * @param fileName a String value representing the name that will be used to store the file in the head unit. You can pass null if you want the library to auto generate the name + * @param fileType a FileType enum value representing the type of the file + * @param uri a URI value representing a file's location. Currently, it only supports local files + * @param persistentFile a boolean value that indicates if the file is meant to persist between sessions / ignition cycles + */ + public SdlArtwork(String fileName, @NonNull FileType fileType, URI uri, boolean persistentFile) { + super(fileName, fileType, uri, persistentFile); + } + /** * Creates a new instance of SdlArtwork * @param fileName a String value representing the name that will be used to store the file in the head unit. You can pass null if you want the library to auto generate the name diff --git a/javaSE/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlFile.java b/javaSE/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlFile.java index 60b3f42e9..bb1c170d4 100644 --- a/javaSE/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlFile.java +++ b/javaSE/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlFile.java @@ -36,6 +36,7 @@ import androidx.annotation.NonNull; import com.smartdevicelink.proxy.rpc.enums.FileType; import com.smartdevicelink.proxy.rpc.enums.StaticIconName; +import java.net.URI; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; @@ -45,6 +46,7 @@ import java.security.NoSuchAlgorithmException; public class SdlFile{ private String fileName; private String filePath; + private URI uri; private byte[] fileData; private FileType fileType; private boolean persistentFile; @@ -72,6 +74,20 @@ public class SdlFile{ setPersistent(persistentFile); } + /** + * Creates a new instance of SdlFile + * @param fileName a String value representing the name that will be used to store the file in the head unit. You can pass null if you want the library to auto generate the name + * @param fileType a FileType enum value representing the type of the file + * @param uri a URI value representing a file's location. Currently, it only supports local files + * @param persistentFile a boolean value that indicates if the file is meant to persist between sessions / ignition cycles + */ + public SdlFile(String fileName, @NonNull FileType fileType, URI uri, boolean persistentFile){ + setName(fileName); + setType(fileType); + setURI(uri); + setPersistent(persistentFile); + } + /** * Creates a new instance of SdlFile * @param fileName a String value representing the name that will be used to store the file in the head unit. You can pass null if you want the library to auto generate the name @@ -109,6 +125,8 @@ public class SdlFile{ this.shouldAutoGenerateName = true; if (this.getFileData() != null) { this.fileName = generateFileNameFromData(this.getFileData()); + } else if (this.getURI() != null) { + this.fileName = generateFileNameFromUri(this.getURI()); } else if (this.getFilePath() != null) { this.fileName = generateFileNameFromFilePath(this.getFilePath()); } @@ -142,6 +160,25 @@ public class SdlFile{ return this.filePath; } + /** + * Sets the uri of the file + * @param uri a URI value representing a file's location. Currently, it only supports local files + */ + public void setURI(URI uri){ + this.uri = uri; + if (shouldAutoGenerateName && uri != null) { + this.fileName = generateFileNameFromUri(uri); + } + } + + /** + * Gets the uri of the file + * @return a URI value representing a file's location. Currently, it only supports local files + */ + public URI getURI(){ + return uri; + } + /** * Sets the byte array that represents the content of the file * @param data a byte array representing the data of the file @@ -261,6 +298,15 @@ public class SdlFile{ return generateFileNameFromData(filePath.getBytes()); } + /** + * Generates a file name from uri by hashing the uri string and returning the last 16 chars + * @param uri a URI value representing a file's location + * @return a String value representing the name that will be used to store the file in the head unit + */ + private String generateFileNameFromUri(@NonNull URI uri) { + return generateFileNameFromData(uri.toString().getBytes()); + } + /** * Used to compile hashcode for SdlFile for use to compare in equals method * @return Custom hashcode of SdlFile variables @@ -269,11 +315,12 @@ public class SdlFile{ public int hashCode() { int result = 1; result += ((getName() == null) ? 0 : Integer.rotateLeft(getName().hashCode(), 1)); - result += ((getFilePath() == null) ? 0 : Integer.rotateLeft(getFilePath().hashCode(), 2)); - result += ((getFileData() == null) ? 0 : Integer.rotateLeft(getFileData().hashCode(), 3)); - result += ((getType() == null) ? 0 : Integer.rotateLeft(getType().hashCode(), 4)); - result += Integer.rotateLeft(Boolean.valueOf(isStaticIcon()).hashCode(), 5); - result += Integer.rotateLeft(Boolean.valueOf(isPersistent()).hashCode(), 6); + result += ((getURI() == null) ? 0 : Integer.rotateLeft(getURI().hashCode(), 2)); + result += ((getFilePath() == null) ? 0 : Integer.rotateLeft(getFilePath().hashCode(), 3)); + result += ((getFileData() == null) ? 0 : Integer.rotateLeft(getFileData().hashCode(), 4)); + result += ((getType() == null) ? 0 : Integer.rotateLeft(getType().hashCode(), 5)); + result += Integer.rotateLeft(Boolean.valueOf(isStaticIcon()).hashCode(), 6); + result += Integer.rotateLeft(Boolean.valueOf(isPersistent()).hashCode(), 7); return result; } -- cgit v1.2.1 From 64543b97b18d07005cb827435ca0161c3dd9291d Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Thu, 27 Aug 2020 17:13:31 -0400 Subject: Fixing issues form Review --- .../smartdevicelink/managers/screen/BaseTextAndGraphicManager.java | 4 ++-- .../managers/screen/TextAndGraphicUpdateOperation.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java index 336abf5ba..e3b2f4242 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java @@ -196,7 +196,7 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { } } - // If Task is IN_PROGRESS it's not on the queue, we need to cancel it, operation will take care of stopping it. + // If Task is IN_PROGRESS it's not on the queue, we need to cancel it, the operation will take care of stopping it and will call the listener back if (updateOperation != null && updateOperation.getState() == Task.IN_PROGRESS) { updateOperation.cancelTask(); } @@ -491,7 +491,7 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { // Update the queue's suspend state updateTransactionQueueSuspended(); if (hasData()) { - update(null); + sdlUpdate(null); } } diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java index 6252488a9..82af3af38 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java @@ -617,7 +617,7 @@ class TextAndGraphicUpdateOperation extends Task { return currentScreenData; } - public void setCurrentScreenData(Show currentScreenData) { + void setCurrentScreenData(Show currentScreenData) { this.currentScreenData = currentScreenData; } -- cgit v1.2.1 From 9b2831fa6f6c6a46c285bf1050e1762243e417b6 Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Thu, 27 Aug 2020 17:15:57 -0400 Subject: Update comments --- .../com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java index e3b2f4242..9c756e758 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java @@ -196,7 +196,7 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { } } - // If Task is IN_PROGRESS it's not on the queue, we need to cancel it, the operation will take care of stopping it and will call the listener back + // If Task is IN_PROGRESS, it’s not on the queue, we need to mark it as cancelled. The task will return at some point when it checks its status and call the listener back if (updateOperation != null && updateOperation.getState() == Task.IN_PROGRESS) { updateOperation.cancelTask(); } -- cgit v1.2.1 From 6840282266eecd22acaa935949dc46f8d4d36cdf Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Thu, 27 Aug 2020 17:21:38 -0400 Subject: Set getCurrentScreenData to package private --- .../smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java index 82af3af38..bac8fa8bc 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java @@ -613,7 +613,7 @@ class TextAndGraphicUpdateOperation extends Task { return defaultMainWindowCapability == null || ManagerUtility.WindowCapabilityUtility.hasTextFieldOfName(defaultMainWindowCapability, name); } - public Show getCurrentScreenData() { + Show getCurrentScreenData() { return currentScreenData; } -- cgit v1.2.1 From ea2de3df25e84f9861a1e459ece8850900bea465 Mon Sep 17 00:00:00 2001 From: Joey Grover Date: Fri, 28 Aug 2020 10:54:54 -0400 Subject: Remove SdlProxy releated classes --- .../java/com/smartdevicelink/test/TestValues.java | 4 +- .../test/proxy/RPCRequestFactoryTests.java | 1102 --- .../test/proxy/SdlProxyBaseTests.java | 298 - .../test/streaming/StreamRPCPacketizerTests.java | 5 +- .../com/smartdevicelink/managers/ProxyBridge.java | 686 -- .../smartdevicelink/proxy/LockScreenManager.java | 161 - .../smartdevicelink/proxy/RPCRequestFactory.java | 1030 --- .../smartdevicelink/proxy/RPCStreamController.java | 64 - .../com/smartdevicelink/proxy/SdlProxyALM.java | 2074 ----- .../com/smartdevicelink/proxy/SdlProxyBase.java | 8494 -------------------- .../com/smartdevicelink/proxy/SdlProxyBuilder.java | 224 - .../proxy/SdlProxyConfigurationResources.java | 66 - .../java/com/smartdevicelink/proxy/Version.java | 39 - .../streaming/StreamRPCPacketizer.java | 18 +- .../com/smartdevicelink/proxy/IProxyListener.java | 51 - .../proxy/interfaces/IProxyListenerALM.java | 37 - .../proxy/interfaces/IProxyListenerBase.java | 461 -- 17 files changed, 11 insertions(+), 14803 deletions(-) delete mode 100644 android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCRequestFactoryTests.java delete mode 100644 android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SdlProxyBaseTests.java delete mode 100644 android/sdl_android/src/main/java/com/smartdevicelink/managers/ProxyBridge.java delete mode 100644 android/sdl_android/src/main/java/com/smartdevicelink/proxy/LockScreenManager.java delete mode 100644 android/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCRequestFactory.java delete mode 100644 android/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCStreamController.java delete mode 100644 android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyALM.java delete mode 100644 android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java delete mode 100644 android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBuilder.java delete mode 100644 android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyConfigurationResources.java delete mode 100644 android/sdl_android/src/main/java/com/smartdevicelink/proxy/Version.java delete mode 100644 base/src/main/java/com/smartdevicelink/proxy/IProxyListener.java delete mode 100644 base/src/main/java/com/smartdevicelink/proxy/interfaces/IProxyListenerALM.java delete mode 100644 base/src/main/java/com/smartdevicelink/proxy/interfaces/IProxyListenerBase.java diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/TestValues.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/TestValues.java index caa9f1e7f..cae14a53a 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/TestValues.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/TestValues.java @@ -6,6 +6,7 @@ import android.util.Log; import com.smartdevicelink.R; import com.smartdevicelink.managers.file.filetypes.SdlArtwork; +import com.smartdevicelink.managers.lifecycle.LifecycleManager; import com.smartdevicelink.managers.lockscreen.LockScreenConfig; import com.smartdevicelink.managers.screen.choiceset.ChoiceCell; import com.smartdevicelink.managers.screen.menu.MenuCell; @@ -15,7 +16,6 @@ import com.smartdevicelink.managers.screen.menu.VoiceCommand; import com.smartdevicelink.managers.screen.menu.VoiceCommandSelectionListener; import com.smartdevicelink.protocol.SdlProtocol; import com.smartdevicelink.protocol.enums.FunctionID; -import com.smartdevicelink.proxy.SdlProxyBase; import com.smartdevicelink.proxy.TTSChunkFactory; import com.smartdevicelink.proxy.rpc.AppInfo; import com.smartdevicelink.proxy.rpc.AppServiceCapability; @@ -225,7 +225,7 @@ import java.util.Vector; public class TestValues { //Versions - public static final Version MAX_RPC_VERSION_SUPPORTED = SdlProxyBase.MAX_SUPPORTED_RPC_VERSION; + public static final Version MAX_RPC_VERSION_SUPPORTED = LifecycleManager.MAX_SUPPORTED_RPC_VERSION; /** * @see SdlProtocol */ diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCRequestFactoryTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCRequestFactoryTests.java deleted file mode 100644 index 8c66446af..000000000 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCRequestFactoryTests.java +++ /dev/null @@ -1,1102 +0,0 @@ -package com.smartdevicelink.test.proxy; - -import com.smartdevicelink.proxy.RPCRequestFactory; -import com.smartdevicelink.proxy.TTSChunkFactory; -import com.smartdevicelink.proxy.rpc.AddCommand; -import com.smartdevicelink.proxy.rpc.AddSubMenu; -import com.smartdevicelink.proxy.rpc.Alert; -import com.smartdevicelink.proxy.rpc.ChangeRegistration; -import com.smartdevicelink.proxy.rpc.Choice; -import com.smartdevicelink.proxy.rpc.CreateInteractionChoiceSet; -import com.smartdevicelink.proxy.rpc.DeleteCommand; -import com.smartdevicelink.proxy.rpc.DeleteFile; -import com.smartdevicelink.proxy.rpc.DeleteInteractionChoiceSet; -import com.smartdevicelink.proxy.rpc.DeleteSubMenu; -import com.smartdevicelink.proxy.rpc.DeviceInfo; -import com.smartdevicelink.proxy.rpc.EndAudioPassThru; -import com.smartdevicelink.proxy.rpc.GetVehicleData; -import com.smartdevicelink.proxy.rpc.Image; -import com.smartdevicelink.proxy.rpc.ListFiles; -import com.smartdevicelink.proxy.rpc.PerformAudioPassThru; -import com.smartdevicelink.proxy.rpc.PerformInteraction; -import com.smartdevicelink.proxy.rpc.PutFile; -import com.smartdevicelink.proxy.rpc.RegisterAppInterface; -import com.smartdevicelink.proxy.rpc.ScrollableMessage; -import com.smartdevicelink.proxy.rpc.SdlMsgVersion; -import com.smartdevicelink.proxy.rpc.SetAppIcon; -import com.smartdevicelink.proxy.rpc.SetDisplayLayout; -import com.smartdevicelink.proxy.rpc.SetGlobalProperties; -import com.smartdevicelink.proxy.rpc.SetMediaClockTimer; -import com.smartdevicelink.proxy.rpc.Show; -import com.smartdevicelink.proxy.rpc.Slider; -import com.smartdevicelink.proxy.rpc.SoftButton; -import com.smartdevicelink.proxy.rpc.Speak; -import com.smartdevicelink.proxy.rpc.SubscribeButton; -import com.smartdevicelink.proxy.rpc.SubscribeVehicleData; -import com.smartdevicelink.proxy.rpc.SystemRequest; -import com.smartdevicelink.proxy.rpc.TTSChunk; -import com.smartdevicelink.proxy.rpc.UnregisterAppInterface; -import com.smartdevicelink.proxy.rpc.UnsubscribeButton; -import com.smartdevicelink.proxy.rpc.UnsubscribeVehicleData; -import com.smartdevicelink.proxy.rpc.VrHelpItem; -import com.smartdevicelink.proxy.rpc.enums.AppHMIType; -import com.smartdevicelink.proxy.rpc.enums.AudioType; -import com.smartdevicelink.proxy.rpc.enums.BitsPerSample; -import com.smartdevicelink.proxy.rpc.enums.ButtonName; -import com.smartdevicelink.proxy.rpc.enums.FileType; -import com.smartdevicelink.proxy.rpc.enums.ImageType; -import com.smartdevicelink.proxy.rpc.enums.InteractionMode; -import com.smartdevicelink.proxy.rpc.enums.Language; -import com.smartdevicelink.proxy.rpc.enums.SamplingRate; -import com.smartdevicelink.proxy.rpc.enums.TextAlignment; -import com.smartdevicelink.proxy.rpc.enums.UpdateMode; -import com.smartdevicelink.test.NullValues; -import com.smartdevicelink.test.TestValues; -import com.smartdevicelink.test.Validator; - -import junit.framework.TestCase; - -import java.util.Vector; - -/** - * This is a unit test class for the SmartDeviceLink library project class : - * {@link com.smartdevicelink.proxy.RPCRequestFactory} - */ -public class RPCRequestFactoryTests extends TestCase { - - public void testBuildSystemRequest () { - - String testData; - Integer testInt; - SystemRequest testBSR; - Vector testVData; - - // Test -- buildSystemRequest(String data, Integer correlationID) - testData = "test"; - testInt = 0; - testBSR = RPCRequestFactory.buildSystemRequest(testData, testInt); - assertNotNull(TestValues.NOT_NULL, testBSR.getBulkData()); - assertEquals(TestValues.MATCH, testInt, testBSR.getCorrelationID()); - - testBSR = RPCRequestFactory.buildSystemRequest(testData, null); - assertNotNull(TestValues.NULL, testBSR.getCorrelationID()); - - testBSR = RPCRequestFactory.buildSystemRequest(null, testInt); - assertNull(TestValues.NULL, testBSR); - - // Test -- buildSystemRequestLegacy(Vector data, Integer correlationID) - testVData = new Vector(); - testVData.add("Test A"); - testVData.add("Test B"); - testVData.add("Test C"); - testBSR = RPCRequestFactory.buildSystemRequestLegacy(testVData, testInt); - assertEquals(TestValues.MATCH, testVData, new Vector(testBSR.getLegacyData())); - assertEquals(TestValues.MATCH, testInt, testBSR.getCorrelationID()); - - testBSR = RPCRequestFactory.buildSystemRequestLegacy(testVData, null); - assertNotNull(TestValues.NOT_NULL, testBSR.getCorrelationID()); - - testBSR = RPCRequestFactory.buildSystemRequestLegacy(null, testInt); - assertNull(TestValues.NULL, testBSR); - - // Issue #166 -- Null values within the Vector parameter. - // TODO: Once resolved, add the following test. - //testVData = new Vector(); - //testVData.add("Test A"); - //testVData.add("Test B"); - //testVData.add(null); - //testBSR = RPCRequestFactory.buildSystemRequestLegacy(testVData, testInt); - //assertNull(Test.NULL, testBSR); - } - - public void testBuildAddCommand () { - - Image testImage; - String testMenuText, testIconValue; - Integer testCommandID, testParentID, testPosition, testCorrelationID; - ImageType testIconType; - AddCommand testBAC; - Vector testVrCommands; - - // Test -- buildAddCommand(Integer commandID, String menuText, Integer parentID, Integer position,Vector vrCommands, Image cmdIcon, Integer correlationID) - testImage = new Image(); - testMenuText = "menu"; - testPosition = 1; - testParentID = 2; - testCommandID = 3; - testCorrelationID = 4; - testVrCommands = new Vector(); - testImage.setImageType(ImageType.STATIC); - testImage.setValue("image"); - testVrCommands.add("Test A"); - testVrCommands.add("Test B"); - testBAC = RPCRequestFactory.buildAddCommand(testCommandID, testMenuText, testParentID, testPosition, testVrCommands, testImage, testCorrelationID); - assertEquals(TestValues.MATCH, testCommandID, testBAC.getCmdID()); - assertEquals(TestValues.MATCH, testMenuText, testBAC.getMenuParams().getMenuName()); - assertEquals(TestValues.MATCH, testParentID, testBAC.getMenuParams().getParentID()); - assertEquals(TestValues.MATCH, testPosition, testBAC.getMenuParams().getPosition()); - assertEquals(TestValues.MATCH, testVrCommands, testBAC.getVrCommands()); - assertTrue(TestValues.TRUE, Validator.validateImage(testImage, testBAC.getCmdIcon())); - assertEquals(TestValues.MATCH, testCorrelationID, testBAC.getCorrelationID()); - - testBAC = RPCRequestFactory.buildAddCommand(null, null, null, null, null, null, null); - assertNull(TestValues.NULL, testBAC.getCmdID()); - assertNull(TestValues.NULL, testBAC.getMenuParams()); - assertNull(TestValues.NULL, testBAC.getVrCommands()); - assertNull(TestValues.NULL, testBAC.getCmdIcon()); - assertNotNull(TestValues.NOT_NULL, testBAC.getCorrelationID()); - - // Test -- buildAddCommand(Integer commandID, String menuText, Integer parentID, Integer position, Vector vrCommands, String IconValue, ImageType IconType, Integer correlationID) - testIconValue = "icon"; - testIconType = ImageType.STATIC; - testImage = new Image(); - testImage.setValue(testIconValue); - testImage.setImageType(testIconType); - testBAC = RPCRequestFactory.buildAddCommand(testCommandID, testMenuText, testParentID, testPosition, testVrCommands, testIconValue, testIconType, testCorrelationID); - assertEquals(TestValues.MATCH, testCommandID, testBAC.getCmdID()); - assertEquals(TestValues.MATCH, testMenuText, testBAC.getMenuParams().getMenuName()); - assertEquals(TestValues.MATCH, testParentID, testBAC.getMenuParams().getParentID()); - assertEquals(TestValues.MATCH, testPosition, testBAC.getMenuParams().getPosition()); - assertEquals(TestValues.MATCH, testVrCommands, testBAC.getVrCommands()); - assertEquals(TestValues.MATCH, testCorrelationID, testBAC.getCorrelationID()); - assertTrue(TestValues.TRUE, Validator.validateImage(testImage, testBAC.getCmdIcon())); - - testBAC = RPCRequestFactory.buildAddCommand(null, null, null, null, null, null, null, null); - assertNull(TestValues.NULL, testBAC.getCmdID()); - assertNull(TestValues.NULL, testBAC.getMenuParams()); - assertNull(TestValues.NULL, testBAC.getVrCommands()); - assertNull(TestValues.NULL, testBAC.getCmdIcon()); - assertNotNull(TestValues.NOT_NULL, testBAC.getCorrelationID()); - - // Test -- buildAddCommand(Integer commandID, String menuText, Integer parentID, Integer position, Vector vrCommands, Integer correlationID) - testBAC = RPCRequestFactory.buildAddCommand(testCommandID, testMenuText, testParentID, testPosition, testVrCommands, testCorrelationID); - assertEquals(TestValues.MATCH, testCommandID, testBAC.getCmdID()); - assertEquals(TestValues.MATCH, testMenuText, testBAC.getMenuParams().getMenuName()); - assertEquals(TestValues.MATCH, testParentID, testBAC.getMenuParams().getParentID()); - assertEquals(TestValues.MATCH, testPosition, testBAC.getMenuParams().getPosition()); - assertEquals(TestValues.MATCH, testVrCommands, testBAC.getVrCommands()); - assertEquals(TestValues.MATCH, testCorrelationID, testBAC.getCorrelationID()); - - testBAC = RPCRequestFactory.buildAddCommand(null, null, null, null, null, null); - assertNull(TestValues.NULL, testBAC.getCmdID()); - assertNull(TestValues.NULL, testBAC.getMenuParams()); - assertNull(TestValues.NULL, testBAC.getVrCommands()); - assertNotNull(TestValues.NOT_NULL, testBAC.getCorrelationID()); - - // Test -- buildAddCommand(Integer commandID, String menuText, Vector vrCommands, Integer correlationID) - testBAC = RPCRequestFactory.buildAddCommand(testCommandID, testMenuText, testVrCommands, testCorrelationID); - assertEquals(TestValues.MATCH, testCommandID, testBAC.getCmdID()); - assertEquals(TestValues.MATCH, testMenuText, testBAC.getMenuParams().getMenuName()); - assertEquals(TestValues.MATCH, testVrCommands, testBAC.getVrCommands()); - assertEquals(TestValues.MATCH, testCorrelationID, testBAC.getCorrelationID()); - - testBAC = RPCRequestFactory.buildAddCommand(null, null, null, null); - assertNull(TestValues.NULL, testBAC.getCmdID()); - assertNull(TestValues.NULL, testBAC.getMenuParams()); - assertNull(TestValues.NULL, testBAC.getVrCommands()); - assertNotNull(TestValues.NOT_NULL, testBAC.getCorrelationID()); - - // Test -- buildAddCommand(Integer commandID, Vector vrCommands, Integer correlationID) - testBAC = RPCRequestFactory.buildAddCommand(testCommandID, testVrCommands, testCorrelationID); - assertEquals(TestValues.MATCH, testCommandID, testBAC.getCmdID()); - assertEquals(TestValues.MATCH, testVrCommands, testBAC.getVrCommands()); - assertEquals(TestValues.MATCH, testCorrelationID, testBAC.getCorrelationID()); - - testBAC = RPCRequestFactory.buildAddCommand(null, null, null); - assertNull(TestValues.NULL, testBAC.getCmdID()); - assertNull(TestValues.NULL, testBAC.getVrCommands()); - assertNotNull(TestValues.NOT_NULL, testBAC.getCorrelationID()); - } - - public void testBuildAddSubMenu () { - - Integer testMenuID, testCorrelationID, testPosition; - String testMenuName; - AddSubMenu testBASM; - - // Test -- buildAddSubMenu(Integer menuID, String menuName, Integer correlationID) - // ^ Calls another build method. - // Test -- buildAddSubMenu(Integer menuID, String menuName, Integer position, Integer correlationID) - testMenuID = 0; - testMenuName = "name"; - testPosition = 1; - testCorrelationID = 2; - testBASM = RPCRequestFactory.buildAddSubMenu(testMenuID, testMenuName, testPosition, testCorrelationID); - assertEquals(TestValues.MATCH, testMenuID, testBASM.getMenuID()); - assertEquals(TestValues.MATCH, testMenuName, testBASM.getMenuName()); - assertEquals(TestValues.MATCH, testPosition, testBASM.getPosition()); - assertEquals(TestValues.MATCH, testCorrelationID, testBASM.getCorrelationID()); - - testBASM = RPCRequestFactory.buildAddSubMenu(null, null, null, null); - assertNull(TestValues.NULL, testBASM.getMenuID()); - assertNull(TestValues.NULL, testBASM.getMenuName()); - assertNull(TestValues.NULL, testBASM.getPosition()); - assertNotNull(TestValues.NOT_NULL, testBASM.getCorrelationID()); - } - - public void testBuildAlert () { - - Alert testAlert; - String testTTSText, testAlertText1, testAlertText2, testAlertText3; - Integer testCorrelationID, testDuration; - Boolean testPlayTone; - Vector testSoftButtons; - Vector testTtsChunks; - - // Test -- buildAlert(String ttsText, Boolean playTone, Vector softButtons, Integer correlationID) - testTTSText = "simple test"; - testCorrelationID = 0; - testPlayTone = true; - testSoftButtons = new Vector(); - SoftButton test1 = new SoftButton(); - test1.setText("test 1"); - SoftButton test2 = new SoftButton(); - test2.setText("test 2"); - testSoftButtons.add(test1); - testSoftButtons.add(test2); - testAlert = RPCRequestFactory.buildAlert(testTTSText, testPlayTone, testSoftButtons, testCorrelationID); - assertTrue(TestValues.TRUE, Validator.validateTtsChunks(TTSChunkFactory.createSimpleTTSChunks(testTTSText), testAlert.getTtsChunks())); - // ^ Calls another build method. - - // Test -- buildAlert(String alertText1, String alertText2, String alertText3, Integer duration, Vector softButtons, Integer correlationID) - testAlertText1 = "test 1"; - testAlertText2 = "test 2"; - testAlertText3 = "test 3"; - testDuration = 1; - // ^ Calls another build method. - - // Test -- buildAlert(String ttsText, String alertText1, String alertText2, String alertText3, Boolean playTone, Integer duration, Vector softButtons, Integer correlationID) - testAlert = RPCRequestFactory.buildAlert(testTTSText, testAlertText1, testAlertText2, testAlertText3, testPlayTone, testDuration, testSoftButtons, testCorrelationID); - assertTrue(TestValues.TRUE, Validator.validateTtsChunks(TTSChunkFactory.createSimpleTTSChunks(testTTSText), testAlert.getTtsChunks())); - // ^ Calls another build method. - - // Test -- buildAlert(Vector chunks, Boolean playTone, Vector softButtons, Integer correlationID) - // ^ Calls another build method. - - // Test -- buildAlert(Vector ttsChunks, String alertText1, String alertText2, String alertText3, Boolean playTone, Integer duration, Vector softButtons, Integer correlationID) - testTtsChunks = TTSChunkFactory.createSimpleTTSChunks(testTTSText); - testAlert = RPCRequestFactory.buildAlert(testTtsChunks, testAlertText1, testAlertText2, testAlertText3, testPlayTone, testDuration, testSoftButtons, testCorrelationID); - assertTrue(TestValues.TRUE, Validator.validateTtsChunks(testTtsChunks, testAlert.getTtsChunks())); - assertEquals(TestValues.MATCH, testAlertText1, testAlert.getAlertText1()); - assertEquals(TestValues.MATCH, testAlertText2, testAlert.getAlertText2()); - assertEquals(TestValues.MATCH, testAlertText3, testAlert.getAlertText3()); - assertEquals(TestValues.MATCH, testPlayTone, testAlert.getPlayTone()); - assertEquals(TestValues.MATCH, testDuration, testAlert.getDuration()); - assertTrue(TestValues.TRUE, Validator.validateSoftButtons(testSoftButtons, testAlert.getSoftButtons())); - assertEquals(TestValues.MATCH, testCorrelationID, testAlert.getCorrelationID()); - - testAlert = RPCRequestFactory.buildAlert((Vector) null, null, null, null, null, null, null, null); - assertNull(TestValues.NULL, testAlert.getTtsChunks()); - assertNull(TestValues.NULL, testAlert.getAlertText1()); - assertNull(TestValues.NULL, testAlert.getAlertText2()); - assertNull(TestValues.NULL, testAlert.getAlertText3()); - assertNull(TestValues.NULL, testAlert.getPlayTone()); - assertNull(TestValues.NULL, testAlert.getDuration()); - assertNull(TestValues.NULL, testAlert.getSoftButtons()); - assertNotNull(TestValues.NOT_NULL, testAlert.getCorrelationID()); - - // Test -- buildAlert(String ttsText, Boolean playTone, Integer correlationID) - // ^ Calls another build method. - - // Test -- buildAlert(String alertText1, String alertText2, Integer duration, Integer correlationID) - // ^ Calls another build method. - - // Test -- buildAlert(String ttsText, String alertText1, String alertText2, Boolean playTone, Integer duration, Integer correlationID) - // ^ Calls another build method. - - // Test -- buildAlert(Vector chunks, Boolean playTone, Integer correlationID) - // ^ Calls another build method. - - // Test -- buildAlert(Vector ttsChunks, String alertText1, String alertText2, Boolean playTone, Integer duration, Integer correlationID) - testAlert = RPCRequestFactory.buildAlert(testTtsChunks, testAlertText1, testAlertText2, testPlayTone, testDuration, testCorrelationID); - assertTrue(TestValues.TRUE, Validator.validateTtsChunks(testTtsChunks, testAlert.getTtsChunks())); - assertEquals(TestValues.MATCH, testAlertText1, testAlert.getAlertText1()); - assertEquals(TestValues.MATCH, testAlertText2, testAlert.getAlertText2()); - assertEquals(TestValues.MATCH, testPlayTone, testAlert.getPlayTone()); - assertEquals(TestValues.MATCH, testDuration, testAlert.getDuration()); - assertEquals(TestValues.MATCH, testCorrelationID, testAlert.getCorrelationID()); - - testAlert = RPCRequestFactory.buildAlert((Vector) null, null, null, null, null, null); - assertNull(TestValues.NULL, testAlert.getTtsChunks()); - assertNull(TestValues.NULL, testAlert.getAlertText1()); - assertNull(TestValues.NULL, testAlert.getAlertText2()); - assertNull(TestValues.NULL, testAlert.getPlayTone()); - assertNull(TestValues.NULL, testAlert.getDuration()); - assertNotNull(TestValues.NOT_NULL, testAlert.getCorrelationID()); - } - - public void testBuildCreateInteractionChoiceSet () { - - Integer testICSID, testCorrelationID; - Vector testChoiceSet; - CreateInteractionChoiceSet testBCICS; - - // Test --buildCreateInteractionChoiceSet(Vector choiceSet, Integer interactionChoiceSetID, Integer correlationID) - testICSID = 0; - testCorrelationID = 1; - testChoiceSet = new Vector(); - Choice testChoice = new Choice(); - testChoiceSet.add(testChoice); - testBCICS = RPCRequestFactory.buildCreateInteractionChoiceSet(testChoiceSet, testICSID, testCorrelationID); - assertEquals(TestValues.MATCH, testChoiceSet, testBCICS.getChoiceSet()); - assertEquals(TestValues.MATCH, testICSID, testBCICS.getInteractionChoiceSetID()); - assertEquals(TestValues.MATCH, testCorrelationID, testBCICS.getCorrelationID()); - - testBCICS = RPCRequestFactory.buildCreateInteractionChoiceSet(null, null, null); - assertNull(TestValues.NULL, testBCICS.getChoiceSet()); - assertNull(TestValues.NULL, testBCICS.getInteractionChoiceSetID()); - assertNotNull(TestValues.NOT_NULL, testBCICS.getCorrelationID()); - } - - public void testBuildDeleteCommand () { - - Integer testCID, testCorrelationID; - DeleteCommand testDC; - - // Test -- buildDeleteCommand(Integer commandID, Integer correlationID) - testCID = 0; - testCorrelationID = 1; - testDC = RPCRequestFactory.buildDeleteCommand(testCID, testCorrelationID); - assertEquals(TestValues.MATCH, testCID, testDC.getCmdID()); - assertEquals(TestValues.MATCH, testCorrelationID, testDC.getCorrelationID()); - - testDC = RPCRequestFactory.buildDeleteCommand(null, null); - assertNull(TestValues.NULL, testDC.getCmdID()); - assertNotNull(TestValues.NOT_NULL, testDC.getCorrelationID()); - - } - - public void testBuildDeleteFile () { - - Integer testCorrelationID; - String testFileName; - DeleteFile testDF; - - // Test --buildDeleteFile(String sdlFileName, Integer correlationID) - testCorrelationID = 0; - testFileName = "test"; - testDF = RPCRequestFactory.buildDeleteFile(testFileName, testCorrelationID); - assertEquals(TestValues.MATCH, testCorrelationID, testDF.getCorrelationID()); - assertEquals(TestValues.MATCH, testFileName, testDF.getSdlFileName()); - - testDF = RPCRequestFactory.buildDeleteFile(null, null); - assertNotNull(TestValues.NOT_NULL, testDF.getCorrelationID()); - assertNull(TestValues.NULL, testDF.getSdlFileName()); - - } - - public void testBuildDeleteInteractionChoiceSet () { - - Integer testICSID, testCorrelationID; - DeleteInteractionChoiceSet testDICS; - - // Test -- buildDeleteInteractionChoiceSet(Integer interactionChoiceSetID, Integer correlationID) - testICSID = 0; - testCorrelationID = 1; - testDICS = RPCRequestFactory.buildDeleteInteractionChoiceSet(testICSID, testCorrelationID); - assertEquals(TestValues.MATCH, testICSID, testDICS.getInteractionChoiceSetID()); - assertEquals(TestValues.MATCH, testCorrelationID, testDICS.getCorrelationID()); - - testDICS = RPCRequestFactory.buildDeleteInteractionChoiceSet(null, null); - assertNull(TestValues.NULL, testDICS.getInteractionChoiceSetID()); - assertNotNull(TestValues.NOT_NULL, testDICS.getCorrelationID()); - } - - public void testBuildDeleteSubMenu () { - - Integer testMenuID, testCorrelationID; - DeleteSubMenu testDSM; - - // Test -- buildDeleteSubMenu(Integer menuID, Integer correlationID) - testMenuID = 0; - testCorrelationID = 1; - testDSM = RPCRequestFactory.buildDeleteSubMenu(testMenuID, testCorrelationID); - assertEquals(TestValues.MATCH, testMenuID, testDSM.getMenuID()); - assertEquals(TestValues.MATCH, testCorrelationID, testDSM.getCorrelationID()); - - testDSM = RPCRequestFactory.buildDeleteSubMenu(null, null); - assertNull(TestValues.NULL, testDSM.getMenuID()); - assertNotNull(TestValues.NOT_NULL, testDSM.getCorrelationID()); - } - - public void testBuildListFiles () { - - Integer testCorrelationID = 0; - ListFiles testLF; - - // Test -- buildListFiles(Integer correlationID) - testLF = RPCRequestFactory.buildListFiles(testCorrelationID); - assertEquals(TestValues.MATCH, testCorrelationID, testLF.getCorrelationID()); - - testLF = RPCRequestFactory.buildListFiles(null); - assertNotNull(TestValues.NOT_NULL, testLF.getCorrelationID()); - } - - @SuppressWarnings("deprecation") - public void testBuildPerformInteraction () { - - String testDisplayText = "test"; - Integer testTimeout = 1, testCorrelationID = 0; - InteractionMode testIM = InteractionMode.BOTH; - Vector testInitChunks, testHelpChunks, testTimeoutChunks; - Vector testCSIDs; - Vector testVrHelpItems; - PerformInteraction testPI; - - // Test -- buildPerformInteraction(Vector initChunks, String displayText, Vector interactionChoiceSetIDList, Vector helpChunks, Vector timeoutChunks, InteractionMode interactionMode, Integer timeout, Vector vrHelp, Integer correlationID) - testInitChunks = TTSChunkFactory.createSimpleTTSChunks("init chunks"); - testHelpChunks = TTSChunkFactory.createSimpleTTSChunks("help items"); - testTimeoutChunks = TTSChunkFactory.createSimpleTTSChunks("timeout"); - testVrHelpItems = new Vector(); - VrHelpItem testItem = new VrHelpItem(); - testItem.setPosition(0); - testItem.setText("text"); - Image image = new Image(); - image.setValue("value"); - image.setImageType(ImageType.DYNAMIC); - testItem.setImage(image); - testVrHelpItems.add(testItem); - testCSIDs = new Vector(); - testCSIDs.add(0); - testCSIDs.add(1); - testPI = RPCRequestFactory.buildPerformInteraction(testInitChunks, testDisplayText, testCSIDs, testHelpChunks, testTimeoutChunks, testIM, testTimeout, testVrHelpItems, testCorrelationID); - assertTrue(TestValues.TRUE, Validator.validateTtsChunks(testInitChunks, testPI.getInitialPrompt())); - assertEquals(TestValues.MATCH, testDisplayText, testPI.getInitialText()); - assertTrue(TestValues.TRUE, Validator.validateIntegerList(testCSIDs, testPI.getInteractionChoiceSetIDList())); - assertTrue(TestValues.TRUE, Validator.validateTtsChunks(testHelpChunks, testPI.getHelpPrompt())); - assertTrue(TestValues.TRUE, Validator.validateTtsChunks(testTimeoutChunks, testPI.getTimeoutPrompt())); - assertEquals(TestValues.MATCH, testIM, testPI.getInteractionMode()); - assertEquals(TestValues.MATCH, testTimeout, testPI.getTimeout()); - assertTrue(TestValues.TRUE, Validator.validateVrHelpItems(testVrHelpItems, testPI.getVrHelp())); - assertEquals(TestValues.MATCH, testCorrelationID, testPI.getCorrelationID()); - - testPI = RPCRequestFactory.buildPerformInteraction((Vector) null, null, null, null, null, null, null, null, null); - assertNull(TestValues.NULL, testPI.getInitialPrompt()); - assertNull(TestValues.NULL, testPI.getInitialText()); - assertNull(TestValues.NULL, testPI.getInteractionChoiceSetIDList()); - assertNull(TestValues.NULL, testPI.getHelpPrompt()); - assertNull(TestValues.NULL, testPI.getTimeoutPrompt()); - assertNull(TestValues.NULL, testPI.getInteractionMode()); - assertNull(TestValues.NULL, testPI.getTimeout()); - assertNull(TestValues.NULL, testPI.getVrHelp()); - assertNotNull(TestValues.NOT_NULL, testPI.getCorrelationID()); - - // Test -- buildPerformInteraction(String initPrompt, String displayText, Vector interactionChoiceSetIDList, String helpPrompt, String timeoutPrompt, InteractionMode interactionMode, Integer timeout, Vector vrHelp, Integer correlationID) - // ^ Calls another build method. - - // Test -- buildPerformInteraction(String initPrompt, String displayText, Integer interactionChoiceSetID, String helpPrompt, String timeoutPrompt, InteractionMode interactionMode, Integer timeout, Vector vrHelp, Integer correlationID) - // ^ Calls another build method. - - // Test -- buildPerformInteraction(String initPrompt, String displayText, Integer interactionChoiceSetID, Vector vrHelp, Integer correlationID) - // ^ Calls another build method. - - // Test -- buildPerformInteraction(Vector initChunks, String displayText, Vector interactionChoiceSetIDList, Vector helpChunks, Vector timeoutChunks, InteractionMode interactionMode, Integer timeout, Integer correlationID) - testPI = RPCRequestFactory.buildPerformInteraction(testInitChunks, testDisplayText, testCSIDs, testHelpChunks, testTimeoutChunks, testIM, testTimeout, testCorrelationID); - assertTrue(TestValues.TRUE, Validator.validateTtsChunks(testInitChunks, testPI.getInitialPrompt())); - assertEquals(TestValues.MATCH, testDisplayText, testPI.getInitialText()); - assertTrue(TestValues.TRUE, Validator.validateIntegerList(testCSIDs, testPI.getInteractionChoiceSetIDList())); - assertTrue(TestValues.TRUE, Validator.validateTtsChunks(testHelpChunks, testPI.getHelpPrompt())); - assertTrue(TestValues.TRUE, Validator.validateTtsChunks(testTimeoutChunks, testPI.getTimeoutPrompt())); - assertEquals(TestValues.MATCH, testIM, testPI.getInteractionMode()); - assertEquals(TestValues.MATCH, testTimeout, testPI.getTimeout()); - assertEquals(TestValues.MATCH, testCorrelationID, testPI.getCorrelationID()); - - testPI = RPCRequestFactory.buildPerformInteraction((Vector) null, null, null, null, null, null, null, null); - assertNull(TestValues.NULL, testPI.getInitialPrompt()); - assertNull(TestValues.NULL, testPI.getInitialText()); - assertNull(TestValues.NULL, testPI.getInteractionChoiceSetIDList()); - assertNull(TestValues.NULL, testPI.getHelpPrompt()); - assertNull(TestValues.NULL, testPI.getTimeoutPrompt()); - assertNull(TestValues.NULL, testPI.getInteractionMode()); - assertNull(TestValues.NULL, testPI.getTimeout()); - assertNotNull(TestValues.NOT_NULL, testPI.getCorrelationID()); - - // Test -- buildPerformInteraction(String initPrompt, String displayText, Vector interactionChoiceSetIDList, String helpPrompt, String timeoutPrompt, InteractionMode interactionMode, Integer timeout, Integer correlationID) - // ^ Calls another build method. - - // Test -- buildPerformInteraction(String initPrompt, String displayText, Integer interactionChoiceSetID, String helpPrompt, String timeoutPrompt, InteractionMode interactionMode, Integer timeout, Integer correlationID) - // ^ Calls another build method. - - // Test -- buildPerformInteraction(String initPrompt, String displayText, Integer interactionChoiceSetID, Integer correlationID) - // ^ Calls another build method. - - // Test -- buildPerformInteraction(Vector initChunks, String displayText, Vector interactionChoiceSetIDList, Vector helpChunks, InteractionMode interactionMode, Integer timeout, Integer correlationID) - testPI = RPCRequestFactory.buildPerformInteraction(testInitChunks, testDisplayText, testCSIDs, testHelpChunks, testIM, testTimeout, testCorrelationID); - assertTrue(TestValues.TRUE, Validator.validateTtsChunks(testInitChunks, testPI.getInitialPrompt())); - assertEquals(TestValues.MATCH, testDisplayText, testPI.getInitialText()); - assertTrue(TestValues.TRUE, Validator.validateIntegerList(testCSIDs, testPI.getInteractionChoiceSetIDList())); - assertTrue(TestValues.TRUE, Validator.validateTtsChunks(testHelpChunks, testPI.getHelpPrompt())); - assertEquals(TestValues.MATCH, testIM, testPI.getInteractionMode()); - assertEquals(TestValues.MATCH, testTimeout, testPI.getTimeout()); - assertEquals(TestValues.MATCH, testCorrelationID, testPI.getCorrelationID()); - - testPI = RPCRequestFactory.buildPerformInteraction((Vector) null, null, null, null, null, null, null); - assertNull(TestValues.NULL, testPI.getInitialPrompt()); - assertNull(TestValues.NULL, testPI.getInitialText()); - assertNull(TestValues.NULL, testPI.getInteractionChoiceSetIDList()); - assertNull(TestValues.NULL, testPI.getHelpPrompt()); - assertNull(TestValues.NULL, testPI.getInteractionMode()); - assertNull(TestValues.NULL, testPI.getTimeout()); - assertNotNull(TestValues.NOT_NULL, testPI.getCorrelationID()); - - // Test -- buildPerformInteraction(String initPrompt, String displayText, Vector interactionChoiceSetIDList, String helpPrompt, InteractionMode interactionMode, Integer timeout, Integer correlationID) - // ^ Calls another build method. - } - - public void testBuildPutFiles () { - - String testFileName = "test"; - Boolean testPFile = true, testSystemFile = true; - Integer testCorrelationID = 0; - Long testOffset = 1L, testLength = 2L; - FileType testFileType = FileType.BINARY; - byte[] testFileData = {(byte) 0x00, (byte) 0x01, (byte) 0x02 }; - PutFile testPF; - - // Test -- buildPutFile(String sdlFileName, FileType fileType, Boolean persistentFile, byte[] fileData, Integer correlationID) - testPF = RPCRequestFactory.buildPutFile(testFileName, testFileType, testPFile, testFileData, testCorrelationID); - assertEquals(TestValues.MATCH, testFileName, testPF.getSdlFileName()); - assertEquals(TestValues.MATCH, testFileType, testPF.getFileType()); - assertEquals(TestValues.MATCH, testPFile, testPF.getPersistentFile()); - assertTrue(TestValues.TRUE, Validator.validateBulkData(testFileData, testPF.getFileData())); - assertEquals(TestValues.MATCH, testCorrelationID, testPF.getCorrelationID()); - - testPF = RPCRequestFactory.buildPutFile(null, null, null, null, null); - assertNull(TestValues.NULL, testPF.getSdlFileName()); - assertNull(TestValues.NULL, testPF.getFileType()); - assertNull(TestValues.NULL, testPF.getPersistentFile()); - assertNull(TestValues.NULL, testPF.getFileData()); - assertNotNull(TestValues.NOT_NULL, testPF.getCorrelationID()); - - // Test -- buildPutFile(String sdlFileName, Integer iOffset, Integer iLength) - testPF = RPCRequestFactory.buildPutFile(testFileName, testOffset, testLength); - assertEquals(TestValues.MATCH, testFileName, testPF.getSdlFileName()); - assertEquals(TestValues.MATCH, testOffset, testPF.getOffset()); - assertEquals(TestValues.MATCH, testLength, testPF.getLength()); - - testPF = RPCRequestFactory.buildPutFile(NullValues.STRING, NullValues.INTEGER, NullValues.INTEGER); - assertNull(TestValues.NULL, testPF.getSdlFileName()); - assertNull(TestValues.NULL, testPF.getOffset()); - assertNull(TestValues.NULL, testPF.getLength()); - - // Test -- buildPutFile(String syncFileName, Integer iOffset, Integer iLength, FileType fileType, Boolean bPersistentFile, Boolean bSystemFile) - testPF = RPCRequestFactory.buildPutFile(testFileName, testOffset, testLength, testFileType, testPFile, testSystemFile); - assertEquals(TestValues.MATCH, testFileName, testPF.getSdlFileName()); - assertEquals(TestValues.MATCH, testOffset, testPF.getOffset()); - assertEquals(TestValues.MATCH, testLength, testPF.getLength()); - assertTrue(TestValues.TRUE, testPF.getPersistentFile()); - assertEquals(TestValues.MATCH, testSystemFile, testPF.getSystemFile()); - - testPF = RPCRequestFactory.buildPutFile(NullValues.STRING, NullValues.INTEGER, NullValues.INTEGER, null, NullValues.BOOLEAN, NullValues.BOOLEAN); - assertNull(TestValues.NULL, testPF.getSdlFileName()); - assertNull(TestValues.NULL, testPF.getOffset()); - assertNull(TestValues.NULL, testPF.getLength()); - assertNull(TestValues.NULL, testPF.getFileType()); - assertNull(TestValues.NULL, testPF.getPersistentFile()); - assertNull(TestValues.NULL, testPF.getSystemFile()); - } - - public void testBuildRegisterAppInterface () { - - SdlMsgVersion testSMV = new SdlMsgVersion(); - testSMV.setMajorVersion(1); - testSMV.setMinorVersion(0); - String testAppName = "test", testNGN = "ngn", testAppID = "id"; - Vector testTTSName = TTSChunkFactory.createSimpleTTSChunks("name"); - Vector testSynonyms = new Vector(); - testSynonyms.add("examine"); - Boolean testIMA = false; - Integer testCorrelationID = 0; - Language testLang = Language.EN_US, testHMILang = Language.EN_GB; - Vector testHMIType = new Vector(); - testHMIType.add(AppHMIType.DEFAULT); - DeviceInfo testDI = RPCRequestFactory.BuildDeviceInfo(null); - RegisterAppInterface testRAI; - - // Test -- buildRegisterAppInterface(String appName, String appID) - // ^ Calls another build method. - - // Test -- buildRegisterAppInterface(String appName, Boolean isMediaApp, String appID) - // ^ Calls another build method. - - // Test -- buildRegisterAppInterface(SdlMsgVersion sdlMsgVersion, String appName, Vector ttsName, String ngnMediaScreenAppName, Vector vrSynonyms, Boolean isMediaApp, Language languageDesired, Language hmiDisplayLanguageDesired, Vector appType, String appID, Integer correlationID) - testRAI = RPCRequestFactory.buildRegisterAppInterface(testSMV, testAppName, testTTSName, testNGN, testSynonyms, testIMA, testLang, testHMILang, testHMIType, testAppID, testCorrelationID,testDI); - assertTrue(TestValues.TRUE, Validator.validateSdlMsgVersion(testSMV, testRAI.getSdlMsgVersion())); - assertEquals(TestValues.MATCH, testAppName, testRAI.getAppName()); - assertTrue(TestValues.TRUE, Validator.validateTtsChunks(testTTSName, testRAI.getTtsName())); - assertEquals(TestValues.MATCH, testNGN, testRAI.getNgnMediaScreenAppName()); - assertTrue(TestValues.TRUE, Validator.validateStringList(testSynonyms, testRAI.getVrSynonyms())); - assertEquals(TestValues.MATCH, testIMA, testRAI.getIsMediaApplication()); - assertEquals(TestValues.MATCH, testLang, testRAI.getLanguageDesired()); - assertEquals(TestValues.MATCH, testHMILang, testRAI.getHmiDisplayLanguageDesired()); - assertEquals(TestValues.MATCH, AppHMIType.DEFAULT, testRAI.getAppHMIType().get(0)); - assertEquals(TestValues.MATCH, testAppID, testRAI.getAppID()); - assertEquals(TestValues.MATCH, testCorrelationID, testRAI.getCorrelationID()); - assertEquals(TestValues.MATCH, testDI, testRAI.getDeviceInfo()); - - - testRAI = RPCRequestFactory.buildRegisterAppInterface(null, null, null, null, null, null, null, null, null, null, null,null); - assertEquals(TestValues.MATCH, (Integer) 1, testRAI.getCorrelationID()); - assertEquals(TestValues.MATCH, testSMV.getMajorVersion(), testRAI.getSdlMsgVersion().getMajorVersion()); - assertEquals(TestValues.MATCH, testSMV.getMinorVersion(), testRAI.getSdlMsgVersion().getMinorVersion()); - assertNull(TestValues.NULL, testRAI.getAppName()); - assertNull(TestValues.NULL, testRAI.getTtsName()); - assertNull(TestValues.NULL, testRAI.getNgnMediaScreenAppName()); - assertNull(TestValues.NULL, testRAI.getVrSynonyms()); - assertNull(TestValues.NULL, testRAI.getIsMediaApplication()); - assertNotNull(TestValues.NOT_NULL, testRAI.getLanguageDesired()); - assertNotNull(TestValues.NOT_NULL, testRAI.getHmiDisplayLanguageDesired()); - assertNull(TestValues.NULL, testRAI.getAppHMIType()); - assertNull(TestValues.NULL, testRAI.getAppID()); - assertNull(TestValues.NULL, testRAI.getDeviceInfo()); - } - - public void testBuildSetAppIcon () { - - String testFileName = "test"; - Integer testCorrelationID = 0; - SetAppIcon testSAI; - - // Test -- buildSetAppIcon(String sdlFileName, Integer correlationID) - testSAI = RPCRequestFactory.buildSetAppIcon(testFileName, testCorrelationID); - assertEquals(TestValues.MATCH, testFileName, testSAI.getSdlFileName()); - assertEquals(TestValues.MATCH, testCorrelationID, testSAI.getCorrelationID()); - - testSAI = RPCRequestFactory.buildSetAppIcon(null, null); - assertNull(TestValues.NULL, testSAI.getSdlFileName()); - assertNotNull(TestValues.NOT_NULL, testSAI.getCorrelationID()); - - } - - public void testBuildSetGlobalProperties () { - - Vector testHelpChunks = TTSChunkFactory.createSimpleTTSChunks("test"), - testTimeoutChunks = TTSChunkFactory.createSimpleTTSChunks("timeout"); - Vector testVrHelp = new Vector(); - VrHelpItem testItem = new VrHelpItem(); - testItem.setPosition(0); - testItem.setText("text"); - Image image = new Image(); - image.setValue("value"); - image.setImageType(ImageType.DYNAMIC); - testItem.setImage(image); - testVrHelp.add(testItem); - Integer testCorrelationID = 0; - String testHelpTitle = "help"; - SetGlobalProperties testSBP; - - // Test -- buildSetGlobalProperties(String helpPrompt, String timeoutPrompt, Integer correlationID) - // ^ Calls another build method. - - // Test -- buildSetGlobalProperties(Vector helpChunks, Vector timeoutChunks, Integer correlationID) - testSBP = RPCRequestFactory.buildSetGlobalProperties(testHelpChunks, testTimeoutChunks, testCorrelationID); - assertTrue(TestValues.TRUE, Validator.validateTtsChunks(testHelpChunks, testSBP.getHelpPrompt())); - assertTrue(TestValues.TRUE, Validator.validateTtsChunks(testTimeoutChunks, testSBP.getTimeoutPrompt())); - assertEquals(TestValues.MATCH, testCorrelationID, testSBP.getCorrelationID()); - - testSBP = RPCRequestFactory.buildSetGlobalProperties((Vector) null, null, null); - assertNull(TestValues.NULL, testSBP.getHelpPrompt()); - assertNull(TestValues.NULL, testSBP.getTimeoutPrompt()); - assertNotNull(TestValues.NOT_NULL, testSBP.getCorrelationID()); - - // Test -- buildSetGlobalProperties(String helpPrompt, String timeoutPrompt, String vrHelpTitle, Vector vrHelp, Integer correlationID) - // ^ Calls another build method. - - // Test -- buildSetGlobalProperties(Vector helpChunks, Vector timeoutChunks, String vrHelpTitle, Vector vrHelp, Integer correlationID) - testSBP = RPCRequestFactory.buildSetGlobalProperties(testHelpChunks, testTimeoutChunks, testHelpTitle, testVrHelp, testCorrelationID); - assertTrue(TestValues.TRUE, Validator.validateTtsChunks(testHelpChunks, testSBP.getHelpPrompt())); - assertTrue(TestValues.TRUE, Validator.validateTtsChunks(testTimeoutChunks, testSBP.getTimeoutPrompt())); - assertEquals(TestValues.MATCH, testHelpTitle, testSBP.getVrHelpTitle()); - assertTrue(TestValues.TRUE, Validator.validateVrHelpItems(testVrHelp, testSBP.getVrHelp())); - assertEquals(TestValues.MATCH, testCorrelationID, testSBP.getCorrelationID()); - - testSBP = RPCRequestFactory.buildSetGlobalProperties((Vector) null, null, null, null, null); - assertNull(TestValues.NULL, testSBP.getHelpPrompt()); - assertNull(TestValues.NULL, testSBP.getTimeoutPrompt()); - assertNull(TestValues.NULL, testSBP.getVrHelpTitle()); - assertNull(TestValues.NULL, testSBP.getVrHelp()); - assertNotNull(TestValues.NOT_NULL, testSBP.getCorrelationID()); - } - - public void testBuildSetMediaClockTimer () { - - Integer hours = 0, minutes = 0, seconds = 0, testCorrelationID = 0; - UpdateMode testMode = UpdateMode.COUNTUP; - SetMediaClockTimer testSMCT; - - // Test -- buildSetMediaClockTimer(Integer hours, Integer minutes, Integer seconds, UpdateMode updateMode, Integer correlationID) - testSMCT = RPCRequestFactory.buildSetMediaClockTimer(hours, minutes, seconds, testMode, testCorrelationID); - assertEquals(TestValues.MATCH, hours, testSMCT.getStartTime().getHours()); - assertEquals(TestValues.MATCH, minutes, testSMCT.getStartTime().getMinutes()); - assertEquals(TestValues.MATCH, seconds, testSMCT.getStartTime().getSeconds()); - assertEquals(TestValues.MATCH, testMode, testSMCT.getUpdateMode()); - assertEquals(TestValues.MATCH, testCorrelationID, testSMCT.getCorrelationID()); - - testSMCT = RPCRequestFactory.buildSetMediaClockTimer(null, null, null, null, null); - assertNull(TestValues.NULL, testSMCT.getStartTime()); - assertNull(TestValues.NULL, testSMCT.getUpdateMode()); - assertNotNull(TestValues.NOT_NULL, testSMCT.getCorrelationID()); - - // Test -- buildSetMediaClockTimer(UpdateMode updateMode, Integer correlationID) - // ^ Calls another build method. - } - - @SuppressWarnings("deprecation") - public void testBuildShow () { - - Image testGraphic = new Image(); - testGraphic.setImageType(ImageType.STATIC); - testGraphic.setValue("test"); - String testText1 = "test1", testText2 = "test2", testText3 = "test3", testText4 = "test4", testStatusBar = "status", testMediaClock = "media", testMediaTrack = "track"; - Vector testSoftButtons = new Vector(); - testSoftButtons.add(new SoftButton()); - Vector testCustomPresets = new Vector(); - testCustomPresets.add("Test"); - TextAlignment testAlignment = TextAlignment.CENTERED; - Integer testCorrelationID = 0; - Show testShow; - - // Test -- buildShow(String mainText1, String mainText2, String mainText3, String mainText4, String statusBar, String mediaClock, String mediaTrack, Image graphic, Vector softButtons, Vector customPresets, TextAlignment alignment, Integer correlationID) - testShow = RPCRequestFactory.buildShow(testText1, testText2, testText3, testText4, testStatusBar, testMediaClock, testMediaTrack, testGraphic, testSoftButtons, testCustomPresets, testAlignment, testCorrelationID); - assertEquals(TestValues.MATCH, testText1, testShow.getMainField1()); - assertEquals(TestValues.MATCH, testText2, testShow.getMainField2()); - assertEquals(TestValues.MATCH, testText3, testShow.getMainField3()); - assertEquals(TestValues.MATCH, testText4, testShow.getMainField4()); - assertEquals(TestValues.MATCH, testStatusBar, testShow.getStatusBar()); - assertEquals(TestValues.MATCH, testMediaClock, testShow.getMediaClock()); - assertEquals(TestValues.MATCH, testMediaTrack, testShow.getMediaTrack()); - assertTrue(TestValues.TRUE, Validator.validateImage(testGraphic, testShow.getGraphic())); - assertTrue(TestValues.TRUE, Validator.validateSoftButtons(testSoftButtons, testShow.getSoftButtons())); - assertTrue(TestValues.TRUE, Validator.validateStringList(testCustomPresets, testShow.getCustomPresets())); - assertEquals(TestValues.MATCH, testAlignment, testShow.getAlignment()); - assertEquals(TestValues.MATCH, testCorrelationID, testShow.getCorrelationID()); - - testShow = RPCRequestFactory.buildShow(null, null, null, null, null, null, null, null, null, null, null, null); - assertNull(TestValues.NULL, testShow.getMainField1()); - assertNull(TestValues.NULL, testShow.getMainField2()); - assertNull(TestValues.NULL, testShow.getMainField3()); - assertNull(TestValues.NULL, testShow.getMainField4()); - assertNull(TestValues.NULL, testShow.getStatusBar()); - assertNull(TestValues.NULL, testShow.getMediaClock()); - assertNull(TestValues.NULL, testShow.getMediaTrack()); - assertNull(TestValues.NULL, testShow.getGraphic()); - assertNull(TestValues.NULL, testShow.getSoftButtons()); - assertNull(TestValues.NULL, testShow.getCustomPresets()); - assertNull(TestValues.NULL, testShow.getAlignment()); - assertNotNull(TestValues.NOT_NULL, testShow.getCorrelationID()); - // Test -- buildShow(String mainText1, String mainText2, String mainText3, String mainText4, TextAlignment alignment, Integer correlationID) - // ^ Calls another build method. - - // Test -- buildShow(String mainText1, String mainText2, String statusBar, String mediaClock, String mediaTrack, TextAlignment alignment, Integer correlationID) - testShow = RPCRequestFactory.buildShow(testText1, testText2, testStatusBar, testMediaClock, testMediaTrack, testAlignment, testCorrelationID); - assertEquals(TestValues.MATCH, testText1, testShow.getMainField1()); - assertEquals(TestValues.MATCH, testText2, testShow.getMainField2()); - assertEquals(TestValues.MATCH, testStatusBar, testShow.getStatusBar()); - assertEquals(TestValues.MATCH, testMediaClock, testShow.getMediaClock()); - assertEquals(TestValues.MATCH, testMediaTrack, testShow.getMediaTrack()); - assertEquals(TestValues.MATCH, testAlignment, testShow.getAlignment()); - assertEquals(TestValues.MATCH, testCorrelationID, testShow.getCorrelationID()); - - testShow = RPCRequestFactory.buildShow(null, null, null, null, null, null, null); - assertNull(TestValues.NULL, testShow.getMainField1()); - assertNull(TestValues.NULL, testShow.getMainField2()); - assertNull(TestValues.NULL, testShow.getStatusBar()); - assertNull(TestValues.NULL, testShow.getMediaClock()); - assertNull(TestValues.NULL, testShow.getMediaTrack()); - assertNull(TestValues.NULL, testShow.getAlignment()); - assertNotNull(TestValues.NOT_NULL, testShow.getCorrelationID()); - - // Test -- buildShow(String mainText1, String mainText2, TextAlignment alignment, Integer correlationID) - // ^ Calls another build method. - } - - public void testBuildSpeak () { - - String testTTSText = "test"; - Integer testCorrelationID = 0; - Vector testTTSChunks = TTSChunkFactory.createSimpleTTSChunks(testTTSText); - Speak testSpeak; - - // Test -- buildSpeak(String ttsText, Integer correlationID) - testSpeak = RPCRequestFactory.buildSpeak(testTTSText, testCorrelationID); - assertTrue(TestValues.TRUE, Validator.validateTtsChunks(testTTSChunks, testSpeak.getTtsChunks())); - assertEquals(TestValues.MATCH, testCorrelationID, testSpeak.getCorrelationID()); - - testSpeak = RPCRequestFactory.buildSpeak((String) null, null); - assertNull(TestValues.NULL, testSpeak.getTtsChunks()); - assertNotNull(TestValues.NOT_NULL, testSpeak.getCorrelationID()); - - // Test -- buildSpeak(Vector ttsChunks, Integer correlationID) - testSpeak = RPCRequestFactory.buildSpeak(testTTSChunks, testCorrelationID); - assertTrue(TestValues.TRUE, Validator.validateTtsChunks(testTTSChunks, testSpeak.getTtsChunks())); - assertEquals(TestValues.MATCH, testCorrelationID, testSpeak.getCorrelationID()); - - testSpeak = RPCRequestFactory.buildSpeak((Vector) null, null); - assertNull(TestValues.NULL, testSpeak.getTtsChunks()); - assertNotNull(TestValues.NOT_NULL, testSpeak.getCorrelationID()); - } - - public void testBuildSubscribeButton () { - - ButtonName testButtonName = ButtonName.CUSTOM_BUTTON; - Integer testCorrelationID = 0; - SubscribeButton testSB; - - // Test -- buildSubscribeButton(ButtonName buttonName, Integer correlationID) - testSB = RPCRequestFactory.buildSubscribeButton(testButtonName, testCorrelationID); - assertEquals(TestValues.MATCH, testButtonName, testSB.getButtonName()); - assertEquals(TestValues.MATCH, testCorrelationID, testSB.getCorrelationID()); - - testSB = RPCRequestFactory.buildSubscribeButton(null, null); - assertNull(TestValues.NULL, testSB.getButtonName()); - assertNotNull(TestValues.NOT_NULL, testSB.getCorrelationID()); - - } - - public void testBuildUnregisterAppInterface () { - - Integer testCorrelationID = 0; - UnregisterAppInterface testUAI; - - // Test -- buildUnregisterAppInterface(Integer correlationID) - testUAI = RPCRequestFactory.buildUnregisterAppInterface(testCorrelationID); - assertEquals(TestValues.MATCH, testCorrelationID, testUAI.getCorrelationID()); - - testUAI = RPCRequestFactory.buildUnregisterAppInterface(null); - assertNotNull(TestValues.NOT_NULL, testUAI.getCorrelationID()); - } - - public void testBuildUnsubscribeButton () { - - ButtonName testButtonName = ButtonName.CUSTOM_BUTTON; - Integer testCorrelationID = 0; - UnsubscribeButton testUB; - - // Test -- buildUnsubscribeButton(ButtonName buttonName, Integer correlationID) - testUB = RPCRequestFactory.buildUnsubscribeButton(testButtonName, testCorrelationID); - assertEquals(TestValues.MATCH, testButtonName, testUB.getButtonName()); - assertEquals(TestValues.MATCH, testCorrelationID, testUB.getCorrelationID()); - - testUB = RPCRequestFactory.buildUnsubscribeButton(null, null); - assertNull(TestValues.NULL, testUB.getButtonName()); - assertNotNull(TestValues.NOT_NULL, testUB.getCorrelationID()); - - } - - public void testBuildSubscribeVehicleData () { - - boolean testGPS = true, testSpeed = true, testRPM = true, testFuelLevel = true, testFuelLevelState = true, testInstantFuelConsumption = true, testExternalTemperature = true, testPRNDL = true, testTirePressure = true, testOdometer = true, testBeltStatus = true, testBodyInformation = true, testDeviceStatus = true, testDriverBraking = true; - Integer testCorrelationID = 0; - SubscribeVehicleData testSVD; - - // Test -- BuildSubscribeVehicleData(boolean gps, boolean speed, boolean rpm, boolean fuelLevel, boolean fuelLevel_State, boolean instantFuelConsumption, boolean externalTemperature, boolean prndl, boolean tirePressure, boolean odometer, boolean beltStatus, boolean bodyInformation, boolean deviceStatus, boolean driverBraking, Integer correlationID) - testSVD = RPCRequestFactory.BuildSubscribeVehicleData(testGPS, testSpeed, testRPM, testFuelLevel, testFuelLevelState, testInstantFuelConsumption, testExternalTemperature, testPRNDL, testTirePressure, testOdometer, testBeltStatus, testBodyInformation, testDeviceStatus, testDriverBraking, testCorrelationID); - assertTrue(TestValues.TRUE, testSVD.getGps()); - assertTrue(TestValues.TRUE, testSVD.getSpeed()); - assertTrue(TestValues.TRUE, testSVD.getRpm()); - assertTrue(TestValues.TRUE, testSVD.getFuelLevel()); - assertTrue(TestValues.TRUE, testSVD.getFuelLevelState()); - assertTrue(TestValues.TRUE, testSVD.getInstantFuelConsumption()); - assertTrue(TestValues.TRUE, testSVD.getExternalTemperature()); - assertTrue(TestValues.TRUE, testSVD.getPrndl()); - assertTrue(TestValues.TRUE, testSVD.getTirePressure()); - assertTrue(TestValues.TRUE, testSVD.getOdometer()); - assertTrue(TestValues.TRUE, testSVD.getBeltStatus()); - assertTrue(TestValues.TRUE, testSVD.getBodyInformation()); - assertTrue(TestValues.TRUE, testSVD.getDeviceStatus()); - assertTrue(TestValues.TRUE, testSVD.getDriverBraking()); - assertEquals(TestValues.MATCH, testCorrelationID, testSVD.getCorrelationID()); - - testSVD = RPCRequestFactory.BuildSubscribeVehicleData(testGPS, testSpeed, testRPM, testFuelLevel, testFuelLevelState, testInstantFuelConsumption, testExternalTemperature, testPRNDL, testTirePressure, testOdometer, testBeltStatus, testBodyInformation, testDeviceStatus, testDriverBraking, null); - assertNotNull(TestValues.NULL, testSVD.getCorrelationID()); - } - - public void testBuildUnsubscribeVehicleData () { - - boolean testGPS = true, testSpeed = true, testRPM = true, testFuelLevel = true, testFuelLevelState = true, testInstantFuelConsumption = true, testExternalTemperature = true, testPRNDL = true, testTirePressure = true, testOdometer = true, testBeltStatus = true, testBodyInformation = true, testDeviceStatus = true, testDriverBraking = true; - Integer testCorrelationID = 0; - UnsubscribeVehicleData testUVD; - - // Test -- BuildUnsubscribeVehicleData(boolean gps, boolean speed, boolean rpm, boolean fuelLevel, boolean fuelLevel_State, boolean instantFuelConsumption, boolean externalTemperature, boolean prndl, boolean tirePressure, boolean odometer, boolean beltStatus, boolean bodyInformation, boolean deviceStatus, boolean driverBraking, Integer correlationID) - testUVD = RPCRequestFactory.BuildUnsubscribeVehicleData(testGPS, testSpeed, testRPM, testFuelLevel, testFuelLevelState, testInstantFuelConsumption, testExternalTemperature, testPRNDL, testTirePressure, testOdometer, testBeltStatus, testBodyInformation, testDeviceStatus, testDriverBraking, testCorrelationID); - assertTrue(TestValues.TRUE, testUVD.getGps()); - assertTrue(TestValues.TRUE, testUVD.getSpeed()); - assertTrue(TestValues.TRUE, testUVD.getRpm()); - assertTrue(TestValues.TRUE, testUVD.getFuelLevel()); - assertTrue(TestValues.TRUE, testUVD.getFuelLevelState()); - assertTrue(TestValues.TRUE, testUVD.getInstantFuelConsumption()); - assertTrue(TestValues.TRUE, testUVD.getExternalTemperature()); - assertTrue(TestValues.TRUE, testUVD.getPrndl()); - assertTrue(TestValues.TRUE, testUVD.getTirePressure()); - assertTrue(TestValues.TRUE, testUVD.getOdometer()); - assertTrue(TestValues.TRUE, testUVD.getBeltStatus()); - assertTrue(TestValues.TRUE, testUVD.getBodyInformation()); - assertTrue(TestValues.TRUE, testUVD.getDeviceStatus()); - assertTrue(TestValues.TRUE, testUVD.getDriverBraking()); - assertEquals(TestValues.MATCH, testCorrelationID, testUVD.getCorrelationID()); - - testUVD = RPCRequestFactory.BuildUnsubscribeVehicleData(testGPS, testSpeed, testRPM, testFuelLevel, testFuelLevelState, testInstantFuelConsumption, testExternalTemperature, testPRNDL, testTirePressure, testOdometer, testBeltStatus, testBodyInformation, testDeviceStatus, testDriverBraking, null); - assertNotNull(TestValues.NULL, testUVD.getCorrelationID()); - } - - public void testBuildGetVehicleData () { - - boolean testGPS = true, testSpeed = true, testRPM = true, testFuelLevel = true, testFuelLevelState = true, testInstantFuelConsumption = true, testExternalTemperature = true, testVIN = true, testPRNDL = true, testTirePressure = true, testOdometer = true, testBeltStatus = true, testBodyInformation = true, testDeviceStatus = true, testDriverBraking = true; - Integer testCorrelationID = 0; - GetVehicleData testGVD; - - // Test -- BuildGetVehicleData(boolean gps, boolean speed, boolean rpm, boolean fuelLevel, boolean fuelLevel_State, boolean instantFuelConsumption, boolean externalTemperature, boolean vin, boolean prndl, boolean tirePressure, boolean odometer, boolean beltStatus, boolean bodyInformation, boolean deviceStatus, boolean driverBraking, Integer correlationID) - testGVD = RPCRequestFactory.BuildGetVehicleData(testGPS, testSpeed, testRPM, testFuelLevel, testFuelLevelState, testInstantFuelConsumption, testExternalTemperature, testVIN, testPRNDL, testTirePressure, testOdometer, testBeltStatus, testBodyInformation, testDeviceStatus, testDriverBraking, testCorrelationID); - assertTrue(TestValues.TRUE, testGVD.getGps()); - assertTrue(TestValues.TRUE, testGVD.getSpeed()); - assertTrue(TestValues.TRUE, testGVD.getRpm()); - assertTrue(TestValues.TRUE, testGVD.getFuelLevel()); - assertTrue(TestValues.TRUE, testGVD.getFuelLevelState()); - assertTrue(TestValues.TRUE, testGVD.getInstantFuelConsumption()); - assertTrue(TestValues.TRUE, testGVD.getExternalTemperature()); - assertTrue(TestValues.TRUE, testGVD.getPrndl()); - assertTrue(TestValues.TRUE, testGVD.getTirePressure()); - assertTrue(TestValues.TRUE, testGVD.getOdometer()); - assertTrue(TestValues.TRUE, testGVD.getBeltStatus()); - assertTrue(TestValues.TRUE, testGVD.getBodyInformation()); - assertTrue(TestValues.TRUE, testGVD.getDeviceStatus()); - assertTrue(TestValues.TRUE, testGVD.getDriverBraking()); - assertTrue(TestValues.TRUE, testGVD.getVin()); - assertEquals(TestValues.MATCH, testCorrelationID, testGVD.getCorrelationID()); - - testGVD = RPCRequestFactory.BuildGetVehicleData(testGPS, testSpeed, testRPM, testFuelLevel, testFuelLevelState, testInstantFuelConsumption, testExternalTemperature, testVIN, testPRNDL, testTirePressure, testOdometer, testBeltStatus, testBodyInformation, testDeviceStatus, testDriverBraking, null); - assertNotNull(TestValues.NULL, testGVD.getCorrelationID()); - } - - public void testBuildScrollableMessage () { - - String testSMB = "test"; - Integer testTimeout = 1, testCorrelationID = 0; - Vector testSoftButtons = new Vector(); - testSoftButtons.add(new SoftButton()); - ScrollableMessage testSM; - - // Test -- BuildScrollableMessage(String scrollableMessageBody, Integer timeout, Vector softButtons, Integer correlationID) - testSM = RPCRequestFactory.BuildScrollableMessage(testSMB, testTimeout, testSoftButtons, testCorrelationID); - assertEquals(TestValues.MATCH, testSMB, testSM.getScrollableMessageBody()); - assertEquals(TestValues.MATCH, testTimeout, testSM.getTimeout()); - assertTrue(TestValues.TRUE, Validator.validateSoftButtons(testSoftButtons, testSM.getSoftButtons())); - assertEquals(TestValues.MATCH, testCorrelationID, testSM.getCorrelationID()); - - testSM = RPCRequestFactory.BuildScrollableMessage(null, null, null, null); - assertNull(TestValues.NULL, testSM.getScrollableMessageBody()); - assertNull(TestValues.NULL, testSM.getTimeout()); - assertNull(TestValues.NULL, testSM.getSoftButtons()); - assertNotNull(TestValues.NOT_NULL, testSM.getCorrelationID()); - } - - public void testBuildSlider () { - - Integer testTicks = 1, testPosition = 2, testTimeout = 3, testCorrelationID = 0; - String testHeader = "header"; - Vector testFooter = new Vector(); - testFooter.add("footer"); - Slider testSlider; - - // Test -- BuildSlider(Integer numTicks, Integer position, String sliderHeader, Vector sliderFooter, Integer timeout, Integer correlationID) - testSlider = RPCRequestFactory.BuildSlider(testTicks, testPosition, testHeader, testFooter, testTimeout, testCorrelationID); - assertEquals(TestValues.MATCH, testTicks, testSlider.getNumTicks()); - assertEquals(TestValues.MATCH, testPosition, testSlider.getPosition()); - assertEquals(TestValues.MATCH, testHeader, testSlider.getSliderHeader()); - assertTrue(TestValues.TRUE, Validator.validateStringList(testFooter, testSlider.getSliderFooter())); - assertEquals(TestValues.MATCH, testCorrelationID, testSlider.getCorrelationID()); - - testSlider = RPCRequestFactory.BuildSlider(null, null, null, null, null, null); - assertNull(TestValues.NULL, testSlider.getNumTicks()); - assertNull(TestValues.NULL, testSlider.getPosition()); - assertNull(TestValues.NULL, testSlider.getSliderHeader()); - assertNull(TestValues.NULL, testSlider.getSliderFooter()); - assertNull(TestValues.NULL, testSlider.getTimeout()); - assertNotNull(TestValues.NOT_NULL, testSlider.getCorrelationID()); - } - - public void testBuildChangeRegistration () { - - Language testLang = Language.EN_US, testHMILang = Language.EN_AU; - Integer testCorrelationID = 0; - ChangeRegistration testCR; - - // Test -- BuildChangeRegistration(Language language, Language hmiDisplayLanguage, Integer correlationID) - testCR = RPCRequestFactory.BuildChangeRegistration(testLang, testHMILang, testCorrelationID); - assertEquals(TestValues.MATCH, testLang, testCR.getLanguage()); - assertEquals(TestValues.MATCH, testHMILang, testCR.getHmiDisplayLanguage()); - assertEquals(TestValues.MATCH, testCorrelationID, testCR.getCorrelationID()); - - testCR = RPCRequestFactory.BuildChangeRegistration(null, null, null); - assertNull(TestValues.NULL, testCR.getLanguage()); - assertNull(TestValues.NULL, testCR.getHmiDisplayLanguage()); - assertNotNull(TestValues.NOT_NULL, testCR.getCorrelationID()); - } - - public void testBuildSetDisplayLayout () { - - String testDL = "layout"; - Integer testCorrelationID = 0; - SetDisplayLayout testSDL; - - // Test -- BuildSetDisplayLayout(String displayLayout, Integer correlationID) - testSDL = RPCRequestFactory.BuildSetDisplayLayout(testDL, testCorrelationID); - assertEquals(TestValues.MATCH, testDL, testSDL.getDisplayLayout()); - assertEquals(TestValues.MATCH, testCorrelationID, testSDL.getCorrelationID()); - - testSDL = RPCRequestFactory.BuildSetDisplayLayout(null, null); - assertNull(TestValues.NULL, testSDL.getDisplayLayout()); - assertNotNull(TestValues.NOT_NULL, testSDL.getCorrelationID()); - } - - public void testBuildPerformAudioPassThru () { - - Vector testInitialPrompt = TTSChunkFactory.createSimpleTTSChunks("test"); - String testAPTDT1 = "audio", testAPTDT2 = "pass"; - SamplingRate testSR = SamplingRate._16KHZ; - Integer testMaxDuration = 1, testCorrelationID = 0; - BitsPerSample testBits = BitsPerSample._16_BIT; - AudioType testAT = AudioType.PCM; - Boolean testMute = false; - PerformAudioPassThru testPAPT; - - // Test -- BuildPerformAudioPassThru(String ttsText, String audioPassThruDisplayText1, String audioPassThruDisplayText2, SamplingRate samplingRate, Integer maxDuration, BitsPerSample bitsPerSample, AudioType audioType, Boolean muteAudio, Integer correlationID) - // ^ Calls another build method. - - // Test -- BuildPerformAudioPassThru(Vector initialPrompt, String audioPassThruDisplayText1, String audioPassThruDisplayText2, SamplingRate samplingRate, Integer maxDuration, BitsPerSample bitsPerSample, AudioType audioType, Boolean muteAudio, Integer correlationID) - testPAPT = RPCRequestFactory.BuildPerformAudioPassThru(testInitialPrompt, testAPTDT1, testAPTDT2, testSR, testMaxDuration, testBits, testAT, testMute, testCorrelationID); - assertTrue(TestValues.TRUE, Validator.validateTtsChunks(testInitialPrompt, testPAPT.getInitialPrompt())); - assertEquals(TestValues.MATCH, testAPTDT1, testPAPT.getAudioPassThruDisplayText1()); - assertEquals(TestValues.MATCH, testAPTDT2, testPAPT.getAudioPassThruDisplayText2()); - assertEquals(TestValues.MATCH, testSR, testPAPT.getSamplingRate()); - assertEquals(TestValues.MATCH, testMaxDuration, testPAPT.getMaxDuration()); - assertEquals(TestValues.MATCH, testBits, testPAPT.getBitsPerSample()); - assertEquals(TestValues.MATCH, testAT, testPAPT.getAudioType()); - assertEquals(TestValues.MATCH, testMute, testPAPT.getMuteAudio()); - assertEquals(TestValues.MATCH, testCorrelationID, testPAPT.getCorrelationID()); - - testPAPT = RPCRequestFactory.BuildPerformAudioPassThru((Vector) null, null, null, null, null, null, null, null, null); - assertNull(TestValues.NULL, testPAPT.getInitialPrompt()); - assertNull(TestValues.NULL, testPAPT.getAudioPassThruDisplayText1()); - assertNull(TestValues.NULL, testPAPT.getAudioPassThruDisplayText2()); - assertNull(TestValues.NULL, testPAPT.getSamplingRate()); - assertNull(TestValues.NULL, testPAPT.getMaxDuration()); - assertNull(TestValues.NULL, testPAPT.getBitsPerSample()); - assertNull(TestValues.NULL, testPAPT.getAudioType()); - assertNull(TestValues.NULL, testPAPT.getMuteAudio()); - assertNotNull(TestValues.NOT_NULL, testPAPT.getCorrelationID()); - } - - public void testBuildEndAudioPassThru () { - - Integer testCorrelationID = 0; - EndAudioPassThru testEAPT; - - // Test -- BuildEndAudioPassThru(Integer correlationID) - testEAPT = RPCRequestFactory.BuildEndAudioPassThru(testCorrelationID); - assertEquals(TestValues.MATCH, testCorrelationID, testEAPT.getCorrelationID()); - - testEAPT = RPCRequestFactory.BuildEndAudioPassThru(null); - assertNotNull(TestValues.NOT_NULL, testEAPT.getCorrelationID()); - } -} \ No newline at end of file diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SdlProxyBaseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SdlProxyBaseTests.java deleted file mode 100644 index 92670c7d4..000000000 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SdlProxyBaseTests.java +++ /dev/null @@ -1,298 +0,0 @@ -package com.smartdevicelink.test.proxy; - -import android.content.Context; -import androidx.test.ext.junit.runners.AndroidJUnit4; -import android.telephony.TelephonyManager; -import android.util.Log; - -import com.smartdevicelink.exception.SdlException; -import com.smartdevicelink.exception.SdlExceptionCause; -import com.smartdevicelink.proxy.RPCMessage; -import com.smartdevicelink.proxy.RPCRequest; -import com.smartdevicelink.proxy.RPCResponse; -import com.smartdevicelink.proxy.SdlProxyALM; -import com.smartdevicelink.proxy.SdlProxyBase; -import com.smartdevicelink.proxy.SdlProxyBuilder; -import com.smartdevicelink.proxy.SdlProxyConfigurationResources; -import com.smartdevicelink.proxy.interfaces.IProxyListenerALM; -import com.smartdevicelink.proxy.rpc.GenericResponse; -import com.smartdevicelink.proxy.rpc.Show; -import com.smartdevicelink.proxy.rpc.ShowResponse; -import com.smartdevicelink.proxy.rpc.Speak; -import com.smartdevicelink.proxy.rpc.SpeakResponse; -import com.smartdevicelink.proxy.rpc.enums.Result; -import com.smartdevicelink.proxy.rpc.listeners.OnMultipleRequestListener; -import com.smartdevicelink.proxy.rpc.listeners.OnRPCResponseListener; -import com.smartdevicelink.streaming.video.SdlRemoteDisplay; -import com.smartdevicelink.streaming.video.VideoStreamingParameters; -import com.smartdevicelink.test.streaming.video.SdlRemoteDisplayTest; - -import junit.framework.Assert; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; - -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -import static junit.framework.TestCase.assertEquals; -import static junit.framework.TestCase.assertNotNull; -import static junit.framework.TestCase.assertTrue; -import static junit.framework.TestCase.fail; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; - -@RunWith(AndroidJUnit4.class) -public class SdlProxyBaseTests { - public static final String TAG = "SdlProxyBaseTests"; - - int onUpdateListenerCounter, onFinishedListenerCounter, onResponseListenerCounter, onErrorListenerCounter, remainingRequestsExpected; - - /** - * Test SdlProxyBase for handling null SdlProxyConfigurationResources - */ - @Test - public void testNullSdlProxyConfigurationResources() { - SdlProxyALM proxy = null; - SdlProxyBuilder.Builder builder = new SdlProxyBuilder.Builder(mock(IProxyListenerALM.class), "appId", "appName", true, getInstrumentation().getTargetContext()); - SdlProxyConfigurationResources config = new SdlProxyConfigurationResources("path", (TelephonyManager) getInstrumentation().getTargetContext().getSystemService(Context.TELEPHONY_SERVICE)); - //Construct with a non-null SdlProxyConfigurationResources - builder.setSdlProxyConfigurationResources(config); - try { - proxy = builder.build(); - } catch (Exception e) { - Log.v(TAG, "Exception in testNullSdlProxyConfigurationResources, testing non null SdlProxyConfigurationResources"); - if (!(e instanceof SdlException) || !((SdlException) e).getSdlExceptionCause().equals(SdlExceptionCause.BLUETOOTH_ADAPTER_NULL)) { - e.printStackTrace(); - Assert.fail("Exception in testNullSdlProxyConfigurationResources - \n" + e.toString()); - } - } - - if (proxy != null) { - try { - proxy.dispose(); - proxy = null; - }catch(SdlException e){ - e.printStackTrace(); - } - } - - //Construct with a null SdlProxyConfigurationResources - builder.setSdlProxyConfigurationResources(null); - try { - proxy = builder.build(); - } catch (Exception e) { - Log.v(TAG, "Exception in testNullSdlProxyConfigurationResources, testing null SdlProxyConfigurationResources"); - if (!(e instanceof SdlException) || !((SdlException) e).getSdlExceptionCause().equals(SdlExceptionCause.BLUETOOTH_ADAPTER_NULL)) { - e.printStackTrace(); - Assert.fail("Exception in testNullSdlProxyConfigurationResources, testing null SdlProxyConfigurationResources"); - } - } - if (proxy != null) { - try { - proxy.dispose(); - proxy = null; - }catch(SdlException e){ - e.printStackTrace(); - } - } - - //Construct with a non-null SdlProxyConfigurationResources and a null TelephonyManager - config.setTelephonyManager(null); - builder.setSdlProxyConfigurationResources(config); - try { - proxy = builder.build(); - } catch (Exception e) { - Log.v(TAG, "Exception in testNullSdlProxyConfigurationResources, testing null TelephonyManager"); - if (!(e instanceof SdlException) || !((SdlException) e).getSdlExceptionCause().equals(SdlExceptionCause.BLUETOOTH_ADAPTER_NULL)) { - Assert.fail("Exception in testNullSdlProxyConfigurationResources, testing null TelephonyManager"); - } - } - if (proxy != null) { - try { - proxy.dispose(); - proxy = null; - }catch(SdlException e){ - e.printStackTrace(); - } - } - } - - @Test - public void testRemoteDisplayStreaming(){ - SdlProxyALM proxy = null; - SdlProxyBuilder.Builder builder = new SdlProxyBuilder.Builder(mock(IProxyListenerALM.class), "appId", "appName", true, getInstrumentation().getTargetContext()); - try{ - proxy = builder.build(); - // public void startRemoteDisplayStream(Context context, final Class remoteDisplay, final VideoStreamingParameters parameters, final boolean encrypted){ - Method m = SdlProxyALM.class.getDeclaredMethod("startRemoteDisplayStream", Context.class, SdlRemoteDisplay.class, VideoStreamingParameters.class, boolean.class); - assertNotNull(m); - m.setAccessible(true); - m.invoke(proxy,getInstrumentation().getTargetContext(), SdlRemoteDisplayTest.MockRemoteDisplay.class, (VideoStreamingParameters)null, false); - assert true; - - }catch (Exception e){ - assert false; - } - } - - @Test - public void testSendRPCsAllSucceed(){ - testSendMultipleRPCs(false, 1); - } - - @Test - public void testSendRPCsSomeFail(){ - testSendMultipleRPCs(false, 2); - } - - @Test - public void testSendSequentialRPCsAllSucceed(){ - testSendMultipleRPCs(true, 1); - } - - @Test - public void testSendSequentialRPCsSomeFail(){ - testSendMultipleRPCs(true, 2); - } - - private void testSendMultipleRPCs(boolean sequentialSend, int caseNumber){ - final List rpcsList = new ArrayList<>(); - final List rpcsTempList = new ArrayList<>(); - final HashMap requestsMap = new HashMap<>(); - onUpdateListenerCounter = 0; - onFinishedListenerCounter = 0; - onResponseListenerCounter = 0; - onErrorListenerCounter = 0; - - - // We extend the SdlProxyBase to be able to override getIsConnected() & sendRPCMessagePrivate() methods so they don't cause issues when trying to send RPCs - // Because otherwise, they will throw exception cause there not actual connection to head unit - SdlProxyBase proxy = new SdlProxyBase() { - - @Override - public Boolean getIsConnected() { - return true; - } - - @Override - protected void sendRPCMessagePrivate(RPCMessage message) { - // Do nothing - } - }; - - - // We need to get list of all OnRPCResponseListeners so we can trigger onResponse/onError for each RPC to fake a response from Core - final Answer answer = new Answer() { - @Override - public Void answer(InvocationOnMock invocation) { - Object[] args = invocation.getArguments(); - RPCRequest request = (RPCRequest) invocation.getMock(); - OnRPCResponseListener listener = (OnRPCResponseListener) args[0]; - requestsMap.put(request, listener); - rpcsTempList.add(request); - return null; - } - }; - - - // Prepare RPCs to send - Speak speak = mock(Speak.class); - doReturn(RPCMessage.KEY_REQUEST).when(speak).getMessageType(); - doAnswer(answer).when(speak).setOnRPCResponseListener(any(OnRPCResponseListener.class)); - rpcsList.add(speak); - - Show show = mock(Show.class); - doReturn(RPCMessage.KEY_REQUEST).when(show).getMessageType(); - doAnswer(answer).when(show).setOnRPCResponseListener(any(OnRPCResponseListener.class)); - rpcsList.add(show); - - - // Send RPCs - remainingRequestsExpected = rpcsList.size(); - OnMultipleRequestListener onMultipleRequestListener = new OnMultipleRequestListener() { - @Override - public void onUpdate(int remainingRequests) { - onUpdateListenerCounter++; - assertEquals(remainingRequestsExpected, remainingRequests); - } - - @Override - public void onFinished() { - onFinishedListenerCounter++; - } - - @Override - public void onResponse(int correlationId, RPCResponse response) { - if (response.getSuccess()) { - onResponseListenerCounter++; - remainingRequestsExpected--; - } else { - onErrorListenerCounter++; - remainingRequestsExpected--; - } - } - }; - try { - if (sequentialSend) { - proxy.sendSequentialRequests(rpcsList, onMultipleRequestListener); - } else { - proxy.sendRequests(rpcsList, onMultipleRequestListener); - } - assertTrue(true); - } catch (SdlException e) { - e.printStackTrace(); - fail(); - } - - - // Trigger fake RPC responses - int onUpdateListenerCounterExpected = 0, onFinishedListenerCounterExpected = 0, onResponseListenerCounterExpected = 0, onErrorListenerCounterExpected = 0; - switch (caseNumber){ - case 1: // All RPCs succeed - onUpdateListenerCounterExpected = 2; - onFinishedListenerCounterExpected = 1; - onResponseListenerCounterExpected = 2; - onErrorListenerCounterExpected = 0; - - while (rpcsTempList.size() != 0){ - RPCRequest request = rpcsTempList.remove(0); - if (request instanceof Speak) { - requestsMap.get(request).onResponse(request.getCorrelationID(), new SpeakResponse(true, Result.SUCCESS)); - } else if (request instanceof Show) { - requestsMap.get(request).onResponse(request.getCorrelationID(), new ShowResponse(true, Result.SUCCESS)); - } - } - break; - case 2: // Some RPCs fail - onUpdateListenerCounterExpected = 2; - onFinishedListenerCounterExpected = 1; - onResponseListenerCounterExpected = 1; - onErrorListenerCounterExpected = 1; - - while (rpcsTempList.size() != 0){ - RPCRequest request = rpcsTempList.remove(0); - if (request instanceof Speak) { - requestsMap.get(request).onResponse(request.getCorrelationID(), new GenericResponse(false, Result.DISALLOWED)); - } else if (request instanceof Show) { - requestsMap.get(request).onResponse(request.getCorrelationID(), new ShowResponse(true, Result.SUCCESS)); - } - } - break; - } - - - // Make sure the listener is called correctly - assertEquals("onUpdate Listener was not called or called more/less frequently than expected", onUpdateListenerCounterExpected, onUpdateListenerCounter); - assertEquals("onFinished Listener was not called or called more/less frequently than expected", onFinishedListenerCounterExpected, onFinishedListenerCounter); - assertEquals("onResponse Listener was not called or called more/less frequently than expected", onResponseListenerCounterExpected, onResponseListenerCounter); - assertEquals("onError Listener was not called or called more/less frequently than expected", onErrorListenerCounterExpected, onErrorListenerCounter); - } -} diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/StreamRPCPacketizerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/StreamRPCPacketizerTests.java index 561cc1ef7..05a579b72 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/StreamRPCPacketizerTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/StreamRPCPacketizerTests.java @@ -3,12 +3,9 @@ package com.smartdevicelink.test.streaming; import com.smartdevicelink.SdlConnection.SdlSession; import com.smartdevicelink.protocol.enums.SessionType; import com.smartdevicelink.proxy.RPCRequest; -import com.smartdevicelink.proxy.SdlProxyBase; import com.smartdevicelink.streaming.IStreamListener; import com.smartdevicelink.streaming.StreamRPCPacketizer; import com.smartdevicelink.test.TestValues; -import com.smartdevicelink.transport.BTTransportConfig; -import com.smartdevicelink.transport.BaseTransportConfig; import com.smartdevicelink.transport.MultiplexTransportConfig; import junit.framework.TestCase; @@ -28,7 +25,7 @@ public class StreamRPCPacketizerTests extends TestCase { /** * This is a unit test for the following methods : - * {@link com.smartdevicelink.streaming.StreamRPCPacketizer#StreamRPCPacketizer(SdlProxyBase, IStreamListener, InputStream, RPCRequest, SessionType, byte, byte, long, SdlSession)} + * {@link com.smartdevicelink.streaming.StreamRPCPacketizer#StreamRPCPacketizer(Object, IStreamListener, InputStream, RPCRequest, SessionType, byte, byte, long, SdlSession)} */ public void testConstructor () { diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/managers/ProxyBridge.java b/android/sdl_android/src/main/java/com/smartdevicelink/managers/ProxyBridge.java deleted file mode 100644 index 69180d255..000000000 --- a/android/sdl_android/src/main/java/com/smartdevicelink/managers/ProxyBridge.java +++ /dev/null @@ -1,686 +0,0 @@ -/* - * Copyright (c) 2019 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. - */ - -package com.smartdevicelink.managers; - -import android.util.SparseArray; - -import com.smartdevicelink.protocol.enums.FunctionID; -import com.smartdevicelink.proxy.IProxyListener; -import com.smartdevicelink.proxy.RPCMessage; -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.CancelInteractionResponse; -import com.smartdevicelink.proxy.rpc.ChangeRegistrationResponse; -import com.smartdevicelink.proxy.rpc.CloseApplicationResponse; -import com.smartdevicelink.proxy.rpc.CreateInteractionChoiceSetResponse; -import com.smartdevicelink.proxy.rpc.CreateWindowResponse; -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.DeleteWindowResponse; -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.GetAppServiceDataResponse; -import com.smartdevicelink.proxy.rpc.GetCloudAppPropertiesResponse; -import com.smartdevicelink.proxy.rpc.GetDTCsResponse; -import com.smartdevicelink.proxy.rpc.GetFileResponse; -import com.smartdevicelink.proxy.rpc.GetInteriorVehicleDataConsentResponse; -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.OnAppInterfaceUnregistered; -import com.smartdevicelink.proxy.rpc.OnAppServiceData; -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.OnPermissionsChange; -import com.smartdevicelink.proxy.rpc.OnRCStatus; -import com.smartdevicelink.proxy.rpc.OnSystemCapabilityUpdated; -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.PerformAppServiceInteractionResponse; -import com.smartdevicelink.proxy.rpc.PerformAudioPassThruResponse; -import com.smartdevicelink.proxy.rpc.PerformInteractionResponse; -import com.smartdevicelink.proxy.rpc.PublishAppServiceResponse; -import com.smartdevicelink.proxy.rpc.PutFileResponse; -import com.smartdevicelink.proxy.rpc.ReadDIDResponse; -import com.smartdevicelink.proxy.rpc.RegisterAppInterfaceResponse; -import com.smartdevicelink.proxy.rpc.ReleaseInteriorVehicleDataModuleResponse; -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.SetCloudAppPropertiesResponse; -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.ShowAppMenuResponse; -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.SubscribeButtonResponse; -import com.smartdevicelink.proxy.rpc.SubscribeVehicleDataResponse; -import com.smartdevicelink.proxy.rpc.SubscribeWayPointsResponse; -import com.smartdevicelink.proxy.rpc.SystemRequestResponse; -import com.smartdevicelink.proxy.rpc.UnpublishAppServiceResponse; -import com.smartdevicelink.proxy.rpc.UnregisterAppInterfaceResponse; -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 com.smartdevicelink.proxy.rpc.listeners.OnRPCListener; - -import java.util.concurrent.CopyOnWriteArrayList; - -@Deprecated -public class ProxyBridge implements IProxyListener{ - private final Object RPC_LISTENER_LOCK = new Object(); - private SparseArray> rpcListeners = null; - private final LifecycleListener lifecycleListener; - - @Override - public void onProxyOpened() {} - - @Override - public void onRegisterAppInterfaceResponse(RegisterAppInterfaceResponse response) { - onRPCReceived(response); - if(response.getSuccess()){ - lifecycleListener.onProxyConnected(); - } - } - - @Override - public void onOnAppInterfaceUnregistered(OnAppInterfaceUnregistered notification) { - onRPCReceived(notification); - } - - @Override - public void onUnregisterAppInterfaceResponse(UnregisterAppInterfaceResponse response) { - onRPCReceived(response); - } - - protected interface LifecycleListener{ - void onProxyConnected(); - 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 listeners = rpcListeners.get(id); - if(listeners!=null && listeners.size()>0) { - for (OnRPCListener listener : listeners) { - listener.onReceived(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()); - } - 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 onCreateWindowResponse(CreateWindowResponse response) { - onRPCReceived(response); - } - - @Override - public void onDeleteWindowResponse(DeleteWindowResponse 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); - } - - @Override - public void onOnRCStatus(OnRCStatus notification) { - onRPCReceived(notification); - } - - @Override - public void onSetCloudAppProperties(SetCloudAppPropertiesResponse response) { - onRPCReceived(response); - } - - @Override - public void onGetCloudAppProperties(GetCloudAppPropertiesResponse response) { - onRPCReceived(response); - } - - @Override - public void onPublishAppServiceResponse(PublishAppServiceResponse response){ - onRPCReceived(response); - } - - @Override - public void onGetAppServiceDataResponse(GetAppServiceDataResponse response){ - onRPCReceived(response); - } - - @Override - public void onGetFileResponse(GetFileResponse response){ - onRPCReceived(response); - } - - @Override - public void onPerformAppServiceInteractionResponse(PerformAppServiceInteractionResponse response){ - onRPCReceived(response); - } - - @Override - public void onOnAppServiceData(OnAppServiceData notification){ - onRPCReceived(notification); - } - - @Override - public void onGetInteriorVehicleDataConsentResponse(GetInteriorVehicleDataConsentResponse response) { - onRPCReceived(response); - } - - @Override - public void onReleaseInteriorVehicleDataModuleResponse(ReleaseInteriorVehicleDataModuleResponse response) { - onRPCReceived(response); - } - - @Override - public void onOnSystemCapabilityUpdated(OnSystemCapabilityUpdated notification){ - onRPCReceived(notification); - } - - @Override - public void onCloseApplicationResponse(CloseApplicationResponse response) { - onRPCReceived(response); - } - - @Override - public void onCancelInteractionResponse(CancelInteractionResponse response) { - onRPCReceived(response); - } - - @Override - public void onShowAppMenuResponse(ShowAppMenuResponse response) { - onRPCReceived(response); - } - - @Override - public void onUnpublishAppServiceResponse(UnpublishAppServiceResponse response) { - onRPCReceived(response); - } -} diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/proxy/LockScreenManager.java b/android/sdl_android/src/main/java/com/smartdevicelink/proxy/LockScreenManager.java deleted file mode 100644 index 6cb19000e..000000000 --- a/android/sdl_android/src/main/java/com/smartdevicelink/proxy/LockScreenManager.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ -package com.smartdevicelink.proxy; - -import android.graphics.Bitmap; - -import com.smartdevicelink.proxy.rpc.enums.HMILevel; -import com.smartdevicelink.proxy.rpc.enums.LockScreenStatus; -import com.smartdevicelink.util.AndroidTools; - -import java.io.IOException; - -@Deprecated -public class LockScreenManager { - - public interface OnLockScreenIconDownloadedListener{ - public void onLockScreenIconDownloaded(Bitmap icon); - public void onLockScreenIconDownloadError(Exception e); - } - - private Bitmap lockScreenIcon; - private Boolean bUserSelected = false; - private Boolean bDriverDistStatus = null; - private HMILevel hmiLevel = null; - @SuppressWarnings("unused") - private int iSessionID; - - public synchronized void setSessionID(int iVal) - { - iSessionID = iVal; - } - - private synchronized void setUserSelectedStatus(boolean bVal) - { - bUserSelected = bVal; - } - - public synchronized void setDriverDistStatus(boolean bVal) - { - bDriverDistStatus = bVal; - } - - public synchronized void setHMILevel(HMILevel hmiVal) - { - hmiLevel = hmiVal; - - if (hmiVal != null) { - if ((hmiVal.equals(HMILevel.HMI_FULL)) || (hmiVal.equals(HMILevel.HMI_LIMITED))) - setUserSelectedStatus(true); - else if (hmiVal.equals(HMILevel.HMI_NONE)) - setUserSelectedStatus(false); - }else{ - setUserSelectedStatus(false); - } - } - -// public synchronized OnLockScreenStatus getLockObj(/*int SessionID*/) -// { -// //int iSessionID = SessionID; -// OnLockScreenStatus myLock = new OnLockScreenStatus(); -// myLock.setDriverDistractionStatus(bDriverDistStatus); -// myLock.setHMILevel(hmiLevel); -// myLock.setUserSelected(bUserSelected); -// myLock.setShowLockScreen(getLockScreenStatus()); -// -// return myLock; -// } - - private synchronized LockScreenStatus getLockScreenStatus() - { - - if ( (hmiLevel == null) || (hmiLevel.equals(HMILevel.HMI_NONE)) ) - { - return LockScreenStatus.OFF; - } - else if ( hmiLevel.equals(HMILevel.HMI_BACKGROUND) ) - { - if (bDriverDistStatus == null) - { - //we don't have driver distraction, lockscreen is entirely based on userselection - if (bUserSelected) - return LockScreenStatus.REQUIRED; - else - return LockScreenStatus.OFF; - } - else if (bDriverDistStatus && bUserSelected) - { - return LockScreenStatus.REQUIRED; - } - else if (!bDriverDistStatus && bUserSelected) - { - return LockScreenStatus.OPTIONAL; - } - else - { - return LockScreenStatus.OFF; - } - } - else if ( (hmiLevel.equals(HMILevel.HMI_FULL)) || (hmiLevel.equals(HMILevel.HMI_LIMITED)) ) - { - if ( (bDriverDistStatus != null) && (!bDriverDistStatus) ) - { - return LockScreenStatus.OPTIONAL; - } - else - return LockScreenStatus.REQUIRED; - } - return LockScreenStatus.OFF; - } - - public void downloadLockScreenIcon(final String url, final OnLockScreenIconDownloadedListener l){ - new Thread(new Runnable(){ - @Override - public void run(){ - try{ - lockScreenIcon = AndroidTools.downloadImage(url); - if(l != null){ - l.onLockScreenIconDownloaded(lockScreenIcon); - } - }catch(IOException e){ - if(l != null){ - l.onLockScreenIconDownloadError(e); - } - } - } - }).start(); - } - - public Bitmap getLockScreenIcon(){ - return this.lockScreenIcon; - } -} diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCRequestFactory.java b/android/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCRequestFactory.java deleted file mode 100644 index 1d1216b40..000000000 --- a/android/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCRequestFactory.java +++ /dev/null @@ -1,1030 +0,0 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ -package com.smartdevicelink.proxy; - -import android.os.Build; - -import com.smartdevicelink.proxy.rpc.AddCommand; -import com.smartdevicelink.proxy.rpc.AddSubMenu; -import com.smartdevicelink.proxy.rpc.Alert; -import com.smartdevicelink.proxy.rpc.ChangeRegistration; -import com.smartdevicelink.proxy.rpc.Choice; -import com.smartdevicelink.proxy.rpc.CreateInteractionChoiceSet; -import com.smartdevicelink.proxy.rpc.DeleteCommand; -import com.smartdevicelink.proxy.rpc.DeleteFile; -import com.smartdevicelink.proxy.rpc.DeleteInteractionChoiceSet; -import com.smartdevicelink.proxy.rpc.DeleteSubMenu; -import com.smartdevicelink.proxy.rpc.DeviceInfo; -import com.smartdevicelink.proxy.rpc.EndAudioPassThru; -import com.smartdevicelink.proxy.rpc.GetVehicleData; -import com.smartdevicelink.proxy.rpc.Image; -import com.smartdevicelink.proxy.rpc.ListFiles; -import com.smartdevicelink.proxy.rpc.MenuParams; -import com.smartdevicelink.proxy.rpc.PerformAudioPassThru; -import com.smartdevicelink.proxy.rpc.PerformInteraction; -import com.smartdevicelink.proxy.rpc.PutFile; -import com.smartdevicelink.proxy.rpc.RegisterAppInterface; -import com.smartdevicelink.proxy.rpc.ScrollableMessage; -import com.smartdevicelink.proxy.rpc.SdlMsgVersion; -import com.smartdevicelink.proxy.rpc.SetAppIcon; -import com.smartdevicelink.proxy.rpc.SetDisplayLayout; -import com.smartdevicelink.proxy.rpc.SetGlobalProperties; -import com.smartdevicelink.proxy.rpc.SetMediaClockTimer; -import com.smartdevicelink.proxy.rpc.Show; -import com.smartdevicelink.proxy.rpc.Slider; -import com.smartdevicelink.proxy.rpc.SoftButton; -import com.smartdevicelink.proxy.rpc.Speak; -import com.smartdevicelink.proxy.rpc.StartTime; -import com.smartdevicelink.proxy.rpc.SubscribeButton; -import com.smartdevicelink.proxy.rpc.SubscribeVehicleData; -import com.smartdevicelink.proxy.rpc.SystemRequest; -import com.smartdevicelink.proxy.rpc.TTSChunk; -import com.smartdevicelink.proxy.rpc.UnregisterAppInterface; -import com.smartdevicelink.proxy.rpc.UnsubscribeButton; -import com.smartdevicelink.proxy.rpc.UnsubscribeVehicleData; -import com.smartdevicelink.proxy.rpc.VrHelpItem; -import com.smartdevicelink.proxy.rpc.enums.AppHMIType; -import com.smartdevicelink.proxy.rpc.enums.AudioType; -import com.smartdevicelink.proxy.rpc.enums.BitsPerSample; -import com.smartdevicelink.proxy.rpc.enums.ButtonName; -import com.smartdevicelink.proxy.rpc.enums.FileType; -import com.smartdevicelink.proxy.rpc.enums.ImageType; -import com.smartdevicelink.proxy.rpc.enums.InteractionMode; -import com.smartdevicelink.proxy.rpc.enums.Language; -import com.smartdevicelink.proxy.rpc.enums.RequestType; -import com.smartdevicelink.proxy.rpc.enums.SamplingRate; -import com.smartdevicelink.proxy.rpc.enums.TextAlignment; -import com.smartdevicelink.proxy.rpc.enums.UpdateMode; - -import java.util.Vector; - -/** - * @deprecated Use RPC constructors directly instead - */ -@Deprecated -public class RPCRequestFactory { - - public static final int SDL_MSG_MAJOR_VERSION = 1; - public static final int SDL_MSG_MINOR_VERSION = 0; - - public static SystemRequest buildSystemRequest( - String data, Integer correlationID) { - - if(data == null) return null; - - SystemRequest msg = new SystemRequest(); - msg.setRequestType(RequestType.PROPRIETARY); - msg.setCorrelationID(correlationID); - msg.setBulkData(data.getBytes()); - return msg; - } - - public static SystemRequest buildSystemRequestLegacy( - Vector data, Integer correlationID) { - - if(data == null) return null; - - SystemRequest msg = new SystemRequest(true); - msg.setCorrelationID(correlationID); - msg.setLegacyData(data); - return msg; - } - - public static AddCommand buildAddCommand(Integer commandID, - String menuText, Integer parentID, Integer position, - Vector vrCommands, Image cmdIcon, Integer correlationID) { - AddCommand msg = new AddCommand(); - msg.setCorrelationID(correlationID); - msg.setCmdID(commandID); - msg.setVrCommands(vrCommands); - - if (cmdIcon != null) msg.setCmdIcon(cmdIcon); - - if(menuText != null || parentID != null || position != null) { - MenuParams menuParams = new MenuParams(); - menuParams.setMenuName(menuText); - menuParams.setPosition(position); - menuParams.setParentID(parentID); - msg.setMenuParams(menuParams); - } - - return msg; - } - - public static AddCommand buildAddCommand(Integer commandID, - String menuText, Integer parentID, Integer position, - Vector vrCommands, String IconValue, ImageType IconType, - Integer correlationID) { - AddCommand msg = new AddCommand(); - msg.setCorrelationID(correlationID); - msg.setCmdID(commandID); - - if (vrCommands != null) msg.setVrCommands(vrCommands); - - Image cmdIcon = null; - - if (IconValue != null && IconType != null) - { - cmdIcon = new Image(); - cmdIcon.setValue(IconValue); - cmdIcon.setImageType(IconType); - } - - if (cmdIcon != null) msg.setCmdIcon(cmdIcon); - - if(menuText != null || parentID != null || position != null) { - MenuParams menuParams = new MenuParams(); - menuParams.setMenuName(menuText); - menuParams.setPosition(position); - menuParams.setParentID(parentID); - msg.setMenuParams(menuParams); - } - - return msg; - } - - public static AddCommand buildAddCommand(Integer commandID, - String menuText, Integer parentID, Integer position, - Vector vrCommands, Integer correlationID) { - AddCommand msg = new AddCommand(); - msg.setCorrelationID(correlationID); - msg.setCmdID(commandID); - msg.setVrCommands(vrCommands); - - if(menuText != null || parentID != null || position != null) { - MenuParams menuParams = new MenuParams(); - menuParams.setMenuName(menuText); - menuParams.setPosition(position); - menuParams.setParentID(parentID); - msg.setMenuParams(menuParams); - } - - return msg; - } - - public static AddCommand buildAddCommand(Integer commandID, - String menuText, Vector vrCommands, Integer correlationID) { - AddCommand msg = buildAddCommand(commandID, menuText, null, null, - vrCommands, correlationID); - return msg; - } - - public static AddCommand buildAddCommand(Integer commandID, - Vector vrCommands, Integer correlationID) { - AddCommand msg = new AddCommand(); - msg.setCorrelationID(correlationID); - msg.setCmdID(commandID); - msg.setVrCommands(vrCommands); - - return msg; - } - - public static AddSubMenu buildAddSubMenu(Integer menuID, String menuName, - Integer correlationID) { - AddSubMenu msg = buildAddSubMenu(menuID, menuName, null, correlationID); - return msg; - } - - public static AddSubMenu buildAddSubMenu(Integer menuID, String menuName, - Integer position, Integer correlationID) { - AddSubMenu msg = new AddSubMenu(); - msg.setCorrelationID(correlationID); - msg.setMenuName(menuName); - msg.setMenuID(menuID); - msg.setPosition(position); - - return msg; - } - - public static Alert buildAlert(String ttsText, Boolean playTone, - Vector softButtons, Integer correlationID) { - Vector chunks = TTSChunkFactory - .createSimpleTTSChunks(ttsText); - Alert msg = buildAlert(chunks, null, null, null, playTone, null, softButtons, - correlationID); - return msg; - } - - public static Alert buildAlert(String alertText1, String alertText2, - String alertText3, Integer duration, Vector softButtons, - Integer correlationID) { - Alert msg = buildAlert((Vector) null, alertText1, alertText2, - alertText3, null, duration, softButtons, correlationID); - return msg; - } - - public static Alert buildAlert(String ttsText, String alertText1, - String alertText2, String alertText3, Boolean playTone, - Integer duration, Vector softButtons, Integer correlationID) { - Vector chunks = TTSChunkFactory - .createSimpleTTSChunks(ttsText); - Alert msg = buildAlert(chunks, alertText1, alertText2, alertText3, - playTone, duration, softButtons, correlationID); - return msg; - } - - public static Alert buildAlert(Vector chunks, Boolean playTone, - Vector softButtons, Integer correlationID) { - Alert msg = buildAlert(chunks, null, null, null, playTone, null, softButtons, correlationID); - return msg; - } - - public static Alert buildAlert(Vector ttsChunks, - String alertText1, String alertText2, String alertText3, - Boolean playTone, Integer duration, Vector softButtons, - Integer correlationID) { - Alert msg = new Alert(); - msg.setCorrelationID(correlationID); - msg.setAlertText1(alertText1); - msg.setAlertText2(alertText2); - msg.setAlertText3(alertText3); - msg.setDuration(duration); - msg.setPlayTone(playTone); - msg.setTtsChunks(ttsChunks); - msg.setSoftButtons(softButtons); - - return msg; - } - - public static Alert buildAlert(String ttsText, Boolean playTone, - Integer correlationID) { - Vector chunks = TTSChunkFactory - .createSimpleTTSChunks(ttsText); - Alert msg = buildAlert(chunks, null, null, playTone, null, - correlationID); - return msg; - } - - public static Alert buildAlert(String alertText1, String alertText2, - Integer duration, Integer correlationID) { - Alert msg = buildAlert((Vector) null, alertText1, alertText2, - null, duration, correlationID); - return msg; - } - - public static Alert buildAlert(String ttsText, String alertText1, - String alertText2, Boolean playTone, Integer duration, - Integer correlationID) { - Vector chunks = TTSChunkFactory - .createSimpleTTSChunks(ttsText); - Alert msg = buildAlert(chunks, alertText1, alertText2, playTone, - duration, correlationID); - return msg; - } - - public static Alert buildAlert(Vector chunks, Boolean playTone, - Integer correlationID) { - Alert msg = buildAlert(chunks, null, null, playTone, null, - correlationID); - return msg; - } - - public static Alert buildAlert(Vector ttsChunks, - String alertText1, String alertText2, Boolean playTone, - Integer duration, Integer correlationID) { - Alert msg = new Alert(); - msg.setCorrelationID(correlationID); - msg.setAlertText1(alertText1); - msg.setAlertText2(alertText2); - msg.setDuration(duration); - msg.setPlayTone(playTone); - msg.setTtsChunks(ttsChunks); - - return msg; - } - - public static CreateInteractionChoiceSet buildCreateInteractionChoiceSet( - Vector choiceSet, Integer interactionChoiceSetID, - Integer correlationID) { - CreateInteractionChoiceSet msg = new CreateInteractionChoiceSet(); - msg.setChoiceSet(choiceSet); - msg.setInteractionChoiceSetID(interactionChoiceSetID); - msg.setCorrelationID(correlationID); - return msg; - } - - public static DeleteCommand buildDeleteCommand(Integer commandID, - Integer correlationID) { - DeleteCommand msg = new DeleteCommand(); - msg.setCmdID(commandID); - msg.setCorrelationID(correlationID); - return msg; - } - - public static DeleteFile buildDeleteFile(String sdlFileName, - Integer correlationID) { - DeleteFile deleteFile = new DeleteFile(); - deleteFile.setCorrelationID(correlationID); - deleteFile.setSdlFileName(sdlFileName); - return deleteFile; - } - - public static DeleteInteractionChoiceSet buildDeleteInteractionChoiceSet( - Integer interactionChoiceSetID, Integer correlationID) { - DeleteInteractionChoiceSet msg = new DeleteInteractionChoiceSet(); - msg.setInteractionChoiceSetID(interactionChoiceSetID); - msg.setCorrelationID(correlationID); - - return msg; - } - - public static DeleteSubMenu buildDeleteSubMenu(Integer menuID, - Integer correlationID) { - DeleteSubMenu msg = new DeleteSubMenu(); - msg.setCorrelationID(correlationID); - msg.setMenuID(menuID); - - return msg; - } - - public static ListFiles buildListFiles(Integer correlationID) { - ListFiles listFiles = new ListFiles(); - listFiles.setCorrelationID(correlationID); - return listFiles; - } - - public static PerformInteraction buildPerformInteraction( - Vector initChunks, String displayText, - Vector interactionChoiceSetIDList, - Vector helpChunks, Vector timeoutChunks, - InteractionMode interactionMode, Integer timeout, - Vector vrHelp, Integer correlationID) { - PerformInteraction msg = new PerformInteraction(); - msg.setInitialPrompt(initChunks); - msg.setInitialText(displayText); - msg.setInteractionChoiceSetIDList(interactionChoiceSetIDList); - msg.setInteractionMode(interactionMode); - msg.setTimeout(timeout); - msg.setHelpPrompt(helpChunks); - msg.setTimeoutPrompt(timeoutChunks); - msg.setVrHelp(vrHelp); - msg.setCorrelationID(correlationID); - - return msg; - } - - public static PerformInteraction buildPerformInteraction( - String initPrompt, String displayText, - Vector interactionChoiceSetIDList, - String helpPrompt, String timeoutPrompt, - InteractionMode interactionMode, Integer timeout, Vector vrHelp, - Integer correlationID) { - Vector initChunks = TTSChunkFactory - .createSimpleTTSChunks(initPrompt); - Vector helpChunks = TTSChunkFactory - .createSimpleTTSChunks(helpPrompt); - Vector timeoutChunks = TTSChunkFactory - .createSimpleTTSChunks(timeoutPrompt); - return buildPerformInteraction(initChunks, - displayText, interactionChoiceSetIDList, helpChunks, - timeoutChunks, interactionMode, timeout, vrHelp, correlationID); - } - - public static PerformInteraction buildPerformInteraction( - String initPrompt, String displayText, - Integer interactionChoiceSetID, - String helpPrompt, String timeoutPrompt, - InteractionMode interactionMode, Integer timeout, Vector vrHelp, - Integer correlationID) { - Vector interactionChoiceSetIDs = new Vector(); - interactionChoiceSetIDs.add(interactionChoiceSetID); - - return buildPerformInteraction( - initPrompt, displayText, interactionChoiceSetIDs, - helpPrompt, timeoutPrompt, interactionMode, - timeout, vrHelp, correlationID); - } - - public static PerformInteraction buildPerformInteraction(String initPrompt, - String displayText, Integer interactionChoiceSetID, Vector vrHelp, - Integer correlationID) { - - return buildPerformInteraction(initPrompt, displayText, - interactionChoiceSetID, null, null, - InteractionMode.BOTH, null, vrHelp, correlationID); - } - - public static PerformInteraction buildPerformInteraction( - Vector initChunks, String displayText, - Vector interactionChoiceSetIDList, - Vector helpChunks, Vector timeoutChunks, - InteractionMode interactionMode, Integer timeout, - Integer correlationID) { - PerformInteraction msg = new PerformInteraction(); - msg.setInitialPrompt(initChunks); - msg.setInitialText(displayText); - msg.setInteractionChoiceSetIDList(interactionChoiceSetIDList); - msg.setInteractionMode(interactionMode); - msg.setTimeout(timeout); - msg.setHelpPrompt(helpChunks); - msg.setTimeoutPrompt(timeoutChunks); - msg.setCorrelationID(correlationID); - - return msg; - } - - public static PerformInteraction buildPerformInteraction( - String initPrompt, String displayText, - Vector interactionChoiceSetIDList, - String helpPrompt, String timeoutPrompt, - InteractionMode interactionMode, Integer timeout, - Integer correlationID) { - Vector initChunks = TTSChunkFactory - .createSimpleTTSChunks(initPrompt); - Vector helpChunks = TTSChunkFactory - .createSimpleTTSChunks(helpPrompt); - Vector timeoutChunks = TTSChunkFactory - .createSimpleTTSChunks(timeoutPrompt); - return buildPerformInteraction(initChunks, - displayText, interactionChoiceSetIDList, helpChunks, - timeoutChunks, interactionMode, timeout, correlationID); - } - - public static PerformInteraction buildPerformInteraction( - String initPrompt, String displayText, - Integer interactionChoiceSetID, - String helpPrompt, String timeoutPrompt, - InteractionMode interactionMode, Integer timeout, - Integer correlationID) { - Vector interactionChoiceSetIDs = new Vector(); - interactionChoiceSetIDs.add(interactionChoiceSetID); - - return buildPerformInteraction( - initPrompt, displayText, interactionChoiceSetIDs, - helpPrompt, timeoutPrompt, interactionMode, - timeout, correlationID); - } - - public static PerformInteraction buildPerformInteraction(String initPrompt, - String displayText, Integer interactionChoiceSetID, - Integer correlationID) { - - return buildPerformInteraction(initPrompt, displayText, - interactionChoiceSetID, null, null, - InteractionMode.BOTH, null, correlationID); - } - - @Deprecated - public static PerformInteraction buildPerformInteraction( - Vector initChunks, String displayText, - Vector interactionChoiceSetIDList, - Vector helpChunks, InteractionMode interactionMode, - Integer timeout, Integer correlationID) { - PerformInteraction msg = new PerformInteraction(); - msg.setInitialPrompt(initChunks); - msg.setInitialText(displayText); - msg.setInteractionChoiceSetIDList(interactionChoiceSetIDList); - msg.setInteractionMode(interactionMode); - msg.setTimeout(timeout); - msg.setHelpPrompt(helpChunks); - msg.setCorrelationID(correlationID); - return msg; - } - - @Deprecated - public static PerformInteraction buildPerformInteraction(String initPrompt, - String displayText, Vector interactionChoiceSetIDList, - String helpPrompt, InteractionMode interactionMode, - Integer timeout, Integer correlationID) { - Vector initChunks = TTSChunkFactory - .createSimpleTTSChunks(initPrompt); - Vector helpChunks = TTSChunkFactory - .createSimpleTTSChunks(helpPrompt); - PerformInteraction msg = buildPerformInteraction(initChunks, - displayText, interactionChoiceSetIDList, helpChunks, - interactionMode, timeout, correlationID); - return msg; - } - - public static PutFile buildPutFile(String sdlFileName, FileType fileType, - Boolean persistentFile, byte[] fileData, Integer correlationID) { - PutFile putFile = new PutFile(); - putFile.setCorrelationID(correlationID); - putFile.setSdlFileName(sdlFileName); - putFile.setFileType(fileType); - putFile.setPersistentFile(persistentFile); - putFile.setBulkData(fileData); - putFile.setCRC(fileData); - return putFile; - } - - @Deprecated - public static PutFile buildPutFile(String sdlFileName, Integer iOffset, Integer iLength) { - PutFile putFile = new PutFile(); - putFile.setCorrelationID(10000); - putFile.setSdlFileName(sdlFileName); - putFile.setFileType(FileType.BINARY); - putFile.setSystemFile(true); - putFile.setOffset(iOffset); - putFile.setLength(iLength); - return putFile; - } - - public static PutFile buildPutFile(String sdlFileName, Long iOffset, Long iLength) { - PutFile putFile = new PutFile(); - putFile.setCorrelationID(10000); - putFile.setSdlFileName(sdlFileName); - putFile.setFileType(FileType.BINARY); - putFile.setSystemFile(true); - putFile.setOffset(iOffset); - putFile.setLength(iLength); - return putFile; - } - - @Deprecated - public static PutFile buildPutFile(String syncFileName, Integer iOffset, Integer iLength, FileType fileType, Boolean bPersistentFile, Boolean bSystemFile) { - PutFile putFile = new PutFile(); - putFile.setCorrelationID(10000); - putFile.setSdlFileName(syncFileName); - putFile.setFileType(fileType); - putFile.setPersistentFile(bPersistentFile); - putFile.setSystemFile(bSystemFile); - putFile.setOffset(iOffset); - putFile.setLength(iLength); - return putFile; - } - - public static PutFile buildPutFile(String syncFileName, Long iOffset, Long iLength, FileType fileType, Boolean bPersistentFile, Boolean bSystemFile) { - PutFile putFile = new PutFile(); - putFile.setCorrelationID(10000); - putFile.setSdlFileName(syncFileName); - putFile.setFileType(fileType); - putFile.setPersistentFile(bPersistentFile); - putFile.setSystemFile(bSystemFile); - putFile.setOffset(iOffset); - putFile.setLength(iLength); - return putFile; - } - - @Deprecated - public static PutFile buildPutFile(String sdlFileName, Integer iOffset, Integer iLength, FileType fileType, Boolean bPersistentFile, Boolean bSystemFile, Integer iCorrelationID) { - PutFile putFile = new PutFile(); - putFile.setCorrelationID(iCorrelationID); - putFile.setSdlFileName(sdlFileName); - putFile.setFileType(fileType); - putFile.setPersistentFile(bPersistentFile); - putFile.setSystemFile(bSystemFile); - putFile.setOffset(iOffset); - putFile.setLength(iLength); - return putFile; - } - - public static PutFile buildPutFile(String sdlFileName, Long iOffset, Long iLength, FileType fileType, Boolean bPersistentFile, Boolean bSystemFile, Boolean isPayloadProtected, Integer iCorrelationID) { - PutFile putFile = new PutFile(); - putFile.setCorrelationID(iCorrelationID); - putFile.setSdlFileName(sdlFileName); - putFile.setFileType(fileType); - putFile.setPersistentFile(bPersistentFile); - putFile.setSystemFile(bSystemFile); - putFile.setOffset(iOffset); - putFile.setLength(iLength); - putFile.setPayloadProtected(isPayloadProtected); - return putFile; - } - - public static RegisterAppInterface buildRegisterAppInterface(String appName, String appID) { - return buildRegisterAppInterface(appName, false, appID); - } - - public static RegisterAppInterface buildRegisterAppInterface( - String appName, Boolean isMediaApp, String appID) { - - return buildRegisterAppInterface(null, appName, null, null, null, isMediaApp, - null, null, null, appID, null, null); - } - - public static RegisterAppInterface buildRegisterAppInterface( - SdlMsgVersion sdlMsgVersion, String appName, Vector ttsName, - String ngnMediaScreenAppName, Vector vrSynonyms, Boolean isMediaApp, - Language languageDesired, Language hmiDisplayLanguageDesired, Vector appType, - String appID, Integer correlationID, DeviceInfo deviceInfo) { - RegisterAppInterface msg = new RegisterAppInterface(); - - if (correlationID == null) { - correlationID = 1; - } - msg.setCorrelationID(correlationID); - - if (sdlMsgVersion == null) { - sdlMsgVersion = new SdlMsgVersion(); - sdlMsgVersion.setMajorVersion(Integer.valueOf(SDL_MSG_MAJOR_VERSION)); - sdlMsgVersion.setMinorVersion(Integer.valueOf(SDL_MSG_MINOR_VERSION)); - } - msg.setSdlMsgVersion(sdlMsgVersion); - msg.setDeviceInfo(deviceInfo); - msg.setAppName(appName); - - msg.setTtsName(ttsName); - - if (ngnMediaScreenAppName == null) { - ngnMediaScreenAppName = appName; - } - - msg.setNgnMediaScreenAppName(ngnMediaScreenAppName); - - if (vrSynonyms == null) { - vrSynonyms = new Vector(); - vrSynonyms.add(appName); - } - msg.setVrSynonyms(vrSynonyms); - - msg.setIsMediaApplication(isMediaApp); - - if (languageDesired == null) { - languageDesired = Language.EN_US; - } - msg.setLanguageDesired(languageDesired); - - if (hmiDisplayLanguageDesired == null) { - hmiDisplayLanguageDesired = Language.EN_US; - } - - msg.setHmiDisplayLanguageDesired(hmiDisplayLanguageDesired); - - msg.setAppHMIType(appType); - - msg.setAppID(appID); - - return msg; - } - - public static SetAppIcon buildSetAppIcon(String sdlFileName, - Integer correlationID) { - SetAppIcon setAppIcon = new SetAppIcon(); - setAppIcon.setCorrelationID(correlationID); - setAppIcon.setSdlFileName(sdlFileName); - return setAppIcon; - } - - public static SetGlobalProperties buildSetGlobalProperties( - String helpPrompt, String timeoutPrompt, Integer correlationID) { - return buildSetGlobalProperties(TTSChunkFactory - .createSimpleTTSChunks(helpPrompt), TTSChunkFactory - .createSimpleTTSChunks(timeoutPrompt), correlationID); - } - - public static SetGlobalProperties buildSetGlobalProperties( - Vector helpChunks, Vector timeoutChunks, - Integer correlationID) { - SetGlobalProperties req = new SetGlobalProperties(); - req.setCorrelationID(correlationID); - - req.setHelpPrompt(helpChunks); - req.setTimeoutPrompt(timeoutChunks); - - return req; - } - - public static SetGlobalProperties buildSetGlobalProperties( - String helpPrompt, String timeoutPrompt, String vrHelpTitle, - Vector vrHelp, Integer correlationID) { - return buildSetGlobalProperties(TTSChunkFactory - .createSimpleTTSChunks(helpPrompt), TTSChunkFactory - .createSimpleTTSChunks(timeoutPrompt), vrHelpTitle, vrHelp, correlationID); - } - - public static SetGlobalProperties buildSetGlobalProperties( - Vector helpChunks, Vector timeoutChunks, - String vrHelpTitle, Vector vrHelp, - Integer correlationID) { - SetGlobalProperties req = new SetGlobalProperties(); - req.setCorrelationID(correlationID); - - req.setHelpPrompt(helpChunks); - req.setTimeoutPrompt(timeoutChunks); - - req.setVrHelpTitle(vrHelpTitle); - req.setVrHelp(vrHelp); - - return req; - } - - public static SetMediaClockTimer buildSetMediaClockTimer(Integer hours, - Integer minutes, Integer seconds, UpdateMode updateMode, - Integer correlationID) { - - SetMediaClockTimer msg = new SetMediaClockTimer(); - if (hours != null || minutes != null || seconds != null) { - StartTime startTime = new StartTime(); - msg.setStartTime(startTime); - startTime.setHours(hours); - startTime.setMinutes(minutes); - startTime.setSeconds(seconds); - } - - msg.setUpdateMode(updateMode); - msg.setCorrelationID(correlationID); - - return msg; - } - - @Deprecated - public static SetMediaClockTimer buildSetMediaClockTimer( - UpdateMode updateMode, Integer correlationID) { - Integer hours = null; - Integer minutes = null; - Integer seconds = null; - - SetMediaClockTimer msg = buildSetMediaClockTimer(hours, minutes, - seconds, updateMode, correlationID); - return msg; - } - - @SuppressWarnings("deprecation") - public static Show buildShow(String mainText1, String mainText2, - String mainText3, String mainText4, - String statusBar, String mediaClock, String mediaTrack, - Image graphic, Vector softButtons, Vector customPresets, - TextAlignment alignment, Integer correlationID) { - Show msg = new Show(); - msg.setCorrelationID(correlationID); - msg.setMainField1(mainText1); - msg.setMainField2(mainText2); - msg.setStatusBar(statusBar); - msg.setMediaClock(mediaClock); - msg.setMediaTrack(mediaTrack); - msg.setAlignment(alignment); - msg.setMainField3(mainText3); - msg.setMainField4(mainText4); - msg.setGraphic(graphic); - msg.setSoftButtons(softButtons); - msg.setCustomPresets(customPresets); - - return msg; - } - - public static Show buildShow(String mainText1, String mainText2, String mainText3, String mainText4, - TextAlignment alignment, Integer correlationID) { - Show msg = buildShow(mainText1, mainText2, mainText3, mainText4, null, null, null, null, null, null, alignment, - correlationID); - return msg; - } - - @SuppressWarnings("deprecation") - public static Show buildShow(String mainText1, String mainText2, - String statusBar, String mediaClock, String mediaTrack, - TextAlignment alignment, Integer correlationID) { - Show msg = new Show(); - msg.setCorrelationID(correlationID); - msg.setMainField1(mainText1); - msg.setMainField2(mainText2); - msg.setStatusBar(statusBar); - msg.setMediaClock(mediaClock); - msg.setMediaTrack(mediaTrack); - msg.setAlignment(alignment); - - return msg; - } - - public static Show buildShow(String mainText1, String mainText2, - TextAlignment alignment, Integer correlationID) { - Show msg = buildShow(mainText1, mainText2, null, null, null, alignment, - correlationID); - return msg; - } - - public static Speak buildSpeak(String ttsText, Integer correlationID) { - Speak msg = buildSpeak(TTSChunkFactory.createSimpleTTSChunks(ttsText), - correlationID); - return msg; - } - - public static Speak buildSpeak(Vector ttsChunks, - Integer correlationID) { - - Speak msg = new Speak(); - msg.setCorrelationID(correlationID); - - msg.setTtsChunks(ttsChunks); - - return msg; - } - - public static SubscribeButton buildSubscribeButton(ButtonName buttonName, - Integer correlationID) { - - SubscribeButton msg = new SubscribeButton(); - msg.setCorrelationID(correlationID); - msg.setButtonName(buttonName); - - return msg; - } - - public static UnregisterAppInterface buildUnregisterAppInterface( - Integer correlationID) { - UnregisterAppInterface msg = new UnregisterAppInterface(); - msg.setCorrelationID(correlationID); - - return msg; - } - - public static UnsubscribeButton buildUnsubscribeButton( - ButtonName buttonName, Integer correlationID) { - - UnsubscribeButton msg = new UnsubscribeButton(); - msg.setCorrelationID(correlationID); - msg.setButtonName(buttonName); - - return msg; - } - - @SuppressWarnings("deprecation") - public static SubscribeVehicleData BuildSubscribeVehicleData(boolean gps, boolean speed, boolean rpm, boolean fuelLevel, boolean fuelLevel_State, - boolean instantFuelConsumption, boolean externalTemperature, boolean prndl, boolean tirePressure, - boolean odometer, boolean beltStatus, boolean bodyInformation, boolean deviceStatus, - boolean driverBraking, Integer correlationID) - { - SubscribeVehicleData msg = new SubscribeVehicleData(); - msg.setGps(gps); - msg.setSpeed(speed); - msg.setRpm(rpm); - msg.setFuelLevel(fuelLevel); - msg.setFuelLevelState(fuelLevel_State); - msg.setInstantFuelConsumption(instantFuelConsumption); - msg.setExternalTemperature(externalTemperature); - msg.setPrndl(prndl); - msg.setTirePressure(tirePressure); - msg.setOdometer(odometer); - msg.setBeltStatus(beltStatus); - msg.setBodyInformation(bodyInformation); - msg.setDeviceStatus(deviceStatus); - msg.setDriverBraking(driverBraking); - msg.setCorrelationID(correlationID); - - return msg; - } - - @SuppressWarnings("deprecation") - public static UnsubscribeVehicleData BuildUnsubscribeVehicleData(boolean gps, boolean speed, boolean rpm, boolean fuelLevel, boolean fuelLevel_State, - boolean instantFuelConsumption, boolean externalTemperature, boolean prndl, boolean tirePressure, - boolean odometer, boolean beltStatus, boolean bodyInformation, boolean deviceStatus, - boolean driverBraking, Integer correlationID) - { - UnsubscribeVehicleData msg = new UnsubscribeVehicleData(); - msg.setGps(gps); - msg.setSpeed(speed); - msg.setRpm(rpm); - msg.setFuelLevel(fuelLevel); - msg.setFuelLevelState(fuelLevel_State); - msg.setInstantFuelConsumption(instantFuelConsumption); - msg.setExternalTemperature(externalTemperature); - msg.setPrndl(prndl); - msg.setTirePressure(tirePressure); - msg.setOdometer(odometer); - msg.setBeltStatus(beltStatus); - msg.setBodyInformation(bodyInformation); - msg.setDeviceStatus(deviceStatus); - msg.setDriverBraking(driverBraking); - msg.setCorrelationID(correlationID); - - return msg; - } - - @SuppressWarnings("deprecation") - public static GetVehicleData BuildGetVehicleData(boolean gps, boolean speed, boolean rpm, boolean fuelLevel, boolean fuelLevel_State, - boolean instantFuelConsumption, boolean externalTemperature, boolean vin, boolean prndl, boolean tirePressure, - boolean odometer, boolean beltStatus, boolean bodyInformation, boolean deviceStatus, - boolean driverBraking, Integer correlationID) - { - GetVehicleData msg = new GetVehicleData(); - msg.setGps(gps); - msg.setSpeed(speed); - msg.setRpm(rpm); - msg.setFuelLevel(fuelLevel); - msg.setFuelLevelState(fuelLevel_State); - msg.setInstantFuelConsumption(instantFuelConsumption); - msg.setExternalTemperature(externalTemperature); - msg.setVin(vin); - msg.setPrndl(prndl); - msg.setTirePressure(tirePressure); - msg.setOdometer(odometer); - msg.setBeltStatus(beltStatus); - msg.setBodyInformation(bodyInformation); - msg.setDeviceStatus(deviceStatus); - msg.setDriverBraking(driverBraking); - msg.setCorrelationID(correlationID); - - return msg; - } - - public static ScrollableMessage BuildScrollableMessage(String scrollableMessageBody, Integer timeout, Vector softButtons, Integer correlationID) - { - ScrollableMessage msg = new ScrollableMessage(); - msg.setCorrelationID(correlationID); - msg.setScrollableMessageBody(scrollableMessageBody); - msg.setTimeout(timeout); - msg.setSoftButtons(softButtons); - - return msg; - } - - public static Slider BuildSlider(Integer numTicks, Integer position, String sliderHeader, Vector sliderFooter, Integer timeout, Integer correlationID) - { - Slider msg = new Slider(); - msg.setCorrelationID(correlationID); - msg.setNumTicks(numTicks); - msg.setPosition(position); - msg.setSliderHeader(sliderHeader); - msg.setSliderFooter(sliderFooter); - msg.setTimeout(timeout); - - return msg; - } - - public static ChangeRegistration BuildChangeRegistration(Language language, Language hmiDisplayLanguage, Integer correlationID) - { - ChangeRegistration msg = new ChangeRegistration(); - msg.setCorrelationID(correlationID); - msg.setLanguage(language); - msg.setHmiDisplayLanguage(hmiDisplayLanguage); - - return msg; - } - - public static SetDisplayLayout BuildSetDisplayLayout(String displayLayout, Integer correlationID) - { - SetDisplayLayout msg = new SetDisplayLayout(); - msg.setCorrelationID(correlationID); - msg.setDisplayLayout(displayLayout); - - return msg; - } - - public static PerformAudioPassThru BuildPerformAudioPassThru(String ttsText, String audioPassThruDisplayText1, String audioPassThruDisplayText2, - SamplingRate samplingRate, Integer maxDuration, BitsPerSample bitsPerSample, - AudioType audioType, Boolean muteAudio, Integer correlationID) - { - Vector chunks = TTSChunkFactory - .createSimpleTTSChunks(ttsText); - - PerformAudioPassThru msg = BuildPerformAudioPassThru(chunks, audioPassThruDisplayText1, audioPassThruDisplayText2, - samplingRate, maxDuration, bitsPerSample,audioType, muteAudio, correlationID); - - return msg; - } - - public static PerformAudioPassThru BuildPerformAudioPassThru(Vector initialPrompt, String audioPassThruDisplayText1, String audioPassThruDisplayText2, - SamplingRate samplingRate, Integer maxDuration, BitsPerSample bitsPerSample, - AudioType audioType, Boolean muteAudio, Integer correlationID) - { - PerformAudioPassThru msg = new PerformAudioPassThru(); - msg.setCorrelationID(correlationID); - msg.setInitialPrompt(initialPrompt); - msg.setAudioPassThruDisplayText1(audioPassThruDisplayText1); - msg.setAudioPassThruDisplayText2(audioPassThruDisplayText2); - msg.setSamplingRate(samplingRate); - msg.setMaxDuration(maxDuration); - msg.setBitsPerSample(bitsPerSample); - msg.setAudioType(audioType); - msg.setMuteAudio(muteAudio); - - return msg; - } - - public static EndAudioPassThru BuildEndAudioPassThru(Integer correlationID) - { - EndAudioPassThru msg = new EndAudioPassThru(); - msg.setCorrelationID(correlationID); - - return msg; - } - - public static DeviceInfo BuildDeviceInfo(String carrierName) - { - DeviceInfo msg = new DeviceInfo(); - msg.setHardware(android.os.Build.MODEL); - msg.setOs("Android"); - msg.setOsVersion(Build.VERSION.RELEASE); - msg.setCarrier(carrierName); - return msg; - } -} diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCStreamController.java b/android/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCStreamController.java deleted file mode 100644 index 28f1989e1..000000000 --- a/android/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCStreamController.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ -package com.smartdevicelink.proxy; - -import com.smartdevicelink.streaming.StreamRPCPacketizer; - -@Deprecated -public class RPCStreamController { - private StreamRPCPacketizer rpcPacketizer; - private Integer iCorrelationID; - - public RPCStreamController(StreamRPCPacketizer rpcPacketizer, Integer iCorrelationID) - { - this.rpcPacketizer = rpcPacketizer; - this.iCorrelationID = iCorrelationID; - } - - public Integer getCorrelationID() - { - return iCorrelationID; - } - - public void pause() - { - rpcPacketizer.pause(); - } - public void resume() - { - rpcPacketizer.resume(); - } - public void stop() - { - rpcPacketizer.onPutFileStreamError(null, "Stop Putfile Stream Requested"); - } -} diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyALM.java b/android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyALM.java deleted file mode 100644 index 066c78b37..000000000 --- a/android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyALM.java +++ /dev/null @@ -1,2074 +0,0 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ -package com.smartdevicelink.proxy; - -import android.app.Service; -import android.content.Context; - -import com.smartdevicelink.BuildConfig; -import com.smartdevicelink.exception.SdlException; -import com.smartdevicelink.exception.SdlExceptionCause; -import com.smartdevicelink.proxy.interfaces.IProxyListenerALM; -import com.smartdevicelink.proxy.rpc.AudioPassThruCapabilities; -import com.smartdevicelink.proxy.rpc.ButtonCapabilities; -import com.smartdevicelink.proxy.rpc.DisplayCapabilities; -import com.smartdevicelink.proxy.rpc.HMICapabilities; -import com.smartdevicelink.proxy.rpc.PresetBankCapabilities; -import com.smartdevicelink.proxy.rpc.SdlMsgVersion; -import com.smartdevicelink.proxy.rpc.SoftButtonCapabilities; -import com.smartdevicelink.proxy.rpc.TTSChunk; -import com.smartdevicelink.proxy.rpc.TemplateColorScheme; -import com.smartdevicelink.proxy.rpc.VehicleType; -import com.smartdevicelink.proxy.rpc.enums.AppHMIType; -import com.smartdevicelink.proxy.rpc.enums.HmiZoneCapabilities; -import com.smartdevicelink.proxy.rpc.enums.Language; -import com.smartdevicelink.proxy.rpc.enums.PrerecordedSpeech; -import com.smartdevicelink.proxy.rpc.enums.SdlDisconnectedReason; -import com.smartdevicelink.proxy.rpc.enums.SpeechCapabilities; -import com.smartdevicelink.proxy.rpc.enums.SystemCapabilityType; -import com.smartdevicelink.proxy.rpc.enums.VrCapabilities; -import com.smartdevicelink.trace.SdlTrace; -import com.smartdevicelink.transport.BTTransportConfig; -import com.smartdevicelink.transport.BaseTransportConfig; -import com.smartdevicelink.transport.MultiplexTransportConfig; -import com.smartdevicelink.transport.enums.TransportType; - -import java.util.List; -import java.util.Vector; - -import static com.smartdevicelink.managers.lifecycle.SystemCapabilityManager.convertToList; - -/** - * @deprecated use {@link com.smartdevicelink.managers.SdlManager} instead. - * - * The guide created for the initial transition of SdlProxyBase/ALM to SdlManager can be found at - * Migrating to SDL Manager - */ -@Deprecated -public class SdlProxyALM extends SdlProxyBase { - - private static final String SDL_LIB_TRACE_KEY = "42baba60-eb57-11df-98cf-0800200c9a66"; - @SuppressWarnings("unused") - private static final String SDL_LIB_PRIVATE_TOKEN = "{DAE1A88C-6C16-4768-ACA5-6F1247EA01C2}"; - /** - * @deprecated - * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL - * - * Takes advantage of the advanced lifecycle management. - * @param listener - Reference to the object in the App listening to callbacks from SDL. - * @param appName - Name of the application displayed on SDL. - * @param isMediaApp - Indicates if the app is a media application. - */ - @Deprecated - public SdlProxyALM(IProxyListenerALM listener, String appName, Boolean isMediaApp, - Language languageDesired, Language hmiDisplayLanguageDesired, String appID) throws SdlException { - super( listener, - /*sdl proxy configuration resources*/null, - /*enable advanced lifecycle management*/true, - appName, - /*TTS Name*/null, - /*ngn media app*/null, - /*vr synonyms*/null, - /*is media app*/isMediaApp, - /*sdlMsgVersion*/null, - /*language desired*/languageDesired, - /*HMI Display Language Desired*/hmiDisplayLanguageDesired, - /*App Type*/null, - /*App ID*/appID, - /*autoActivateID*/null, - /*callbackToUIThread*/ false, - new BTTransportConfig()); - } - - /** - * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL - * - * Takes advantage of the advanced lifecycle management. - * @param context - Used to create a multiplexing transport config - * @param listener - Reference to the object in the App listening to callbacks from SDL. - * @param appName - Name of the application displayed on SDL. - * @param isMediaApp - Indicates if the app is a media application. - */ - public SdlProxyALM(Context context,IProxyListenerALM listener, String appName, Boolean isMediaApp, - Language languageDesired, Language hmiDisplayLanguageDesired, String appID) throws SdlException { - super( listener, - /*sdl proxy configuration resources*/null, - /*enable advanced lifecycle management*/true, - appName, - /*TTS Name*/null, - /*ngn media app*/null, - /*vr synonyms*/null, - /*is media app*/isMediaApp, - /*sdlMsgVersion*/null, - /*language desired*/languageDesired, - /*HMI Display Language Desired*/hmiDisplayLanguageDesired, - /*App Type*/null, - /*App ID*/appID, - /*autoActivateID*/null, - /*callbackToUIThread*/ false, - new MultiplexTransportConfig(context,appID)); - - SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, appName, and isMediaApp.", SDL_LIB_TRACE_KEY); - } - /** - * @deprecated - * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL. - * - * Takes advantage of the advanced lifecycle management. - * - * @param listener - Reference to the object in the App listening to callbacks from SDL. - * @param appName - Name of the application displayed on SDL. - * @param ngnMediaScreenAppName - Name of the application displayed on SDL for Navigation equipped - * vehicles. Limited to five characters. - * @param vrSynonyms - A vector of strings, all of which can be used as voice commands to - * @param isMediaApp - Indicates if the app is a media application. - * @param sdlMsgVersion - Indicates the version of SDL SmartDeviceLink Messages desired. Must be less than - * or equal to the version of SDL SmartDeviceLink running on the vehicle. - * @param languageDesired - Indicates the language desired for the SDL interface. - * @param autoActivateID - ID used to re-register previously registered application. - * @throws SdlException - */ - @Deprecated - public SdlProxyALM(IProxyListenerALM listener, String appName, String ngnMediaScreenAppName, - Vector vrSynonyms, Boolean isMediaApp, SdlMsgVersion sdlMsgVersion, - Language languageDesired, Language hmiDisplayLanguageDesired, String appID, - String autoActivateID) throws SdlException { - super( listener, - /*sdl proxy configuration resources*/null, - /*enable advanced lifecycle management*/true, - appName, - /*TTS Name*/null, - ngnMediaScreenAppName, - vrSynonyms, - isMediaApp, - sdlMsgVersion, - languageDesired, - /*HMI Display Language Desired*/hmiDisplayLanguageDesired, - /*App Type*/null, - /*App ID*/appID, - autoActivateID, - /*callbackToUIThread*/ false, - new BTTransportConfig()); - - SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, appName, ngnMediaScreenAppName, " + - "vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, and autoActivateID.", SDL_LIB_TRACE_KEY); - } - /** - * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL. - * - * Takes advantage of the advanced lifecycle management. - * - * @param context - Used to create a multiplexing transport config - * @param listener - Reference to the object in the App listening to callbacks from SDL. - * @param appName - Name of the application displayed on SDL. - * @param ngnMediaScreenAppName - Name of the application displayed on SDL for Navigation equipped - * vehicles. Limited to five characters. - * @param vrSynonyms - A vector of strings, all of which can be used as voice commands to - * @param isMediaApp - Indicates if the app is a media application. - * @param sdlMsgVersion - Indicates the version of SDL SmartDeviceLink Messages desired. Must be less than - * or equal to the version of SDL SmartDeviceLink running on the vehicle. - * @param languageDesired - Indicates the language desired for the SDL interface. - * @param autoActivateID - ID used to re-register previously registered application. - * @throws SdlException - */ - public SdlProxyALM(Context context,IProxyListenerALM listener, String appName, String ngnMediaScreenAppName, - Vector vrSynonyms, Boolean isMediaApp, SdlMsgVersion sdlMsgVersion, - Language languageDesired, Language hmiDisplayLanguageDesired, String appID, - String autoActivateID) throws SdlException { - super( listener, - /*sdl proxy configuration resources*/null, - /*enable advanced lifecycle management*/true, - appName, - /*TTS Name*/null, - ngnMediaScreenAppName, - vrSynonyms, - isMediaApp, - sdlMsgVersion, - languageDesired, - /*HMI Display Language Desired*/hmiDisplayLanguageDesired, - /*App Type*/null, - /*App ID*/appID, - autoActivateID, - /*callbackToUIThread*/ false, - new MultiplexTransportConfig(context,appID)); - - SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, appName, ngnMediaScreenAppName, " + - "vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, and autoActivateID.", SDL_LIB_TRACE_KEY); - } - /** - * @deprecated - * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL. - * - * Takes advantage of the advanced lifecycle management. - * - * @param listener - Reference to the object in the App listening to callbacks from SDL. - * @param appName - Name of the application displayed on SDL. - * @param ngnMediaScreenAppName - Name of the application displayed on SDL for Navigation equipped - * vehicles. Limited to five characters. - * @param vrSynonyms - A vector of strings, all of which can be used as voice commands to - * @param isMediaApp - Indicates if the app is a media application. - * @param sdlMsgVersion - Indicates the version of SDL SmartDeviceLink Messages desired. Must be less than - * or equal to the version of SDL SmartDeviceLink running on the vehicle. - * @param languageDesired - Indicates the language desired for the SDL interface. - * @param autoActivateID - ID used to re-register previously registered application. - * @throws SdlException - */ - @Deprecated - public SdlProxyALM(IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources, - String appName, String ngnMediaScreenAppName, Vector vrSynonyms, - Boolean isMediaApp, SdlMsgVersion sdlMsgVersion, Language languageDesired, - Language hmiDisplayLanguageDesired, String appID, String autoActivateID) throws SdlException { - super( listener, - sdlProxyConfigurationResources, - /*enable advanced lifecycle management*/true, - appName, - /*TTS Name*/null, - ngnMediaScreenAppName, - vrSynonyms, - isMediaApp, - sdlMsgVersion, - languageDesired, - /*HMI Display Language Desired*/hmiDisplayLanguageDesired, - /*App Type*/null, - /*App ID*/appID, - autoActivateID, - /*callbackToUIThread*/ false, - new BTTransportConfig()); - - SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " + - "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, and autoActivateID.", SDL_LIB_TRACE_KEY); - } - /** - * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL. - * - * Takes advantage of the advanced lifecycle management. - * - * @param context - Used to create a multiplexing transport config - * @param listener - Reference to the object in the App listening to callbacks from SDL. - * @param appName - Name of the application displayed on SDL. - * @param ngnMediaScreenAppName - Name of the application displayed on SDL for Navigation equipped - * vehicles. Limited to five characters. - * @param vrSynonyms - A vector of strings, all of which can be used as voice commands to - * @param isMediaApp - Indicates if the app is a media application. - * @param sdlMsgVersion - Indicates the version of SDL SmartDeviceLink Messages desired. Must be less than - * or equal to the version of SDL SmartDeviceLink running on the vehicle. - * @param languageDesired - Indicates the language desired for the SDL interface. - * @param autoActivateID - ID used to re-register previously registered application. - * @throws SdlException - */ - public SdlProxyALM(Context context,IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources, - String appName, String ngnMediaScreenAppName, Vector vrSynonyms, - Boolean isMediaApp, SdlMsgVersion sdlMsgVersion, Language languageDesired, - Language hmiDisplayLanguageDesired, String appID, String autoActivateID) throws SdlException { - super( listener, - sdlProxyConfigurationResources, - /*enable advanced lifecycle management*/true, - appName, - /*TTS Name*/null, - ngnMediaScreenAppName, - vrSynonyms, - isMediaApp, - sdlMsgVersion, - languageDesired, - /*HMI Display Language Desired*/hmiDisplayLanguageDesired, - /*App Type*/null, - /*App ID*/appID, - autoActivateID, - /*callbackToUIThread*/ false, - new MultiplexTransportConfig(context,appID)); - - SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " + - "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, and autoActivateID.", SDL_LIB_TRACE_KEY); - } - /** - * @deprecated - * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL. - * - * Takes advantage of the advanced lifecycle management. - * - * @param listener - Reference to the object in the App listening to callbacks from SDL. - * @param appName - Name of the application displayed on SDL. - * @param ngnMediaScreenAppName - Name of the application displayed on SDL for Navigation equipped - * vehicles. Limited to five characters. - * @param vrSynonyms - A vector of strings, all of which can be used as voice commands to - * @param isMediaApp - Indicates if the app is a media application. - * @param sdlMsgVersion - Indicates the version of SDL SmartDeviceLink Messages desired. Must be less than - * or equal to the version of SDL SmartDeviceLink running on the vehicle. - * @param languageDesired - Indicates the language desired for the SDL interface. - * @param autoActivateID - ID used to re-register previously registered application. - * @param callbackToUIThread - If true, all callbacks will occur on the UI thread. - * @throws SdlException - */ - @Deprecated - public SdlProxyALM(IProxyListenerALM listener, String appName, String ngnMediaScreenAppName, - Vector vrSynonyms, Boolean isMediaApp, SdlMsgVersion sdlMsgVersion, - Language languageDesired, Language hmiDisplayLanguageDesired, String appID, - String autoActivateID, boolean callbackToUIThread) throws SdlException { - super( listener, - /*sdl proxy configuration resources*/null, - /*enable advanced lifecycle management*/true, - appName, - /*TTS Name*/null, - ngnMediaScreenAppName, - vrSynonyms, - isMediaApp, - sdlMsgVersion, - languageDesired, - /*HMI Display Language Desired*/hmiDisplayLanguageDesired, - /*App Type*/null, - /*App ID*/appID, - autoActivateID, - callbackToUIThread, - new BTTransportConfig()); - - SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, " + - "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " + - "and callbackToUIThread", SDL_LIB_TRACE_KEY); - } - /** - * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL. - * - * Takes advantage of the advanced lifecycle management. - * - * @param context - Used to create a multiplexing transport config - * @param listener - Reference to the object in the App listening to callbacks from SDL. - * @param appName - Name of the application displayed on SDL. - * @param ngnMediaScreenAppName - Name of the application displayed on SDL for Navigation equipped - * vehicles. Limited to five characters. - * @param vrSynonyms - A vector of strings, all of which can be used as voice commands to - * @param isMediaApp - Indicates if the app is a media application. - * @param sdlMsgVersion - Indicates the version of SDL SmartDeviceLink Messages desired. Must be less than - * or equal to the version of SDL SmartDeviceLink running on the vehicle. - * @param languageDesired - Indicates the language desired for the SDL interface. - * @param autoActivateID - ID used to re-register previously registered application. - * @param callbackToUIThread - If true, all callbacks will occur on the UI thread. - * @throws SdlException - */ - public SdlProxyALM(Context context,IProxyListenerALM listener, String appName, String ngnMediaScreenAppName, - Vector vrSynonyms, Boolean isMediaApp, SdlMsgVersion sdlMsgVersion, - Language languageDesired, Language hmiDisplayLanguageDesired, String appID, - String autoActivateID, boolean callbackToUIThread) throws SdlException { - super( listener, - /*sdl proxy configuration resources*/null, - /*enable advanced lifecycle management*/true, - appName, - /*TTS Name*/null, - ngnMediaScreenAppName, - vrSynonyms, - isMediaApp, - sdlMsgVersion, - languageDesired, - /*HMI Display Language Desired*/hmiDisplayLanguageDesired, - /*App Type*/null, - /*App ID*/appID, - autoActivateID, - callbackToUIThread, - new MultiplexTransportConfig(context,appID)); - - SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, " + - "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " + - "and callbackToUIThread", SDL_LIB_TRACE_KEY); - } - /** - * @deprecated - * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL. - * - * Takes advantage of the advanced lifecycle management. - * - * @param listener - Reference to the object in the App listening to callbacks from SDL. - * @param appName - Name of the application displayed on SDL. - * @param ngnMediaScreenAppName - Name of the application displayed on SDL for Navigation equipped - * vehicles. Limited to five characters. - * @param vrSynonyms - A vector of strings, all of which can be used as voice commands to - * @param isMediaApp - Indicates if the app is a media application. - * @param sdlMsgVersion - Indicates the version of SDL SmartDeviceLink Messages desired. Must be less than - * or equal to the version of SDL SmartDeviceLink running on the vehicle. - * @param languageDesired - Indicates the language desired for the SDL interface. - * @param autoActivateID - ID used to re-register previously registered application. - * @param callbackToUIThread - If true, all callbacks will occur on the UI thread. - * @throws SdlException - */ - @Deprecated - public SdlProxyALM(IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources, - String appName, String ngnMediaScreenAppName, Vector vrSynonyms, Boolean isMediaApp, - SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired, - String appID, String autoActivateID, - boolean callbackToUIThread) throws SdlException { - super( listener, - sdlProxyConfigurationResources, - /*enable advanced lifecycle management*/true, - appName, - /*TTS Name*/null, - ngnMediaScreenAppName, - vrSynonyms, - isMediaApp, - sdlMsgVersion, - languageDesired, - /*HMI Display Language Desired*/hmiDisplayLanguageDesired, - /*App Type*/null, - /*App ID*/appID, - autoActivateID, - callbackToUIThread, - new BTTransportConfig()); - - SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " + - "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " + - "and callbackToUIThread", SDL_LIB_TRACE_KEY); - } - /** - * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL. - * - * Takes advantage of the advanced lifecycle management. - * - * @param context - Used to create a multiplexing transport config - * @param listener - Reference to the object in the App listening to callbacks from SDL. - * @param appName - Name of the application displayed on SDL. - * @param ngnMediaScreenAppName - Name of the application displayed on SDL for Navigation equipped - * vehicles. Limited to five characters. - * @param vrSynonyms - A vector of strings, all of which can be used as voice commands to - * @param isMediaApp - Indicates if the app is a media application. - * @param sdlMsgVersion - Indicates the version of SDL SmartDeviceLink Messages desired. Must be less than - * or equal to the version of SDL SmartDeviceLink running on the vehicle. - * @param languageDesired - Indicates the language desired for the SDL interface. - * @param autoActivateID - ID used to re-register previously registered application. - * @param callbackToUIThread - If true, all callbacks will occur on the UI thread. - * @throws SdlException - */ - public SdlProxyALM(Context context,IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources, - String appName, String ngnMediaScreenAppName, Vector vrSynonyms, Boolean isMediaApp, - SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired, - String appID, String autoActivateID, - boolean callbackToUIThread) throws SdlException { - super( listener, - sdlProxyConfigurationResources, - /*enable advanced lifecycle management*/true, - appName, - /*TTS Name*/null, - ngnMediaScreenAppName, - vrSynonyms, - isMediaApp, - sdlMsgVersion, - languageDesired, - /*HMI Display Language Desired*/hmiDisplayLanguageDesired, - /*App Type*/null, - /*App ID*/appID, - autoActivateID, - callbackToUIThread, - new MultiplexTransportConfig(context,appID)); - - SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " + - "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " + - "and callbackToUIThread", SDL_LIB_TRACE_KEY); - } - - @Deprecated - public SdlProxyALM(IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources, - String appName, String ngnMediaScreenAppName, Vector vrSynonyms, Boolean isMediaApp, - SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired, - String appID, String autoActivateID, boolean callbackToUIThread, boolean preRegister) throws SdlException { - super( listener, - sdlProxyConfigurationResources, - /*enable advanced lifecycle management*/true, - appName, - /*TTS Name*/null, - ngnMediaScreenAppName, - vrSynonyms, - isMediaApp, - sdlMsgVersion, - languageDesired, - /*HMI Display Language Desired*/hmiDisplayLanguageDesired, - /*App Type*/null, - /*App ID*/appID, - autoActivateID, - callbackToUIThread, - preRegister, - new BTTransportConfig()); - - SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " + - "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " + - "callbackToUIThread and version", SDL_LIB_TRACE_KEY); - } - - public SdlProxyALM(Context context,IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources, - String appName, String ngnMediaScreenAppName, Vector vrSynonyms, Boolean isMediaApp, - SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired, - String appID, String autoActivateID, boolean callbackToUIThread, boolean preRegister) throws SdlException { - super( listener, - sdlProxyConfigurationResources, - /*enable advanced lifecycle management*/true, - appName, - /*TTS Name*/null, - ngnMediaScreenAppName, - vrSynonyms, - isMediaApp, - sdlMsgVersion, - languageDesired, - /*HMI Display Language Desired*/hmiDisplayLanguageDesired, - /*App Type*/null, - /*App ID*/appID, - autoActivateID, - callbackToUIThread, - preRegister, - new MultiplexTransportConfig(context,appID)); - - SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " + - "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " + - "callbackToUIThread and version", SDL_LIB_TRACE_KEY); - } - - /********************************************** TRANSPORT SWITCHING SUPPORT *****************************************/ - - /** - * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport. - * - * Takes advantage of the advanced lifecycle management. - * - * @param listener Reference to the object in the App listening to callbacks from SDL. - * @param appName Name of the application displayed on SDL. - * @param isMediaApp Indicates if the app is a media application. - * @param transportConfig Initial configuration for transport. - * @throws SdlException - */ - public SdlProxyALM(IProxyListenerALM listener, String appName, Boolean isMediaApp, - Language languageDesired, Language hmiDisplayLanguageDesired, String appID, - BaseTransportConfig transportConfig) throws SdlException { - super( listener, - /*sdl proxy configuration resources*/null, - /*enable advanced lifecycle management*/true, - appName, - /*TTS Name*/null, - /*ngn media app*/null, - /*vr synonyms*/null, - /*is media app*/isMediaApp, - /*sdlMsgVersion*/null, - /*language desired*/languageDesired, - /*HMI Display Language Desired*/hmiDisplayLanguageDesired, - /*App Type*/null, - /*App ID*/appID, - /*autoActivateID*/null, - /*callbackToUIThread*/ false, - transportConfig); - - SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using new constructor with specified transport) instance passing in: IProxyListener, appName, and isMediaApp.", SDL_LIB_TRACE_KEY); - } - - /** - * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport. - * - * Takes advantage of the advanced lifecycle management. - * - * @param listener Reference to the object in the App listening to callbacks from SDL. - * @param appName Name of the application displayed on SDL. - * @param ngnMediaScreenAppName Name of the application displayed on SDL for Navigation equipped - * vehicles. Limited to five characters. - * @param vrSynonyms A vector of strings, all of which can be used as voice commands to - * @param isMediaApp Indicates if the app is a media application. - * @param sdlMsgVersion Indicates the version of SDL SmartDeviceLink Messages desired. Must be less than - * or equal to the version of SDL SmartDeviceLink running on the vehicle. - * @param languageDesired Indicates the language desired for the SDL interface. - * @param autoActivateID ID used to re-register previously registered application. - * @param transportConfig Initial configuration for transport. - * @throws SdlException - */ - public SdlProxyALM(IProxyListenerALM listener, String appName, String ngnMediaScreenAppName, - Vector vrSynonyms, Boolean isMediaApp, SdlMsgVersion sdlMsgVersion, - Language languageDesired, Language hmiDisplayLanguageDesired, String appID, - String autoActivateID, TransportType transportType, BaseTransportConfig transportConfig) throws SdlException { - super( listener, - /*sdl proxy configuration resources*/null, - /*enable advanced lifecycle management*/true, - appName, - /*TTS Name*/null, - ngnMediaScreenAppName, - vrSynonyms, - isMediaApp, - sdlMsgVersion, - languageDesired, - /*HMI Display Language Desired*/hmiDisplayLanguageDesired, - /*App Type*/null, - /*App ID*/appID, - autoActivateID, - /*callbackToUIThread*/ false, - transportConfig); - - SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using new constructor with specified transport) instance passing in: IProxyListener, appName, ngnMediaScreenAppName, " + - "vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, and autoActivateID.", SDL_LIB_TRACE_KEY); - } - - /** - * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport. - * - * Takes advantage of the advanced lifecycle management. - * - * @param listener Reference to the object in the App listening to callbacks from SDL. - * @param appName Name of the application displayed on SDL. - * @param ngnMediaScreenAppName Name of the application displayed on SDL for Navigation equipped - * vehicles. Limited to five characters. - * @param vrSynonyms A vector of strings, all of which can be used as voice commands to - * @param isMediaApp Indicates if the app is a media application. - * @param sdlMsgVersion Indicates the version of SDL SmartDeviceLink Messages desired. Must be less than - * or equal to the version of SDL SmartDeviceLink running on the vehicle. - * @param languageDesired Indicates the language desired for the SDL interface. - * @param autoActivateID ID used to re-register previously registered application. - * @param transportConfig Initial configuration for transport. - * @throws SdlException - */ - public SdlProxyALM(IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources, - String appName, String ngnMediaScreenAppName, Vector vrSynonyms, - Boolean isMediaApp, SdlMsgVersion sdlMsgVersion, Language languageDesired, - Language hmiDisplayLanguageDesired, String appID, String autoActivateID, - BaseTransportConfig transportConfig) throws SdlException { - super( listener, - sdlProxyConfigurationResources, - /*enable advanced lifecycle management*/true, - appName, - /*TTS Name*/null, - ngnMediaScreenAppName, - vrSynonyms, - isMediaApp, - sdlMsgVersion, - languageDesired, - /*HMI Display Language Desired*/hmiDisplayLanguageDesired, - /*App Type*/null, - /*App ID*/appID, - autoActivateID, - /*callbackToUIThread*/ false, - transportConfig); - - SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using new constructor with specified transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " + - "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, and autoActivateID.", SDL_LIB_TRACE_KEY); - } - - /** - * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport. - * - * Takes advantage of the advanced lifecycle management. - * - * @param listener Reference to the object in the App listening to callbacks from SDL. - * @param appName Name of the application displayed on SDL. - * @param ngnMediaScreenAppName Name of the application displayed on SDL for Navigation equipped - * vehicles. Limited to five characters. - * @param vrSynonyms A vector of strings, all of which can be used as voice commands to - * @param isMediaApp Indicates if the app is a media application. - * @param sdlMsgVersion Indicates the version of SDL SmartDeviceLink Messages desired. Must be less than - * or equal to the version of SDL SmartDeviceLink running on the vehicle. - * @param languageDesired Indicates the language desired for the SDL interface. - * @param autoActivateID ID used to re-register previously registered application. - * @param callbackToUIThread If true, all callbacks will occur on the UI thread. - * @param transportConfig Initial configuration for transport. - * @throws SdlException - */ - public SdlProxyALM(IProxyListenerALM listener, String appName, String ngnMediaScreenAppName, - Vector vrSynonyms, Boolean isMediaApp, SdlMsgVersion sdlMsgVersion, - Language languageDesired, Language hmiDisplayLanguageDesired, String appID, - String autoActivateID, boolean callbackToUIThread, - BaseTransportConfig transportConfig) throws SdlException { - super( listener, - /*sdl proxy configuration resources*/null, - /*enable advanced lifecycle management*/true, - appName, - /*TTS Name*/null, - ngnMediaScreenAppName, - vrSynonyms, - isMediaApp, - sdlMsgVersion, - languageDesired, - /*HMI Display Language Desired*/hmiDisplayLanguageDesired, - /*App Type*/null, - /*App ID*/appID, - autoActivateID, - callbackToUIThread, - transportConfig); - - SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using new constructor with specified transport) instance passing in: IProxyListener, " + - "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " + - "and callbackToUIThread", SDL_LIB_TRACE_KEY); - } - - /** - * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport. - * - * Takes advantage of the advanced lifecycle management. - * - * @param listener Reference to the object in the App listening to callbacks from SDL. - * @param appName Name of the application displayed on SDL. - * @param ngnMediaScreenAppName Name of the application displayed on SDL for Navigation equipped - * vehicles. Limited to five characters. - * @param vrSynonyms A vector of strings, all of which can be used as voice commands too - * @param isMediaApp Indicates if the app is a media application. - * @param sdlMsgVersion Indicates the version of SDL SmartDeviceLink Messages desired. Must be less than - * or equal to the version of SDL SmartDeviceLink running on the vehicle. - * @param languageDesired Indicates the language desired for the SDL interface. - * @param autoActivateID ID used to re-register previously registered application. - * @param callbackToUIThread If true, all callbacks will occur on the UI thread. - * @param transportConfig Initial configuration for transport. - * @throws SdlException - */ - public SdlProxyALM(IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources, - String appName, String ngnMediaScreenAppName, Vector vrSynonyms, Boolean isMediaApp, - SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired, - String appID, String autoActivateID, - boolean callbackToUIThread, BaseTransportConfig transportConfig) throws SdlException { - super( listener, - sdlProxyConfigurationResources, - /*enable advanced lifecycle management*/true, - appName, - /*TTS Name*/null, - ngnMediaScreenAppName, - vrSynonyms, - isMediaApp, - sdlMsgVersion, - languageDesired, - /*HMI Display Language Desired*/hmiDisplayLanguageDesired, - /*App Type*/null, - /*App ID*/appID, - autoActivateID, - callbackToUIThread, - transportConfig); - - SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using new constructor with specified transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " + - "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " + - "and callbackToUIThread", SDL_LIB_TRACE_KEY); - } - - /** - * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport. - * - * Takes advantage of the advanced lifecycle management. - * - * @param listener Reference to the object in the App listening to callbacks from SDL. - * @param sdlProxyConfigurationResources Proxy configuration resources. - * @param appName Name of the application displayed on SDL. - * @param ngnMediaScreenAppName Name of the application displayed on SDL for Navigation equipped - * vehicles. Limited to five characters. - * @param vrSynonyms A vector of strings, all of which can be used as voice commands too - * @param isMediaApp Indicates if the app is a media application. - * @param sdlMsgVersion Indicates the version of SDL SmartDeviceLink Messages desired. Must be less than - * or equal to the version of SDL SmartDeviceLink running on the vehicle. - * @param languageDesired Indicates the language desired for the SDL interface. - * @param hmiDisplayLanguageDesired Desired language in HMI. - * @param appID Identifier of the client application. - * @param autoActivateID ID used to re-register previously registered application. - * @param callbackToUIThread If true, all callbacks will occur on the UI thread. - * @param preRegister Flag that indicates that client should be pre-registred or not - * @param transportConfig Initial configuration for transport. - * @throws SdlException - */ - public SdlProxyALM(IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources, - String appName, String ngnMediaScreenAppName, Vector vrSynonyms, Boolean isMediaApp, - SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired, - String appID, String autoActivateID, boolean callbackToUIThread, boolean preRegister, - BaseTransportConfig transportConfig) throws SdlException { - super( listener, - sdlProxyConfigurationResources, - /*enable advanced lifecycle management*/true, - appName, - /*TTS Name*/null, - ngnMediaScreenAppName, - vrSynonyms, - isMediaApp, - sdlMsgVersion, - languageDesired, - /*HMI Display Language Desired*/hmiDisplayLanguageDesired, - /*App Type*/null, - /*App ID*/appID, - autoActivateID, - callbackToUIThread, - preRegister, - transportConfig); - - SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using new constructor with specified transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " + - "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " + - "callbackToUIThread and version", SDL_LIB_TRACE_KEY); - } - - /** - * @deprecated - * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport. - * - * Takes advantage of the advanced lifecycle management. - * - * @param listener Reference to the object in the App listening to callbacks from SDL. - * @param appName Name of the application displayed on SDL. - * @param isMediaApp Indicates if the app is a media application. - * @param languageDesired Indicates the language desired for the SDL interface. - * @param hmiDisplayLanguageDesired Desired language in HMI. - * @param appID Identifier of the client application. - * @param callbackToUIThread If true, all callbacks will occur on the UI thread. - * @param preRegister Flag that indicates that client should be pre-registred or not - * @throws SdlException - */ - @Deprecated - public SdlProxyALM(IProxyListenerALM listener, String appName, Boolean isMediaApp,Language languageDesired, Language hmiDisplayLanguageDesired, - String appID, boolean callbackToUIThread, boolean preRegister) throws SdlException - { - super( listener, - /*sdlProxyConfigurationResources*/null, - /*enable advanced lifecycle management*/true, - appName, - /*ttsName*/null, - /*ngnMediaScreenAppName*/null, - /*vrSynonyms*/null, - isMediaApp, - /*sdlMsgVersion*/null, - languageDesired, - hmiDisplayLanguageDesired, - /*App Type*/null, - /*App ID*/appID, - /*autoActivateID*/null, - callbackToUIThread, - preRegister, - new BTTransportConfig()); - - SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, " + - "appName, isMediaApp, languageDesired, hmiDisplayLanguageDesired" + "callbackToUIThread and version", SDL_LIB_TRACE_KEY); - } - /** - * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport. - * - * Takes advantage of the advanced lifecycle management. - * - * @param context - Used to create a multiplexing transport config - * @param listener Reference to the object in the App listening to callbacks from SDL. - * @param appName Name of the application displayed on SDL. - * @param isMediaApp Indicates if the app is a media application. - * @param languageDesired Indicates the language desired for the SDL interface. - * @param hmiDisplayLanguageDesired Desired language in HMI. - * @param appID Identifier of the client application. - * @param callbackToUIThread If true, all callbacks will occur on the UI thread. - * @param preRegister Flag that indicates that client should be pre-registred or not - * @throws SdlException - */ - public SdlProxyALM(Context context,IProxyListenerALM listener, String appName, Boolean isMediaApp,Language languageDesired, Language hmiDisplayLanguageDesired, - String appID, boolean callbackToUIThread, boolean preRegister) throws SdlException - { - super( listener, - /*sdlProxyConfigurationResources*/null, - /*enable advanced lifecycle management*/true, - appName, - /*ttsName*/null, - /*ngnMediaScreenAppName*/null, - /*vrSynonyms*/null, - isMediaApp, - /*sdlMsgVersion*/null, - languageDesired, - hmiDisplayLanguageDesired, - /*App Type*/null, - /*App ID*/appID, - /*autoActivateID*/null, - callbackToUIThread, - preRegister, - new MultiplexTransportConfig(context,appID)); - - SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, " + - "appName, isMediaApp, languageDesired, hmiDisplayLanguageDesired" + "callbackToUIThread and version", SDL_LIB_TRACE_KEY); - } - - /** - * @deprecated - * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport. - * - * Takes advantage of the advanced lifecycle management. - * - * @param listener Reference to the object in the App listening to callbacks from SDL. - * @param appName Name of the application displayed on SDL. - * @param isMediaApp Indicates if the app is a media application. - * @param appID Identifier of the client application. - * @throws SdlException - */ - @Deprecated - public SdlProxyALM(IProxyListenerALM listener, String appName, Boolean isMediaApp,String appID) throws SdlException { - super( listener, - /*sdlProxyConfigurationResources*/null, - /*enable advanced lifecycle management*/true, - appName, - /*ttsName*/null, - /*ngnMediaScreenAppName*/null, - /*vrSynonyms*/null, - isMediaApp, - /*sdlMsgVersion*/null, - /*languageDesired*/null, - /*hmiDisplayLanguageDesired*/null, - /*App Type*/null, - /*App ID*/appID, - /*autoActivateID*/null, - false, - false, - new BTTransportConfig()); - - SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, " + - "appName, isMediaApp, appID", SDL_LIB_TRACE_KEY); - } - - /** - * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport. - * - * Takes advantage of the advanced lifecycle management. - * - * @param context - Used to create a multiplexing transport config - * @param listener Reference to the object in the App listening to callbacks from SDL. - * @param appName Name of the application displayed on SDL. - * @param isMediaApp Indicates if the app is a media application. - * @param appID Identifier of the client application. - * @throws SdlException - */ - public SdlProxyALM(Context context,IProxyListenerALM listener, String appName, Boolean isMediaApp,String appID) throws SdlException { - super( listener, - /*sdlProxyConfigurationResources*/null, - /*enable advanced lifecycle management*/true, - appName, - /*ttsName*/null, - /*ngnMediaScreenAppName*/null, - /*vrSynonyms*/null, - isMediaApp, - /*sdlMsgVersion*/null, - /*languageDesired*/null, - /*hmiDisplayLanguageDesired*/null, - /*App Type*/null, - /*App ID*/appID, - /*autoActivateID*/null, - false, - false, - new MultiplexTransportConfig(context,appID)); - - SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, " + - "appName, isMediaApp, appID", SDL_LIB_TRACE_KEY); - } - - /** - * @deprecated - * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport. - * - * Takes advantage of the advanced lifecycle management. - * - * @param listener Reference to the object in the App listening to callbacks from SDL. - * @param sdlProxyConfigurationResources Proxy configuration resources. - * @param appName Name of the application displayed on SDL. - * @param isMediaApp Indicates if the app is a media application. - * @param appID Identifier of the client application. - * @throws SdlException - */ - @Deprecated - public SdlProxyALM(IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources, String appName, Boolean isMediaApp,String appID) throws SdlException { - super( listener, - sdlProxyConfigurationResources, - /*enable advanced lifecycle management*/true, - appName, - /*ttsName*/null, - /*ngnMediaScreenAppName*/null, - /*vrSynonyms*/null, - isMediaApp, - /*sdlMsgVersion*/null, - /*languageDesired*/null, - /*hmiDisplayLanguageDesired*/null, - /*App Type*/null, - /*App ID*/appID, - /*autoActivateID*/null, - false, - false, - new BTTransportConfig()); - - SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, " + - "sdlProxyConfigurationResources, appName, isMediaApp, appID", SDL_LIB_TRACE_KEY); - } - - /** - * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport. - * - * Takes advantage of the advanced lifecycle management. - * - * @param context - Used to create a multiplexing transport config - * @param listener Reference to the object in the App listening to callbacks from SDL. - * @param sdlProxyConfigurationResources Proxy configuration resources. - * @param appName Name of the application displayed on SDL. - * @param isMediaApp Indicates if the app is a media application. - * @param appID Identifier of the client application. - * @throws SdlException - */ - public SdlProxyALM(Context context, IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources, String appName, Boolean isMediaApp,String appID) throws SdlException { - super( listener, - sdlProxyConfigurationResources, - /*enable advanced lifecycle management*/true, - appName, - /*ttsName*/null, - /*ngnMediaScreenAppName*/null, - /*vrSynonyms*/null, - isMediaApp, - /*sdlMsgVersion*/null, - /*languageDesired*/null, - /*hmiDisplayLanguageDesired*/null, - /*App Type*/null, - /*App ID*/appID, - /*autoActivateID*/null, - false, - false, - new MultiplexTransportConfig(context,appID)); - - SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, " + - "sdlProxyConfigurationResources, appName, isMediaApp, appID", SDL_LIB_TRACE_KEY); - } - - public SdlProxyALM(IProxyListenerALM listener, String appName, Boolean isMediaApp,String appID,BaseTransportConfig transportConfig) throws SdlException { - super( listener, - /*sdlProxyConfigurationResources*/null, - /*enable advanced lifecycle management*/true, - appName, - /*ttsName*/null, - /*ngnMediaScreenAppName*/null, - /*vrSynonyms*/null, - isMediaApp, - /*sdlMsgVersion*/null, - /*languageDesired*/null, - /*hmiDisplayLanguageDesired*/null, - /*App Type*/null, - /*App ID*/appID, - /*autoActivateID*/null, - false, - false, - transportConfig); - - SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, " + - "appName, isMediaApp, appID", SDL_LIB_TRACE_KEY); - } - - public SdlProxyALM(IProxyListenerALM listener, String appName, Boolean isMediaApp, String appID, - TemplateColorScheme dayColorScheme, TemplateColorScheme nightColorScheme, BaseTransportConfig transportConfig) throws SdlException { - super( listener, - /*sdlProxyConfigurationResources*/null, - /*enable advanced lifecycle management*/true, - appName, - /*ttsName*/null, - /*ngnMediaScreenAppName*/null, - /*vrSynonyms*/null, - isMediaApp, - /*sdlMsgVersion*/null, - /*languageDesired*/null, - /*hmiDisplayLanguageDesired*/null, - /*App Type*/null, - /*App ID*/appID, - /*autoActivateID*/null, - dayColorScheme, - nightColorScheme, - false, - false, - transportConfig); - - SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, " + - "appName, isMediaApp, appID, dayColorScheme, nightColorScheme", SDL_LIB_TRACE_KEY); - } - - /** - * @deprecated - * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport. - * - * Takes advantage of the advanced lifecycle management. - * - * @param listener Reference to the object in the App listening to callbacks from SDL. - * @param appName Name of the application displayed on SDL. - * @param isMediaApp Indicates if the app is a media application. - * @param appID Identifier of the client application. - * @param callbackToUIThread If true, all callbacks will occur on the UI thread. - * @param preRegister Flag that indicates that client should be pre-registred or not - * @throws SdlException - */ - @Deprecated - public SdlProxyALM(IProxyListenerALM listener, String appName, Boolean isMediaApp,String appID, - boolean callbackToUIThread, boolean preRegister) throws SdlException { - super( listener, - /*sdlProxyConfigurationResources*/null, - /*enable advanced lifecycle management*/true, - appName, - /*ttsName*/null, - /*ngnMediaScreenAppName*/null, - /*vrSynonyms*/null, - isMediaApp, - /*sdlMsgVersion*/null, - /*languageDesired*/null, - /*hmiDisplayLanguageDesired*/null, - /*App Type*/null, - /*App ID*/appID, - /*autoActivateID*/null, - callbackToUIThread, - preRegister, - new BTTransportConfig()); - - SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, " + - "appName, isMediaApp, " + "callbackToUIThread and version", SDL_LIB_TRACE_KEY); - } - /** - * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport. - * - * Takes advantage of the advanced lifecycle management. - * - * @param context - Used to create a multiplexing transport config - * @param listener Reference to the object in the App listening to callbacks from SDL. - * @param appName Name of the application displayed on SDL. - * @param isMediaApp Indicates if the app is a media application. - * @param appID Identifier of the client application. - * @param callbackToUIThread If true, all callbacks will occur on the UI thread. - * @param preRegister Flag that indicates that client should be pre-registred or not - * @throws SdlException - */ - public SdlProxyALM(Context context,IProxyListenerALM listener, String appName, Boolean isMediaApp,String appID, - boolean callbackToUIThread, boolean preRegister) throws SdlException { - super( listener, - /*sdlProxyConfigurationResources*/null, - /*enable advanced lifecycle management*/true, - appName, - /*ttsName*/null, - /*ngnMediaScreenAppName*/null, - /*vrSynonyms*/null, - isMediaApp, - /*sdlMsgVersion*/null, - /*languageDesired*/null, - /*hmiDisplayLanguageDesired*/null, - /*App Type*/null, - /*App ID*/appID, - /*autoActivateID*/null, - callbackToUIThread, - preRegister, - new MultiplexTransportConfig(context,appID)); - - SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, " + - "appName, isMediaApp, " + "callbackToUIThread and version", SDL_LIB_TRACE_KEY); - } - - /** - * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport. - * - * Takes advantage of the advanced lifecycle management. - * @param appService Reference to the apps service object. - * @param listener Reference to the object in the App listening to callbacks from SDL. - * @param sdlProxyConfigurationResources Proxy configuration resources. - * @param appName Name of the application displayed on SDL. - * @param ttsName TTS name. - * @param ngnMediaScreenAppName Name of the application displayed on SDL for Navigation equipped - * vehicles. Limited to five characters. - * @param vrSynonyms A vector of strings, all of which can be used as voice commands too - * @param isMediaApp Indicates if the app is a media application. - * @param sdlMsgVersion Indicates the version of SDL SmartDeviceLink Messages desired. Must be less than - * or equal to the version of SDL SmartDeviceLink running on the vehicle. - * @param languageDesired Indicates the language desired for the SDL interface. - * @param hmiDisplayLanguageDesired Desired language in HMI. - * @param appID Identifier of the client application. - * @param autoActivateID ID used to re-register previously registered application. - * @param callbackToUIThread If true, all callbacks will occur on the UI thread. - * @param preRegister Flag that indicates that client should be pre-registred or not - * @throws SdlException - */ - public SdlProxyALM(Service appService, IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources, - String appName, Vector ttsName, String ngnMediaScreenAppName, Vector vrSynonyms, Boolean isMediaApp, - SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired, - String appID, String autoActivateID, boolean callbackToUIThread, boolean preRegister) throws SdlException { - super( listener, - sdlProxyConfigurationResources, - /*enable advanced lifecycle management*/true, - appName, - ttsName, - ngnMediaScreenAppName, - vrSynonyms, - isMediaApp, - sdlMsgVersion, - languageDesired, - /*HMI Display Language Desired*/hmiDisplayLanguageDesired, - /*App Type*/null, - /*App ID*/appID, - autoActivateID, - callbackToUIThread, - preRegister, - new MultiplexTransportConfig(appService.getBaseContext(),appID)); - - this.setAppService(appService); - this.sendTransportBroadcast(); - - SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " + - "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " + - "callbackToUIThread and version", SDL_LIB_TRACE_KEY); - } - - - public SdlProxyALM(Service appService, IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources, - String appName, Vector ttsName, String ngnMediaScreenAppName, Vector vrSynonyms, Boolean isMediaApp, - SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired, - String appID, String autoActivateID, boolean callbackToUIThread, boolean preRegister, BaseTransportConfig transportConfig) throws SdlException { - super( listener, - sdlProxyConfigurationResources, - /*enable advanced lifecycle management*/true, - appName, - ttsName, - ngnMediaScreenAppName, - vrSynonyms, - isMediaApp, - sdlMsgVersion, - languageDesired, - /*HMI Display Language Desired*/hmiDisplayLanguageDesired, - /*App Type*/null, - /*App ID*/appID, - autoActivateID, - callbackToUIThread, - preRegister, - transportConfig); - - this.setAppService(appService); - this.sendTransportBroadcast(); - - SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " + - "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " + - "callbackToUIThread and version", SDL_LIB_TRACE_KEY); - } - - - - /** - * @deprecated - * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport. - * - * Takes advantage of the advanced lifecycle management. - * - * @param listener Reference to the object in the App listening to callbacks from SDL. - * @param sdlProxyConfigurationResources Proxy configuration resources. - * @param appName Name of the application displayed on SDL. - * @param ttsName TTS name. - * @param ngnMediaScreenAppName Name of the application displayed on SDL for Navigation equipped - * vehicles. Limited to five characters. - * @param vrSynonyms A vector of strings, all of which can be used as voice commands too - * @param isMediaApp Indicates if the app is a media application. - * @param sdlMsgVersion Indicates the version of SDL SmartDeviceLink Messages desired. Must be less than - * or equal to the version of SDL SmartDeviceLink running on the vehicle. - * @param languageDesired Indicates the language desired for the SDL interface. - * @param hmiDisplayLanguageDesired Desired language in HMI. - * @param appID Identifier of the client application. - * @param autoActivateID ID used to re-register previously registered application. - * @param callbackToUIThread If true, all callbacks will occur on the UI thread. - * @param preRegister Flag that indicates that client should be pre-registred or not - * @throws SdlException - */ - @Deprecated - public SdlProxyALM(IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources, - String appName, Vector ttsName, String ngnMediaScreenAppName, Vector vrSynonyms, Boolean isMediaApp, - SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired, - String appID, String autoActivateID, boolean callbackToUIThread, boolean preRegister) throws SdlException { - super( listener, - sdlProxyConfigurationResources, - /*enable advanced lifecycle management*/true, - appName, - ttsName, - ngnMediaScreenAppName, - vrSynonyms, - isMediaApp, - sdlMsgVersion, - languageDesired, - /*HMI Display Language Desired*/hmiDisplayLanguageDesired, - /*App Type*/null, - /*App ID*/appID, - autoActivateID, - callbackToUIThread, - preRegister, - new BTTransportConfig()); - - SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " + - "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " + - "callbackToUIThread and version", SDL_LIB_TRACE_KEY); - } - /** - * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport. - * - * Takes advantage of the advanced lifecycle management. - * - * @param context - Used to create a multiplexing transport config - * @param listener Reference to the object in the App listening to callbacks from SDL. - * @param sdlProxyConfigurationResources Proxy configuration resources. - * @param appName Name of the application displayed on SDL. - * @param ttsName TTS name. - * @param ngnMediaScreenAppName Name of the application displayed on SDL for Navigation equipped - * vehicles. Limited to five characters. - * @param vrSynonyms A vector of strings, all of which can be used as voice commands too - * @param isMediaApp Indicates if the app is a media application. - * @param sdlMsgVersion Indicates the version of SDL SmartDeviceLink Messages desired. Must be less than - * or equal to the version of SDL SmartDeviceLink running on the vehicle. - * @param languageDesired Indicates the language desired for the SDL interface. - * @param hmiDisplayLanguageDesired Desired language in HMI. - * @param appID Identifier of the client application. - * @param autoActivateID ID used to re-register previously registered application. - * @param callbackToUIThread If true, all callbacks will occur on the UI thread. - * @param preRegister Flag that indicates that client should be pre-registred or not - * @throws SdlException - */ - public SdlProxyALM(Context context,IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources, - String appName, Vector ttsName, String ngnMediaScreenAppName, Vector vrSynonyms, Boolean isMediaApp, - SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired, - String appID, String autoActivateID, boolean callbackToUIThread, boolean preRegister) throws SdlException { - super( listener, - sdlProxyConfigurationResources, - /*enable advanced lifecycle management*/true, - appName, - ttsName, - ngnMediaScreenAppName, - vrSynonyms, - isMediaApp, - sdlMsgVersion, - languageDesired, - /*HMI Display Language Desired*/hmiDisplayLanguageDesired, - /*App Type*/null, - /*App ID*/appID, - autoActivateID, - callbackToUIThread, - preRegister, - new MultiplexTransportConfig(context,appID)); - - SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " + - "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " + - "callbackToUIThread and version", SDL_LIB_TRACE_KEY); - } - - - /** - * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport. - * - * Takes advantage of the advanced lifecycle management. - * - * @param listener Reference to the object in the App listening to callbacks from SDL. - * @param sdlProxyConfigurationResources Proxy configuration resources. - * @param appName Name of the application displayed on SDL. - * @param ttsName TTS name. - * @param ngnMediaScreenAppName Name of the application displayed on SDL for Navigation equipped - * vehicles. Limited to five characters. - * @param vrSynonyms A vector of strings, all of which can be used as voice commands too - * @param isMediaApp Indicates if the app is a media application. - * @param sdlMsgVersion Indicates the version of SDL SmartDeviceLink Messages desired. Must be less than - * or equal to the version of SDL SmartDeviceLink running on the vehicle. - * @param languageDesired Indicates the language desired for the SDL interface. - * @param hmiDisplayLanguageDesired Desired language in HMI. - * @param appID Identifier of the client application. - * @param autoActivateID ID used to re-register previously registered application. - * @param callbackToUIThread If true, all callbacks will occur on the UI thread. - * @param preRegister Flag that indicates that client should be pre-registred or not - * @param transportConfig Initial configuration for transport. - * @throws SdlException - */ - public SdlProxyALM(IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources, - String appName, Vector ttsName, String ngnMediaScreenAppName, Vector vrSynonyms, Boolean isMediaApp, - SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired, - String appID, String autoActivateID, boolean callbackToUIThread, boolean preRegister, - BaseTransportConfig transportConfig) throws SdlException { - super( listener, - sdlProxyConfigurationResources, - /*enable advanced lifecycle management*/true, - appName, - ttsName, - ngnMediaScreenAppName, - vrSynonyms, - isMediaApp, - sdlMsgVersion, - languageDesired, - /*HMI Display Language Desired*/hmiDisplayLanguageDesired, - /*App Type*/null, - /*App ID*/appID, - autoActivateID, - callbackToUIThread, - preRegister, - transportConfig); - - SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using new constructor with specified transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " + - "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " + - "callbackToUIThread and version", SDL_LIB_TRACE_KEY); - } - /** - * @deprecated - * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport. - * - * Takes advantage of the advanced lifecycle management. - * - * @param listener Reference to the object in the App listening to callbacks from SDL. - * @param sdlProxyConfigurationResources Proxy configuration resources. - * @param appName Name of the application displayed on SDL. - * @param ttsName TTS name. - * @param ngnMediaScreenAppName Name of the application displayed on SDL for Navigation equipped - * vehicles. Limited to five characters. - * @param vrSynonyms A vector of strings, all of which can be used as voice commands too - * @param isMediaApp Indicates if the app is a media application. - * @param sdlMsgVersion Indicates the version of SDL SmartDeviceLink Messages desired. Must be less than - * or equal to the version of SDL SmartDeviceLink running on the vehicle. - * @param languageDesired Indicates the language desired for the SDL interface. - * @param hmiDisplayLanguageDesired Desired language in HMI. - * @param appType Type of application. - * @param appID Identifier of the client application. - * @param autoActivateID ID used to re-register previously registered application. - * @param callbackToUIThread If true, all callbacks will occur on the UI thread. - * @param preRegister Flag that indicates that client should be pre-registred or not - * @throws SdlException - */ - @Deprecated - public SdlProxyALM(IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources, - String appName, Vector ttsName, String ngnMediaScreenAppName, Vector vrSynonyms, Boolean isMediaApp, - SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired, - Vector appType, String appID, String autoActivateID, boolean callbackToUIThread, boolean preRegister) throws SdlException { - super( listener, - sdlProxyConfigurationResources, - /*enable advanced lifecycle management*/true, - appName, - ttsName, - ngnMediaScreenAppName, - vrSynonyms, - isMediaApp, - sdlMsgVersion, - languageDesired, - /*HMI Display Language Desired*/hmiDisplayLanguageDesired, - /*App Type*/appType, - /*App ID*/appID, - autoActivateID, - callbackToUIThread, - preRegister, - new BTTransportConfig()); - - SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " + - "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, appType, appID, autoActivateID, " + - "callbackToUIThread and version", SDL_LIB_TRACE_KEY); - } - /** - * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport. - * - * Takes advantage of the advanced lifecycle management. - * - * @param context - Used to create a multiplexing transport config - * @param listener Reference to the object in the App listening to callbacks from SDL. - * @param sdlProxyConfigurationResources Proxy configuration resources. - * @param appName Name of the application displayed on SDL. - * @param ttsName TTS name. - * @param ngnMediaScreenAppName Name of the application displayed on SDL for Navigation equipped - * vehicles. Limited to five characters. - * @param vrSynonyms A vector of strings, all of which can be used as voice commands too - * @param isMediaApp Indicates if the app is a media application. - * @param sdlMsgVersion Indicates the version of SDL SmartDeviceLink Messages desired. Must be less than - * or equal to the version of SDL SmartDeviceLink running on the vehicle. - * @param languageDesired Indicates the language desired for the SDL interface. - * @param hmiDisplayLanguageDesired Desired language in HMI. - * @param appType Type of application. - * @param appID Identifier of the client application. - * @param autoActivateID ID used to re-register previously registered application. - * @param callbackToUIThread If true, all callbacks will occur on the UI thread. - * @param preRegister Flag that indicates that client should be pre-registred or not - * @throws SdlException - */ - public SdlProxyALM(Context context,IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources, - String appName, Vector ttsName, String ngnMediaScreenAppName, Vector vrSynonyms, Boolean isMediaApp, - SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired, - Vector appType, String appID, String autoActivateID, boolean callbackToUIThread, boolean preRegister) throws SdlException { - super( listener, - sdlProxyConfigurationResources, - /*enable advanced lifecycle management*/true, - appName, - ttsName, - ngnMediaScreenAppName, - vrSynonyms, - isMediaApp, - sdlMsgVersion, - languageDesired, - /*HMI Display Language Desired*/hmiDisplayLanguageDesired, - /*App Type*/appType, - /*App ID*/appID, - autoActivateID, - callbackToUIThread, - preRegister, - new MultiplexTransportConfig(context,appID)); - - SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " + - "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, appType, appID, autoActivateID, " + - "callbackToUIThread and version", SDL_LIB_TRACE_KEY); - } - /** - * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport. - * - * Takes advantage of the advanced lifecycle management. - * - * @param listener Reference to the object in the App listening to callbacks from SDL. - * @param sdlProxyConfigurationResources Proxy configuration resources. - * @param appName Name of the application displayed on SDL. - * @param ttsName TTS name. - * @param ngnMediaScreenAppName Name of the application displayed on SDL for Navigation equipped - * vehicles. Limited to five characters. - * @param vrSynonyms A vector of strings, all of which can be used as voice commands too - * @param isMediaApp Indicates if the app is a media application. - * @param sdlMsgVersion Indicates the version of SDL SmartDeviceLink Messages desired. Must be less than - * or equal to the version of SDL SmartDeviceLink running on the vehicle. - * @param languageDesired Indicates the language desired for the SDL interface. - * @param hmiDisplayLanguageDesired Desired language in HMI. - * @param appType Type of application. - * @param appID Identifier of the client application. - * @param autoActivateID ID used to re-register previously registered application. - * @param callbackToUIThread If true, all callbacks will occur on the UI thread. - * @param preRegister Flag that indicates that client should be pre-registred or not - * @param transportConfig Initial configuration for transport. - * @throws SdlException - */ - public SdlProxyALM(IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources, - String appName, Vector ttsName, String ngnMediaScreenAppName, Vector vrSynonyms, Boolean isMediaApp, - SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired, Vector appType, - String appID, String autoActivateID, boolean callbackToUIThread, boolean preRegister, - BaseTransportConfig transportConfig) throws SdlException { - super( listener, - sdlProxyConfigurationResources, - /*enable advanced lifecycle management*/true, - appName, - ttsName, - ngnMediaScreenAppName, - vrSynonyms, - isMediaApp, - sdlMsgVersion, - languageDesired, - /*HMI Display Language Desired*/hmiDisplayLanguageDesired, - /*App Type*/appType, - /*App ID*/appID, - autoActivateID, - callbackToUIThread, - preRegister, - transportConfig); - - SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using new constructor with specified transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " + - "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, appType, appID, autoActivateID, " + - "callbackToUIThread and version", SDL_LIB_TRACE_KEY); - } - public SdlProxyALM(Service appService, IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources, - String appName, Vector ttsName, String ngnMediaScreenAppName, Vector vrSynonyms, Boolean isMediaApp, - SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired, Vector appType, - String appID, String autoActivateID, boolean callbackToUIThread, boolean preRegister, - BaseTransportConfig transportConfig) throws SdlException { - super( listener, - sdlProxyConfigurationResources, - /*enable advanced lifecycle management*/true, - appName, - ttsName, - ngnMediaScreenAppName, - vrSynonyms, - isMediaApp, - sdlMsgVersion, - languageDesired, - /*HMI Display Language Desired*/hmiDisplayLanguageDesired, - /*App Type*/appType, - /*App ID*/appID, - autoActivateID, - callbackToUIThread, - preRegister, - transportConfig); - - this.setAppService(appService); - this.sendTransportBroadcast(); - - SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using new constructor with specified transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " + - "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, appType, appID, autoActivateID, " + - "callbackToUIThread and version", SDL_LIB_TRACE_KEY); - } - /** - * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport. - * - * Takes advantage of the advanced lifecycle management. - * - * @param listener Reference to the object in the App listening to callbacks from SDL. - * @param sdlProxyConfigurationResources Proxy configuration resources. - * @param appName Name of the application displayed on SDL. - * @param ttsName TTS name. - * @param ngnMediaScreenAppName Name of the application displayed on SDL for Navigation equipped - * vehicles. Limited to five characters. - * @param vrSynonyms A vector of strings, all of which can be used as voice commands too - * @param isMediaApp Indicates if the app is a media application. - * @param sdlMsgVersion Indicates the version of SDL SmartDeviceLink Messages desired. Must be less than - * or equal to the version of SDL SmartDeviceLink running on the vehicle. - * @param languageDesired Indicates the language desired for the SDL interface. - * @param hmiDisplayLanguageDesired Desired language in HMI. - * @param appType Type of application. - * @param appID Identifier of the client application. - * @param autoActivateID ID used to re-register previously registered application. - * @param callbackToUIThread If true, all callbacks will occur on the UI thread. - * @param preRegister Flag that indicates that client should be pre-registred or not - * @param sHashID HashID used for app resumption - * @param transportConfig Initial configuration for transport. - * @throws SdlException - */ - public SdlProxyALM(IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources, - String appName, Vector ttsName, String ngnMediaScreenAppName, Vector vrSynonyms, Boolean isMediaApp, - SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired, Vector appType, - String appID, String autoActivateID, boolean callbackToUIThread, boolean preRegister, String sHashID, - BaseTransportConfig transportConfig) throws SdlException { - super( listener, - sdlProxyConfigurationResources, - /*enable advanced lifecycle management*/true, - appName, - ttsName, - ngnMediaScreenAppName, - vrSynonyms, - isMediaApp, - sdlMsgVersion, - languageDesired, - /*HMI Display Language Desired*/hmiDisplayLanguageDesired, - /*App Type*/appType, - /*App ID*/appID, - autoActivateID, - null, - null, - callbackToUIThread, - preRegister, - /*sHashID*/sHashID, - true, - transportConfig); - - SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using new constructor with specified transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " + - "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, appType, appID, autoActivateID, " + - "callbackToUIThread and version", SDL_LIB_TRACE_KEY); - } - public SdlProxyALM(Service appService, IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources, - String appName, Vector ttsName, String ngnMediaScreenAppName, Vector vrSynonyms, Boolean isMediaApp, - SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired, Vector appType, - String appID, String autoActivateID, boolean callbackToUIThread, boolean preRegister, String sHashID, - BaseTransportConfig transportConfig) throws SdlException { - super( listener, - sdlProxyConfigurationResources, - /*enable advanced lifecycle management*/true, - appName, - ttsName, - ngnMediaScreenAppName, - vrSynonyms, - isMediaApp, - sdlMsgVersion, - languageDesired, - /*HMI Display Language Desired*/hmiDisplayLanguageDesired, - /*App Type*/appType, - /*App ID*/appID, - autoActivateID, - null, - null, - callbackToUIThread, - preRegister, - /*sHashID*/sHashID, - /*bEnableResume*/true, - transportConfig); - - this.setAppService(appService); - this.sendTransportBroadcast(); - - SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using new constructor with specified transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " + - "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, appType, appID, autoActivateID, " + - "callbackToUIThread and version", SDL_LIB_TRACE_KEY); - } - public SdlProxyALM(Service appService, IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources, - String appName, Vector ttsName, String ngnMediaScreenAppName, Vector vrSynonyms, Boolean isMediaApp, - SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired, Vector appType, - String appID, String autoActivateID, TemplateColorScheme dayColorScheme, TemplateColorScheme nightColorScheme, boolean callbackToUIThread, boolean preRegister, String sHashID, - BaseTransportConfig transportConfig) throws SdlException { - super( listener, - sdlProxyConfigurationResources, - /*enable advanced lifecycle management*/true, - appName, - ttsName, - ngnMediaScreenAppName, - vrSynonyms, - isMediaApp, - sdlMsgVersion, - languageDesired, - /*HMI Display Language Desired*/hmiDisplayLanguageDesired, - /*App Type*/appType, - /*App ID*/appID, - autoActivateID, - dayColorScheme, - nightColorScheme, - callbackToUIThread, - preRegister, - /*sHashID*/sHashID, - /*bEnableResume*/true, - transportConfig); - - this.setAppService(appService); - this.sendTransportBroadcast(); - - SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using new constructor with specified transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " + - "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, appType, appID, autoActivateID, dayColorScheme, nightColorScheme" + - "callbackToUIThread and version", SDL_LIB_TRACE_KEY); - } - /***************************************** END OF TRANSPORT SWITCHING SUPPORT ***************************************/ - - // Allow applications using ALM to reset the proxy (dispose and reinstantiate) - /** - * Disconnects the application from SDL, then recreates the transport such that - * the next time a SDL unit discovers applications, this application will be - * available. - */ - public void resetProxy() throws SdlException { - super.cycleProxy(SdlDisconnectedReason.APPLICATION_REQUESTED_DISCONNECT); - } - - /********* Getters for values returned by RegisterAppInterfaceResponse **********/ - - /** - * Gets buttonCapabilities set when application interface is registered. - * - * @return buttonCapabilities - * @throws SdlException - * @deprecated use {@link SystemCapabilityManager#getCapability(SystemCapabilityType)} instead - */ - @Deprecated - public List getButtonCapabilities() throws SdlException{ - // Test if proxy has been disposed - if (_proxyDisposed) { - throw new SdlException("This object has been disposed, it is no long capable of executing methods.", SdlExceptionCause.SDL_PROXY_DISPOSED); - } - - // Test SDL availability - if (!_appInterfaceRegisterd || _systemCapabilityManager == null) { - throw new SdlException("SDL is unavailable. Unable to get the buttonCapabilities.", SdlExceptionCause.SDL_UNAVAILABLE); - } - - return convertToList(_systemCapabilityManager.getCapability(SystemCapabilityType.BUTTON), ButtonCapabilities.class); - } - - /** - * Gets getSoftButtonCapabilities set when application interface is registered. - * - * @return softButtonCapabilities - * @throws SdlException - * @deprecated use {@link SystemCapabilityManager#getCapability(SystemCapabilityType)} instead - */ - @Deprecated - public List getSoftButtonCapabilities() throws SdlException { - // Test if proxy has been disposed - if (_proxyDisposed) { - throw new SdlException("This object has been disposed, it is no long capable of executing methods.", SdlExceptionCause.SDL_PROXY_DISPOSED); - } - - // Test SDL availability - if (!_appInterfaceRegisterd || _systemCapabilityManager == null) { - throw new SdlException("SDL is not connected. Unable to get the softButtonCapabilities.", SdlExceptionCause.SDL_UNAVAILABLE); - } - return convertToList(_systemCapabilityManager.getCapability(SystemCapabilityType.SOFTBUTTON),SoftButtonCapabilities.class); - } - - /** - * Gets getPresetBankCapabilities set when application interface is registered. - * - * @return presetBankCapabilities - * @throws SdlException - * @deprecated use {@link SystemCapabilityManager#getCapability(SystemCapabilityType)} instead - */ - @Deprecated - public PresetBankCapabilities getPresetBankCapabilities() throws SdlException { - // Test if proxy has been disposed - if (_proxyDisposed) { - throw new SdlException("This object has been disposed, it is no long capable of executing methods.", SdlExceptionCause.SDL_PROXY_DISPOSED); - } - - // Test SDL availability - if (!_appInterfaceRegisterd) { - throw new SdlException("SDL is not connected. Unable to get the presetBankCapabilities.", SdlExceptionCause.SDL_UNAVAILABLE); - } - return ( PresetBankCapabilities ) _systemCapabilityManager.getCapability(SystemCapabilityType.PRESET_BANK); - } - - /** - * Gets the current version information of the proxy. - * - * @return String - * @throws SdlException - */ - public String getProxyVersionInfo() throws SdlException { - // Test if proxy has been disposed - if (_proxyDisposed) { - throw new SdlException("This object has been disposed, it is no long capable of executing methods.", SdlExceptionCause.SDL_PROXY_DISPOSED); - } - - if (BuildConfig.VERSION_NAME != null) - return BuildConfig.VERSION_NAME; - - return null; - } - - - - /** - * Gets displayCapabilities set when application interface is registered. - * - * @return displayCapabilities - * @throws SdlException - * @deprecated use {@link SystemCapabilityManager#getCapability(SystemCapabilityType)} instead - */ - @Deprecated - public DisplayCapabilities getDisplayCapabilities() throws SdlException { - // Test if proxy has been disposed - if (_proxyDisposed) { - throw new SdlException("This object has been disposed, it is no long capable of executing methods.", SdlExceptionCause.SDL_PROXY_DISPOSED); - } - - // Test SDL availability - if (!_appInterfaceRegisterd || _systemCapabilityManager == null) { - throw new SdlException("SDL is unavailable. Unable to get the displayCapabilities.", SdlExceptionCause.SDL_UNAVAILABLE); - } - return ( DisplayCapabilities ) _systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAY); - } - - /** - * Gets hmiZoneCapabilities set when application interface is registered. - * - * @return hmiZoneCapabilities - * @throws SdlException - * @deprecated use {@link SystemCapabilityManager#getCapability(SystemCapabilityType)} instead - */ - @Deprecated - public List getHmiZoneCapabilities() throws SdlException { - // Test if proxy has been disposed - if (_proxyDisposed) { - throw new SdlException("This object has been disposed, it is no long capable of executing methods.", SdlExceptionCause.SDL_PROXY_DISPOSED); - } - - // Test SDL availability - if (!_appInterfaceRegisterd || _systemCapabilityManager == null) { - throw new SdlException("SDL is unavailable. Unable to get the hmiZoneCapabilities.", SdlExceptionCause.SDL_UNAVAILABLE); - } - return convertToList(_systemCapabilityManager.getCapability(SystemCapabilityType.HMI_ZONE), HmiZoneCapabilities.class); - } - - /** - * Gets speechCapabilities set when application interface is registered. - * - * @return speechCapabilities - * @throws SdlException - * @deprecated use {@link SystemCapabilityManager#getCapability(SystemCapabilityType)} instead - */ - @Deprecated - public List getSpeechCapabilities() throws SdlException { - // Test if proxy has been disposed - if (_proxyDisposed) { - throw new SdlException("This object has been disposed, it is no long capable of executing methods.", SdlExceptionCause.SDL_PROXY_DISPOSED); - } - - // Test SDL availability - if (!_appInterfaceRegisterd || _systemCapabilityManager == null) { - throw new SdlException("SDL is unavailable. Unable to get the speechCapabilities.", SdlExceptionCause.SDL_UNAVAILABLE); - } - - return convertToList(_systemCapabilityManager.getCapability(SystemCapabilityType.SPEECH), SpeechCapabilities.class); - } - /** - * Gets PrerecordedSpeech set when application interface is registered. - * - * @return PrerecordedSpeech - * @throws SdlException - */ - public List getPrerecordedSpeech() throws SdlException { - // Test if proxy has been disposed - if (_proxyDisposed) { - throw new SdlException("This object has been disposed, it is no long capable of executing methods.", SdlExceptionCause.SDL_PROXY_DISPOSED); - } - - // Test SDL availability - if (!_appInterfaceRegisterd) { - throw new SdlException("SDL is unavailable. Unable to get the PrerecordedSpeech.", SdlExceptionCause.SDL_UNAVAILABLE); - } - - return _prerecordedSpeech; - } - /** - * Gets sdlLanguage set when application interface is registered. - * - * @return sdlLanguage - * @throws SdlException - */ - public Language getSdlLanguage() throws SdlException { - // Test if proxy has been disposed - if (_proxyDisposed) { - throw new SdlException("This object has been disposed, it is no long capable of executing methods.", SdlExceptionCause.SDL_PROXY_DISPOSED); - } - - // Test SDL availability - if (!_appInterfaceRegisterd) { - throw new SdlException("SDL is unavailable. Unable to get the sdlLanguage.", SdlExceptionCause.SDL_UNAVAILABLE); - } - return _sdlLanguage; - } - - /** - * Gets getHmiDisplayLanguage set when application interface is registered. - * - * @return hmiDisplayLanguage - * @throws SdlException - */ - public Language getHmiDisplayLanguage() throws SdlException { - // Test if proxy has been disposed - if (_proxyDisposed) { - throw new SdlException("This object has been disposed, it is no long capable of executing methods.", SdlExceptionCause.SDL_PROXY_DISPOSED); - } - - // Test SDL availability - if (!_appInterfaceRegisterd) { - throw new SdlException("SDL is not connected. Unable to get the hmiDisplayLanguage.", SdlExceptionCause.SDL_UNAVAILABLE); - } - return _hmiDisplayLanguage; - } - - /** - * Gets sdlMsgVersion set when application interface is registered. - * - * @return sdlMsgVersion - * @throws SdlException - */ - public SdlMsgVersion getSdlMsgVersion() throws SdlException { - // Test if proxy has been disposed - if (_proxyDisposed) { - throw new SdlException("This object has been disposed, it is no long capable of executing methods.", SdlExceptionCause.SDL_PROXY_DISPOSED); - } - - // Test SDL availability - if (!_appInterfaceRegisterd) { - throw new SdlException("SDL is unavailable. Unable to get the sdlMsgVersion.", SdlExceptionCause.SDL_UNAVAILABLE); - } - return _sdlMsgVersion; - } - - /** - * Gets vrCapabilities set when application interface is registered. - * - * @return vrCapabilities - * @throws SdlException - * @deprecated use {@link SystemCapabilityManager#getCapability(SystemCapabilityType)} instead - */ - @Deprecated - public List getVrCapabilities() throws SdlException { - // Test if proxy has been disposed - if (_proxyDisposed) { - throw new SdlException("This object has been disposed, it is no long capable of executing methods.", SdlExceptionCause.SDL_PROXY_DISPOSED); - } - - // Test SDL availability - if (!_appInterfaceRegisterd || _systemCapabilityManager == null) { - throw new SdlException("SDL is unavailable. Unable to get the vrCapabilities.", SdlExceptionCause.SDL_UNAVAILABLE); - } - return convertToList(_systemCapabilityManager.getCapability(SystemCapabilityType.VOICE_RECOGNITION), VrCapabilities.class); - } - - /** - * Gets getVehicleType set when application interface is registered. - * - * @return vehicleType - * @throws SdlException - */ - public VehicleType getVehicleType() throws SdlException { - // Test if proxy has been disposed - if (_proxyDisposed) { - throw new SdlException("This object has been disposed, it is no long capable of executing methods.", SdlExceptionCause.SDL_PROXY_DISPOSED); - } - - // Test SDL availability - if (!_appInterfaceRegisterd) { - throw new SdlException("SDL is not connected. Unable to get the vehicleType.", SdlExceptionCause.SDL_UNAVAILABLE); - } - return _vehicleType; - } - - /** - * Gets AudioPassThruCapabilities set when application interface is registered. - * - * @return AudioPassThruCapabilities - * @throws SdlException - * @deprecated use {@link SystemCapabilityManager#getCapability(SystemCapabilityType)} instead - */ - @Deprecated - public List getAudioPassThruCapabilities() throws SdlException { - // Test if proxy has been disposed - if (_proxyDisposed) { - throw new SdlException("This object has been disposed, it is no long capable of executing methods.", SdlExceptionCause.SDL_PROXY_DISPOSED); - } - - // Test SDL availability - if (!_appInterfaceRegisterd || _systemCapabilityManager == null) { - throw new SdlException("SDL is not connected. Unable to get the vehicleType.", SdlExceptionCause.SDL_UNAVAILABLE); - } - return convertToList(_systemCapabilityManager.getCapability(SystemCapabilityType.AUDIO_PASSTHROUGH), AudioPassThruCapabilities.class); - } - - public List getSupportedDiagModes() throws SdlException { - // Test if proxy has been disposed - if (_proxyDisposed) { - throw new SdlException("This object has been disposed, it is no long capable of executing methods.", SdlExceptionCause.SDL_PROXY_DISPOSED); - } - - // Test SDL availability - if (!_appInterfaceRegisterd) { - throw new SdlException("SDL is not connected. Unable to get SupportedDiagModes.", SdlExceptionCause.SDL_UNAVAILABLE); - } - return _diagModes; - } - - /** - * Gets HMICapabilities when application interface is registered. - * - * @return HMICapabilities - * @throws SdlException - * @deprecated use {@link SystemCapabilityManager#getCapability(SystemCapabilityType)} instead - */ - @Deprecated - public HMICapabilities getHmiCapabilities() throws SdlException { - // Test if proxy has been disposed - if (_proxyDisposed) { - throw new SdlException("This object has been disposed, it is no long capable of executing methods.", SdlExceptionCause.SDL_PROXY_DISPOSED); - } - - // Test SDL availability - if (!_appInterfaceRegisterd || _systemCapabilityManager == null) { - throw new SdlException("SDL is not connected. Unable to get the HMICapabilities.", SdlExceptionCause.SDL_UNAVAILABLE); - } - return ( HMICapabilities ) _systemCapabilityManager.getCapability(SystemCapabilityType.HMI); - } - - - public String getSystemSoftwareVersion() throws SdlException { - // Test if proxy has been disposed - if (_proxyDisposed) { - throw new SdlException("This object has been disposed, it is no long capable of executing methods.", SdlExceptionCause.SDL_PROXY_DISPOSED); - } - - // Test SDL availability - if (!_appInterfaceRegisterd) { - throw new SdlException("SDL is not connected. Unable to get the SystemSoftwareVersion.", SdlExceptionCause.SDL_UNAVAILABLE); - } - return _systemSoftwareVersion; - } - - public boolean isAppResumeSuccess() throws SdlException { - // Test if proxy has been disposed - if (_proxyDisposed) { - throw new SdlException("This object has been disposed, it is no long capable of executing methods.", SdlExceptionCause.SDL_PROXY_DISPOSED); - } - - // Test SDL availability - if (!_appInterfaceRegisterd) { - throw new SdlException("SDL is not connected. Unable to get isResumeSuccess.", SdlExceptionCause.SDL_UNAVAILABLE); - } - return _bResumeSuccess; - } - -} diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java b/android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java deleted file mode 100644 index 90dba74bd..000000000 --- a/android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java +++ /dev/null @@ -1,8494 +0,0 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ -package com.smartdevicelink.proxy; - -import android.annotation.TargetApi; -import android.app.Service; -import android.content.Context; -import android.content.Intent; -import android.graphics.Bitmap; -import android.os.Build; -import android.os.Handler; -import android.os.Looper; -import android.os.SystemClock; -import android.telephony.TelephonyManager; -import android.util.DisplayMetrics; -import android.util.SparseArray; -import android.view.Display; -import android.view.InputDevice; -import android.view.MotionEvent; -import android.view.Surface; - -import androidx.annotation.NonNull; - -import com.livio.taskmaster.Taskmaster; -import com.smartdevicelink.BuildConfig; -import com.smartdevicelink.Dispatcher.IDispatchingStrategy; -import com.smartdevicelink.Dispatcher.ProxyMessageDispatcher; -import com.smartdevicelink.SdlConnection.ISdlSessionListener; -import com.smartdevicelink.SdlConnection.SdlSession; -import com.smartdevicelink.encoder.VirtualDisplayEncoder; -import com.smartdevicelink.exception.SdlException; -import com.smartdevicelink.exception.SdlExceptionCause; -import com.smartdevicelink.managers.ServiceEncryptionListener; -import com.smartdevicelink.managers.lifecycle.OnSystemCapabilityListener; -import com.smartdevicelink.managers.lifecycle.RpcConverter; -import com.smartdevicelink.managers.lifecycle.SystemCapabilityManager; -import com.smartdevicelink.marshal.JsonRPCMarshaller; -import com.smartdevicelink.protocol.ProtocolMessage; -import com.smartdevicelink.protocol.enums.FunctionID; -import com.smartdevicelink.protocol.enums.MessageType; -import com.smartdevicelink.protocol.enums.SessionType; -import com.smartdevicelink.proxy.LockScreenManager.OnLockScreenIconDownloadedListener; -import com.smartdevicelink.proxy.callbacks.InternalProxyMessage; -import com.smartdevicelink.proxy.callbacks.OnError; -import com.smartdevicelink.proxy.callbacks.OnProxyClosed; -import com.smartdevicelink.proxy.callbacks.OnServiceEnded; -import com.smartdevicelink.proxy.callbacks.OnServiceNACKed; -import com.smartdevicelink.proxy.interfaces.IAudioStreamListener; -import com.smartdevicelink.proxy.interfaces.IProxyListenerBase; -import com.smartdevicelink.proxy.interfaces.IPutFileResponseListener; -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.*; -import com.smartdevicelink.proxy.rpc.enums.AppHMIType; -import com.smartdevicelink.proxy.rpc.enums.AudioStreamingState; -import com.smartdevicelink.proxy.rpc.enums.AudioType; -import com.smartdevicelink.proxy.rpc.enums.BitsPerSample; -import com.smartdevicelink.proxy.rpc.enums.ButtonName; -import com.smartdevicelink.proxy.rpc.enums.DriverDistractionState; -import com.smartdevicelink.proxy.rpc.enums.FileType; -import com.smartdevicelink.proxy.rpc.enums.GlobalProperty; -import com.smartdevicelink.proxy.rpc.enums.HMILevel; -import com.smartdevicelink.proxy.rpc.enums.ImageType; -import com.smartdevicelink.proxy.rpc.enums.InteractionMode; -import com.smartdevicelink.proxy.rpc.enums.Language; -import com.smartdevicelink.proxy.rpc.enums.PrerecordedSpeech; -import com.smartdevicelink.proxy.rpc.enums.RequestType; -import com.smartdevicelink.proxy.rpc.enums.Result; -import com.smartdevicelink.proxy.rpc.enums.SamplingRate; -import com.smartdevicelink.proxy.rpc.enums.SdlDisconnectedReason; -import com.smartdevicelink.proxy.rpc.enums.SdlInterfaceAvailability; -import com.smartdevicelink.proxy.rpc.enums.SystemCapabilityType; -import com.smartdevicelink.proxy.rpc.enums.TextAlignment; -import com.smartdevicelink.proxy.rpc.enums.TouchType; -import com.smartdevicelink.proxy.rpc.enums.UpdateMode; -import com.smartdevicelink.proxy.rpc.listeners.OnMultipleRequestListener; -import com.smartdevicelink.proxy.rpc.listeners.OnRPCListener; -import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener; -import com.smartdevicelink.proxy.rpc.listeners.OnRPCRequestListener; -import com.smartdevicelink.proxy.rpc.listeners.OnRPCResponseListener; -import com.smartdevicelink.security.SdlSecurityBase; -import com.smartdevicelink.streaming.StreamRPCPacketizer; -import com.smartdevicelink.streaming.audio.AudioStreamingCodec; -import com.smartdevicelink.streaming.audio.AudioStreamingParams; -import com.smartdevicelink.streaming.video.SdlRemoteDisplay; -import com.smartdevicelink.streaming.video.VideoStreamingParameters; -import com.smartdevicelink.trace.SdlTrace; -import com.smartdevicelink.trace.TraceDeviceInfo; -import com.smartdevicelink.trace.enums.InterfaceActivityDirection; -import com.smartdevicelink.transport.BaseTransportConfig; -import com.smartdevicelink.transport.MultiplexTransportConfig; -import com.smartdevicelink.transport.SiphonServer; -import com.smartdevicelink.transport.TCPTransportConfig; -import com.smartdevicelink.transport.USBTransportConfig; -import com.smartdevicelink.transport.enums.TransportType; -import com.smartdevicelink.util.CorrelationIdGenerator; -import com.smartdevicelink.util.DebugTool; -import com.smartdevicelink.util.FileUtls; -import com.smartdevicelink.util.Version; - -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; - -import java.io.BufferedReader; -import java.io.DataOutputStream; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.UnsupportedEncodingException; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.ProtocolException; -import java.net.URL; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.Hashtable; -import java.util.List; -import java.util.Set; -import java.util.Vector; -import java.util.concurrent.Callable; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.concurrent.Executors; -import java.util.concurrent.FutureTask; -import java.util.concurrent.ScheduledExecutorService; - -//import com.smartdevicelink.managers.video.HapticInterfaceManager; - - -/** - * @deprecated use {@link com.smartdevicelink.managers.SdlManager} instead. - * - * The guide created for the initial transition of SdlProxyBase to SdlManager can be found at - * Migrating to SDL Manager - */ -@SuppressWarnings({"WeakerAccess", "Convert2Diamond"}) -@Deprecated -public abstract class SdlProxyBase { - // Used for calls to Android Log class. - public static final String TAG = "SdlProxy"; - private static final String SDL_LIB_TRACE_KEY = "42baba60-eb57-11df-98cf-0800200c9a66"; - private static final int PROX_PROT_VER_ONE = 1; - private static final int RESPONSE_WAIT_TIME = 2000; - - public static final com.smartdevicelink.util.Version MAX_SUPPORTED_RPC_VERSION = new com.smartdevicelink.util.Version("6.0.0"); - - private SdlSession sdlSession = null; - private proxyListenerType _proxyListener = null; - - protected Service _appService = null; - private Context _appContext; - private String sPoliciesURL = ""; //for testing only - - // Protected Correlation IDs - private final int REGISTER_APP_INTERFACE_CORRELATION_ID = 65529, - UNREGISTER_APP_INTERFACE_CORRELATION_ID = 65530, - POLICIES_CORRELATION_ID = 65535; - - // Sdl Synchronization Objects - private static final Object CONNECTION_REFERENCE_LOCK = new Object(), - INCOMING_MESSAGE_QUEUE_THREAD_LOCK = new Object(), - OUTGOING_MESSAGE_QUEUE_THREAD_LOCK = new Object(), - INTERNAL_MESSAGE_QUEUE_THREAD_LOCK = new Object(), - ON_UPDATE_LISTENER_LOCK = new Object(), - RPC_LISTENER_LOCK = new Object(), - ON_NOTIFICATION_LISTENER_LOCK = new Object(); - - private final Object APP_INTERFACE_REGISTERED_LOCK = new Object(); - - private int iFileCount = 0; - - private boolean navServiceStartResponseReceived = false; - private boolean navServiceStartResponse = false; - private List navServiceStartRejectedParams = null; - private boolean pcmServiceStartResponseReceived = false; - private boolean pcmServiceStartResponse = false; - @SuppressWarnings("FieldCanBeLocal") - private List pcmServiceStartRejectedParams = null; - private boolean navServiceEndResponseReceived = false; - private boolean navServiceEndResponse = false; - private boolean pcmServiceEndResponseReceived = false; - private boolean pcmServiceEndResponse = false; - private boolean rpcProtectedResponseReceived = false; - private boolean rpcProtectedStartResponse = false; - - // Device Info for logging - private TraceDeviceInfo _traceDeviceInterrogator = null; - - // Declare Queuing Threads - private ProxyMessageDispatcher _incomingProxyMessageDispatcher; - private ProxyMessageDispatcher _outgoingProxyMessageDispatcher; - private ProxyMessageDispatcher _internalProxyMessageDispatcher; - - // Flag indicating if callbacks should be called from UIThread - private Boolean _callbackToUIThread = false; - // UI Handler - private Handler _mainUIHandler = null; - final int HEARTBEAT_CORRELATION_ID = 65531; - - // SdlProxy Advanced Lifecycle Management - protected Boolean _advancedLifecycleManagementEnabled = false; - // Parameters passed to the constructor from the app to register an app interface - private String _applicationName = null; - private final long instanceDateTime = System.currentTimeMillis(); - private String sConnectionDetails = "N/A"; - private Vector _ttsName = null; - private String _ngnMediaScreenAppName = null; - private Boolean _isMediaApp = null; - private Language _sdlLanguageDesired = null; - private Language _hmiDisplayLanguageDesired = null; - private Vector _appType = null; - private String _appID = null; - private TemplateColorScheme _dayColorScheme = null; - private TemplateColorScheme _nightColorScheme = null; - @SuppressWarnings({"FieldCanBeLocal", "unused"}) //Need to understand what this is used for - private String _autoActivateIdDesired = null; - private String _lastHashID = null; - private SdlMsgVersion _sdlMsgVersionRequest = null; - private Vector _vrSynonyms = null; - private boolean _bAppResumeEnabled = false; - private OnSystemRequest lockScreenIconRequest = null; - private TelephonyManager telephonyManager = null; - private DeviceInfo deviceInfo = null; - private ISdlServiceListener navServiceListener; - - /** - * Contains current configuration for the transport that was selected during - * construction of this object - */ - private BaseTransportConfig _transportConfig = null; - // Proxy State Variables - protected Boolean _appInterfaceRegisterd = false; - protected Boolean _preRegisterd = false; - @SuppressWarnings({"unused", "FieldCanBeLocal"}) - private Boolean _haveReceivedFirstNonNoneHMILevel = false; - protected Boolean _haveReceivedFirstFocusLevel = false; - protected Boolean _haveReceivedFirstFocusLevelFull = false; - protected Boolean _proxyDisposed = false; - //protected SdlConnectionState _sdlConnectionState = null; - protected SdlInterfaceAvailability _sdlIntefaceAvailablity = null; - protected HMILevel _hmiLevel = null; - protected OnHMIStatus lastHmiStatus; - protected AudioStreamingState _audioStreamingState = null; - // Variables set by RegisterAppInterfaceResponse - protected SdlMsgVersion _sdlMsgVersion = null; - protected String _autoActivateIdReturned = null; - protected Language _sdlLanguage = null; - protected Language _hmiDisplayLanguage = null; - protected List _prerecordedSpeech = null; - protected VehicleType _vehicleType = null; - protected String _systemSoftwareVersion = null; - protected List _diagModes = null; - protected Boolean firstTimeFull = true; - protected String _proxyVersionInfo = null; - protected Boolean _bResumeSuccess = false; - protected List> _secList = null; - protected SystemCapabilityManager _systemCapabilityManager; - protected Boolean _iconResumed = false; - protected RegisterAppInterfaceResponse raiResponse = null; - - private final CopyOnWriteArrayList _putFileListenerList = new CopyOnWriteArrayList(); - - protected com.smartdevicelink.util.Version protocolVersion = new com.smartdevicelink.util.Version(1,0,0); - protected com.smartdevicelink.util.Version rpcSpecVersion; - - protected SparseArray rpcResponseListeners = null; - protected SparseArray> rpcNotificationListeners = null; - protected SparseArray> rpcRequestListeners = null; - protected SparseArray> rpcListeners = null; - - protected VideoStreamingManager manager; //Will move to SdlSession once the class becomes public - - protected String authToken; - - private Version minimumProtocolVersion; - private Version minimumRPCVersion; - - private Set encryptionRequiredRPCs = new HashSet<>(); - private boolean rpcSecuredServiceStarted; - private ServiceEncryptionListener serviceEncryptionListener; - private Taskmaster taskmaster; - - // Interface broker - private SdlInterfaceBroker _interfaceBroker = null; - //We create an easily passable anonymous class of the interface so that we don't expose the internal interface to developers - private ISdl _internalInterface = new ISdl() { - @Override - public void start() { - try{ - initializeProxy(); - }catch (SdlException e){ - e.printStackTrace(); - } - } - - @Override - public void stop() { - try{ - dispose(); - }catch (SdlException e){ - e.printStackTrace(); - } - } - - @Override - public boolean isConnected() { - return getIsConnected(); - } - - @Override - public void addServiceListener(SessionType serviceType, ISdlServiceListener sdlServiceListener) { - SdlProxyBase.this.addServiceListener(serviceType,sdlServiceListener); - } - - @Override - public void removeServiceListener(SessionType serviceType, ISdlServiceListener sdlServiceListener) { - SdlProxyBase.this.removeServiceListener(serviceType,sdlServiceListener); - } - - @Override - public void startVideoService(VideoStreamingParameters parameters, boolean encrypted) { - if(isConnected()){ - sdlSession.setDesiredVideoParams(parameters); - sdlSession.startService(SessionType.NAV,encrypted); - addNavListener(); - } - } - - @Override - public void stopVideoService() { - if(isConnected()){ - sdlSession.endService(SessionType.NAV); - } - } - - @Override public void stopAudioService() { - if(isConnected()){ - sdlSession.endService(SessionType.PCM); - } - } - - @Override - public void sendRPCRequest(RPCRequest message){ - try { - SdlProxyBase.this.sendRPCRequest(message); - } catch (SdlException e) { - e.printStackTrace(); - } - } - - @Override - public void sendRPC(RPCMessage message) { - try { - SdlProxyBase.this.sendRPC(message); - } catch (SdlException e) { - e.printStackTrace(); - } - } - - @Override - public void sendRequests(List rpcs, OnMultipleRequestListener listener) { - try { - SdlProxyBase.this.sendRequests(rpcs, listener); - } catch (SdlException e) { - e.printStackTrace(); - } - } - - @Override - public void sendRPCs(List rpcs, OnMultipleRequestListener listener) { - try { - SdlProxyBase.this.sendRequests(rpcs, listener); - } catch (SdlException e) { - e.printStackTrace(); - } - } - - @Override - public void sendSequentialRPCs(List rpcs, OnMultipleRequestListener listener) { - try{ - SdlProxyBase.this.sendSequentialRequests(rpcs,listener); - }catch (SdlException e ){ - DebugTool.logError(TAG, "Issue sending sequential RPCs ", e); - } - } - - @Override - public void addOnRPCNotificationListener(FunctionID notificationId, OnRPCNotificationListener listener) { - SdlProxyBase.this.addOnRPCNotificationListener(notificationId,listener); - } - - @Override - public boolean removeOnRPCNotificationListener(FunctionID notificationId, OnRPCNotificationListener listener) { - return SdlProxyBase.this.removeOnRPCNotificationListener(notificationId,listener); - } - - @Override - public void addOnRPCRequestListener(FunctionID functionID, OnRPCRequestListener listener) { - SdlProxyBase.this.addOnRPCRequestListener(functionID,listener); - } - - @Override - public boolean removeOnRPCRequestListener(FunctionID functionID, OnRPCRequestListener listener) { - return SdlProxyBase.this.removeOnRPCRequestListener(functionID,listener); - } - - @Override - public void addOnRPCListener(FunctionID responseId, OnRPCListener listener) { - SdlProxyBase.this.addOnRPCListener(responseId, listener); - } - - @Override - public boolean removeOnRPCListener(FunctionID responseId, OnRPCListener listener) { - return SdlProxyBase.this.removeOnRPCListener(responseId, listener); - } - - @Override - public Object getCapability(SystemCapabilityType systemCapabilityType){ - return SdlProxyBase.this.getCapability(systemCapabilityType); - } - - @Override - public RegisterAppInterfaceResponse getRegisterAppInterfaceResponse() { - return SdlProxyBase.this.getRegisterAppInterfaceResponse(); - } - - @Override - public void getCapability(SystemCapabilityType systemCapabilityType, OnSystemCapabilityListener scListener) { - SdlProxyBase.this.getCapability(systemCapabilityType, scListener); - } - - @Override - public Object getCapability(SystemCapabilityType systemCapabilityType, OnSystemCapabilityListener scListener, boolean forceUpdate) { - if (_systemCapabilityManager != null) { - return _systemCapabilityManager.getCapability(systemCapabilityType, scListener, forceUpdate); - } - return null; - } - - @Override - public SdlMsgVersion getSdlMsgVersion(){ - try { - return SdlProxyBase.this.getSdlMsgVersion(); - } catch (SdlException e) { - e.printStackTrace(); - } - return null; - } - - @Override - public com.smartdevicelink.util.Version getProtocolVersion() { - return SdlProxyBase.this.protocolVersion; - } - - @Override - public boolean isCapabilitySupported(SystemCapabilityType systemCapabilityType){ - return SdlProxyBase.this.isCapabilitySupported(systemCapabilityType); - } - - @Override - public void addOnSystemCapabilityListener(SystemCapabilityType systemCapabilityType, OnSystemCapabilityListener listener) { - SdlProxyBase.this.removeOnSystemCapabilityListener(systemCapabilityType, listener); - } - - @Override - public boolean removeOnSystemCapabilityListener(SystemCapabilityType systemCapabilityType, OnSystemCapabilityListener listener) { - return SdlProxyBase.this.removeOnSystemCapabilityListener(systemCapabilityType, listener); - } - - @Override - public boolean isTransportForServiceAvailable(SessionType serviceType) { - return SdlProxyBase.this.sdlSession != null - && SdlProxyBase.this.sdlSession.isTransportForServiceAvailable(serviceType); - } - - @Override - public void startAudioService(boolean isEncrypted, AudioStreamingCodec codec, - AudioStreamingParams params) { - if(getIsConnected()){ - SdlProxyBase.this.startAudioStream(isEncrypted, codec, params); - } - } - - @Override - public void startAudioService(boolean encrypted) { - if(isConnected()){ - sdlSession.startService(SessionType.PCM,encrypted); - } - } - - @Override - public IVideoStreamListener startVideoStream(boolean isEncrypted, VideoStreamingParameters parameters){ - return SdlProxyBase.this.startVideoStream(isEncrypted, parameters); - } - - @Override - public IAudioStreamListener startAudioStream(boolean isEncrypted, AudioStreamingCodec codec, - AudioStreamingParams params) { - return SdlProxyBase.this.startAudioStream(isEncrypted, codec, params); - } - - @Override - public void startRPCEncryption() { - SdlProxyBase.this.startProtectedRPCService(); - } - - @Override - public Taskmaster getTaskmaster() { - return SdlProxyBase.this.getTaskmaster(); - } - }; - - Taskmaster getTaskmaster() { - if (taskmaster == null) { - Taskmaster.Builder builder = new Taskmaster.Builder(); - builder.setThreadCount(2); - builder.shouldBeDaemon(false); - taskmaster = builder.build(); - taskmaster.start(); - } - return taskmaster; - } - - private void notifyPutFileStreamError(Exception e, String info) - { - for (IPutFileResponseListener _putFileListener : _putFileListenerList) { - _putFileListener.onPutFileStreamError(e, info); - } - } - - private void notifyPutFileStreamResponse(PutFileResponse msg) - { - for (IPutFileResponseListener _putFileListener : _putFileListenerList) { - _putFileListener.onPutFileResponse(msg); - } - } - - public void addPutFileResponseListener(IPutFileResponseListener _putFileListener) - { - _putFileListenerList.addIfAbsent(_putFileListener); - } - - public void remPutFileResponseListener(IPutFileResponseListener _putFileListener) - { - _putFileListenerList.remove(_putFileListener); - } - - // Private Class to Interface with SdlConnection - private class SdlInterfaceBroker implements ISdlSessionListener { - - @Override - public void onTransportDisconnected(String info, boolean altTransportAvailable, BaseTransportConfig transportConfig) { - - notifyPutFileStreamError(null, info); - - if (altTransportAvailable){ - SdlProxyBase.this._transportConfig = transportConfig; - DebugTool.logInfo(TAG, "notifying RPC session ended, but potential primary transport available"); - cycleProxy(SdlDisconnectedReason.PRIMARY_TRANSPORT_CYCLE_REQUEST); - }else{ - notifyProxyClosed(info, new SdlException("Transport disconnected.", SdlExceptionCause.SDL_UNAVAILABLE), SdlDisconnectedReason.TRANSPORT_DISCONNECT); - } - } - - - @Override - public void onRPCMessageReceived(RPCMessage rpcMessage) { - - } - - @Override - public void onSessionStarted(int sessionID, Version version) { - - } - - @Override - public void onSessionEnded(int sessionID) { - - } - - @Override - public void onAuthTokenReceived(String authToken, int sessionID) { - - } - - - public void onProtocolServiceDataACK(SessionType sessionType, final int dataSize, - byte sessionID) { - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onServiceDataACK(dataSize); - } - }); - } else { - _proxyListener.onServiceDataACK(dataSize); - } - } - - } - - protected SdlProxyBase(){} - - /** - * Used by the SdlManager - * - * @param listener Type of listener for this proxy base. - * @param context Application context. - * @param appName Client application name. - * @param shortAppName Client short application name. - * @param isMediaApp Flag that indicates that client application if media application or not. - * @param languageDesired Desired language. - * @param hmiDisplayLanguageDesired Desired language for HMI. - * @param appType Type of application. - * @param appID Application identifier. - * @param dayColorScheme TemplateColorScheme for the day - * @param nightColorScheme TemplateColorScheme for the night - * @param transportConfig Configuration of transport to be used by underlying connection. - * @param vrSynonyms List of synonyms. - * @param ttsName TTS name. - * @throws SdlException - */ - public SdlProxyBase(proxyListenerType listener, Context context, String appName,String shortAppName, Boolean isMediaApp, Language languageDesired, Language hmiDisplayLanguageDesired, Vector appType, String appID, - BaseTransportConfig transportConfig, Vector vrSynonyms, Vector ttsName, TemplateColorScheme dayColorScheme, TemplateColorScheme nightColorScheme) throws SdlException { - performBaseCommon(listener, null, true, appName, ttsName, shortAppName, vrSynonyms, isMediaApp, - null, languageDesired, hmiDisplayLanguageDesired, appType, appID, null, dayColorScheme,nightColorScheme, false, false, null, null, transportConfig); - _appContext = context; - } - - /** - * Constructor. - * - * @param listener Type of listener for this proxy base. - * @param sdlProxyConfigurationResources Configuration resources for this proxy. - * @param enableAdvancedLifecycleManagement Flag that ALM should be enabled or not. - * @param appName Client application name. - * @param ttsName TTS name. - * @param ngnMediaScreenAppName Media Screen Application name. - * @param vrSynonyms List of synonyms. - * @param isMediaApp Flag that indicates that client application if media application or not. - * @param sdlMsgVersion Version of Sdl Message. - * @param languageDesired Desired language. - * @param hmiDisplayLanguageDesired Desired language for HMI. - * @param appType Type of application. - * @param appID Application identifier. - * @param autoActivateID Auto activation identifier. - * @param callbackToUIThread Flag that indicates that this proxy should send callback to UI thread or not. - * @param transportConfig Configuration of transport to be used by underlying connection. - * @throws SdlException if there is an unrecoverable error class might throw an exception. - */ - protected SdlProxyBase(proxyListenerType listener, SdlProxyConfigurationResources sdlProxyConfigurationResources, - boolean enableAdvancedLifecycleManagement, String appName, Vector ttsName, - String ngnMediaScreenAppName, Vector vrSynonyms, Boolean isMediaApp, SdlMsgVersion sdlMsgVersion, - Language languageDesired, Language hmiDisplayLanguageDesired, Vector appType, String appID, - String autoActivateID, boolean callbackToUIThread, BaseTransportConfig transportConfig) - throws SdlException { - - performBaseCommon(listener, sdlProxyConfigurationResources, enableAdvancedLifecycleManagement, appName, ttsName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, - sdlMsgVersion, languageDesired, hmiDisplayLanguageDesired, appType, appID, autoActivateID, null, null, callbackToUIThread, null, null, null, transportConfig); - } - - @SuppressWarnings("ConstantConditions") - private void performBaseCommon(proxyListenerType listener, SdlProxyConfigurationResources sdlProxyConfigurationResources, - boolean enableAdvancedLifecycleManagement, String appName, Vector ttsName, - String ngnMediaScreenAppName, Vector vrSynonyms, Boolean isMediaApp, SdlMsgVersion sdlMsgVersion, - Language languageDesired, Language hmiDisplayLanguageDesired, Vector appType, String appID, - String autoActivateID, TemplateColorScheme dayColorScheme, TemplateColorScheme nightColorScheme, - boolean callbackToUIThread, Boolean preRegister, String sHashID, Boolean bAppResumeEnab, - BaseTransportConfig transportConfig) throws SdlException - { - DebugTool.logInfo(TAG, "SDL_LIB_VERSION: " + BuildConfig.VERSION_NAME); - setProtocolVersion(new Version(PROX_PROT_VER_ONE,0,0)); - - if (preRegister != null && preRegister) - { - _appInterfaceRegisterd = preRegister; - _preRegisterd = preRegister; - } - - if (bAppResumeEnab != null && bAppResumeEnab) - { - _bAppResumeEnabled = true; - _lastHashID = sHashID; - } - _interfaceBroker = new SdlInterfaceBroker(); - - _callbackToUIThread = callbackToUIThread; - - if (_callbackToUIThread) { - _mainUIHandler = new Handler(Looper.getMainLooper()); - } - - // Set variables for Advanced Lifecycle Management - _advancedLifecycleManagementEnabled = enableAdvancedLifecycleManagement; - _applicationName = appName; - _ttsName = ttsName; - _ngnMediaScreenAppName = ngnMediaScreenAppName; - _isMediaApp = isMediaApp; - _sdlMsgVersionRequest = sdlMsgVersion; - _vrSynonyms = vrSynonyms; - _sdlLanguageDesired = languageDesired; - _hmiDisplayLanguageDesired = hmiDisplayLanguageDesired; - _appType = appType; - _appID = appID; - _autoActivateIdDesired = autoActivateID; - _dayColorScheme = dayColorScheme; - _nightColorScheme = nightColorScheme; - _transportConfig = transportConfig; - - // Test conditions to invalidate the proxy - if (listener == null) { - throw new IllegalArgumentException("IProxyListener listener must be provided to instantiate SdlProxy object."); - } - if (_advancedLifecycleManagementEnabled) { - /* if (_applicationName == null ) { - throw new IllegalArgumentException("To use SdlProxyALM, an application name, appName, must be provided"); - } - if (_applicationName.length() < 1 || _applicationName.length() > 100) { - throw new IllegalArgumentException("A provided application name, appName, must be between 1 and 100 characters in length."); - }*/ - if (_isMediaApp == null) { - throw new IllegalArgumentException("isMediaApp must not be null when using SdlProxyALM."); - } - } - - _proxyListener = listener; - - // Get information from sdlProxyConfigurationResources - if (sdlProxyConfigurationResources != null) { - telephonyManager = sdlProxyConfigurationResources.getTelephonyManager(); - } - - // Use the telephonyManager to get and log phone info - if (telephonyManager != null) { - // Following is not quite thread-safe (because m_traceLogger could test null twice), - // so we need to fix this, but vulnerability (i.e. two instances of listener) is - // likely harmless. - if (_traceDeviceInterrogator == null) { - _traceDeviceInterrogator = new TraceDeviceInfo(telephonyManager); - } // end-if - - } // end-if - - // Setup Internal ProxyMessage Dispatcher - synchronized(INTERNAL_MESSAGE_QUEUE_THREAD_LOCK) { - // Ensure internalProxyMessageDispatcher is null - if (_internalProxyMessageDispatcher != null) { - _internalProxyMessageDispatcher.dispose(); - _internalProxyMessageDispatcher = null; - } - - _internalProxyMessageDispatcher = new ProxyMessageDispatcher("INTERNAL_MESSAGE_DISPATCHER", new IDispatchingStrategy() { - - @Override - public void dispatch(InternalProxyMessage message) { - dispatchInternalMessage(message); - } - - @Override - public void handleDispatchingError(String info, Exception ex) { - handleErrorsFromInternalMessageDispatcher(info, ex); - } - - @Override - public void handleQueueingError(String info, Exception ex) { - handleErrorsFromInternalMessageDispatcher(info, ex); - } - }); - } - - // Setup Incoming ProxyMessage Dispatcher - synchronized(INCOMING_MESSAGE_QUEUE_THREAD_LOCK) { - // Ensure incomingProxyMessageDispatcher is null - if (_incomingProxyMessageDispatcher != null) { - _incomingProxyMessageDispatcher.dispose(); - _incomingProxyMessageDispatcher = null; - } - - _incomingProxyMessageDispatcher = new ProxyMessageDispatcher("INCOMING_MESSAGE_DISPATCHER",new IDispatchingStrategy() { - @Override - public void dispatch(ProtocolMessage message) { - dispatchIncomingMessage(message); - } - - @Override - public void handleDispatchingError(String info, Exception ex) { - handleErrorsFromIncomingMessageDispatcher(info, ex); - } - - @Override - public void handleQueueingError(String info, Exception ex) { - handleErrorsFromIncomingMessageDispatcher(info, ex); - } - }); - } - - // Setup Outgoing ProxyMessage Dispatcher - synchronized(OUTGOING_MESSAGE_QUEUE_THREAD_LOCK) { - // Ensure outgoingProxyMessageDispatcher is null - if (_outgoingProxyMessageDispatcher != null) { - _outgoingProxyMessageDispatcher.dispose(); - _outgoingProxyMessageDispatcher = null; - } - - _outgoingProxyMessageDispatcher = new ProxyMessageDispatcher("OUTGOING_MESSAGE_DISPATCHER",new IDispatchingStrategy() { - @Override - public void dispatch(ProtocolMessage message) { - dispatchOutgoingMessage(message); - } - - @Override - public void handleDispatchingError(String info, Exception ex) { - handleErrorsFromOutgoingMessageDispatcher(info, ex); - } - - @Override - public void handleQueueingError(String info, Exception ex) { - handleErrorsFromOutgoingMessageDispatcher(info, ex); - } - }); - } - - rpcResponseListeners = new SparseArray(); - rpcNotificationListeners = new SparseArray>(); - rpcRequestListeners = new SparseArray>(); - rpcListeners = new SparseArray>(); - - // Initialize the proxy - try { - initializeProxy(); - } catch (SdlException e) { - // Couldn't initialize the proxy - // Dispose threads and then rethrow exception - - if (_internalProxyMessageDispatcher != null) { - _internalProxyMessageDispatcher.dispose(); - _internalProxyMessageDispatcher = null; - } - if (_incomingProxyMessageDispatcher != null) { - _incomingProxyMessageDispatcher.dispose(); - _incomingProxyMessageDispatcher = null; - } - if (_outgoingProxyMessageDispatcher != null) { - _outgoingProxyMessageDispatcher.dispose(); - _outgoingProxyMessageDispatcher = null; - } - throw e; - } - - addOnRPCNotificationListener(FunctionID.ON_PERMISSIONS_CHANGE, onPermissionsChangeListener); - this._internalInterface.addServiceListener(SessionType.RPC, securedServiceListener); - this._internalInterface.addServiceListener(SessionType.NAV, securedServiceListener); - this._internalInterface.addServiceListener(SessionType.PCM, securedServiceListener); - - - // Trace that ctor has fired - SdlTrace.logProxyEvent("SdlProxy Created, instanceID=" + this.toString(), SDL_LIB_TRACE_KEY); - } - - protected SdlProxyBase(proxyListenerType listener, SdlProxyConfigurationResources sdlProxyConfigurationResources, - boolean enableAdvancedLifecycleManagement, String appName, Vector ttsName, - String ngnMediaScreenAppName, Vector vrSynonyms, Boolean isMediaApp, SdlMsgVersion sdlMsgVersion, - Language languageDesired, Language hmiDisplayLanguageDesired, Vector appType, String appID, - String autoActivateID, TemplateColorScheme dayColorScheme, TemplateColorScheme nightColorScheme, - boolean callbackToUIThread, boolean preRegister, String sHashID, Boolean bEnableResume, BaseTransportConfig transportConfig) - throws SdlException - { - performBaseCommon(listener, sdlProxyConfigurationResources, enableAdvancedLifecycleManagement, appName, ttsName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, - sdlMsgVersion, languageDesired, hmiDisplayLanguageDesired, appType, appID, autoActivateID, dayColorScheme, nightColorScheme, callbackToUIThread, preRegister, sHashID, bEnableResume, transportConfig); - } - - /** - * Constructor. - * - * @param listener Type of listener for this proxy base. - * @param sdlProxyConfigurationResources Configuration resources for this proxy. - * @param enableAdvancedLifecycleManagement Flag that ALM should be enabled or not. - * @param appName Client application name. - * @param ttsName TTS name. - * @param ngnMediaScreenAppName Media Screen Application name. - * @param vrSynonyms List of synonyms. - * @param isMediaApp Flag that indicates that client application if media application or not. - * @param sdlMsgVersion Version of Sdl Message. - * @param languageDesired Desired language. - * @param hmiDisplayLanguageDesired Desired language for HMI. - * @param appType Type of application. - * @param appID Application identifier. - * @param autoActivateID Auto activation identifier. - * @param callbackToUIThread Flag that indicates that this proxy should send callback to UI thread or not. - * @param preRegister Flag that indicates that this proxy should be pre-registerd or not. - * @param transportConfig Configuration of transport to be used by underlying connection. - * @throws SdlException if there is an unrecoverable error class might throw an exception. - */ - protected SdlProxyBase(proxyListenerType listener, SdlProxyConfigurationResources sdlProxyConfigurationResources, - boolean enableAdvancedLifecycleManagement, String appName, Vector ttsName, - String ngnMediaScreenAppName, Vector vrSynonyms, Boolean isMediaApp, SdlMsgVersion sdlMsgVersion, - Language languageDesired, Language hmiDisplayLanguageDesired, Vector appType, String appID, - String autoActivateID, boolean callbackToUIThread, boolean preRegister, BaseTransportConfig transportConfig) - throws SdlException - { - performBaseCommon(listener, sdlProxyConfigurationResources, enableAdvancedLifecycleManagement, appName, ttsName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, - sdlMsgVersion, languageDesired, hmiDisplayLanguageDesired, appType, appID, autoActivateID, null, null, callbackToUIThread, preRegister, null, null, transportConfig); - } - - /** - * Constructor. - * - * @param listener Type of listener for this proxy base. - * @param sdlProxyConfigurationResources Configuration resources for this proxy. - * @param enableAdvancedLifecycleManagement Flag that ALM should be enabled or not. - * @param appName Client application name. - * @param ttsName TTS name. - * @param ngnMediaScreenAppName Media Screen Application name. - * @param vrSynonyms List of synonyms. - * @param isMediaApp Flag that indicates that client application if media application or not. - * @param sdlMsgVersion Version of Sdl Message. - * @param languageDesired Desired language. - * @param hmiDisplayLanguageDesired Desired language for HMI. - * @param appType Type of application. - * @param appID Application identifier. - * @param autoActivateID Auto activation identifier. - * @param dayColorScheme Day color scheme. - * @param dayColorScheme Night color scheme. - * @param callbackToUIThread Flag that indicates that this proxy should send callback to UI thread or not. - * @param preRegister Flag that indicates that this proxy should be pre-registerd or not. - * @param transportConfig Configuration of transport to be used by underlying connection. - * @throws SdlException if there is an unrecoverable error class might throw an exception. - */ - protected SdlProxyBase(proxyListenerType listener, SdlProxyConfigurationResources sdlProxyConfigurationResources, - boolean enableAdvancedLifecycleManagement, String appName, Vector ttsName, - String ngnMediaScreenAppName, Vector vrSynonyms, Boolean isMediaApp, SdlMsgVersion sdlMsgVersion, - Language languageDesired, Language hmiDisplayLanguageDesired, Vector appType, String appID, - String autoActivateID, TemplateColorScheme dayColorScheme, TemplateColorScheme nightColorScheme, - boolean callbackToUIThread, boolean preRegister, BaseTransportConfig transportConfig) - throws SdlException - { - performBaseCommon(listener, sdlProxyConfigurationResources, enableAdvancedLifecycleManagement, appName, ttsName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, - sdlMsgVersion, languageDesired, hmiDisplayLanguageDesired, appType, appID, autoActivateID, dayColorScheme, nightColorScheme, callbackToUIThread, preRegister, null, null, transportConfig); - } - - private Intent createBroadcastIntent() - { - Intent sendIntent = new Intent(); - sendIntent.setAction("com.smartdevicelink.broadcast"); - sendIntent.putExtra("APP_NAME", this._applicationName); - sendIntent.putExtra("APP_ID", this._appID); - sendIntent.putExtra("RPC_NAME", ""); - sendIntent.putExtra("TYPE", ""); - sendIntent.putExtra("SUCCESS", true); - sendIntent.putExtra("CORRID", 0); - sendIntent.putExtra("FUNCTION_NAME", ""); - sendIntent.putExtra("COMMENT1", ""); - sendIntent.putExtra("COMMENT2", ""); - sendIntent.putExtra("COMMENT3", ""); - sendIntent.putExtra("COMMENT4", ""); - sendIntent.putExtra("COMMENT5", ""); - sendIntent.putExtra("COMMENT6", ""); - sendIntent.putExtra("COMMENT7", ""); - sendIntent.putExtra("COMMENT8", ""); - sendIntent.putExtra("COMMENT9", ""); - sendIntent.putExtra("COMMENT10", ""); - sendIntent.putExtra("DATA", ""); - sendIntent.putExtra("SHOW_ON_UI", true); - return sendIntent; - } - private void updateBroadcastIntent(Intent sendIntent, String sKey, String sValue) - { - if (sValue == null) sValue = ""; - sendIntent.putExtra(sKey, sValue); - } - private void updateBroadcastIntent(Intent sendIntent, String sKey, boolean bValue) - { - sendIntent.putExtra(sKey, bValue); - } - private void updateBroadcastIntent(Intent sendIntent, String sKey, int iValue) - { - sendIntent.putExtra(sKey, iValue); - } - - private Service getService() - { - try { - Service myService = null; - if (_proxyListener != null && _proxyListener instanceof Service) { - myService = (Service) _proxyListener; - } else if (_appService != null) { - myService = _appService; - } else if (_appContext != null && _appContext instanceof Service) { - myService = (Service) _appContext; - } - return myService; - } catch (Exception ex){ - return null; - } - } - - private void sendBroadcastIntent(Intent sendIntent) - { - Service myService = null; - if (_proxyListener != null && _proxyListener instanceof Service) - { - myService = (Service) _proxyListener; - } - else if (_appService != null) - { - myService = _appService; - } - Context myContext; - if (myService != null){ - myContext = myService.getApplicationContext(); - } else if (_appContext != null){ - myContext = _appContext; - } - else - { - return; - } - try - { - if (myContext != null) myContext.sendBroadcast(sendIntent); - } - catch(Exception ex) - { - //If the service or context has become unavailable unexpectedly, catch the exception and move on -- no broadcast log will occur. - } - } - - private HttpURLConnection getURLConnection(Headers myHeader, String sURLString, int Timeout, int iContentLen) - { - String sContentType = "application/json"; - int CONNECTION_TIMEOUT = Timeout * 1000; - int READ_TIMEOUT = Timeout * 1000; - boolean bDoOutput = true; - boolean bDoInput = true; - boolean bUsesCaches = false; - String sRequestMeth = "POST"; - - boolean bInstFolRed = false; - String sCharSet = "utf-8"; - int iContentLength = iContentLen; - - URL url; - HttpURLConnection urlConnection; - - Intent sendIntent = createBroadcastIntent(); - updateBroadcastIntent(sendIntent, "FUNCTION_NAME", "getURLConnection"); - updateBroadcastIntent(sendIntent, "COMMENT1", "Actual Content Length: " + iContentLen); - - if (myHeader != null) - { - //if the header isn't null, use it and replace the hardcoded params - int iTimeout; - int iReadTimeout; - sContentType = myHeader.getContentType(); - iTimeout = myHeader.getConnectTimeout(); - bDoOutput = myHeader.getDoOutput(); - bDoInput = myHeader.getDoInput(); - bUsesCaches = myHeader.getUseCaches(); - sRequestMeth = myHeader.getRequestMethod(); - iReadTimeout = myHeader.getReadTimeout(); - bInstFolRed = myHeader.getInstanceFollowRedirects(); - sCharSet = myHeader.getCharset(); - iContentLength = myHeader.getContentLength(); - CONNECTION_TIMEOUT = iTimeout*1000; - READ_TIMEOUT = iReadTimeout*1000; - updateBroadcastIntent(sendIntent, "COMMENT2", "\nHeader Defined Content Length: " + iContentLength); - } - - try - { - url = new URL(sURLString); - urlConnection = (HttpURLConnection) url.openConnection(); - urlConnection.setConnectTimeout(CONNECTION_TIMEOUT); - urlConnection.setDoOutput(bDoOutput); - urlConnection.setDoInput(bDoInput); - urlConnection.setRequestMethod(sRequestMeth); - urlConnection.setReadTimeout(READ_TIMEOUT); - urlConnection.setInstanceFollowRedirects(bInstFolRed); - urlConnection.setRequestProperty("Content-Type", sContentType); - urlConnection.setRequestProperty("charset", sCharSet); - urlConnection.setRequestProperty("Content-Length", "" + Integer.toString(iContentLength)); - urlConnection.setUseCaches(bUsesCaches); - return urlConnection; - } - catch (Exception e) - { - return null; - } - finally - { - sendBroadcastIntent(sendIntent); - } - } - - - private void sendOnSystemRequestToUrl(OnSystemRequest msg) - { - Intent sendIntent = createBroadcastIntent(); - Intent sendIntent2 = createBroadcastIntent(); - - HttpURLConnection urlConnection = null; - boolean bLegacy = false; - - String sURLString; - if (!getPoliciesURL().equals("")) { - sURLString = sPoliciesURL; - } else { - sURLString = msg.getUrl(); - } - sURLString = sURLString.replaceFirst("http://", "https://"); - - Integer iTimeout = msg.getTimeout(); - - if (iTimeout == null) - iTimeout = 2000; - - Headers myHeader = msg.getHeader(); - - RequestType requestType = msg.getRequestType(); - updateBroadcastIntent(sendIntent, "FUNCTION_NAME", "sendOnSystemRequestToUrl"); - updateBroadcastIntent(sendIntent, "COMMENT5", "\r\nCloud URL: " + sURLString); - - try - { - if (myHeader == null) { - updateBroadcastIntent(sendIntent, "COMMENT7", "\r\nHTTPRequest Header is null"); - } - - String sBodyString = msg.getBody(); - - JSONObject jsonObjectToSendToServer; - String valid_json = ""; - int length; - if (sBodyString == null) - { - if(requestType == RequestType.HTTP ){ - length = msg.getBulkData().length; - Intent sendIntent3 = createBroadcastIntent(); - updateBroadcastIntent(sendIntent3, "FUNCTION_NAME", "replace"); - updateBroadcastIntent(sendIntent3, "COMMENT1", "Valid Json length before replace: " + length); - sendBroadcastIntent(sendIntent3); - - }else{ - List legacyData = msg.getLegacyData(); - JSONArray jsonArrayOfSdlPPackets = new JSONArray(legacyData); - jsonObjectToSendToServer = new JSONObject(); - jsonObjectToSendToServer.put("data", jsonArrayOfSdlPPackets); - bLegacy = true; - updateBroadcastIntent(sendIntent, "COMMENT6", "\r\nLegacy SystemRequest: true"); - valid_json = jsonObjectToSendToServer.toString().replace("\\", ""); - length = valid_json.getBytes("UTF-8").length; - } - } - else - { - Intent sendIntent3 = createBroadcastIntent(); - updateBroadcastIntent(sendIntent3, "FUNCTION_NAME", "replace"); - updateBroadcastIntent(sendIntent3, "COMMENT1", "Valid Json length before replace: " + sBodyString.getBytes("UTF-8").length); - sendBroadcastIntent(sendIntent3); - valid_json = sBodyString.replace("\\", ""); - length = valid_json.getBytes("UTF-8").length; - } - - urlConnection = getURLConnection(myHeader, sURLString, iTimeout, length); - - if (urlConnection == null) - { - DebugTool.logInfo(TAG, "urlConnection is null, check RPC input parameters"); - updateBroadcastIntent(sendIntent, "COMMENT2", "urlConnection is null, check RPC input parameters"); - return; - } - - DataOutputStream wr = new DataOutputStream(urlConnection.getOutputStream()); - if(requestType == RequestType.HTTP){ - wr.write(msg.getBulkData()); - }else{ - wr.writeBytes(valid_json); - } - - wr.flush(); - wr.close(); - - - long BeforeTime = System.currentTimeMillis(); - long AfterTime = System.currentTimeMillis(); - final long roundtriptime = AfterTime - BeforeTime; - - updateBroadcastIntent(sendIntent, "COMMENT4", " Round trip time: " + roundtriptime); - updateBroadcastIntent(sendIntent, "COMMENT1", "Received response from cloud, response code=" + urlConnection.getResponseCode() + " "); - - int iResponseCode = urlConnection.getResponseCode(); - - if (iResponseCode != HttpURLConnection.HTTP_OK) - { - DebugTool.logInfo(TAG, "Response code not HTTP_OK, returning from sendOnSystemRequestToUrl."); - updateBroadcastIntent(sendIntent, "COMMENT2", "Response code not HTTP_OK, aborting request. "); - return; - } - - InputStream is = urlConnection.getInputStream(); - BufferedReader rd = new BufferedReader(new InputStreamReader(is)); - String line; - StringBuilder response = new StringBuilder(); - while((line = rd.readLine()) != null) - { - response.append(line); - response.append('\r'); - } - rd.close(); - //We've read the body - if(requestType == RequestType.HTTP){ - // Create the SystemRequest RPC to send to module. - PutFile putFile = new PutFile(); - putFile.setFileType(FileType.JSON); - putFile.setCorrelationID(POLICIES_CORRELATION_ID); - putFile.setSdlFileName("response_data"); - putFile.setFileData(response.toString().getBytes("UTF-8")); - putFile.setCRC(response.toString().getBytes()); - updateBroadcastIntent(sendIntent, "DATA", "Data from cloud response: " + response.toString()); - - sendRPCMessagePrivate(putFile); - DebugTool.logInfo(TAG, "sendSystemRequestToUrl sent to sdl"); - - updateBroadcastIntent(sendIntent2, "RPC_NAME", FunctionID.PUT_FILE.toString()); - updateBroadcastIntent(sendIntent2, "TYPE", RPCMessage.KEY_REQUEST); - updateBroadcastIntent(sendIntent2, "CORRID", putFile.getCorrelationID()); - - }else{ - Vector cloudDataReceived = new Vector(); - final String dataKey = "data"; - // Convert the response to JSON - JSONObject jsonResponse = new JSONObject(response.toString()); - if(jsonResponse.has(dataKey)){ - if (jsonResponse.get(dataKey) instanceof JSONArray) - { - JSONArray jsonArray = jsonResponse.getJSONArray(dataKey); - for (int i=0; i 512) - { - sResponse = sResponse.substring(0, 511); - } - - updateBroadcastIntent(sendIntent, "DATA", "Data from cloud response: " + sResponse); - - // Send new SystemRequest to SDL - SystemRequest mySystemRequest = null; - - if (bLegacy){ - if(cloudDataReceived != null) { - mySystemRequest = new SystemRequest(true); - mySystemRequest.setCorrelationID(getPoliciesReservedCorrelationID()); - mySystemRequest.setLegacyData(cloudDataReceived); - } - }else{ - if (response != null) { - mySystemRequest = new SystemRequest(); - mySystemRequest.setRequestType(RequestType.PROPRIETARY); - mySystemRequest.setCorrelationID(getPoliciesReservedCorrelationID()); - mySystemRequest.setBulkData(response.toString().getBytes()); - } - } - - if (getIsConnected()) - { - sendRPCMessagePrivate(mySystemRequest); - DebugTool.logInfo(TAG, "sendSystemRequestToUrl sent to sdl"); - - updateBroadcastIntent(sendIntent2, "RPC_NAME", FunctionID.SYSTEM_REQUEST.toString()); - updateBroadcastIntent(sendIntent2, "TYPE", RPCMessage.KEY_REQUEST); - updateBroadcastIntent(sendIntent2, "CORRID", mySystemRequest.getCorrelationID()); - } - } - } - catch (SdlException e) - { - DebugTool.logError(TAG, "sendSystemRequestToUrl: Could not get data from JSONObject received.", e); - updateBroadcastIntent(sendIntent, "COMMENT3", " SdlException encountered sendOnSystemRequestToUrl: "+ e); - //Log.i("pt", "sendSystemRequestToUrl: Could not get data from JSONObject received."+ e); - } - catch (JSONException e) - { - DebugTool.logError(TAG, "sendSystemRequestToUrl: JSONException: ", e); - updateBroadcastIntent(sendIntent, "COMMENT3", " JSONException encountered sendOnSystemRequestToUrl: "+ e); - //Log.i("pt", "sendSystemRequestToUrl: JSONException: "+ e); - } - catch (UnsupportedEncodingException e) - { - DebugTool.logError(TAG, "sendSystemRequestToUrl: Could not encode string.", e); - updateBroadcastIntent(sendIntent, "COMMENT3", " UnsupportedEncodingException encountered sendOnSystemRequestToUrl: "+ e); - //Log.i("pt", "sendSystemRequestToUrl: Could not encode string."+ e); - } - catch (ProtocolException e) - { - DebugTool.logError(TAG, "sendSystemRequestToUrl: Could not set request method to post.", e); - updateBroadcastIntent(sendIntent, "COMMENT3", " ProtocolException encountered sendOnSystemRequestToUrl: "+ e); - //Log.i("pt", "sendSystemRequestToUrl: Could not set request method to post."+ e); - } - catch (MalformedURLException e) - { - DebugTool.logError(TAG, "sendSystemRequestToUrl: URL Exception when sending SystemRequest to an external server.", e); - updateBroadcastIntent(sendIntent, "COMMENT3", " MalformedURLException encountered sendOnSystemRequestToUrl: "+ e); - //Log.i("pt", "sendSystemRequestToUrl: URL Exception when sending SystemRequest to an external server."+ e); - } - catch (IOException e) - { - DebugTool.logError(TAG, "sendSystemRequestToUrl: IOException: ", e); - updateBroadcastIntent(sendIntent, "COMMENT3", " IOException while sending to cloud: IOException: "+ e); - //Log.i("pt", "sendSystemRequestToUrl: IOException: "+ e); - } - catch (Exception e) - { - DebugTool.logError(TAG, "sendSystemRequestToUrl: Unexpected Exception: ", e); - updateBroadcastIntent(sendIntent, "COMMENT3", " Exception encountered sendOnSystemRequestToUrl: "+ e); - //Log.i("pt", "sendSystemRequestToUrl: Unexpected Exception: " + e); - } - finally - { - sendBroadcastIntent(sendIntent); - sendBroadcastIntent(sendIntent2); - - if (iFileCount < 10) - iFileCount++; - else - iFileCount = 0; - - if(urlConnection != null) - { - urlConnection.disconnect(); - } - } - } - - private int getPoliciesReservedCorrelationID() { - return POLICIES_CORRELATION_ID; - } - - // Test correlationID - private boolean isCorrelationIDProtected(Integer correlationID) { - return correlationID != null && - (HEARTBEAT_CORRELATION_ID == correlationID - || REGISTER_APP_INTERFACE_CORRELATION_ID == correlationID - || UNREGISTER_APP_INTERFACE_CORRELATION_ID == correlationID - || POLICIES_CORRELATION_ID == correlationID); - - } - - // Protected isConnected method to allow legacy proxy to poll isConnected state - public Boolean getIsConnected() { - return sdlSession != null && sdlSession.getIsConnected(); - } - - - /** - * Returns whether the application is registered in SDL. Note: for testing - * purposes, it's possible that the connection is established, but the - * application is not registered. - * - * @return true if the application is registered in SDL - */ - public Boolean getAppInterfaceRegistered() { - return _appInterfaceRegisterd; - } - - // Function to initialize new proxy connection - public void initializeProxy() throws SdlException { - // Reset all of the flags and state variables - _haveReceivedFirstNonNoneHMILevel = false; - _haveReceivedFirstFocusLevel = false; - _haveReceivedFirstFocusLevelFull = false; - _appInterfaceRegisterd = _preRegisterd; - - _putFileListenerList.clear(); - - _sdlIntefaceAvailablity = SdlInterfaceAvailability.SDL_INTERFACE_UNAVAILABLE; - - //Initialize _systemCapabilityManager here. - //_systemCapabilityManager = new SystemCapabilityManager(_internalInterface); - // Setup SdlConnection - synchronized(CONNECTION_REFERENCE_LOCK) { - - //Handle legacy USB connections - if (_transportConfig != null - && TransportType.USB.equals(_transportConfig.getTransportType())) { - //A USB transport config was provided - USBTransportConfig usbTransportConfig = (USBTransportConfig) _transportConfig; - if (usbTransportConfig.getUsbAccessory() == null) { - DebugTool.logInfo(TAG, "Legacy USB transport config was used, but received null for accessory. Attempting to connect with router service"); - //The accessory was null which means it came from a router service - MultiplexTransportConfig multiplexTransportConfig = new MultiplexTransportConfig(usbTransportConfig.getUSBContext(), _appID); - multiplexTransportConfig.setRequiresHighBandwidth(true); - multiplexTransportConfig.setSecurityLevel(MultiplexTransportConfig.FLAG_MULTI_SECURITY_OFF); - multiplexTransportConfig.setPrimaryTransports(Collections.singletonList(TransportType.USB)); - multiplexTransportConfig.setSecondaryTransports(new ArrayList()); - _transportConfig = multiplexTransportConfig; - } - } - - if (_transportConfig != null && _transportConfig.getTransportType().equals(TransportType.MULTIPLEX)) { - this.sdlSession = new SdlSession(_interfaceBroker, (MultiplexTransportConfig) _transportConfig); - }else if(_transportConfig != null &&_transportConfig.getTransportType().equals(TransportType.TCP)){ - this.sdlSession = new SdlSession(_interfaceBroker, (TCPTransportConfig) _transportConfig); - }else { - throw new SdlException(new UnsupportedOperationException("Unable to create session with supplied transport config")); - } - } - - synchronized(CONNECTION_REFERENCE_LOCK) { - this.sdlSession.startSession(); - sendTransportBroadcast(); - } - } - /** - * This method will fake the multiplex connection event - */ - @SuppressWarnings("unused") - public void forceOnConnected(){ - synchronized(CONNECTION_REFERENCE_LOCK) { - if (sdlSession != null) { - DebugTool.logInfo(TAG, "Forcing on connected.... might actually need this"); //FIXME - /*if(sdlSession.getSdlConnection()==null){ //There is an issue when switching from v1 to v2+ where the connection is closed. So we restart the session during this call. - try { - sdlSession.startSession(); - } catch (SdlException e) { - e.printStackTrace(); - } - } - sdlSession.getSdlConnection().forceHardwareConnectEvent(TransportType.BLUETOOTH); - */ - } - } - } - - public void sendTransportBroadcast() - { - if (sdlSession == null || _transportConfig == null) return; - - String sTransComment = "no";//sdlSession.getBroadcastComment(_transportConfig); - - if (sTransComment == null || sTransComment.equals("")) return; - - Intent sendIntent = createBroadcastIntent(); - updateBroadcastIntent(sendIntent, "FUNCTION_NAME", "initializeProxy"); - updateBroadcastIntent(sendIntent, "COMMENT1", sTransComment); - sendBroadcastIntent(sendIntent); - } - - - /** - * Public method to enable the siphon transport - */ - @SuppressWarnings("unused") - public void enableSiphonDebug() { - - short enabledPortNumber = SiphonServer.enableSiphonServer(); - String sSiphonPortNumber = "Enabled Siphon Port Number: " + enabledPortNumber; - Intent sendIntent = createBroadcastIntent(); - updateBroadcastIntent(sendIntent, "FUNCTION_NAME", "enableSiphonDebug"); - updateBroadcastIntent(sendIntent, "COMMENT1", sSiphonPortNumber); - sendBroadcastIntent(sendIntent); - } - - - - /** - * Public method to disable the Siphon Trace Server - */ - @SuppressWarnings("unused") - public void disableSiphonDebug() { - - short disabledPortNumber = SiphonServer.disableSiphonServer(); - if (disabledPortNumber != -1) { - String sSiphonPortNumber = "Disabled Siphon Port Number: " + disabledPortNumber; - Intent sendIntent = createBroadcastIntent(); - updateBroadcastIntent(sendIntent, "FUNCTION_NAME", "disableSiphonDebug"); - updateBroadcastIntent(sendIntent, "COMMENT1", sSiphonPortNumber); - sendBroadcastIntent(sendIntent); - } - } - - - - /** - * Public method to enable the Debug Tool - */ - public static void enableDebugTool() { - DebugTool.enableDebugTool(); - } - - /** - * Public method to disable the Debug Tool - */ - public static void disableDebugTool() { - DebugTool.disableDebugTool(); - } - - /** - * Public method to determine Debug Tool enabled - */ - @SuppressWarnings("BooleanMethodIsAlwaysInverted") - public static boolean isDebugEnabled() { - return DebugTool.isDebugEnabled(); - } - - - /** - * Check to see if it a transport is available to perform audio streaming. - *
NOTE: This is only for the audio streaming service, not regular - * streaming of media playback. - * @return true if there is either an audio streaming supported - * transport currently connected or a transport is - * available to connect with. false if there is no - * transport connected to support audio streaming and - * no possibility in the foreseeable future. - */ - public boolean isAudioStreamTransportAvailable(){ - return sdlSession!= null && sdlSession.isTransportForServiceAvailable(SessionType.PCM); - } - - /** - * Check to see if it a transport is available to perform video streaming. - - * @return true if there is either an video streaming supported - * transport currently connected or a transport is - * available to connect with. false if there is no - * transport connected to support video streaming and - * no possibility in the foreseeable future. - */ - public boolean isVideoStreamTransportAvailable(){ - return sdlSession!= null && sdlSession.isTransportForServiceAvailable(SessionType.NAV); - } - - - @SuppressWarnings("unused") - @Deprecated - public void close() throws SdlException { - dispose(); - } - - @SuppressWarnings("UnusedParameters") - private void cleanProxy(SdlDisconnectedReason disconnectedReason) throws SdlException { - try { - - // ALM Specific Cleanup - if (_advancedLifecycleManagementEnabled) { - //_sdlConnectionState = SdlConnectionState.SDL_DISCONNECTED; - - firstTimeFull = true; - - // Should we wait for the interface to be unregistered? - Boolean waitForInterfaceUnregistered = false; - // Unregister app interface - synchronized(CONNECTION_REFERENCE_LOCK) { - if (getIsConnected() && getAppInterfaceRegistered()) { - waitForInterfaceUnregistered = true; - unregisterAppInterfacePrivate(UNREGISTER_APP_INTERFACE_CORRELATION_ID); - } - } - - // Wait for the app interface to be unregistered - if (waitForInterfaceUnregistered) { - synchronized(APP_INTERFACE_REGISTERED_LOCK) { - try { - APP_INTERFACE_REGISTERED_LOCK.wait(3000); - } catch (InterruptedException e) { - // Do nothing - } - } - } - } - - if(rpcResponseListeners != null){ - rpcResponseListeners.clear(); - } - if(rpcNotificationListeners != null){ - rpcNotificationListeners.clear(); - } - - // Clean up SDL Connection - synchronized(CONNECTION_REFERENCE_LOCK) { - if (sdlSession != null) { - sdlSession.close(); - } - } - } finally { - SdlTrace.logProxyEvent("SdlProxy cleaned.", SDL_LIB_TRACE_KEY); - } - } - - /** - * Check to see if the proxy has already been disposed - * @return if the proxy has been disposed - */ - public synchronized boolean isDisposed(){ - return _proxyDisposed; - } - - /** - * Terminates the App's Interface Registration, closes the transport connection, ends the protocol session, and frees any resources used by the proxy. - */ - public void dispose() throws SdlException { - SdlTrace.logProxyEvent("Application called dispose() method.", SDL_LIB_TRACE_KEY); - disposeInternal(SdlDisconnectedReason.APPLICATION_REQUESTED_DISCONNECT); - if (taskmaster != null) { - taskmaster.shutdown(); - } - } - /** - * Terminates the App's Interface Registration, closes the transport connection, ends the protocol session, and frees any resources used by the proxy. - * @param sdlDisconnectedReason the reason the proxy should be disposed. - */ - private synchronized void disposeInternal(SdlDisconnectedReason sdlDisconnectedReason) throws SdlException - { - if (_proxyDisposed) { - throw new SdlException("This object has been disposed, it is no long capable of executing methods.", SdlExceptionCause.SDL_PROXY_DISPOSED); - } - - _proxyDisposed = true; - rpcSecuredServiceStarted = false; - encryptionRequiredRPCs.clear(); - serviceEncryptionListener = null; - - try{ - // Clean the proxy - cleanProxy(sdlDisconnectedReason); - - if (sdlDisconnectedReason == SdlDisconnectedReason.MINIMUM_PROTOCOL_VERSION_HIGHER_THAN_SUPPORTED - || sdlDisconnectedReason == SdlDisconnectedReason.MINIMUM_RPC_VERSION_HIGHER_THAN_SUPPORTED){ - //We want to notify listeners for this case before disposing the dispatchers - notifyProxyClosed(sdlDisconnectedReason.toString(), null, sdlDisconnectedReason); - } - - // Close IncomingProxyMessageDispatcher thread - synchronized(INCOMING_MESSAGE_QUEUE_THREAD_LOCK) { - if (_incomingProxyMessageDispatcher != null) { - _incomingProxyMessageDispatcher.dispose(); - _incomingProxyMessageDispatcher = null; - } - } - - // Close OutgoingProxyMessageDispatcher thread - synchronized(OUTGOING_MESSAGE_QUEUE_THREAD_LOCK) { - if (_outgoingProxyMessageDispatcher != null) { - _outgoingProxyMessageDispatcher.dispose(); - _outgoingProxyMessageDispatcher = null; - } - } - - // Close InternalProxyMessageDispatcher thread - synchronized(INTERNAL_MESSAGE_QUEUE_THREAD_LOCK) { - if (_internalProxyMessageDispatcher != null) { - _internalProxyMessageDispatcher.dispose(); - _internalProxyMessageDispatcher = null; - } - } - - _traceDeviceInterrogator = null; - - rpcResponseListeners = null; - - } finally { - SdlTrace.logProxyEvent("SdlProxy disposed.", SDL_LIB_TRACE_KEY); - } - } // end-method - - - private final static Object CYCLE_LOCK = new Object(); - - private boolean _cycling = false; - - // Method to cycle the proxy, only called in ALM - protected void cycleProxy(SdlDisconnectedReason disconnectedReason) { - if (_cycling) return; - - synchronized(CYCLE_LOCK) - { - try{ - _cycling = true; - cleanProxy(disconnectedReason); - - initializeProxy(); - if(!SdlDisconnectedReason.LEGACY_BLUETOOTH_MODE_ENABLED.equals(disconnectedReason) - && !SdlDisconnectedReason.PRIMARY_TRANSPORT_CYCLE_REQUEST.equals(disconnectedReason)){//We don't want to alert higher if we are just cycling for legacy bluetooth - notifyProxyClosed("Sdl Proxy Cycled", new SdlException("Sdl Proxy Cycled", SdlExceptionCause.SDL_PROXY_CYCLED), disconnectedReason); - } - } - catch (SdlException e) { - Intent sendIntent = createBroadcastIntent(); - updateBroadcastIntent(sendIntent, "FUNCTION_NAME", "cycleProxy"); - updateBroadcastIntent(sendIntent, "COMMENT1", "Proxy cycled, exception cause: " + e.getSdlExceptionCause()); - sendBroadcastIntent(sendIntent); - - switch(e.getSdlExceptionCause()) { - case BLUETOOTH_DISABLED: - notifyProxyClosed("Bluetooth is disabled. Bluetooth must be enabled to connect to SDL. Reattempt a connection once Bluetooth is enabled.", - new SdlException("Bluetooth is disabled. Bluetooth must be enabled to connect to SDL. Reattempt a connection once Bluetooth is enabled.", SdlExceptionCause.BLUETOOTH_DISABLED), SdlDisconnectedReason.BLUETOOTH_DISABLED); - break; - case BLUETOOTH_ADAPTER_NULL: - notifyProxyClosed("Cannot locate a Bluetooth adapater. A SDL connection is impossible on this device until a Bluetooth adapter is added.", - new SdlException("Cannot locate a Bluetooth adapater. A SDL connection is impossible on this device until a Bluetooth adapter is added.", SdlExceptionCause.BLUETOOTH_ADAPTER_NULL), SdlDisconnectedReason.BLUETOOTH_ADAPTER_ERROR); - break; - default : - notifyProxyClosed("Cycling the proxy failed.", e, SdlDisconnectedReason.GENERIC_ERROR); - break; - } - } catch (Exception e) { - notifyProxyClosed("Cycling the proxy failed.", e, SdlDisconnectedReason.GENERIC_ERROR); - } - _cycling = false; - } - } - - - - /************* Functions used by the Message Dispatching Queues ****************/ - private void dispatchIncomingMessage(ProtocolMessage message) { - try{ - // Dispatching logic - if (message.getSessionType().equals(SessionType.RPC) - ||message.getSessionType().equals(SessionType.BULK_DATA) ) { - try { - if (protocolVersion!= null && protocolVersion.getMajor() == 1 && message.getVersion() > 1) { - if(sdlSession != null - && sdlSession.getProtocolVersion()!= null - && sdlSession.getProtocolVersion().getMajor() > 1){ - setProtocolVersion(sdlSession.getProtocolVersion()); - }else{ - setProtocolVersion(new Version(message.getVersion(),0,0)); - } - } - - Hashtable hash = new Hashtable(); - if (protocolVersion!= null && protocolVersion.getMajor() > 1) { - Hashtable hashTemp = new Hashtable(); - hashTemp.put(RPCMessage.KEY_CORRELATION_ID, message.getCorrID()); - if (message.getJsonSize() > 0) { - final Hashtable mhash = JsonRPCMarshaller.unmarshall(message.getData()); - //hashTemp.put(Names.parameters, mhash.get(Names.parameters)); - if (mhash != null) { - hashTemp.put(RPCMessage.KEY_PARAMETERS, mhash); - } - } - - String functionName = FunctionID.getFunctionName(message.getFunctionID()); - if (functionName != null) { - hashTemp.put(RPCMessage.KEY_FUNCTION_NAME, functionName); - } else { - DebugTool.logWarning(TAG, "Dispatch Incoming Message - function name is null unknown RPC. FunctionId: " + message.getFunctionID()); - return; - } - if (message.getRPCType() == 0x00) { - hash.put(RPCMessage.KEY_REQUEST, hashTemp); - } else if (message.getRPCType() == 0x01) { - hash.put(RPCMessage.KEY_RESPONSE, hashTemp); - } else if (message.getRPCType() == 0x02) { - hash.put(RPCMessage.KEY_NOTIFICATION, hashTemp); - } - if (message.getBulkData() != null) hash.put(RPCStruct.KEY_BULK_DATA, message.getBulkData()); - if (message.getPayloadProtected()) hash.put(RPCStruct.KEY_PROTECTED, true); - } else { - hash = JsonRPCMarshaller.unmarshall(message.getData()); - } - handleRPCMessage(hash); - } catch (final Exception excp) { - DebugTool.logError(TAG, "Failure handling protocol message: " + excp.toString(), excp); - passErrorToProxyListener("Error handing incoming protocol message.", excp); - } // end-catch - } //else { Handle other protocol message types here} - } catch (final Exception e) { - // Pass error to application through listener - DebugTool.logError(TAG, "Error handing proxy event.", e); - passErrorToProxyListener("Error handing incoming protocol message.", e); - } - } - - /** - * Get the SDL protocol spec version being used - * @return Version of the protocol spec - */ - public @NonNull Version getProtocolVersion(){ - if(this.protocolVersion == null){ - this.protocolVersion = new Version(1,0,0); - } - return this.protocolVersion; - } - - private void setProtocolVersion(@NonNull Version version) { - this.protocolVersion = version; - } - - public String serializeJSON(RPCMessage msg) - { - try - { - return msg.serializeJSON((byte)this.getProtocolVersion().getMajor()).toString(2); - } - catch (final Exception e) - { - DebugTool.logError(TAG, "Error handing proxy event.", e); - passErrorToProxyListener("Error serializing message.", e); - return null; - } - } - - private void handleErrorsFromIncomingMessageDispatcher(String info, Exception e) { - passErrorToProxyListener(info, e); - } - - private void dispatchOutgoingMessage(ProtocolMessage message) { - synchronized(CONNECTION_REFERENCE_LOCK) { - if (sdlSession != null) { - sdlSession.sendMessage(message); - } - } - SdlTrace.logProxyEvent("SdlProxy sending Protocol Message: " + message.toString(), SDL_LIB_TRACE_KEY); - } - - private void handleErrorsFromOutgoingMessageDispatcher(String info, Exception e) { - passErrorToProxyListener(info, e); - } - - void dispatchInternalMessage(final InternalProxyMessage message) { - try{ - switch (message.getFunctionName()) { - case InternalProxyMessage.OnProxyError: { - final OnError msg = (OnError) message; - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onError(msg.getInfo(), msg.getException()); - } - }); - } else { - _proxyListener.onError(msg.getInfo(), msg.getException()); - } - break; - } - case InternalProxyMessage.OnServiceEnded: { - final OnServiceEnded msg = (OnServiceEnded) message; - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onServiceEnded(msg); - } - }); - } else { - _proxyListener.onServiceEnded(msg); - } - break; - } - case InternalProxyMessage.OnServiceNACKed: { - final OnServiceNACKed msg = (OnServiceNACKed) message; - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onServiceNACKed(msg); - } - }); - } else { - _proxyListener.onServiceNACKed(msg); - } - - /* *************Start Legacy Specific Call-backs************/ - break; - } - case InternalProxyMessage.OnProxyOpened: - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - ((IProxyListener) _proxyListener).onProxyOpened(); - } - }); - } else { - ((IProxyListener) _proxyListener).onProxyOpened(); - } - break; - case InternalProxyMessage.OnProxyClosed: { - final OnProxyClosed msg = (OnProxyClosed) message; - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onProxyClosed(msg.getInfo(), msg.getException(), msg.getReason()); - } - }); - } else { - _proxyListener.onProxyClosed(msg.getInfo(), msg.getException(), msg.getReason()); - } - /* ***************End Legacy Specific Call-backs************/ - break; - } - default: - // Diagnostics - SdlTrace.logProxyEvent("Unknown RPC Message encountered. Check for an updated version of the SDL Proxy.", SDL_LIB_TRACE_KEY); - DebugTool.logError(TAG, "Unknown RPC Message encountered. Check for an updated version of the SDL Proxy."); - break; - } - - SdlTrace.logProxyEvent("Proxy fired callback: " + message.getFunctionName(), SDL_LIB_TRACE_KEY); - } catch(final Exception e) { - // Pass error to application through listener - DebugTool.logError(TAG, "Error handing proxy event.", e); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onError("Error handing proxy event.", e); - } - }); - } else { - _proxyListener.onError("Error handing proxy event.", e); - } - } - } - - private void handleErrorsFromInternalMessageDispatcher(String info, Exception e) { - DebugTool.logError(TAG, info, e); - // This error cannot be passed to the user, as it indicates an error - // in the communication between the proxy and the application. - - DebugTool.logError(TAG, "InternalMessageDispatcher failed.", e); - - // Note, this is the only place where the _proxyListener should be referenced asdlhronously, - // with an error on the internalMessageDispatcher, we have no other reliable way of - // communicating with the application. - notifyProxyClosed("Proxy callback dispatcher is down. Proxy instance is invalid.", e, SdlDisconnectedReason.GENERIC_ERROR); - _proxyListener.onError("Proxy callback dispatcher is down. Proxy instance is invalid.", e); - } - /************* END Functions used by the Message Dispatching Queues ****************/ - - - private OnRPCNotificationListener onPermissionsChangeListener = new OnRPCNotificationListener() { - @Override - public void onNotified(RPCNotification notification) { - List permissionItems = ((OnPermissionsChange) notification).getPermissionItem(); - Boolean requireEncryptionAppLevel = ((OnPermissionsChange) notification).getRequireEncryption(); - encryptionRequiredRPCs.clear(); - if (requireEncryptionAppLevel == null || requireEncryptionAppLevel) { - if (permissionItems != null && !permissionItems.isEmpty()) { - for (PermissionItem permissionItem : permissionItems) { - if (permissionItem != null && Boolean.TRUE.equals(permissionItem.getRequireEncryption())) { - String rpcName = permissionItem.getRpcName(); - if (rpcName != null) { - encryptionRequiredRPCs.add(rpcName); - } - } - } - } - checkStatusAndInitSecuredService(); - } - } - }; - - private ISdlServiceListener securedServiceListener = new ISdlServiceListener() { - @Override - public void onServiceStarted(SdlSession session, SessionType type, boolean isEncrypted) { - if(_proxyDisposed){ - DebugTool.logInfo(TAG, "Ignoring start service packet, proxy is disposed"); - return; - } - if(SessionType.RPC.equals(type)){ - rpcSecuredServiceStarted = isEncrypted; - } - if (serviceEncryptionListener != null) { - serviceEncryptionListener.onEncryptionServiceUpdated(type, isEncrypted, null); - } - DebugTool.logInfo(TAG, "onServiceStarted, session Type: " + type.getName() + ", isEncrypted: " + isEncrypted); - } - - @Override - public void onServiceEnded(SdlSession session, SessionType type) { - if(_proxyDisposed){ - DebugTool.logInfo(TAG, "Ignoring end service packet, proxy is disposed"); - return; - } - if (SessionType.RPC.equals(type)) { - rpcSecuredServiceStarted = false; - } - if (serviceEncryptionListener != null) { - serviceEncryptionListener.onEncryptionServiceUpdated(type, false, null); - } - DebugTool.logInfo(TAG, "onServiceEnded, session Type: " + type.getName()); - } - - @Override - public void onServiceError(SdlSession session, SessionType type, String reason) { - if(_proxyDisposed){ - DebugTool.logInfo(TAG, "Ignoring start service error, proxy is disposed"); - return; - } - if (SessionType.RPC.equals(type)) { - rpcSecuredServiceStarted = false; - } - if (serviceEncryptionListener != null) { - serviceEncryptionListener.onEncryptionServiceUpdated(type, false, "onServiceError: " + reason); - } - DebugTool.logError(TAG, "onServiceError, session Type: " + type.getName() + ", reason: " + reason); - } - }; - - /** - * Checks if an RPC requires encryption - * - * @param rpcName the rpc name (FunctionID) to check - * @return true if the given RPC requires encryption; false, otherwise - */ - public boolean getRPCRequiresEncryption(@NonNull FunctionID rpcName) { - return encryptionRequiredRPCs.contains(rpcName.toString()); - } - - /** - * Gets the encryption requirement - * @return true if encryption is required; false otherwise - */ - public boolean getRequiresEncryption() { - return !encryptionRequiredRPCs.isEmpty(); - } - - private void checkStatusAndInitSecuredService() { - if ((_hmiLevel != null && _hmiLevel != HMILevel.HMI_NONE) && getRequiresEncryption() && !rpcSecuredServiceStarted) { - startProtectedRPCService(); - } - } - - // Private sendRPCMessagePrivate method. All RPCMessages are funneled through this method after error checking. - protected void sendRPCMessagePrivate(RPCMessage message) throws SdlException { - try { - SdlTrace.logRPCEvent(InterfaceActivityDirection.Transmit, message, SDL_LIB_TRACE_KEY); - - //FIXME this is temporary until the next major release of the library where OK is removed - if (message.getMessageType().equals(RPCMessage.KEY_REQUEST)) { - RPCRequest request = (RPCRequest) message; - if (FunctionID.SUBSCRIBE_BUTTON.toString().equals(request.getFunctionName()) - || FunctionID.UNSUBSCRIBE_BUTTON.toString().equals(request.getFunctionName()) - || FunctionID.BUTTON_PRESS.toString().equals(request.getFunctionName())) { - - ButtonName buttonName = (ButtonName) request.getObject(ButtonName.class, SubscribeButton.KEY_BUTTON_NAME); - - - if (rpcSpecVersion != null) { - if (rpcSpecVersion.getMajor() < 5) { - - if (ButtonName.PLAY_PAUSE.equals(buttonName)) { - request.setParameters(SubscribeButton.KEY_BUTTON_NAME, ButtonName.OK); - } - } else { //Newer than version 5.0.0 - if (ButtonName.OK.equals(buttonName)) { - RPCRequest request2 = new RPCRequest(request); - request2.setParameters(SubscribeButton.KEY_BUTTON_NAME, ButtonName.PLAY_PAUSE); - request2.setOnRPCResponseListener(request.getOnRPCResponseListener()); - sendRPCMessagePrivate(request2); - return; - } - } - } - - } - } - - message.format(rpcSpecVersion,true); - byte[] msgBytes = JsonRPCMarshaller.marshall(message, (byte)getProtocolVersion().getMajor()); - - ProtocolMessage pm = new ProtocolMessage(); - pm.setData(msgBytes); - pm.setMessageType(MessageType.RPC); - pm.setSessionType(SessionType.RPC); - pm.setFunctionID(FunctionID.getFunctionId(message.getFunctionName())); - if (rpcSecuredServiceStarted && getRPCRequiresEncryption(message.getFunctionID())) { - pm.setPayloadProtected(true); - } else { - pm.setPayloadProtected(message.isPayloadProtected()); - } - if (pm.getPayloadProtected() && (!rpcSecuredServiceStarted || !rpcProtectedStartResponse)){ - String errorInfo = "Trying to send an encrypted message and there is no secured service"; - if (message.getMessageType().equals((RPCMessage.KEY_REQUEST))) { - RPCRequest request = (RPCRequest) message; - OnRPCResponseListener listener = ((RPCRequest) message).getOnRPCResponseListener(); - if (listener != null) { - GenericResponse response = new GenericResponse(false, Result.REJECTED); - response.setInfo(errorInfo); - listener.onResponse(request.getCorrelationID(), response); - } - } - DebugTool.logWarning(TAG, errorInfo); - return; - } - - if (sdlSession != null) { - pm.setSessionID((byte)sdlSession.getSessionId()); - } - - if (message.getBulkData() != null) { - pm.setBulkData(message.getBulkData()); - } - - - if (message.getMessageType().equals(RPCMessage.KEY_REQUEST)) { // Request Specifics - pm.setRPCType((byte)0x00); - RPCRequest request = (RPCRequest) message; - if (request.getCorrelationID() == null) { - //Log error here - throw new SdlException("CorrelationID cannot be null. RPC: " + request.getFunctionName(), SdlExceptionCause.INVALID_ARGUMENT); - } else { - pm.setCorrID(request.getCorrelationID()); - } - if (request.getFunctionName().equalsIgnoreCase(FunctionID.PUT_FILE.name())) { - pm.setPriorityCoefficient(1); - } - } else if (message.getMessageType().equals(RPCMessage.KEY_RESPONSE)) { // Response Specifics - pm.setRPCType((byte)0x01); - RPCResponse response = (RPCResponse) message; - if (response.getCorrelationID() == null) { - //Log error here - throw new SdlException("CorrelationID cannot be null. RPC: " + response.getFunctionName(), SdlExceptionCause.INVALID_ARGUMENT); - } else { - pm.setCorrID(response.getCorrelationID()); - } - } else if (message.getMessageType().equals(RPCMessage.KEY_NOTIFICATION)) { // Notification Specifics - pm.setRPCType((byte)0x02); - } else { - //Log error here - throw new SdlException("RPC message is not a valid type", SdlExceptionCause.INVALID_ARGUMENT); - } - - // Queue this outgoing message - synchronized(OUTGOING_MESSAGE_QUEUE_THREAD_LOCK) { - if (_outgoingProxyMessageDispatcher != null) { - _outgoingProxyMessageDispatcher.queueMessage(pm); - //Since the message is queued we can add it's listener to our list, if it is a Request - if (message.getMessageType().equals(RPCMessage.KEY_REQUEST)) { - RPCRequest request = (RPCRequest) message; - OnRPCResponseListener listener = request.getOnRPCResponseListener(); - addOnRPCResponseListener(listener, request.getCorrelationID(), msgBytes.length); - } - } - } - } catch (OutOfMemoryError e) { - SdlTrace.logProxyEvent("OutOfMemory exception while sending message " + message.getFunctionName(), SDL_LIB_TRACE_KEY); - throw new SdlException("OutOfMemory exception while sending message " + message.getFunctionName(), e, SdlExceptionCause.INVALID_ARGUMENT); - } - } - - /** - * Will provide callback to the listener either onFinish or onError depending on the RPCResponses result code, - *

Will automatically remove the listener for the list of listeners on completion. - * @param msg The RPCResponse message that was received - * @return if a listener was called or not - */ - @SuppressWarnings("UnusedReturnValue") - private boolean onRPCResponseReceived(RPCResponse msg){ - synchronized(ON_UPDATE_LISTENER_LOCK){ - int correlationId = msg.getCorrelationID(); - if(rpcResponseListeners !=null - && rpcResponseListeners.indexOfKey(correlationId)>=0){ - OnRPCResponseListener listener = rpcResponseListeners.get(correlationId); - listener.onResponse(correlationId, msg); - rpcResponseListeners.remove(correlationId); - return true; - } - return false; - } - } - -/** - * Add a listener that will receive the response to the specific RPCRequest sent with the corresponding correlation id - * @param listener that will get called back when a response is received - * @param correlationId of the RPCRequest that was sent - * @param totalSize only include if this is an OnPutFileUpdateListener. Otherwise it will be ignored. - */ - public void addOnRPCResponseListener(OnRPCResponseListener listener,int correlationId, int totalSize){ - synchronized(ON_UPDATE_LISTENER_LOCK){ - if(rpcResponseListeners!=null - && listener !=null){ - listener.onStart(correlationId); - rpcResponseListeners.put(correlationId, listener); - } - } - } - - @SuppressWarnings("unused") - public SparseArray getResponseListeners(){ - synchronized(ON_UPDATE_LISTENER_LOCK){ - return this.rpcResponseListeners; - } - } - - @SuppressWarnings("UnusedReturnValue") - public boolean onRPCNotificationReceived(RPCNotification notification){ - synchronized(ON_NOTIFICATION_LISTENER_LOCK){ - CopyOnWriteArrayList listeners = rpcNotificationListeners.get(FunctionID.getFunctionId(notification.getFunctionName())); - if(listeners!=null && listeners.size()>0) { - for (OnRPCNotificationListener listener : listeners) { - listener.onNotified(notification); - } - return true; - } - return false; - } - } - - @SuppressWarnings("UnusedReturnValue") - public boolean onRPCReceived(RPCMessage message){ - synchronized(RPC_LISTENER_LOCK){ - CopyOnWriteArrayList listeners = rpcListeners.get(FunctionID.getFunctionId(message.getFunctionName())); - if(listeners!=null && listeners.size()>0) { - for (OnRPCListener listener : listeners) { - listener.onReceived(message); - } - return true; - } - return false; - } - } - - @SuppressWarnings("UnusedReturnValue") - public boolean onRPCRequestReceived(RPCRequest request){ - synchronized(ON_NOTIFICATION_LISTENER_LOCK){ - CopyOnWriteArrayList listeners = rpcRequestListeners.get(FunctionID.getFunctionId(request.getFunctionName())); - if(listeners!=null && listeners.size()>0) { - for (OnRPCRequestListener listener : listeners) { - listener.onRequest(request); - } - return true; - } - return false; - } - } - - /** - * This will ad a listener for the specific type of notification. As of now it will only allow - * a single listener per notification function id - * @param notificationId The notification type that this listener is designated for - * @param listener The listener that will be called when a notification of the provided type is received - */ - @SuppressWarnings("unused") - public void addOnRPCNotificationListener(FunctionID notificationId, OnRPCNotificationListener listener){ - synchronized(ON_NOTIFICATION_LISTENER_LOCK){ - if(notificationId != null && listener != null){ - if(rpcNotificationListeners.indexOfKey(notificationId.getId()) < 0 ){ - rpcNotificationListeners.put(notificationId.getId(),new CopyOnWriteArrayList()); - } - rpcNotificationListeners.get(notificationId.getId()).add(listener); - } - } - } - - /** - * This will add a listener for the specific type of message. As of now it will only allow - * a single listener per request function id - * @param messageId The message type that this listener is designated for - * @param listener The listener that will be called when a request of the provided type is received - */ - @SuppressWarnings("unused") - public void addOnRPCListener(FunctionID messageId, OnRPCListener listener){ - synchronized(RPC_LISTENER_LOCK){ - if(messageId != null && listener != null){ - if(rpcListeners.indexOfKey(messageId.getId()) < 0 ){ - rpcListeners.put(messageId.getId(),new CopyOnWriteArrayList()); - } - rpcListeners.get(messageId.getId()).add(listener); - } - } - } - - public boolean removeOnRPCListener(FunctionID messageId, OnRPCListener listener){ - synchronized(RPC_LISTENER_LOCK){ - if(rpcListeners!= null - && messageId != null - && listener != null - && rpcListeners.indexOfKey(messageId.getId()) >= 0){ - return rpcListeners.get(messageId.getId()).remove(listener); - } - } - return false; - } - - /** - * This will add a listener for the specific type of request. As of now it will only allow - * a single listener per request function id - * @param requestId The request type that this listener is designated for - * @param listener The listener that will be called when a request of the provided type is received - */ - @SuppressWarnings("unused") - public void addOnRPCRequestListener(FunctionID requestId, OnRPCRequestListener listener){ - synchronized(ON_NOTIFICATION_LISTENER_LOCK){ - if(requestId != null && listener != null){ - if(rpcRequestListeners.indexOfKey(requestId.getId()) < 0 ){ - rpcRequestListeners.put(requestId.getId(),new CopyOnWriteArrayList()); - } - rpcRequestListeners.get(requestId.getId()).add(listener); - } - } - } - - /** - * This method is no longer valid and will not remove the listener for the supplied notificaiton id - * @param notificationId n/a - * @see #removeOnRPCNotificationListener(FunctionID, OnRPCNotificationListener) - */ - @SuppressWarnings("unused") - @Deprecated - public void removeOnRPCNotificationListener(FunctionID notificationId){ - synchronized(ON_NOTIFICATION_LISTENER_LOCK){ - //rpcNotificationListeners.delete(notificationId.getId()); - } - } - - public boolean removeOnRPCNotificationListener(FunctionID notificationId, OnRPCNotificationListener listener){ - synchronized(ON_NOTIFICATION_LISTENER_LOCK){ - if(rpcNotificationListeners!= null - && notificationId != null - && listener != null - && rpcNotificationListeners.indexOfKey(notificationId.getId()) >= 0){ - return rpcNotificationListeners.get(notificationId.getId()).remove(listener); - } - } - return false; - } - - public boolean removeOnRPCRequestListener(FunctionID requestId, OnRPCRequestListener listener){ - synchronized(ON_NOTIFICATION_LISTENER_LOCK){ - if(rpcRequestListeners!= null - && requestId != null - && listener != null - && rpcRequestListeners.indexOfKey(requestId.getId()) >= 0){ - return rpcRequestListeners.get(requestId.getId()).remove(listener); - } - } - return false; - } - - private void processRaiResponse(RegisterAppInterfaceResponse rai) - { - if (rai == null) return; - - this.raiResponse = rai; - - VehicleType vt = rai.getVehicleType(); - if (vt == null) return; - - String make = vt.getMake(); - if (make == null) return; - - if (_secList == null) return; - - SdlSecurityBase sec; - Service svc = getService(); - SdlSecurityBase.setAppService(svc); - if (svc != null && svc.getApplicationContext() != null){ - SdlSecurityBase.setContext(svc.getApplicationContext()); - } else { - SdlSecurityBase.setContext(_appContext); - } - - for (Class cls : _secList) - { - try - { - sec = cls.newInstance(); - } - catch (Exception e) - { - continue; - } - - if ( (sec != null) && (sec.getMakeList() != null) ) - { - if (sec.getMakeList().contains(make)) - { - setSdlSecurity(sec); - sec.setAppId(_appID); - if (sdlSession != null) - sec.handleSdlSession(sdlSession); - return; - } - } - } - } - - private void handleRPCMessage(Hashtable hash) { - - if (hash == null){ - DebugTool.logError(TAG, "handleRPCMessage: hash is null, returning."); - return; - } - - RPCMessage rpcMsg = RpcConverter.convertTableToRpc(hash); - - if (rpcMsg == null){ - DebugTool.logError(TAG, "handleRPCMessage: rpcMsg is null, returning."); - return; - } - - SdlTrace.logRPCEvent(InterfaceActivityDirection.Receive, rpcMsg, SDL_LIB_TRACE_KEY); - - String functionName = rpcMsg.getFunctionName(); - String messageType = rpcMsg.getMessageType(); - - rpcMsg.format(rpcSpecVersion, true); - - onRPCReceived(rpcMsg); // Should only be called for internal use - - // Requests need to be listened for using the SDLManager's addOnRPCRequestListener method. - // Requests are not supported by IProxyListenerBase - if (messageType.equals(RPCMessage.KEY_REQUEST)) { - - onRPCRequestReceived((RPCRequest) rpcMsg); - - } else if (messageType.equals(RPCMessage.KEY_RESPONSE)) { - // Check to ensure response is not from an internal message (reserved correlation ID) - if (isCorrelationIDProtected((new RPCResponse(hash)).getCorrelationID())) { - // This is a response generated from an internal message, it can be trapped here - // The app should not receive a response for a request it did not send - if ((new RPCResponse(hash)).getCorrelationID() == REGISTER_APP_INTERFACE_CORRELATION_ID - && _advancedLifecycleManagementEnabled - && functionName.equals(FunctionID.REGISTER_APP_INTERFACE.toString())) { - final RegisterAppInterfaceResponse msg = new RegisterAppInterfaceResponse(hash); - msg.format(rpcSpecVersion, true); - if (msg.getSuccess()) { - _appInterfaceRegisterd = true; - } - processRaiResponse(msg); - - //Populate the system capability manager with the RAI response - //_systemCapabilityManager.parseRAIResponse(msg); - - Intent sendIntent = createBroadcastIntent(); - updateBroadcastIntent(sendIntent, "RPC_NAME", FunctionID.REGISTER_APP_INTERFACE.toString()); - updateBroadcastIntent(sendIntent, "TYPE", RPCMessage.KEY_RESPONSE); - updateBroadcastIntent(sendIntent, "SUCCESS", msg.getSuccess()); - updateBroadcastIntent(sendIntent, "COMMENT1", msg.getInfo()); - updateBroadcastIntent(sendIntent, "COMMENT2", msg.getResultCode().toString()); - updateBroadcastIntent(sendIntent, "DATA",serializeJSON(msg)); - updateBroadcastIntent(sendIntent, "CORRID", msg.getCorrelationID()); - sendBroadcastIntent(sendIntent); - - //_autoActivateIdReturned = msg.getAutoActivateID(); - /*Place holder for legacy support*/ _autoActivateIdReturned = "8675309"; - _prerecordedSpeech = msg.getPrerecordedSpeech(); - _sdlLanguage = msg.getLanguage(); - _hmiDisplayLanguage = msg.getHmiDisplayLanguage(); - _sdlMsgVersion = msg.getSdlMsgVersion(); - if(_sdlMsgVersion != null){ - rpcSpecVersion = new com.smartdevicelink.util.Version(_sdlMsgVersion.getMajorVersion(),_sdlMsgVersion.getMinorVersion(), _sdlMsgVersion.getPatchVersion()); - }else{ - rpcSpecVersion = MAX_SUPPORTED_RPC_VERSION; - } - DebugTool.logInfo(TAG, "Negotiated RPC Spec version = " + rpcSpecVersion); - - _vehicleType = msg.getVehicleType(); - _systemSoftwareVersion = msg.getSystemSoftwareVersion(); - _proxyVersionInfo = BuildConfig.VERSION_NAME; - _iconResumed = msg.getIconResumed(); - - if (_iconResumed == null){ - _iconResumed = false; - } - - if (_bAppResumeEnabled) - { - if ( (_sdlMsgVersion.getMajorVersion() > 2) && (_lastHashID != null) && (msg.getSuccess()) && (msg.getResultCode() != Result.RESUME_FAILED) ) - _bResumeSuccess = true; - else - { - _bResumeSuccess = false; - _lastHashID = null; - } - } - _diagModes = msg.getSupportedDiagModes(); - - String sVersionInfo = "SDL Proxy Version: " + _proxyVersionInfo; - - if (!isDebugEnabled()) - { - enableDebugTool(); - DebugTool.logInfo(TAG, sVersionInfo, false); - disableDebugTool(); - } - else - DebugTool.logInfo(TAG, sVersionInfo, false); - - sendIntent = createBroadcastIntent(); - updateBroadcastIntent(sendIntent, "FUNCTION_NAME", "RAI_RESPONSE"); - updateBroadcastIntent(sendIntent, "COMMENT1", sVersionInfo); - sendBroadcastIntent(sendIntent); - - // Send onSdlConnected message in ALM - //_sdlConnectionState = SdlConnectionState.SDL_CONNECTED; - - // If registerAppInterface failed, exit with OnProxyUnusable - if (!msg.getSuccess()) { - notifyProxyClosed("Unable to register app interface. Review values passed to the SdlProxy constructor. RegisterAppInterface result code: ", - new SdlException("Unable to register app interface. Review values passed to the SdlProxy constructor. RegisterAppInterface result code: " + msg.getResultCode(), SdlExceptionCause.SDL_REGISTRATION_ERROR), SdlDisconnectedReason.SDL_REGISTRATION_ERROR); - } - - //If the RPC version is too low we should simply dispose this proxy - if (minimumRPCVersion != null && minimumRPCVersion.isNewerThan(rpcSpecVersion) == 1) { - DebugTool.logWarning(TAG, String.format("Disconnecting from head unit, the configured minimum RPC version %s is greater than the supported RPC version %s", minimumRPCVersion, rpcSpecVersion)); - try { - disposeInternal(SdlDisconnectedReason.MINIMUM_RPC_VERSION_HIGHER_THAN_SUPPORTED); - } catch (SdlException e) { - e.printStackTrace(); - } - return; - } - - - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - if (_proxyListener instanceof IProxyListener) { - ((IProxyListener)_proxyListener).onRegisterAppInterfaceResponse(msg); - } - onRPCResponseReceived(msg); - } - }); - } else { - if (_proxyListener instanceof IProxyListener) { - ((IProxyListener)_proxyListener).onRegisterAppInterfaceResponse(msg); - } - onRPCResponseReceived(msg); - } - } else if ((new RPCResponse(hash)).getCorrelationID() == POLICIES_CORRELATION_ID - && functionName.equals(FunctionID.ON_ENCODED_SYNC_P_DATA.toString())) { - - DebugTool.logInfo(TAG, "POLICIES_CORRELATION_ID SystemRequest Notification (Legacy)"); - - final OnSystemRequest msg = new OnSystemRequest(hash); - - // If url is not null, then send to URL - if ( (msg.getUrl() != null) ) - { - // URL has data, attempt to post request to external server - Thread handleOffboardTransmissionThread = new Thread() { - @Override - public void run() { - sendOnSystemRequestToUrl(msg); - } - }; - - handleOffboardTransmissionThread.start(); - } - } - else if ((new RPCResponse(hash)).getCorrelationID() == POLICIES_CORRELATION_ID - && functionName.equals(FunctionID.ENCODED_SYNC_P_DATA.toString())) { - - DebugTool.logInfo(TAG, "POLICIES_CORRELATION_ID SystemRequest Response (Legacy)"); - final SystemRequestResponse msg = new SystemRequestResponse(hash); - - Intent sendIntent = createBroadcastIntent(); - updateBroadcastIntent(sendIntent, "RPC_NAME", FunctionID.SYSTEM_REQUEST.toString()); - updateBroadcastIntent(sendIntent, "TYPE", RPCMessage.KEY_RESPONSE); - updateBroadcastIntent(sendIntent, "SUCCESS", msg.getSuccess()); - updateBroadcastIntent(sendIntent, "COMMENT1", msg.getInfo()); - updateBroadcastIntent(sendIntent, "COMMENT2", msg.getResultCode().toString()); - updateBroadcastIntent(sendIntent, "CORRID", msg.getCorrelationID()); - sendBroadcastIntent(sendIntent); - } - else if ((new RPCResponse(hash)).getCorrelationID() == POLICIES_CORRELATION_ID - && functionName.equals(FunctionID.SYSTEM_REQUEST.toString())) { - final SystemRequestResponse msg = new SystemRequestResponse(hash); - - Intent sendIntent = createBroadcastIntent(); - updateBroadcastIntent(sendIntent, "RPC_NAME", FunctionID.SYSTEM_REQUEST.toString()); - updateBroadcastIntent(sendIntent, "TYPE", RPCMessage.KEY_RESPONSE); - updateBroadcastIntent(sendIntent, "SUCCESS", msg.getSuccess()); - updateBroadcastIntent(sendIntent, "COMMENT1", msg.getInfo()); - updateBroadcastIntent(sendIntent, "COMMENT2", msg.getResultCode().toString()); - updateBroadcastIntent(sendIntent, "CORRID", msg.getCorrelationID()); - updateBroadcastIntent(sendIntent, "DATA", serializeJSON(msg)); - sendBroadcastIntent(sendIntent); - } - else if (functionName.equals(FunctionID.UNREGISTER_APP_INTERFACE.toString())) { - // UnregisterAppInterface - _appInterfaceRegisterd = false; - synchronized(APP_INTERFACE_REGISTERED_LOCK) { - APP_INTERFACE_REGISTERED_LOCK.notify(); - } - final UnregisterAppInterfaceResponse msg = new UnregisterAppInterfaceResponse(hash); - msg.format(rpcSpecVersion, true); - Intent sendIntent = createBroadcastIntent(); - updateBroadcastIntent(sendIntent, "RPC_NAME", FunctionID.UNREGISTER_APP_INTERFACE.toString()); - updateBroadcastIntent(sendIntent, "TYPE", RPCMessage.KEY_RESPONSE); - updateBroadcastIntent(sendIntent, "SUCCESS", msg.getSuccess()); - updateBroadcastIntent(sendIntent, "COMMENT1", msg.getInfo()); - updateBroadcastIntent(sendIntent, "COMMENT2", msg.getResultCode().toString()); - updateBroadcastIntent(sendIntent, "DATA",serializeJSON(msg)); - updateBroadcastIntent(sendIntent, "CORRID", msg.getCorrelationID()); - sendBroadcastIntent(sendIntent); - } - return; - } - - if (functionName.equals(FunctionID.REGISTER_APP_INTERFACE.toString())) { - final RegisterAppInterfaceResponse msg = new RegisterAppInterfaceResponse(hash); - msg.format(rpcSpecVersion, true); - if (msg.getSuccess()) { - _appInterfaceRegisterd = true; - } - processRaiResponse(msg); - //Populate the system capability manager with the RAI response - //_systemCapabilityManager.parseRAIResponse(msg); - - //_autoActivateIdReturned = msg.getAutoActivateID(); - /*Place holder for legacy support*/ _autoActivateIdReturned = "8675309"; - _prerecordedSpeech = msg.getPrerecordedSpeech(); - _sdlLanguage = msg.getLanguage(); - _hmiDisplayLanguage = msg.getHmiDisplayLanguage(); - _sdlMsgVersion = msg.getSdlMsgVersion(); - if(_sdlMsgVersion != null){ - rpcSpecVersion = new com.smartdevicelink.util.Version(_sdlMsgVersion.getMajorVersion(),_sdlMsgVersion.getMinorVersion(), _sdlMsgVersion.getPatchVersion()); - } else { - rpcSpecVersion = MAX_SUPPORTED_RPC_VERSION; - } - DebugTool.logInfo(TAG, "Negotiated RPC Spec version = " + rpcSpecVersion); - - _vehicleType = msg.getVehicleType(); - _systemSoftwareVersion = msg.getSystemSoftwareVersion(); - _proxyVersionInfo = BuildConfig.VERSION_NAME; - - if (_bAppResumeEnabled) - { - if ( (_sdlMsgVersion.getMajorVersion() > 2) && (_lastHashID != null) && (msg.getSuccess()) && (msg.getResultCode() != Result.RESUME_FAILED) ) - _bResumeSuccess = true; - else - { - _bResumeSuccess = false; - _lastHashID = null; - } - } - - _diagModes = msg.getSupportedDiagModes(); - - if (!isDebugEnabled()) - { - enableDebugTool(); - DebugTool.logInfo(TAG, "SDL Proxy Version: " + _proxyVersionInfo); - disableDebugTool(); - } - else - DebugTool.logInfo(TAG, "SDL Proxy Version: " + _proxyVersionInfo); - - // RegisterAppInterface - if (_advancedLifecycleManagementEnabled) { - - // Send onSdlConnected message in ALM - //_sdlConnectionState = SdlConnectionState.SDL_CONNECTED; - - // If registerAppInterface failed, exit with OnProxyUnusable - if (!msg.getSuccess()) { - notifyProxyClosed("Unable to register app interface. Review values passed to the SdlProxy constructor. RegisterAppInterface result code: ", - new SdlException("Unable to register app interface. Review values passed to the SdlProxy constructor. RegisterAppInterface result code: " + msg.getResultCode(), SdlExceptionCause.SDL_REGISTRATION_ERROR), SdlDisconnectedReason.SDL_REGISTRATION_ERROR); - } - //If the RPC version is too low we should simply dispose this proxy - if (minimumRPCVersion != null && minimumRPCVersion.isNewerThan(rpcSpecVersion) == 1) { - DebugTool.logWarning(TAG, String.format("Disconnecting from head unit, the configured minimum RPC version %s is greater than the supported RPC version %s", minimumRPCVersion, rpcSpecVersion)); - try { - disposeInternal(SdlDisconnectedReason.MINIMUM_RPC_VERSION_HIGHER_THAN_SUPPORTED); - } catch (SdlException e) { - e.printStackTrace(); - } - return; - } - } else { - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - if (_proxyListener instanceof IProxyListener) { - ((IProxyListener)_proxyListener).onRegisterAppInterfaceResponse(msg); - } - onRPCResponseReceived(msg); - } - }); - } else { - if (_proxyListener instanceof IProxyListener) { - ((IProxyListener)_proxyListener).onRegisterAppInterfaceResponse(msg); - } - onRPCResponseReceived(msg); - } - } - } else if (functionName.equals(FunctionID.SPEAK.toString())) { - // SpeakResponse - - final SpeakResponse msg = new SpeakResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onSpeakResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onSpeakResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.ALERT.toString())) { - // AlertResponse - - final AlertResponse msg = new AlertResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onAlertResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onAlertResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.SHOW.toString())) { - // ShowResponse - - final ShowResponse msg = new ShowResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onShowResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onShowResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.ADD_COMMAND.toString())) { - // AddCommand - - final AddCommandResponse msg = new AddCommandResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onAddCommandResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onAddCommandResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.DELETE_COMMAND.toString())) { - // DeleteCommandResponse - - final DeleteCommandResponse msg = new DeleteCommandResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onDeleteCommandResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onDeleteCommandResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.ADD_SUB_MENU.toString())) { - // AddSubMenu - - final AddSubMenuResponse msg = new AddSubMenuResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onAddSubMenuResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onAddSubMenuResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.DELETE_SUB_MENU.toString())) { - // DeleteSubMenu - - final DeleteSubMenuResponse msg = new DeleteSubMenuResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onDeleteSubMenuResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onDeleteSubMenuResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.SUBSCRIBE_BUTTON.toString())) { - // SubscribeButton - - final SubscribeButtonResponse msg = new SubscribeButtonResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onSubscribeButtonResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onSubscribeButtonResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.UNSUBSCRIBE_BUTTON.toString())) { - // UnsubscribeButton - - final UnsubscribeButtonResponse msg = new UnsubscribeButtonResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onUnsubscribeButtonResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onUnsubscribeButtonResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.SET_MEDIA_CLOCK_TIMER.toString())) { - // SetMediaClockTimer - - final SetMediaClockTimerResponse msg = new SetMediaClockTimerResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onSetMediaClockTimerResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onSetMediaClockTimerResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.ENCODED_SYNC_P_DATA.toString())) { - - final SystemRequestResponse msg = new SystemRequestResponse(hash); - msg.format(rpcSpecVersion,true); - Intent sendIntent = createBroadcastIntent(); - updateBroadcastIntent(sendIntent, "RPC_NAME", FunctionID.SYSTEM_REQUEST.toString()); - updateBroadcastIntent(sendIntent, "TYPE", RPCMessage.KEY_RESPONSE); - updateBroadcastIntent(sendIntent, "SUCCESS", msg.getSuccess()); - updateBroadcastIntent(sendIntent, "COMMENT1", msg.getInfo()); - updateBroadcastIntent(sendIntent, "COMMENT2", msg.getResultCode().toString()); - updateBroadcastIntent(sendIntent, "CORRID", msg.getCorrelationID()); - sendBroadcastIntent(sendIntent); - - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onSystemRequestResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onSystemRequestResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.CREATE_INTERACTION_CHOICE_SET.toString())) { - // CreateInteractionChoiceSet - - final CreateInteractionChoiceSetResponse msg = new CreateInteractionChoiceSetResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onCreateInteractionChoiceSetResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onCreateInteractionChoiceSetResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.DELETE_INTERACTION_CHOICE_SET.toString())) { - // DeleteInteractionChoiceSet - - final DeleteInteractionChoiceSetResponse msg = new DeleteInteractionChoiceSetResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onDeleteInteractionChoiceSetResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onDeleteInteractionChoiceSetResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.PERFORM_INTERACTION.toString())) { - // PerformInteraction - - final PerformInteractionResponse msg = new PerformInteractionResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onPerformInteractionResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onPerformInteractionResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.SET_GLOBAL_PROPERTIES.toString())) { - // SetGlobalPropertiesResponse - - final SetGlobalPropertiesResponse msg = new SetGlobalPropertiesResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onSetGlobalPropertiesResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onSetGlobalPropertiesResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.RESET_GLOBAL_PROPERTIES.toString())) { - // ResetGlobalProperties - - final ResetGlobalPropertiesResponse msg = new ResetGlobalPropertiesResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onResetGlobalPropertiesResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onResetGlobalPropertiesResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.UNREGISTER_APP_INTERFACE.toString())) { - // UnregisterAppInterface - - _appInterfaceRegisterd = false; - synchronized(APP_INTERFACE_REGISTERED_LOCK) { - APP_INTERFACE_REGISTERED_LOCK.notify(); - } - - final UnregisterAppInterfaceResponse msg = new UnregisterAppInterfaceResponse(hash); - msg.format(rpcSpecVersion,true); - Intent sendIntent = createBroadcastIntent(); - updateBroadcastIntent(sendIntent, "RPC_NAME", FunctionID.UNREGISTER_APP_INTERFACE.toString()); - updateBroadcastIntent(sendIntent, "TYPE", RPCMessage.KEY_RESPONSE); - updateBroadcastIntent(sendIntent, "SUCCESS", msg.getSuccess()); - updateBroadcastIntent(sendIntent, "COMMENT1", msg.getInfo()); - updateBroadcastIntent(sendIntent, "COMMENT2", msg.getResultCode().toString()); - updateBroadcastIntent(sendIntent, "DATA",serializeJSON(msg)); - updateBroadcastIntent(sendIntent, "CORRID", msg.getCorrelationID()); - sendBroadcastIntent(sendIntent); - - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - if (_proxyListener instanceof IProxyListener) { - ((IProxyListener)_proxyListener).onUnregisterAppInterfaceResponse(msg); - } - onRPCResponseReceived(msg); - } - }); - } else { - if (_proxyListener instanceof IProxyListener) { - ((IProxyListener)_proxyListener).onUnregisterAppInterfaceResponse(msg); - } - onRPCResponseReceived(msg); - } - - notifyProxyClosed("UnregisterAppInterfaceResponse", null, SdlDisconnectedReason.APP_INTERFACE_UNREG); - } else if (functionName.equals(FunctionID.GENERIC_RESPONSE.toString())) { - // GenericResponse (Usually and error) - final GenericResponse msg = new GenericResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onGenericResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onGenericResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.SLIDER.toString())) { - // Slider - final SliderResponse msg = new SliderResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onSliderResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onSliderResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.PUT_FILE.toString())) { - // PutFile - final PutFileResponse msg = new PutFileResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onPutFileResponse(msg); - onRPCResponseReceived(msg); - notifyPutFileStreamResponse(msg); - } - }); - } else { - _proxyListener.onPutFileResponse(msg); - onRPCResponseReceived(msg); - notifyPutFileStreamResponse(msg); - } - } else if (functionName.equals(FunctionID.DELETE_FILE.toString())) { - // DeleteFile - final DeleteFileResponse msg = new DeleteFileResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onDeleteFileResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onDeleteFileResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.LIST_FILES.toString())) { - // ListFiles - final ListFilesResponse msg = new ListFilesResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onListFilesResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onListFilesResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.SET_APP_ICON.toString())) { - // SetAppIcon - final SetAppIconResponse msg = new SetAppIconResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onSetAppIconResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onSetAppIconResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.SCROLLABLE_MESSAGE.toString())) { - // ScrollableMessage - final ScrollableMessageResponse msg = new ScrollableMessageResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onScrollableMessageResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onScrollableMessageResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.CHANGE_REGISTRATION.toString())) { - // ChangeLanguageRegistration - final ChangeRegistrationResponse msg = new ChangeRegistrationResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onChangeRegistrationResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onChangeRegistrationResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.SET_DISPLAY_LAYOUT.toString())) { - // SetDisplayLayout - final SetDisplayLayoutResponse msg = new SetDisplayLayoutResponse(hash); - msg.format(rpcSpecVersion,true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onSetDisplayLayoutResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onSetDisplayLayoutResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.PERFORM_AUDIO_PASS_THRU.toString())) { - // PerformAudioPassThru - final PerformAudioPassThruResponse msg = new PerformAudioPassThruResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onPerformAudioPassThruResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onPerformAudioPassThruResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.END_AUDIO_PASS_THRU.toString())) { - // EndAudioPassThru - final EndAudioPassThruResponse msg = new EndAudioPassThruResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onEndAudioPassThruResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onEndAudioPassThruResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.SUBSCRIBE_VEHICLE_DATA.toString())) { - // SubscribeVehicleData - final SubscribeVehicleDataResponse msg = new SubscribeVehicleDataResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onSubscribeVehicleDataResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onSubscribeVehicleDataResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.UNSUBSCRIBE_VEHICLE_DATA.toString())) { - // UnsubscribeVehicleData - final UnsubscribeVehicleDataResponse msg = new UnsubscribeVehicleDataResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onUnsubscribeVehicleDataResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onUnsubscribeVehicleDataResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.GET_VEHICLE_DATA.toString())) { - // GetVehicleData - final GetVehicleDataResponse msg = new GetVehicleDataResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onGetVehicleDataResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onGetVehicleDataResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.SUBSCRIBE_WAY_POINTS.toString())) { - // SubscribeWayPoints - final SubscribeWayPointsResponse msg = new SubscribeWayPointsResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onSubscribeWayPointsResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onSubscribeWayPointsResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.UNSUBSCRIBE_WAY_POINTS.toString())) { - // UnsubscribeWayPoints - final UnsubscribeWayPointsResponse msg = new UnsubscribeWayPointsResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onUnsubscribeWayPointsResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onUnsubscribeWayPointsResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.GET_WAY_POINTS.toString())) { - // GetWayPoints - final GetWayPointsResponse msg = new GetWayPointsResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onGetWayPointsResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onGetWayPointsResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.READ_DID.toString())) { - final ReadDIDResponse msg = new ReadDIDResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onReadDIDResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onReadDIDResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.GET_DTCS.toString())) { - final GetDTCsResponse msg = new GetDTCsResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onGetDTCsResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onGetDTCsResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.DIAGNOSTIC_MESSAGE.toString())) { - final DiagnosticMessageResponse msg = new DiagnosticMessageResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onDiagnosticMessageResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onDiagnosticMessageResponse(msg); - onRPCResponseReceived(msg); - } - } - else if (functionName.equals(FunctionID.SYSTEM_REQUEST.toString())) { - - final SystemRequestResponse msg = new SystemRequestResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onSystemRequestResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onSystemRequestResponse(msg); - onRPCResponseReceived(msg); - } - } - else if (functionName.equals(FunctionID.SEND_LOCATION.toString())) { - - final SendLocationResponse msg = new SendLocationResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onSendLocationResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onSendLocationResponse(msg); - onRPCResponseReceived(msg); - } - } - else if (functionName.equals(FunctionID.DIAL_NUMBER.toString())) { - - final DialNumberResponse msg = new DialNumberResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onDialNumberResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onDialNumberResponse(msg); - onRPCResponseReceived(msg); - } - } - else if (functionName.equals(FunctionID.SHOW_CONSTANT_TBT.toString())) { - final ShowConstantTbtResponse msg = new ShowConstantTbtResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onShowConstantTbtResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onShowConstantTbtResponse(msg); - onRPCResponseReceived(msg); - } - } - else if (functionName.equals(FunctionID.ALERT_MANEUVER.toString())) { - final AlertManeuverResponse msg = new AlertManeuverResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onAlertManeuverResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onAlertManeuverResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.UPDATE_TURN_LIST.toString())) { - final UpdateTurnListResponse msg = new UpdateTurnListResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onUpdateTurnListResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onUpdateTurnListResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.SET_INTERIOR_VEHICLE_DATA.toString())) { - final SetInteriorVehicleDataResponse msg = new SetInteriorVehicleDataResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onSetInteriorVehicleDataResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onSetInteriorVehicleDataResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.GET_INTERIOR_VEHICLE_DATA.toString())) { - final GetInteriorVehicleDataResponse msg = new GetInteriorVehicleDataResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onGetInteriorVehicleDataResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onGetInteriorVehicleDataResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.CREATE_WINDOW.toString())) { - final CreateWindowResponse msg = new CreateWindowResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onCreateWindowResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onCreateWindowResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.DELETE_WINDOW.toString())) { - final DeleteWindowResponse msg = new DeleteWindowResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onDeleteWindowResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onDeleteWindowResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.GET_SYSTEM_CAPABILITY.toString())) { - // GetSystemCapabilityResponse - final GetSystemCapabilityResponse msg = new GetSystemCapabilityResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onGetSystemCapabilityResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onGetSystemCapabilityResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.BUTTON_PRESS.toString())) { - final ButtonPressResponse msg = new ButtonPressResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onButtonPressResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onButtonPressResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.SEND_HAPTIC_DATA.toString())) { - final SendHapticDataResponse msg = new SendHapticDataResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onSendHapticDataResponse( msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onSendHapticDataResponse( msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.SET_CLOUD_APP_PROPERTIES.toString())) { - final SetCloudAppPropertiesResponse msg = new SetCloudAppPropertiesResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onSetCloudAppProperties(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onSetCloudAppProperties(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.GET_CLOUD_APP_PROPERTIES.toString())) { - final GetCloudAppPropertiesResponse msg = new GetCloudAppPropertiesResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onGetCloudAppProperties(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onGetCloudAppProperties(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.PUBLISH_APP_SERVICE.toString())) { - final PublishAppServiceResponse msg = new PublishAppServiceResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onPublishAppServiceResponse( msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onPublishAppServiceResponse( msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.GET_APP_SERVICE_DATA.toString())) { - final GetAppServiceDataResponse msg = new GetAppServiceDataResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onGetAppServiceDataResponse( msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onGetAppServiceDataResponse( msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.GET_FILE.toString())) { - final GetFileResponse msg = new GetFileResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onGetFileResponse( msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onGetFileResponse( msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.PERFORM_APP_SERVICES_INTERACTION.toString())) { - final PerformAppServiceInteractionResponse msg = new PerformAppServiceInteractionResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onPerformAppServiceInteractionResponse( msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onPerformAppServiceInteractionResponse( msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.CLOSE_APPLICATION.toString())) { - final CloseApplicationResponse msg = new CloseApplicationResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onCloseApplicationResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onCloseApplicationResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.CANCEL_INTERACTION.toString())) { - final CancelInteractionResponse msg = new CancelInteractionResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onCancelInteractionResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onCancelInteractionResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.UNPUBLISH_APP_SERVICE.toString())) { - final UnpublishAppServiceResponse msg = new UnpublishAppServiceResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onUnpublishAppServiceResponse( msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onUnpublishAppServiceResponse( msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.SHOW_APP_MENU.toString())) { - final ShowAppMenuResponse msg = new ShowAppMenuResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onShowAppMenuResponse( msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onShowAppMenuResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.GET_INTERIOR_VEHICLE_DATA_CONSENT.toString())) { - final GetInteriorVehicleDataConsentResponse msg = new GetInteriorVehicleDataConsentResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onGetInteriorVehicleDataConsentResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onGetInteriorVehicleDataConsentResponse(msg); - onRPCResponseReceived(msg); - } - } else if (functionName.equals(FunctionID.RELEASE_INTERIOR_VEHICLE_MODULE.toString())) { - final ReleaseInteriorVehicleDataModuleResponse msg = new ReleaseInteriorVehicleDataModuleResponse(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onReleaseInteriorVehicleDataModuleResponse(msg); - onRPCResponseReceived(msg); - } - }); - } else { - _proxyListener.onReleaseInteriorVehicleDataModuleResponse(msg); - onRPCResponseReceived(msg); - } - } else { - if (_sdlMsgVersion != null) { - DebugTool.logError(TAG, "Unrecognized response Message: " + functionName + - " SDL Message Version = " + _sdlMsgVersion); - } else { - DebugTool.logError(TAG, "Unrecognized response Message: " + functionName); - } - } // end-if - - - } else if (messageType.equals(RPCMessage.KEY_NOTIFICATION)) { - if (functionName.equals(FunctionID.ON_HMI_STATUS.toString())) { - // OnHMIStatus - - final OnHMIStatus msg = new OnHMIStatus(hash); - - //setup lockscreeninfo - if (sdlSession != null) - { - //sdlSession.getLockScreenMan().setHMILevel(msg.getHmiLevel()); - } - - msg.setFirstRun(firstTimeFull); - if (msg.getHmiLevel() == HMILevel.HMI_FULL) firstTimeFull = false; - - _hmiLevel = msg.getHmiLevel(); - if (_hmiLevel != HMILevel.HMI_NONE) { - checkStatusAndInitSecuredService(); - } - _audioStreamingState = msg.getAudioStreamingState(); - - msg.format(rpcSpecVersion, true); - lastHmiStatus = msg; - - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onOnHMIStatus(msg); - //_proxyListener.onOnLockScreenNotification(sdlSession.getLockScreenMan().getLockObj()); - onRPCNotificationReceived(msg); - } - }); - } else { - _proxyListener.onOnHMIStatus(msg); - //_proxyListener.onOnLockScreenNotification(sdlSession.getLockScreenMan().getLockObj()); - onRPCNotificationReceived(msg); - } - } else if (functionName.equals(FunctionID.ON_COMMAND.toString())) { - // OnCommand - - final OnCommand msg = new OnCommand(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onOnCommand(msg); - onRPCNotificationReceived(msg); - } - }); - } else { - _proxyListener.onOnCommand(msg); - onRPCNotificationReceived(msg); - } - } else if (functionName.equals(FunctionID.ON_DRIVER_DISTRACTION.toString())) { - // OnDriverDistration - - final OnDriverDistraction msg = new OnDriverDistraction(hash); - - //setup lockscreeninfo - if (sdlSession != null) - { - DriverDistractionState drDist = msg.getState(); - //sdlSession.getLockScreenMan().setDriverDistStatus(drDist == DriverDistractionState.DD_ON); - } - - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onOnDriverDistraction(msg); - //_proxyListener.onOnLockScreenNotification(sdlSession.getLockScreenMan().getLockObj()); - onRPCNotificationReceived(msg); - } - }); - } else { - _proxyListener.onOnDriverDistraction(msg); - //_proxyListener.onOnLockScreenNotification(sdlSession.getLockScreenMan().getLockObj()); - onRPCNotificationReceived(msg); - } - } else if (functionName.equals(FunctionID.ON_ENCODED_SYNC_P_DATA.toString())) { - - final OnSystemRequest msg = new OnSystemRequest(hash); - - Intent sendIntent = createBroadcastIntent(); - updateBroadcastIntent(sendIntent, "RPC_NAME", FunctionID.ON_SYSTEM_REQUEST.toString()); - updateBroadcastIntent(sendIntent, "TYPE", RPCMessage.KEY_NOTIFICATION); - - // If url is null, then send notification to the app, otherwise, send to URL - if (msg.getUrl() == null) { - updateBroadcastIntent(sendIntent, "COMMENT1", "URL is a null value (received)"); - sendBroadcastIntent(sendIntent); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onOnSystemRequest(msg); - onRPCNotificationReceived(msg); - } - }); - } else { - _proxyListener.onOnSystemRequest(msg); - onRPCNotificationReceived(msg); - } - } else { - updateBroadcastIntent(sendIntent, "COMMENT1", "Sending to cloud: " + msg.getUrl()); - sendBroadcastIntent(sendIntent); - - DebugTool.logInfo(TAG, "send to url"); - - if ( (msg.getUrl() != null) ) - { - Thread handleOffboardTransmissionThread = new Thread() { - @Override - public void run() { - sendOnSystemRequestToUrl(msg); - } - }; - - handleOffboardTransmissionThread.start(); - } - } - } else if (functionName.equals(FunctionID.ON_PERMISSIONS_CHANGE.toString())) { - //OnPermissionsChange - - final OnPermissionsChange msg = new OnPermissionsChange(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onOnPermissionsChange(msg); - onRPCNotificationReceived(msg); - } - }); - } else { - _proxyListener.onOnPermissionsChange(msg); - onRPCNotificationReceived(msg); - } - } else if (functionName.equals(FunctionID.ON_TBT_CLIENT_STATE.toString())) { - // OnTBTClientState - - final OnTBTClientState msg = new OnTBTClientState(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onOnTBTClientState(msg); - onRPCNotificationReceived(msg); - } - }); - } else { - _proxyListener.onOnTBTClientState(msg); - onRPCNotificationReceived(msg); - } - } else if (functionName.equals(FunctionID.ON_BUTTON_PRESS.toString())) { - // OnButtonPress - - final OnButtonPress msg = new OnButtonPress(hash); - msg.format(rpcSpecVersion, true); - final OnButtonPress onButtonPressCompat = (OnButtonPress)handleButtonNotificationFormatting(msg); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onOnButtonPress(msg); - onRPCNotificationReceived(msg); - if(onButtonPressCompat != null){ - onRPCNotificationReceived(onButtonPressCompat); - _proxyListener.onOnButtonPress(onButtonPressCompat); - } - } - }); - } else { - _proxyListener.onOnButtonPress(msg); - onRPCNotificationReceived(msg); - if(onButtonPressCompat != null){ - onRPCNotificationReceived(onButtonPressCompat); - _proxyListener.onOnButtonPress(onButtonPressCompat); - } - } - } else if (functionName.equals(FunctionID.ON_BUTTON_EVENT.toString())) { - // OnButtonEvent - - final OnButtonEvent msg = new OnButtonEvent(hash); - msg.format(rpcSpecVersion, true); - final OnButtonEvent onButtonEventCompat = (OnButtonEvent)handleButtonNotificationFormatting(msg); - - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onOnButtonEvent(msg); - onRPCNotificationReceived(msg); - if(onButtonEventCompat != null){ - onRPCNotificationReceived(onButtonEventCompat); - _proxyListener.onOnButtonEvent(onButtonEventCompat); - } - } - }); - } else { - _proxyListener.onOnButtonEvent(msg); - onRPCNotificationReceived(msg); - if(onButtonEventCompat != null){ - onRPCNotificationReceived(onButtonEventCompat); - _proxyListener.onOnButtonEvent(onButtonEventCompat); - } - } - } else if (functionName.equals(FunctionID.ON_LANGUAGE_CHANGE.toString())) { - // OnLanguageChange - - final OnLanguageChange msg = new OnLanguageChange(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onOnLanguageChange(msg); - onRPCNotificationReceived(msg); - } - }); - } else { - _proxyListener.onOnLanguageChange(msg); - onRPCNotificationReceived(msg); - } - } else if (functionName.equals(FunctionID.ON_HASH_CHANGE.toString())) { - // OnLanguageChange - - final OnHashChange msg = new OnHashChange(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onOnHashChange(msg); - onRPCNotificationReceived(msg); - if (_bAppResumeEnabled) - { - _lastHashID = msg.getHashID(); - } - } - }); - } else { - _proxyListener.onOnHashChange(msg); - onRPCNotificationReceived(msg); - if (_bAppResumeEnabled) - { - _lastHashID = msg.getHashID(); - } - } - } else if (functionName.equals(FunctionID.ON_SYSTEM_REQUEST.toString())) { - // OnSystemRequest - - final OnSystemRequest msg = new OnSystemRequest(hash); - msg.format(rpcSpecVersion,true); - RequestType requestType = msg.getRequestType(); - if(msg.getUrl() != null) { - if (((requestType == RequestType.PROPRIETARY) && (msg.getFileType() == FileType.JSON)) - || ((requestType == RequestType.HTTP) && (msg.getFileType() == FileType.BINARY))) { - Thread handleOffboardTransmissionThread = new Thread() { - @Override - public void run() { - sendOnSystemRequestToUrl(msg); - } - }; - - handleOffboardTransmissionThread.start(); - } else if (requestType == RequestType.LOCK_SCREEN_ICON_URL) { - //Cache this for when the lockscreen is displayed - lockScreenIconRequest = msg; - } else if (requestType == RequestType.ICON_URL) { - if (msg.getUrl() != null) { - //Download the icon file and send SystemRequest RPC - Thread handleOffBoardTransmissionThread = new Thread() { - @Override - public void run() { - String urlHttps = msg.getUrl().replaceFirst("http://", "https://"); - byte[] file = FileUtls.downloadFile(urlHttps); - if (file != null) { - SystemRequest systemRequest = new SystemRequest(); - systemRequest.setFileName(msg.getUrl()); - systemRequest.setBulkData(file); - systemRequest.setRequestType(RequestType.ICON_URL); - try { - sendRPCMessagePrivate(systemRequest); - } catch (SdlException e) { - e.printStackTrace(); - } - } else { - DebugTool.logError(TAG, "File was null at: " + urlHttps); - } - } - }; - handleOffBoardTransmissionThread.start(); - } - } - } - - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onOnSystemRequest(msg); - onRPCNotificationReceived(msg); - } - }); - } else { - _proxyListener.onOnSystemRequest(msg); - onRPCNotificationReceived(msg); - } - } else if (functionName.equals(FunctionID.ON_AUDIO_PASS_THRU.toString())) { - // OnAudioPassThru - final OnAudioPassThru msg = new OnAudioPassThru(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onOnAudioPassThru(msg); - onRPCNotificationReceived(msg); - } - }); - } else { - _proxyListener.onOnAudioPassThru(msg); - onRPCNotificationReceived(msg); - } - } else if (functionName.equals(FunctionID.ON_VEHICLE_DATA.toString())) { - // OnVehicleData - final OnVehicleData msg = new OnVehicleData(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onOnVehicleData(msg); - onRPCNotificationReceived(msg); - } - }); - } else { - _proxyListener.onOnVehicleData(msg); - onRPCNotificationReceived(msg); - } - } - else if (functionName.equals(FunctionID.ON_APP_INTERFACE_UNREGISTERED.toString())) { - // OnAppInterfaceUnregistered - - _appInterfaceRegisterd = false; - synchronized(APP_INTERFACE_REGISTERED_LOCK) { - APP_INTERFACE_REGISTERED_LOCK.notify(); - } - - final OnAppInterfaceUnregistered msg = new OnAppInterfaceUnregistered(hash); - msg.format(rpcSpecVersion,true); - - Intent sendIntent = createBroadcastIntent(); - updateBroadcastIntent(sendIntent, "RPC_NAME", FunctionID.ON_APP_INTERFACE_UNREGISTERED.toString()); - updateBroadcastIntent(sendIntent, "TYPE", RPCMessage.KEY_NOTIFICATION); - updateBroadcastIntent(sendIntent, "DATA",serializeJSON(msg)); - sendBroadcastIntent(sendIntent); - - if (_advancedLifecycleManagementEnabled) { - // This requires the proxy to be cycled - - if(_mainUIHandler == null){ - _mainUIHandler = new Handler(Looper.getMainLooper()); - } - - //This needs to be ran on the main thread - - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - cycleProxy(SdlDisconnectedReason.convertAppInterfaceUnregisteredReason(msg.getReason())); - } - }); - } else { - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - ((IProxyListener)_proxyListener).onOnAppInterfaceUnregistered(msg); - onRPCNotificationReceived(msg); - } - }); - } else { - ((IProxyListener)_proxyListener).onOnAppInterfaceUnregistered(msg); - onRPCNotificationReceived(msg); - } - notifyProxyClosed("OnAppInterfaceUnregistered", null, SdlDisconnectedReason.APP_INTERFACE_UNREG); - } - } - else if (functionName.equals(FunctionID.ON_KEYBOARD_INPUT.toString())) { - final OnKeyboardInput msg = new OnKeyboardInput(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onOnKeyboardInput(msg); - onRPCNotificationReceived(msg); - } - }); - } else { - _proxyListener.onOnKeyboardInput(msg); - onRPCNotificationReceived(msg); - } - } - else if (functionName.equals(FunctionID.ON_TOUCH_EVENT.toString())) { - final OnTouchEvent msg = new OnTouchEvent(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onOnTouchEvent(msg); - onRPCNotificationReceived(msg); - } - }); - } else { - _proxyListener.onOnTouchEvent(msg); - onRPCNotificationReceived(msg); - } - } - else if (functionName.equals(FunctionID.ON_WAY_POINT_CHANGE.toString())) { - final OnWayPointChange msg = new OnWayPointChange(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onOnWayPointChange(msg); - onRPCNotificationReceived(msg); - } - }); - } else { - _proxyListener.onOnWayPointChange(msg); - onRPCNotificationReceived(msg); - } - } - else if (functionName.equals(FunctionID.ON_INTERIOR_VEHICLE_DATA.toString())) { - final OnInteriorVehicleData msg = new OnInteriorVehicleData(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onOnInteriorVehicleData(msg); - onRPCNotificationReceived(msg); - } - }); - } else { - _proxyListener.onOnInteriorVehicleData(msg); - onRPCNotificationReceived(msg); - } - } - else if (functionName.equals(FunctionID.ON_RC_STATUS.toString())) { - final OnRCStatus msg = new OnRCStatus(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onOnRCStatus(msg); - onRPCNotificationReceived(msg); - } - }); - } else { - _proxyListener.onOnRCStatus(msg); - onRPCNotificationReceived(msg); - } - } else if (functionName.equals(FunctionID.ON_APP_SERVICE_DATA.toString())) { - final OnAppServiceData msg = new OnAppServiceData(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onOnAppServiceData(msg); - onRPCNotificationReceived(msg); - } - }); - } else { - _proxyListener.onOnAppServiceData(msg); - onRPCNotificationReceived(msg); - } - } else if (functionName.equals(FunctionID.ON_SYSTEM_CAPABILITY_UPDATED.toString())) { - final OnSystemCapabilityUpdated msg = new OnSystemCapabilityUpdated(hash); - msg.format(rpcSpecVersion, true); - if (_callbackToUIThread) { - // Run in UI thread - _mainUIHandler.post(new Runnable() { - @Override - public void run() { - _proxyListener.onOnSystemCapabilityUpdated(msg); - onRPCNotificationReceived(msg); - } - }); - } else { - _proxyListener.onOnSystemCapabilityUpdated(msg); - onRPCNotificationReceived(msg); - } - } else { - if (_sdlMsgVersion != null) { - DebugTool.logInfo(TAG, "Unrecognized notification Message: " + functionName + - " connected to SDL using message version: " + _sdlMsgVersion.getMajorVersion() + "." + _sdlMsgVersion.getMinorVersion()); - } else { - DebugTool.logInfo(TAG, "Unrecognized notification Message: " + functionName); - } - } // end-if - } // end-if notification - - SdlTrace.logProxyEvent("Proxy received RPC Message: " + functionName, SDL_LIB_TRACE_KEY); - } - - //FIXME - /** - * Temporary method to bridge the new PLAY_PAUSE and OKAY button functionality with the old - * OK button name. This should be removed during the next major release - * @param notification - */ - private RPCNotification handleButtonNotificationFormatting(RPCNotification notification){ - if(FunctionID.ON_BUTTON_EVENT.toString().equals(notification.getFunctionName()) - || FunctionID.ON_BUTTON_PRESS.toString().equals(notification.getFunctionName())){ - - ButtonName buttonName = (ButtonName)notification.getObject(ButtonName.class, OnButtonEvent.KEY_BUTTON_NAME); - ButtonName compatBtnName = null; - - if(rpcSpecVersion != null && rpcSpecVersion.getMajor() >= 5){ - if(ButtonName.PLAY_PAUSE.equals(buttonName)){ - compatBtnName = ButtonName.OK; - } - }else{ // rpc spec version is either null or less than 5 - if(ButtonName.OK.equals(buttonName)){ - compatBtnName = ButtonName.PLAY_PAUSE; - } - } - - try { - if (compatBtnName != null) { //There is a button name that needs to be swapped out - RPCNotification notification2; - //The following is done because there is currently no way to make a deep copy - //of an RPC. Since this code will be removed, it's ugliness is borderline acceptable. - if (notification instanceof OnButtonEvent) { - OnButtonEvent onButtonEvent = new OnButtonEvent(); - onButtonEvent.setButtonEventMode(((OnButtonEvent) notification).getButtonEventMode()); - onButtonEvent.setCustomButtonID(((OnButtonEvent) notification).getCustomButtonID()); - notification2 = onButtonEvent; - } else if (notification instanceof OnButtonPress) { - OnButtonPress onButtonPress = new OnButtonPress(); - onButtonPress.setButtonPressMode(((OnButtonPress) notification).getButtonPressMode()); - onButtonPress.setCustomButtonID(((OnButtonPress) notification).getCustomButtonID()); - notification2 = onButtonPress; - } else { - return null; - } - - notification2.setParameters(OnButtonEvent.KEY_BUTTON_NAME, compatBtnName); - return notification2; - } - }catch (Exception e){ - //Should never get here - } - } - return null; - } - - /** - * Get SDL Message Version - * @return SdlMsgVersion - * @throws SdlException - */ - public SdlMsgVersion getSdlMsgVersion() throws SdlException{ - return _sdlMsgVersion; - } - - /** - * Takes a list of RPCMessages and sends it to SDL in a synchronous fashion. Responses are captured through callback on OnMultipleRequestListener. - * For sending requests asynchronously, use sendRequests
- * - * NOTE: This will override any listeners on individual RPCs - * - * @param rpcs is the list of RPCMessages being sent - * @param listener listener for updates and completions - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void sendSequentialRequests(final List rpcs, final OnMultipleRequestListener listener) throws SdlException { - if (_proxyDisposed) { - throw new SdlException("This object has been disposed, it is no long capable of executing methods.", SdlExceptionCause.SDL_PROXY_DISPOSED); - } - - SdlTrace.logProxyEvent("Application called sendSequentialRequests", SDL_LIB_TRACE_KEY); - - synchronized(CONNECTION_REFERENCE_LOCK) { - if (!getIsConnected()) { - SdlTrace.logProxyEvent("Application attempted to call sendSequentialRequests without a connected transport.", SDL_LIB_TRACE_KEY); - throw new SdlException("There is no valid connection to SDL. sendSequentialRequests cannot be called until SDL has been connected.", SdlExceptionCause.SDL_UNAVAILABLE); - } - } - - if (rpcs == null){ - //Log error here - throw new SdlException("You must send some RPCs", SdlExceptionCause.INVALID_ARGUMENT); - } - - // Break out of recursion, we have finished the requests - if (rpcs.size() == 0) { - if(listener != null){ - listener.onFinished(); - } - return; - } - - RPCMessage rpc = rpcs.remove(0); - - // Request Specifics - if (rpc.getMessageType().equals(RPCMessage.KEY_REQUEST)) { - RPCRequest request = (RPCRequest) rpc; - request.setCorrelationID(CorrelationIdGenerator.generateId()); - - final OnRPCResponseListener devOnRPCResponseListener = request.getOnRPCResponseListener(); - - request.setOnRPCResponseListener(new OnRPCResponseListener() { - @Override - public void onResponse(int correlationId, RPCResponse response) { - if (devOnRPCResponseListener != null){ - devOnRPCResponseListener.onResponse(correlationId, response); - } - if (listener != null) { - listener.onResponse(correlationId, response); - listener.onUpdate(rpcs.size()); - - } - try { - // recurse after onResponse - sendSequentialRequests(rpcs, listener); - } catch (SdlException e) { - e.printStackTrace(); - if (listener != null) { - GenericResponse genericResponse = new GenericResponse(false, Result.GENERIC_ERROR); - genericResponse.setInfo(e.toString()); - listener.onResponse(correlationId, genericResponse); - } - } - } - }); - sendRPCMessagePrivate(request); - } else { - // Notifications and Responses - sendRPCMessagePrivate(rpc); - if (listener != null) { - listener.onUpdate(rpcs.size()); - } - // recurse after sending a notification or response as there is no response. - try { - sendSequentialRequests(rpcs, listener); - } catch (SdlException e) { - e.printStackTrace(); - if (listener != null) { - GenericResponse response = new GenericResponse(false, Result.REJECTED); - response.setInfo(e.toString()); - listener.onResponse(0, response); - } - } - } - - - } - - /** - * Takes a list of RPCMessages and sends it to SDL. Responses are captured through callback on OnMultipleRequestListener. - * For sending requests synchronously, use sendSequentialRequests
- * - * NOTE: This will override any listeners on individual RPCs - * - * @param rpcs is the list of RPCMessages being sent - * @param listener listener for updates and completions - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void sendRequests(List rpcs, final OnMultipleRequestListener listener) throws SdlException { - - if (_proxyDisposed) { - throw new SdlException("This object has been disposed, it is no long capable of executing methods.", SdlExceptionCause.SDL_PROXY_DISPOSED); - } - - SdlTrace.logProxyEvent("Application called sendRequests", SDL_LIB_TRACE_KEY); - - synchronized(CONNECTION_REFERENCE_LOCK) { - if (!getIsConnected()) { - SdlTrace.logProxyEvent("Application attempted to call sendRequests without a connected transport.", SDL_LIB_TRACE_KEY); - throw new SdlException("There is no valid connection to SDL. sendRequests cannot be called until SDL has been connected.", SdlExceptionCause.SDL_UNAVAILABLE); - } - } - - if (rpcs == null){ - //Log error here - throw new SdlException("You must send some RPCs, the array is null", SdlExceptionCause.INVALID_ARGUMENT); - } - - int arraySize = rpcs.size(); - - if (arraySize == 0) { - throw new SdlException("You must send some RPCs, the array is empty", SdlExceptionCause.INVALID_ARGUMENT); - } - - for (int i = 0; i < arraySize; i++) { - RPCMessage rpc = rpcs.get(i); - // Request Specifics - if (rpc.getMessageType().equals(RPCMessage.KEY_REQUEST)) { - RPCRequest request = (RPCRequest) rpc; - final OnRPCResponseListener devOnRPCResponseListener = request.getOnRPCResponseListener(); - request.setCorrelationID(CorrelationIdGenerator.generateId()); - if (listener != null) { - listener.addCorrelationId(request.getCorrelationID()); - request.setOnRPCResponseListener(new OnRPCResponseListener() { - @Override - public void onResponse(int correlationId, RPCResponse response) { - if (devOnRPCResponseListener != null){ - devOnRPCResponseListener.onResponse(correlationId, response); - } - if (listener.getSingleRpcResponseListener() != null) { - listener.getSingleRpcResponseListener().onResponse(correlationId, response); - } - } - }); - } - sendRPCMessagePrivate(request); - }else { - // Notifications and Responses - sendRPCMessagePrivate(rpc); - if (listener != null){ - listener.onUpdate(rpcs.size()); - if (rpcs.size() == 0){ - listener.onFinished(); - } - } - } - } - } - - public void sendRPC(RPCMessage message) throws SdlException { - if (_proxyDisposed) { - throw new SdlException("This object has been disposed, it is no long capable of executing methods.", SdlExceptionCause.SDL_PROXY_DISPOSED); - } - - // Test if request is null - if (message == null) { - SdlTrace.logProxyEvent("Application called sendRPCRequest method with a null RPCRequest.", SDL_LIB_TRACE_KEY); - throw new IllegalArgumentException("sendRPCRequest cannot be called with a null request."); - } - - SdlTrace.logProxyEvent("Application called sendRPCRequest method for RPCRequest: ." + message.getFunctionName(), SDL_LIB_TRACE_KEY); - - // Test if SdlConnection is null - synchronized(CONNECTION_REFERENCE_LOCK) { - if (!getIsConnected()) { - SdlTrace.logProxyEvent("Application attempted to send and RPCRequest without a connected transport.", SDL_LIB_TRACE_KEY); - throw new SdlException("There is no valid connection to SDL. sendRPCRequest cannot be called until SDL has been connected.", SdlExceptionCause.SDL_UNAVAILABLE); - } - } - - // Test for illegal correlation ID - if (message.getMessageType().equals(RPCMessage.KEY_REQUEST)) { - RPCRequest request = (RPCRequest) message; - if (isCorrelationIDProtected(request.getCorrelationID())) { - - SdlTrace.logProxyEvent("Application attempted to use the reserved correlation ID, " + request.getCorrelationID(), SDL_LIB_TRACE_KEY); - throw new SdlException("Invalid correlation ID. The correlation ID, " + request.getCorrelationID() - + " , is a reserved correlation ID.", SdlExceptionCause.RESERVED_CORRELATION_ID); - } - } - // Throw exception if RPCRequest is sent when SDL is unavailable - if (!_appInterfaceRegisterd && !message.getFunctionName().equals(FunctionID.REGISTER_APP_INTERFACE.toString())) { - - SdlTrace.logProxyEvent("Application attempted to send an RPCRequest (non-registerAppInterface), before the interface was registerd.", SDL_LIB_TRACE_KEY); - throw new SdlException("SDL is currently unavailable. RPC Requests cannot be sent.", SdlExceptionCause.SDL_UNAVAILABLE); - } - - if (_advancedLifecycleManagementEnabled) { - if (message.getFunctionName().equals(FunctionID.REGISTER_APP_INTERFACE.toString()) - || message.getFunctionName().equals(FunctionID.UNREGISTER_APP_INTERFACE.toString())) { - - SdlTrace.logProxyEvent("Application attempted to send a RegisterAppInterface or UnregisterAppInterface while using ALM.", SDL_LIB_TRACE_KEY); - throw new SdlException("The RPCRequest, " + message.getFunctionName() + - ", is un-allowed using the Advanced Lifecycle Management Model.", SdlExceptionCause.INCORRECT_LIFECYCLE_MODEL); - } - } - - sendRPCMessagePrivate(message); - } - - /** - * Takes an RPCRequest and sends it to SDL. Responses are captured through callback on IProxyListener. - * - * @param request is the RPCRequest being sent - * @throws SdlException if an unrecoverable error is encountered - * @deprecated - use sendRPC instead - */ - @Deprecated - public void sendRPCRequest(RPCRequest request) throws SdlException { - sendRPC(request); - } - - protected void notifyProxyClosed(final String info, final Exception e, final SdlDisconnectedReason reason) { - SdlTrace.logProxyEvent("NotifyProxyClose", SDL_LIB_TRACE_KEY); - DebugTool.logInfo(TAG, "notifyProxyClosed: " + info); - OnProxyClosed message = new OnProxyClosed(info, e, reason); - queueInternalMessage(message); - } - - private void passErrorToProxyListener(final String info, final Exception e) { - - OnError message = new OnError(info, e); - queueInternalMessage(message); - } - - private void startRPCProtocolSession() { - - // Set Proxy Lifecyclek Available - if (_advancedLifecycleManagementEnabled) { - - try { - registerAppInterfacePrivate( - _sdlMsgVersionRequest, - _applicationName, - _ttsName, - _ngnMediaScreenAppName, - _vrSynonyms, - _isMediaApp, - _sdlLanguageDesired, - _hmiDisplayLanguageDesired, - _appType, - _appID, - _dayColorScheme, - _nightColorScheme, - REGISTER_APP_INTERFACE_CORRELATION_ID); - - } catch (Exception e) { - notifyProxyClosed("Failed to register application interface with SDL. Check parameter values given to SdlProxy constructor.", e, SdlDisconnectedReason.SDL_REGISTRATION_ERROR); - } - } else { - InternalProxyMessage message = new InternalProxyMessage(InternalProxyMessage.OnProxyOpened); - queueInternalMessage(message); - } - } - - // Queue internal callback message - private void queueInternalMessage(InternalProxyMessage message) { - synchronized(INTERNAL_MESSAGE_QUEUE_THREAD_LOCK) { - if (_internalProxyMessageDispatcher != null) { - _internalProxyMessageDispatcher.queueMessage(message); - } - } - } - - // Queue incoming ProtocolMessage - private void queueIncomingMessage(ProtocolMessage message) { - synchronized(INCOMING_MESSAGE_QUEUE_THREAD_LOCK) { - if (_incomingProxyMessageDispatcher != null) { - _incomingProxyMessageDispatcher.queueMessage(message); - } - } - } - - private FileInputStream getFileInputStream(String sLocalFile) - { - FileInputStream is = null; - try - { - is = new FileInputStream(sLocalFile); - } - catch (IOException e1) - { - e1.printStackTrace(); - } - return is; - } - - private Long getFileInputStreamSize(FileInputStream is) - { - Long lSize = null; - - try - { - lSize = is.getChannel().size(); - } - catch (IOException e) - { - e.printStackTrace(); - } - return lSize; - } - - private void closeFileInputStream(FileInputStream is) - { - try - { - is.close(); - } - catch (Exception e) - { - e.printStackTrace(); - } - } - - @SuppressWarnings("unchecked") - private RPCStreamController startRPCStream(String sLocalFile, PutFile request, SessionType sType, byte rpcSessionID, Version protocolVersion) - { - if (sdlSession == null) return null; - - FileInputStream is = getFileInputStream(sLocalFile); - if (is == null) return null; - - Long lSize = getFileInputStreamSize(is); - if (lSize == null) - { - closeFileInputStream(is); - return null; - } - - try { - StreamRPCPacketizer rpcPacketizer = null;//new StreamRPCPacketizer((SdlProxyBase) this, sdlSession, is, request, sType, rpcSessionID, protocolVersion, rpcSpecVersion, lSize, sdlSession); - rpcPacketizer.start(); - return new RPCStreamController(rpcPacketizer, request.getCorrelationID()); - } catch (Exception e) { - DebugTool.logError(TAG, "SyncConnectionUnable to start streaming:", e); - return null; - } - } - - @SuppressWarnings({"unchecked", "UnusedReturnValue"}) - private RPCStreamController startRPCStream(InputStream is, PutFile request, SessionType sType, byte rpcSessionID, Version protocolVersion) - { - if (sdlSession == null) return null; - Long lSize = request.getLength(); - - if (lSize == null) - { - return null; - } - - try { - StreamRPCPacketizer rpcPacketizer = null;//new StreamRPCPacketizer((SdlProxyBase) this, sdlSession, is, request, sType, rpcSessionID, protocolVersion, rpcSpecVersion, lSize, sdlSession); - rpcPacketizer.start(); - return new RPCStreamController(rpcPacketizer, request.getCorrelationID()); - } catch (Exception e) { - DebugTool.logError(TAG, "SyncConnection Unable to start streaming:", e); - return null; - } - } - - private RPCStreamController startPutFileStream(String sPath, PutFile msg) { - if (sdlSession == null) return null; - return startRPCStream(sPath, msg, SessionType.RPC, (byte)sdlSession.getSessionId(), protocolVersion); - } - - private RPCStreamController startPutFileStream(InputStream is, PutFile msg) { - if (sdlSession == null) return null; - if (is == null) return null; - return startRPCStream(is, msg, SessionType.RPC, (byte)sdlSession.getSessionId(), protocolVersion); - } - - @SuppressWarnings("UnusedReturnValue") - public boolean startRPCStream(InputStream is, RPCRequest msg) { - if (sdlSession == null) return false; - //sdlSession.startRPCStream(is, msg, SessionType.RPC, sdlSession.getSessionId(), (byte)getProtocolVersion().getMajor()); - return true; - } - - public OutputStream startRPCStream(RPCRequest msg) { - if (sdlSession == null) return null; - return null;//sdlSession.startRPCStream(msg, SessionType.RPC, sdlSession.getSessionId(), (byte)getProtocolVersion().getMajor()); - } - - public void endRPCStream() { - if (sdlSession == null) return; - //sdlSession.stopRPCStream(); - } - - private class CallableMethod implements Callable { - - private final long waitTime; - - public CallableMethod(int timeInMillis){ - this.waitTime=timeInMillis; - } - @Override - public Void call() { - try { - Thread.sleep(waitTime); - } catch (InterruptedException e) { - e.printStackTrace(); - } - return null; - } - } - - public FutureTask createFutureTask(CallableMethod callMethod){ - return new FutureTask(callMethod); - } - - public ScheduledExecutorService createScheduler(){ - return Executors.newSingleThreadScheduledExecutor(); - } - - @SuppressWarnings("unused") - public void startService(SessionType serviceType, boolean isEncrypted){ - sdlSession.startService(serviceType, isEncrypted); - } - - @SuppressWarnings("unused") - public void endService(SessionType serviceType){ - sdlSession.endService(serviceType); - } - - - - /** - * @deprecated - *Opens the video service (serviceType 11) and subsequently streams raw H264 video from an InputStream provided by the app - *@return true if service is opened successfully and stream is started, return false otherwise - * @see #startRemoteDisplayStream(Context, Class, VideoStreamingParameters, boolean) startRemoteDisplayStream - * @see #startVideoStream(boolean, VideoStreamingParameters) startVideoStream - * @see #createOpenGLInputSurface(int, int, int, int, int, boolean) createOpenGLInputSurface - */ - @SuppressWarnings("unused") - @Deprecated - public boolean startH264(InputStream is, boolean isEncrypted) { - - if (sdlSession == null) return false; - - navServiceStartResponseReceived = false; - navServiceStartResponse = false; - navServiceStartRejectedParams = null; - - // When startH264() API is used, we will not send video format / width / height information - // with StartService. (Reasons: InputStream does not provide timestamp information so RTP - // cannot be used. startH264() does not provide with/height information.) - VideoStreamingParameters emptyParam = new VideoStreamingParameters(); - emptyParam.setResolution(null); - emptyParam.setFormat(null); - sdlSession.setDesiredVideoParams(emptyParam); - - sdlSession.startService(SessionType.NAV, isEncrypted); - addNavListener(); - FutureTask fTask = createFutureTask(new CallableMethod(RESPONSE_WAIT_TIME)); - ScheduledExecutorService scheduler = createScheduler(); - scheduler.execute(fTask); - - //noinspection StatementWithEmptyBody - while (!navServiceStartResponseReceived && !fTask.isDone()); - scheduler.shutdown(); - - if (navServiceStartResponse) { - try { - //sdlSession.startStream(is, SessionType.NAV, sdlSession.getSessionId()); - return true; - } catch (Exception e) { - return false; - } - } else { - return false; - } - } - - /** - * @deprecated - *Opens the video service (serviceType 11) and subsequently provides an OutputStream to the app to use for a raw H264 video stream - *@return OutputStream if service is opened successfully and stream is started, return null otherwise - * @see #startRemoteDisplayStream(Context, Class, VideoStreamingParameters, boolean) startRemoteDisplayStream - * @see #startVideoStream(boolean, VideoStreamingParameters) startVideoStream - * @see #createOpenGLInputSurface(int, int, int, int, int, boolean) createOpenGLInputSurface - */ - @SuppressWarnings("unused") - @Deprecated - public OutputStream startH264(boolean isEncrypted) { - - if (sdlSession == null) return null; - - navServiceStartResponseReceived = false; - navServiceStartResponse = false; - navServiceStartRejectedParams = null; - - // When startH264() API is used, we will not send video format / width / height information - // with StartService. (Reasons: OutputStream does not provide timestamp information so RTP - // cannot be used. startH264() does not provide with/height information.) - VideoStreamingParameters emptyParam = new VideoStreamingParameters(); - emptyParam.setResolution(null); - emptyParam.setFormat(null); - sdlSession.setDesiredVideoParams(emptyParam); - - sdlSession.startService(SessionType.NAV, isEncrypted); - addNavListener(); - FutureTask fTask = createFutureTask(new CallableMethod(RESPONSE_WAIT_TIME)); - ScheduledExecutorService scheduler = createScheduler(); - scheduler.execute(fTask); - - //noinspection StatementWithEmptyBody - while (!navServiceStartResponseReceived && !fTask.isDone()); - scheduler.shutdown(); - - if (navServiceStartResponse) { - try { - return null;//sdlSession.startStream(SessionType.NAV, sdlSession.getSessionId()); - } catch (Exception e) { - return null; - } - } else { - return null; - } - } - - /** - *Closes the opened video service (serviceType 11) - *@return true if the video service is closed successfully, return false otherwise - */ - @SuppressWarnings("unused") - @Deprecated - public boolean endH264() { - return endVideoStream(); - } - /** - *Pauses the stream for the opened audio service (serviceType 10) - *@return true if the audio service stream is paused successfully, return false otherwise - */ - @SuppressWarnings("unused") - @Deprecated - public boolean pausePCM() { - return pauseAudioStream(); - } - - /** - *Pauses the stream for the opened video service (serviceType 11) - *@return true if the video service stream is paused successfully, return false otherwise - */ - @SuppressWarnings("unused") - @Deprecated - public boolean pauseH264() { - return pauseVideoStream(); - } - - /** - *Resumes the stream for the opened audio service (serviceType 10) - *@return true if the audio service stream is resumed successfully, return false otherwise - */ - @SuppressWarnings("unused") - @Deprecated - public boolean resumePCM() { - return resumeAudioStream(); - } - - /** - *Resumes the stream for the opened video service (serviceType 11) - *@return true if the video service is resumed successfully, return false otherwise - */ - @SuppressWarnings("unused") - @Deprecated - public boolean resumeH264() { - return resumeVideoStream(); - } - - - /** - *Opens the audio service (serviceType 10) and subsequently streams raw PCM audio from an InputStream provided by the app - *@return true if service is opened successfully and stream is started, return false otherwise - */ - @SuppressWarnings("unused") - @Deprecated - public boolean startPCM(InputStream is, boolean isEncrypted) { - if (sdlSession == null) return false; - - pcmServiceStartResponseReceived = false; - pcmServiceStartResponse = false; - sdlSession.startService(SessionType.PCM, isEncrypted); - - FutureTask fTask = createFutureTask(new CallableMethod(RESPONSE_WAIT_TIME)); - ScheduledExecutorService scheduler = createScheduler(); - scheduler.execute(fTask); - - //noinspection StatementWithEmptyBody - while (!pcmServiceStartResponseReceived && !fTask.isDone()); - scheduler.shutdown(); - - if (pcmServiceStartResponse) { - try { - //sdlSession.startStream(is, SessionType.PCM, sdlSession.getSessionId()); - return true; - } catch (Exception e) { - return false; - } - } else { - return false; - } - } - - /** - *Opens the audio service (serviceType 10) and subsequently provides an OutputStream to the app - *@return OutputStream if service is opened successfully and stream is started, return null otherwise - */ - @SuppressWarnings("unused") - @Deprecated - public OutputStream startPCM(boolean isEncrypted) { - if (sdlSession == null) return null; - - pcmServiceStartResponseReceived = false; - pcmServiceStartResponse = false; - sdlSession.startService(SessionType.PCM, isEncrypted); - - FutureTask fTask = createFutureTask(new CallableMethod(RESPONSE_WAIT_TIME)); - ScheduledExecutorService scheduler = createScheduler(); - scheduler.execute(fTask); - - //noinspection StatementWithEmptyBody - while (!pcmServiceStartResponseReceived && !fTask.isDone()); - scheduler.shutdown(); - - if (pcmServiceStartResponse) { - try { - return null; - //return sdlSession.startStream(SessionType.PCM, sdlSession.getSessionId()); - } catch (Exception e) { - return null; - } - } else { - if (pcmServiceStartRejectedParams != null) { - StringBuilder builder = new StringBuilder(); - for (String paramName : pcmServiceStartRejectedParams) { - if (builder.length() > 0) { - builder.append(", "); - } - builder.append(paramName); - } - DebugTool.logWarning(TAG, "StartService for nav failed. Rejected params: " + builder.toString()); - - } else { - DebugTool.logWarning(TAG, "StartService for nav failed (rejected params not supplied)"); - } - return null; - } - } - - /** - *Closes the opened audio service (serviceType 10) - *@return true if the audio service is closed successfully, return false otherwise - */ - @SuppressWarnings("unused") - @Deprecated - public boolean endPCM() { - return endAudioStream(); - } - - /** - * Opens a video service (service type 11) and subsequently provides an IVideoStreamListener - * to the app to send video data. The supplied VideoStreamingParameters will be set as desired parameters - * that will be used to negotiate - * - *

NOTE: IF USING SECONDARY TRANSPORTS, THE VIDEO SERVICE MUST BE STARTED BEFORE CALLING THIS - * THIS METHOD. USE A `ISdlServiceListener` TO BE NOTIFIED THAT IT STARTS THEN CALL THIS METHOD TO - * START STREAMING. ADD A LISTENER USE {@link #addServiceListener(SessionType, ISdlServiceListener)}. - * - * @param isEncrypted Specify true if packets on this service have to be encrypted - * @param parameters Video streaming parameters including: codec which will be used for streaming (currently, only - * VideoStreamingCodec.H264 is accepted), height and width of the video in pixels. - * - * @return IVideoStreamListener interface if service is opened successfully and streaming is - * started, null otherwise - * - * @see ISdlServiceListener - */ - @SuppressWarnings("unused") - public IVideoStreamListener startVideoStream(boolean isEncrypted, VideoStreamingParameters parameters) { - if (sdlSession == null) { - DebugTool.logWarning(TAG, "SdlSession is not created yet."); - return null; - } - if (!sdlSession.getIsConnected()) { - DebugTool.logWarning(TAG, "Connection is not available."); - return null; - } - - sdlSession.setDesiredVideoParams(parameters); - - VideoStreamingParameters acceptedParams = tryStartVideoStream(isEncrypted, parameters); - if (acceptedParams != null) { - return null;// sdlSession.startVideoStream(); - } else { - return null; - } - } - - /** - * This method will try to start the video service with the requested parameters. - * When it returns it will attempt to store the accepted parameters if available. - * @param isEncrypted if the service should be encrypted - * @param parameters the desiered video streaming parameters - */ - public void startVideoService(boolean isEncrypted, VideoStreamingParameters parameters) { - if (sdlSession == null) { - DebugTool.logWarning(TAG, "SdlSession is not created yet."); - return; - } - if (!sdlSession.getIsConnected()) { - DebugTool.logWarning(TAG, "Connection is not available."); - return; - } - - sdlSession.setDesiredVideoParams(parameters); - - tryStartVideoStream(isEncrypted, parameters); - } - - /** - *Closes the opened video service (serviceType 11) - *@return true if the video service is closed successfully, return false otherwise - */ - @SuppressWarnings("unused") - public boolean endVideoStream() { - if (sdlSession == null){ return false; } - - navServiceEndResponseReceived = false; - navServiceEndResponse = false; - //sdlSession.stopVideoStream(); - - FutureTask fTask = createFutureTask(new CallableMethod(RESPONSE_WAIT_TIME)); - ScheduledExecutorService scheduler = createScheduler(); - scheduler.execute(fTask); - - //noinspection StatementWithEmptyBody - while (!navServiceEndResponseReceived && !fTask.isDone()); - scheduler.shutdown(); - - return navServiceEndResponse; - } - - /** - *Pauses the stream for the opened video service (serviceType 11) - *@return true if the video service stream is paused successfully, return false otherwise - */ - @SuppressWarnings("unused") - public boolean pauseVideoStream() { - return false;//sdlSession != null && sdlSession.pauseVideoStream(); - } - - /** - *Resumes the stream for the opened video service (serviceType 11) - *@return true if the video service is resumed successfully, return false otherwise - */ - @SuppressWarnings("unused") - public boolean resumeVideoStream() { - return false;//sdlSession != null && sdlSession.resumeVideoStream(); - } - - /** - * Opens the video service (serviceType 11) and creates a Surface (used for streaming video) with input parameters provided by the app - * @param frameRate - specified rate of frames to utilize for creation of Surface - * @param iFrameInterval - specified interval to utilize for creation of Surface - * @param width - specified width to utilize for creation of Surface - * @param height - specified height to utilize for creation of Surface - * @param bitrate - specified bitrate to utilize for creation of Surface - *@return Surface if service is opened successfully and stream is started, return null otherwise - */ - @SuppressWarnings("unused") - public Surface createOpenGLInputSurface(int frameRate, int iFrameInterval, int width, - int height, int bitrate, boolean isEncrypted) { - - if (sdlSession == null || !sdlSession.getIsConnected()){ - return null; - } - - VideoStreamingParameters desired = new VideoStreamingParameters(); - desired.setFrameRate(frameRate); - desired.setInterval(iFrameInterval); - ImageResolution resolution = new ImageResolution(); - resolution.setResolutionWidth(width); - resolution.setResolutionHeight(height); - desired.setResolution(resolution); - desired.setBitrate(bitrate); - - VideoStreamingParameters acceptedParams = tryStartVideoStream(isEncrypted, desired); - if (acceptedParams != null) { - return null;//sdlSession.createOpenGLInputSurface(frameRate, iFrameInterval, width, - //height, bitrate, SessionType.NAV, sdlSession.getSessionId()); - } else { - return null; - } - } - - /** - * Starts streaming a remote display to the module if there is a connected session. This method of streaming requires the device to be on API level 19 or higher - * @param context a context that can be used to create the remote display - * @param remoteDisplay class object of the remote display. This class will be used to create an instance of the remote display and will be projected to the module - * @param parameters streaming parameters to be used when streaming. If null is sent in, the default/optimized options will be used. - * If you are unsure about what parameters to be used it is best to just send null and let the system determine what - * works best for the currently connected module. - * - * @param encrypted a flag of if the stream should be encrypted. Only set if you have a supplied encryption library that the module can understand. - */ - @TargetApi(19) - public void startRemoteDisplayStream(Context context, final Class remoteDisplay, final VideoStreamingParameters parameters, final boolean encrypted){ - if(protocolVersion!= null && protocolVersion.getMajor() >= 5 && !_systemCapabilityManager.isCapabilitySupported(SystemCapabilityType.VIDEO_STREAMING)){ - DebugTool.logError(TAG, "Video streaming not supported on this module"); - return; - } - //Create streaming manager - if(manager == null){ - manager = new VideoStreamingManager(context,this._internalInterface); - } - - if(parameters == null){ - if(protocolVersion!= null && protocolVersion.getMajor() >= 5) { - _systemCapabilityManager.getCapability(SystemCapabilityType.VIDEO_STREAMING, new OnSystemCapabilityListener() { - @Override - public void onCapabilityRetrieved(Object capability) { - VideoStreamingParameters params = new VideoStreamingParameters(); - params.update((VideoStreamingCapability)capability); //Streaming parameters are ready time to stream - sdlSession.setDesiredVideoParams(params); - manager.startVideoStreaming(remoteDisplay, params, encrypted); - } - - @Override - public void onError(String info) { - DebugTool.logError(TAG, "Error retrieving video streaming capability: " + info); - - } - }); - }else{ - //We just use default video streaming params - VideoStreamingParameters params = new VideoStreamingParameters(); - DisplayCapabilities dispCap = (DisplayCapabilities)_systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAY); - if(dispCap !=null){ - params.setResolution(dispCap.getScreenParams().getImageResolution()); - } - sdlSession.setDesiredVideoParams(params); - manager.startVideoStreaming(remoteDisplay,params, encrypted); - } - }else{ - sdlSession.setDesiredVideoParams(parameters); - manager.startVideoStreaming(remoteDisplay,parameters, encrypted); - } - } - - /** - * Stops the remote display stream if one has been started - */ - public void stopRemoteDisplayStream(){ - if(manager!=null){ - manager.dispose(); - } - manager = null; - } - - /** - * Try to open a video service by using the video streaming parameters supplied. - * - * Only information from codecs, width and height are used during video format negotiation. - * - * @param isEncrypted Specify true if packets on this service have to be encrypted - * @param parameters VideoStreamingParameters that are desired. Does not guarantee this is what will be accepted. - * - * @return If the service is opened successfully, an instance of VideoStreamingParams is - * returned which contains accepted video format. If the service is opened with legacy - * mode (i.e. without any negotiation) then an instance of VideoStreamingParams is - * returned. If the service was not opened then null is returned. - */ - @SuppressWarnings("unused") - private VideoStreamingParameters tryStartVideoStream(boolean isEncrypted, VideoStreamingParameters parameters) { - if (sdlSession == null) { - DebugTool.logWarning(TAG, "SdlSession is not created yet."); - return null; - } - if(protocolVersion!= null && protocolVersion.getMajor() >= 5 && !_systemCapabilityManager.isCapabilitySupported(SystemCapabilityType.VIDEO_STREAMING)){ - DebugTool.logWarning(TAG, "Module doesn't support video streaming."); - return null; - } - if (parameters == null) { - DebugTool.logWarning(TAG, "Video parameters were not supplied."); - return null; - } - - if(!navServiceStartResponseReceived || !navServiceStartResponse //If we haven't started the service before - || (navServiceStartResponse && isEncrypted && !sdlSession.isServiceProtected(SessionType.NAV))) { //Or the service has been started but we'd like to start an encrypted one - sdlSession.setDesiredVideoParams(parameters); - - navServiceStartResponseReceived = false; - navServiceStartResponse = false; - navServiceStartRejectedParams = null; - - sdlSession.startService(SessionType.NAV, isEncrypted); - addNavListener(); - FutureTask fTask = createFutureTask(new CallableMethod(RESPONSE_WAIT_TIME)); - ScheduledExecutorService scheduler = createScheduler(); - scheduler.execute(fTask); - - //noinspection StatementWithEmptyBody - while (!navServiceStartResponseReceived && !fTask.isDone()) ; - scheduler.shutdown(); - } - - if (navServiceStartResponse) { - if(protocolVersion!= null && protocolVersion.getMajor() < 5){ //Versions 1-4 do not support streaming parameter negotiations - sdlSession.setAcceptedVideoParams(parameters); - } - return sdlSession.getAcceptedVideoParams(); - } - - if (navServiceStartRejectedParams != null) { - StringBuilder builder = new StringBuilder(); - for (String paramName : navServiceStartRejectedParams) { - if (builder.length() > 0) { - builder.append(", "); - } - builder.append(paramName); - } - - DebugTool.logWarning(TAG, "StartService for nav failed. Rejected params: " + builder.toString()); - - } else { - DebugTool.logWarning(TAG, "StartService for nav failed (rejected params not supplied)"); - } - - return null; - } - - /** - *Starts the MediaCodec encoder utilized in conjunction with the Surface returned via the createOpenGLInputSurface method - */ - @SuppressWarnings("unused") - public void startEncoder () { - if (sdlSession == null || !sdlSession.getIsConnected()) return; - - //sdlSession.startEncoder(); - } - - /** - *Releases the MediaCodec encoder utilized in conjunction with the Surface returned via the createOpenGLInputSurface method - */ - @SuppressWarnings("unused") - public void releaseEncoder() { - if (sdlSession == null || !sdlSession.getIsConnected()) return; - - //sdlSession.releaseEncoder(); - } - - /** - *Releases the MediaCodec encoder utilized in conjunction with the Surface returned via the createOpenGLInputSurface method - */ - @SuppressWarnings("unused") - public void drainEncoder(boolean endOfStream) { - if (sdlSession == null || !sdlSession.getIsConnected()) return; - - //sdlSession.drainEncoder(endOfStream); - } - - private void addNavListener(){ - - // videos may be started and stopped. Only add this once - if (navServiceListener == null){ - - navServiceListener = new ISdlServiceListener() { - @Override - public void onServiceStarted(SdlSession session, SessionType type, boolean isEncrypted) { } - - @Override - public void onServiceEnded(SdlSession session, SessionType type) { - // reset nav flags so nav can start upon the next transport connection - resetNavStartFlags(); - // propagate notification up to proxy listener so the developer will know that the service is ended - if (_proxyListener != null) { - _proxyListener.onServiceEnded(new OnServiceEnded(type)); - } - } - - @Override - public void onServiceError(SdlSession session, SessionType type, String reason) { - // if there is an error reset the flags so that there is a chance to restart streaming - resetNavStartFlags(); - } - }; - this.sdlSession.addServiceListener(SessionType.NAV, navServiceListener); - } - } - - /** - * Opens a audio service (service type 10) and subsequently provides an IAudioStreamListener - * to the app to send audio data. - * - * Currently information passed by "params" are ignored, since Audio Streaming feature lacks - * capability negotiation mechanism. App should configure audio stream data to align with - * head unit's capability by checking (upcoming) pcmCapabilities. The default format is in - * 16kHz and 16 bits. - * - * @param isEncrypted Specify true if packets on this service have to be encrypted - * @param codec Audio codec which will be used for streaming. Currently, only - * AudioStreamingCodec.LPCM is accepted. - * @param params (Reserved for future use) Additional configuration information for each - * codec. If "codec" is AudioStreamingCodec.LPCM, "params" must be an - * instance of LPCMParams class. - * - * @return IAudioStreamListener interface if service is opened successfully and streaming is - * started, null otherwise - */ - @SuppressWarnings("unused") - public IAudioStreamListener startAudioStream(boolean isEncrypted, AudioStreamingCodec codec, - AudioStreamingParams params) { - if (sdlSession == null) { - DebugTool.logWarning(TAG, "SdlSession is not created yet."); - return null; - } - if (!sdlSession.getIsConnected()) { - DebugTool.logWarning(TAG, "Connection is not available."); - return null; - } - if (codec != AudioStreamingCodec.LPCM) { - DebugTool.logWarning(TAG, "Audio codec " + codec + " is not supported."); - return null; - } - - pcmServiceStartResponseReceived = false; - pcmServiceStartResponse = false; - sdlSession.startService(SessionType.PCM, isEncrypted); - - FutureTask fTask = createFutureTask(new CallableMethod(RESPONSE_WAIT_TIME)); - ScheduledExecutorService scheduler = createScheduler(); - scheduler.execute(fTask); - - //noinspection StatementWithEmptyBody - while (!pcmServiceStartResponseReceived && !fTask.isDone()); - scheduler.shutdown(); - - if (pcmServiceStartResponse) { - DebugTool.logInfo(TAG, "StartService for audio succeeded"); - return null;//sdlSession.startAudioStream(); - } else { - if (pcmServiceStartRejectedParams != null) { - StringBuilder builder = new StringBuilder(); - for (String paramName : pcmServiceStartRejectedParams) { - if (builder.length() > 0) { - builder.append(", "); - } - builder.append(paramName); - } - DebugTool.logWarning(TAG, "StartService for audio failed. Rejected params: " + builder.toString()); - } else { - DebugTool.logWarning(TAG, "StartService for audio failed (rejected params not supplied)"); - } - return null; - } - } - - /** - *Closes the opened audio service (serviceType 10) - *@return true if the audio service is closed successfully, return false otherwise - */ - @SuppressWarnings("unused") - public boolean endAudioStream() { - if (sdlSession == null || !sdlSession.getIsConnected()) return false; - - pcmServiceEndResponseReceived = false; - pcmServiceEndResponse = false; - //sdlSession.stopAudioStream(); - - FutureTask fTask = createFutureTask(new CallableMethod(RESPONSE_WAIT_TIME)); - ScheduledExecutorService scheduler = createScheduler(); - scheduler.execute(fTask); - - //noinspection StatementWithEmptyBody - while (!pcmServiceEndResponseReceived && !fTask.isDone()); - scheduler.shutdown(); - - return pcmServiceEndResponse; - } - - /** - *Pauses the stream for the opened audio service (serviceType 10) - *@return true if the audio service stream is paused successfully, return false otherwise - */ - @SuppressWarnings("unused") - public boolean pauseAudioStream() { - return false;//sdlSession != null && sdlSession.pauseAudioStream(); - } - - /** - *Resumes the stream for the opened audio service (serviceType 10) - *@return true if the audio service stream is resumed successfully, return false otherwise - */ - @SuppressWarnings("unused") - public boolean resumeAudioStream() { - return false;//sdlSession != null && sdlSession.resumeAudioStream(); - } - - private void NavServiceStarted() { - navServiceStartResponseReceived = true; - navServiceStartResponse = true; - } - - private void NavServiceStartedNACK(List rejectedParams) { - navServiceStartResponseReceived = true; - navServiceStartResponse = false; - navServiceStartRejectedParams = rejectedParams; - } - - private void AudioServiceStarted() { - pcmServiceStartResponseReceived = true; - pcmServiceStartResponse = true; - } - - private void RPCProtectedServiceStarted() { - rpcProtectedResponseReceived = true; - rpcProtectedStartResponse = true; - } - private void AudioServiceStartedNACK(List rejectedParams) { - pcmServiceStartResponseReceived = true; - pcmServiceStartResponse = false; - pcmServiceStartRejectedParams = rejectedParams; - } - - private void NavServiceEnded() { - navServiceEndResponseReceived = true; - navServiceEndResponse = true; - } - - private void NavServiceEndedNACK() { - navServiceEndResponseReceived = true; - navServiceEndResponse = false; - } - - private void AudioServiceEnded() { - pcmServiceEndResponseReceived = true; - pcmServiceEndResponse = true; - } - - private void AudioServiceEndedNACK() { - pcmServiceEndResponseReceived = true; - pcmServiceEndResponse = false; - } - - private void resetNavStartFlags() { - navServiceStartResponseReceived = false; - navServiceStartResponse = false; - navServiceStartRejectedParams = null; - } - - public void setAppService(Service mService) - { - _appService = mService; - } - - @SuppressWarnings("unused") - public boolean startProtectedRPCService() { - rpcProtectedResponseReceived = false; - rpcProtectedStartResponse = false; - sdlSession.startService(SessionType.RPC, true); - - FutureTask fTask = createFutureTask(new CallableMethod(RESPONSE_WAIT_TIME)); - ScheduledExecutorService scheduler = createScheduler(); - scheduler.execute(fTask); - - //noinspection StatementWithEmptyBody - while (!rpcProtectedResponseReceived && !fTask.isDone()); - scheduler.shutdown(); - - return rpcProtectedStartResponse; - } - - @SuppressWarnings("unused") - public void getLockScreenIcon(final OnLockScreenIconDownloadedListener l){ - if(lockScreenIconRequest == null){ - l.onLockScreenIconDownloadError(new SdlException("This version of SDL core may not support lock screen icons.", - SdlExceptionCause.LOCK_SCREEN_ICON_NOT_SUPPORTED)); - return; - } - - LockScreenManager lockMan = null;//sdlSession.getLockScreenMan(); - Bitmap bitmap = lockMan.getLockScreenIcon(); - - // read bitmap if it was already downloaded so we don't have to download it every time - if(bitmap != null){ - l.onLockScreenIconDownloaded(bitmap); - } - else{ - String url = lockScreenIconRequest.getUrl().replaceFirst("http://", "https://"); - //sdlSession.getLockScreenMan().downloadLockScreenIcon(url, l); - } - } - - /* ******************* Public Helper Methods *************************/ - - /*Begin V1 Enhanced helper*/ - - /** - *Sends an AddCommand RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - *@param commandID -Unique command ID of the command to add. - *@param menuText -Menu text for optional sub value containing menu parameters. - *@param parentID -Menu parent ID for optional sub value containing menu parameters. - *@param position -Menu position for optional sub value containing menu parameters. - *@param vrCommands -VR synonyms for this AddCommand. - *@param IconValue -A static hex icon value or the binary image file name identifier (sent by the PutFile RPC). - *@param IconType -Describes whether the image is static or dynamic - *@param correlationID -A unique ID that correlates each RPCRequest and RPCResponse - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("SameParameterValue") - public void addCommand(@NonNull Integer commandID, - String menuText, Integer parentID, Integer position, - Vector vrCommands, String IconValue, ImageType IconType, Integer correlationID) - throws SdlException { - - - AddCommand msg = new AddCommand(commandID); - msg.setCorrelationID(correlationID); - - if (vrCommands != null) msg.setVrCommands(vrCommands); - - Image cmdIcon = null; - - if (IconValue != null && IconType != null) - { - cmdIcon = new Image(); - cmdIcon.setValue(IconValue); - cmdIcon.setImageType(IconType); - } - - if (cmdIcon != null) msg.setCmdIcon(cmdIcon); - - if(menuText != null || parentID != null || position != null) { - MenuParams menuParams = new MenuParams(); - menuParams.setMenuName(menuText); - menuParams.setPosition(position); - menuParams.setParentID(parentID); - msg.setMenuParams(menuParams); - } - - sendRPCRequest(msg); - } - - /** - *Sends an AddCommand RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - *@param commandID -Unique command ID of the command to add. - *@param menuText -Menu text for optional sub value containing menu parameters. - *@param position -Menu position for optional sub value containing menu parameters. - *@param vrCommands -VR synonyms for this AddCommand. - *@param IconValue -A static hex icon value or the binary image file name identifier (sent by the PutFile RPC). - *@param IconType -Describes whether the image is static or dynamic - *@param correlationID -A unique ID that correlates each RPCRequest and RPCResponse - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void addCommand(Integer commandID, - String menuText, Integer position, - Vector vrCommands, String IconValue, ImageType IconType, Integer correlationID) - throws SdlException { - - addCommand(commandID, menuText, null, position, vrCommands, IconValue, IconType, correlationID); - } - - /** - *Sends an AddCommand RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - *@param commandID -Unique command ID of the command to add. - *@param menuText -Menu text for optional sub value containing menu parameters. - *@param position -Menu position for optional sub value containing menu parameters. - *@param IconValue -A static hex icon value or the binary image file name identifier (sent by the PutFile RPC). - *@param IconType -Describes whether the image is static or dynamic - *@param correlationID -A unique ID that correlates each RPCRequest and RPCResponse - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void addCommand(Integer commandID, - String menuText, Integer position, String IconValue, ImageType IconType, - Integer correlationID) - throws SdlException { - - addCommand(commandID, menuText, null, position, null, IconValue, IconType, correlationID); - } - - /** - *Sends an AddCommand RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - *@param commandID -Unique command ID of the command to add. - *@param menuText -Menu text for optional sub value containing menu parameters. - *@param IconValue -A static hex icon value or the binary image file name identifier (sent by the PutFile RPC). - *@param IconType -Describes whether the image is static or dynamic - *@param correlationID -A unique ID that correlates each RPCRequest and RPCResponse - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void addCommand(Integer commandID, - String menuText, String IconValue, ImageType IconType, Integer correlationID) - throws SdlException { - - addCommand(commandID, menuText, null, null, null, IconValue, IconType, correlationID); - } - - /** - * Sends an AddCommand RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - * @param commandID -Unique command ID of the command to add. - * @param menuText -Menu text for optional sub value containing menu parameters. - * @param vrCommands -VR synonyms for this AddCommand. - * @param IconValue -A static hex icon value or the binary image file name identifier (sent by the PutFile RPC). - * @param IconType -Describes whether the image is static or dynamic - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void addCommand(Integer commandID, - String menuText, Vector vrCommands, String IconValue, ImageType IconType, Integer correlationID) - throws SdlException { - - addCommand(commandID, menuText, null, null, vrCommands, IconValue, IconType, correlationID); - } - - /** - * Sends an AddCommand RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - * @param commandID -Unique command ID of the command to add. - * @param vrCommands -VR synonyms for this AddCommand. - * @param IconValue -A static hex icon value or the binary image file name identifier (sent by the PutFile RPC). - * @param IconType -Describes whether the image is static or dynamic - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void addCommand(Integer commandID, - Vector vrCommands, String IconValue, ImageType IconType, Integer correlationID) - throws SdlException { - - addCommand(commandID, null, null, null, vrCommands, IconValue, IconType, correlationID); - } - - /*End V1 Enhanced helper*/ - - /** - *Sends an AddCommand RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - *@param commandID -Unique command ID of the command to add. - *@param menuText -Menu text for optional sub value containing menu parameters. - *@param parentID -Menu parent ID for optional sub value containing menu parameters. - *@param position -Menu position for optional sub value containing menu parameters. - *@param vrCommands -VR synonyms for this AddCommand. - *@param correlationID -A unique ID that correlates each RPCRequest and RPCResponse - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("SameParameterValue") - public void addCommand(@NonNull Integer commandID, - String menuText, Integer parentID, Integer position, - Vector vrCommands, Integer correlationID) - throws SdlException { - - AddCommand msg = new AddCommand(commandID); - msg.setCorrelationID(correlationID); - msg.setVrCommands(vrCommands); - if(menuText != null || parentID != null || position != null) { - MenuParams menuParams = new MenuParams(); - menuParams.setMenuName(menuText); - menuParams.setPosition(position); - menuParams.setParentID(parentID); - msg.setMenuParams(menuParams); - } - - sendRPCRequest(msg); - } - - /** - *Sends an AddCommand RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - *@param commandID -Unique command ID of the command to add. - *@param menuText -Menu text for optional sub value containing menu parameters. - *@param position -Menu position for optional sub value containing menu parameters. - *@param vrCommands -VR synonyms for this AddCommand. - *@param correlationID -A unique ID that correlates each RPCRequest and RPCResponse - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void addCommand(Integer commandID, - String menuText, Integer position, - Vector vrCommands, Integer correlationID) - throws SdlException { - - addCommand(commandID, menuText, null, position, vrCommands, correlationID); - } - - /** - *Sends an AddCommand RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - *@param commandID -Unique command ID of the command to add. - *@param menuText -Menu text for optional sub value containing menu parameters. - *@param position -Menu position for optional sub value containing menu parameters. - *@param correlationID -A unique ID that correlates each RPCRequest and RPCResponse - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void addCommand(Integer commandID, - String menuText, Integer position, - Integer correlationID) - throws SdlException { - - addCommand(commandID, menuText, null, position, null, correlationID); - } - - /** - *Sends an AddCommand RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - *@param commandID -Unique command ID of the command to add. - *@param menuText -Menu text for optional sub value containing menu parameters. - *@param correlationID -A unique ID that correlates each RPCRequest and RPCResponse - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void addCommand(Integer commandID, - String menuText, Integer correlationID) - throws SdlException { - addCommand(commandID, menuText, null, null, (Vector)null, correlationID); - } - - /** - * Sends an AddCommand RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - *@param commandID -Unique command ID of the command to add. - *@param menuText -Menu text for optional sub value containing menu parameters. - *@param vrCommands -VR synonyms for this AddCommand. - *@param correlationID -A unique ID that correlates each RPCRequest and RPCResponse - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void addCommand(Integer commandID, - String menuText, Vector vrCommands, Integer correlationID) - throws SdlException { - - addCommand(commandID, menuText, null, null, vrCommands, correlationID); - } - - /** - * Sends an AddCommand RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - *@param commandID -Unique command ID of the command to add. - *@param vrCommands -VR synonyms for this AddCommand. - *@param correlationID -A unique ID that correlates each RPCRequest and RPCResponse - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void addCommand(Integer commandID, - Vector vrCommands, Integer correlationID) - throws SdlException { - - addCommand(commandID, null, null, null, vrCommands, correlationID); - } - - /** - * Sends an AddSubMenu RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - * @param menuID -Unique ID of the sub menu to add. - * @param menuName -Text to show in the menu for this sub menu. - * @param position -Position within the items that are are at top level of the in application menu. - * @param menuIcon -Image to be be shown along with the submenu item - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("SameParameterValue") - public void addSubMenu(@NonNull Integer menuID, @NonNull String menuName, - Integer position, Image menuIcon, Integer correlationID) - throws SdlException { - - AddSubMenu msg = new AddSubMenu(menuID, menuName); - msg.setCorrelationID(correlationID); - msg.setPosition(position); - msg.setMenuIcon(menuIcon); - - sendRPCRequest(msg); - } - - /** - * Sends an AddSubMenu RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - * @param menuID -Unique ID of the sub menu to add. - * @param menuName -Text to show in the menu for this sub menu. - * @param position -Position within the items that are are at top level of the in application menu. - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse - * @throws SdlException if an unrecoverable error is encountered - */ - @Deprecated - @SuppressWarnings("SameParameterValue") - public void addSubMenu(@NonNull Integer menuID, @NonNull String menuName, - Integer position, Integer correlationID) - throws SdlException { - - addSubMenu(menuID, menuName, position, null, correlationID); - } - - /** - * Sends an AddSubMenu RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - * @param menuID -Unique ID of the sub menu to add. - * @param menuName -Text to show in the menu for this sub menu. - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse - * @throws SdlException if an unrecoverable error is encountered - */ - @Deprecated - @SuppressWarnings("unused") - public void addSubMenu(Integer menuID, String menuName, - Integer correlationID) throws SdlException { - - addSubMenu(menuID, menuName, null, null, correlationID); - } - - /*Begin V1 Enhanced helper*/ - /** - * Sends an Alert RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - * @param ttsText -The text to speech message in the form of a string. - * @param alertText1 -The first line of the alert text field. - * @param alertText2 -The second line of the alert text field. - * @param alertText3 -The optional third line of the alert text field. - * @param playTone -Defines if tone should be played. - * @param duration -Timeout in milliseconds. - * @param softButtons -A list of App defined SoftButtons. - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("SameParameterValue") - public void alert(String ttsText, String alertText1, - String alertText2, String alertText3, Boolean playTone, Integer duration, Vector softButtons, - Integer correlationID) throws SdlException { - - Vector chunks = TTSChunkFactory.createSimpleTTSChunks(ttsText); - Alert msg = new Alert(); - msg.setCorrelationID(correlationID); - msg.setAlertText1(alertText1); - msg.setAlertText2(alertText2); - msg.setAlertText3(alertText3); - msg.setDuration(duration); - msg.setPlayTone(playTone); - msg.setTtsChunks(chunks); - msg.setSoftButtons(softButtons); - - sendRPCRequest(msg); - } - - /** - * Sends an Alert RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - * @param ttsChunks -Text/phonemes to speak in the form of ttsChunks. - * @param alertText1 -The first line of the alert text field. - * @param alertText2 -The second line of the alert text field. - * @param alertText3 -The optional third line of the alert text field. - * @param playTone -Defines if tone should be played. - * @param duration -Timeout in milliseconds. - * @param softButtons -A list of App defined SoftButtons. - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse - * @throws SdlException if an unrecoverable error is encountered - */ - public void alert(Vector ttsChunks, - String alertText1, String alertText2, String alertText3, Boolean playTone, - Integer duration, Vector softButtons, Integer correlationID) throws SdlException { - - Alert msg = new Alert(); - msg.setCorrelationID(correlationID); - msg.setAlertText1(alertText1); - msg.setAlertText2(alertText2); - msg.setAlertText3(alertText3); - msg.setDuration(duration); - msg.setPlayTone(playTone); - msg.setTtsChunks(ttsChunks); - msg.setSoftButtons(softButtons); - - sendRPCRequest(msg); - } - - /** - * Sends an Alert RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - * @param ttsText -The text to speech message in the form of a string. - * @param playTone -Defines if tone should be played. - * @param softButtons -A list of App defined SoftButtons. - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void alert(String ttsText, Boolean playTone, Vector softButtons, - Integer correlationID) throws SdlException { - - alert(ttsText, null, null, null, playTone, null, softButtons, correlationID); - } - - /** - * Sends an Alert RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - * @param chunks -A list of text/phonemes to speak in the form of ttsChunks. - * @param playTone -Defines if tone should be played. - * @param softButtons -A list of App defined SoftButtons. - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void alert(Vector chunks, Boolean playTone, Vector softButtons, - Integer correlationID) throws SdlException { - - alert(chunks, null, null, null, playTone, null, softButtons, correlationID); - } - - /** - * Sends an Alert RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - * @param alertText1 -The first line of the alert text field. - * @param alertText2 -The second line of the alert text field. - * @param alertText3 -The optional third line of the alert text field. - * @param playTone -Defines if tone should be played. - * @param duration -Timeout in milliseconds. - * @param softButtons -A list of App defined SoftButtons. - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void alert(String alertText1, String alertText2, String alertText3, - Boolean playTone, Integer duration, Vector softButtons, Integer correlationID) - throws SdlException { - - alert((Vector)null, alertText1, alertText2, alertText3, playTone, duration, softButtons, correlationID); - } - - /*End V1 Enhanced helper*/ - - /** - * Sends an Alert RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - * @param ttsText -The text to speech message in the form of a string. - * @param alertText1 -The first line of the alert text field. - * @param alertText2 -The second line of the alert text field. - * @param playTone -Defines if tone should be played. - * @param duration -Timeout in milliseconds. - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("SameParameterValue") - public void alert(String ttsText, String alertText1, - String alertText2, Boolean playTone, Integer duration, - Integer correlationID) throws SdlException { - - Vector chunks = TTSChunkFactory.createSimpleTTSChunks(ttsText); - Alert msg = new Alert(); - msg.setCorrelationID(correlationID); - msg.setAlertText1(alertText1); - msg.setAlertText2(alertText2); - msg.setDuration(duration); - msg.setPlayTone(playTone); - msg.setTtsChunks(chunks); - - sendRPCRequest(msg); - } - - /** - * Sends an Alert RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - * @param ttsChunks -A list of text/phonemes to speak in the form of ttsChunks. - * @param alertText1 -The first line of the alert text field. - * @param alertText2 -The second line of the alert text field. - * @param playTone -Defines if tone should be played. - * @param duration -Timeout in milliseconds. - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse - * @throws SdlException if an unrecoverable error is encountered - */ - public void alert(Vector ttsChunks, - String alertText1, String alertText2, Boolean playTone, - Integer duration, Integer correlationID) throws SdlException { - - Alert msg = new Alert(); - msg.setCorrelationID(correlationID); - msg.setAlertText1(alertText1); - msg.setAlertText2(alertText2); - msg.setDuration(duration); - msg.setPlayTone(playTone); - msg.setTtsChunks(ttsChunks); - - sendRPCRequest(msg); - } - - /** - * Sends an Alert RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - * @param ttsText -The text to speech message in the form of a string. - * @param playTone -Defines if tone should be played. - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void alert(String ttsText, Boolean playTone, - Integer correlationID) throws SdlException { - - alert(ttsText, null, null, playTone, null, correlationID); - } - - /** - * Sends an Alert RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - * @param chunks -A list of text/phonemes to speak in the form of ttsChunks. - * @param playTone -Defines if tone should be played. - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void alert(Vector chunks, Boolean playTone, - Integer correlationID) throws SdlException { - - alert(chunks, null, null, playTone, null, correlationID); - } - - /** - * Sends an Alert RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - * @param alertText1 -The first line of the alert text field. - * @param alertText2 -The second line of the alert text field. - * @param playTone -Defines if tone should be played. - * @param duration -Timeout in milliseconds. - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void alert(String alertText1, String alertText2, - Boolean playTone, Integer duration, Integer correlationID) - throws SdlException { - - alert((Vector)null, alertText1, alertText2, playTone, duration, correlationID); - } - - /** - * Sends a CreateInteractionChoiceSet RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - * @param choiceSet to be sent to the module - * @param interactionChoiceSetID to be used in reference to the supplied choiceSet - * @param correlationID to be set to the RPCRequest - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void createInteractionChoiceSet( - @NonNull Vector choiceSet, @NonNull Integer interactionChoiceSetID, - Integer correlationID) throws SdlException { - - CreateInteractionChoiceSet msg = new CreateInteractionChoiceSet(interactionChoiceSetID, choiceSet); - msg.setCorrelationID(correlationID); - - sendRPCRequest(msg); - } - - /** - * Sends a DeleteCommand RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - * @param commandID -ID of the command(s) to delete. - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void deleteCommand(@NonNull Integer commandID, - Integer correlationID) throws SdlException { - - DeleteCommand msg = new DeleteCommand(commandID); - msg.setCorrelationID(correlationID); - - sendRPCRequest(msg); - } - - /** - * Sends a DeleteInteractionChoiceSet RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - * @param interactionChoiceSetID -ID of the interaction choice set to delete. - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void deleteInteractionChoiceSet( - @NonNull Integer interactionChoiceSetID, Integer correlationID) - throws SdlException { - - DeleteInteractionChoiceSet msg = new DeleteInteractionChoiceSet(interactionChoiceSetID); - msg.setCorrelationID(correlationID); - - sendRPCRequest(msg); - } - - /** - * Sends a DeleteSubMenu RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - * @param menuID -The menuID of the submenu to delete. - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void deleteSubMenu(Integer menuID, - Integer correlationID) throws SdlException { - - DeleteSubMenu msg = new DeleteSubMenu(menuID); - msg.setCorrelationID(correlationID); - - sendRPCRequest(msg); - } - - - - /*Begin V1 Enhanced helper*/ - - /** - * Sends a PerformInteraction RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - * @param initPrompt -Intial prompt spoken to the user at the start of an interaction. - * @param displayText -Text to be displayed first. - * @param interactionChoiceSetID -Interaction choice set IDs to use with an interaction. - * @param vrHelp -Suggested VR Help Items to display on-screen during Perform Interaction. - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse. - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void performInteraction(String initPrompt, - @NonNull String displayText, @NonNull Integer interactionChoiceSetID, Vector vrHelp, - Integer correlationID) throws SdlException { - - Vector interactionChoiceSetIDs = new Vector(); - interactionChoiceSetIDs.add(interactionChoiceSetID); - Vector initChunks = TTSChunkFactory.createSimpleTTSChunks(initPrompt); - PerformInteraction msg = new PerformInteraction(displayText, InteractionMode.BOTH, interactionChoiceSetIDs); - msg.setInitialPrompt(initChunks); - msg.setVrHelp(vrHelp); - msg.setCorrelationID(correlationID); - - sendRPCRequest(msg); - } - - /** - * Sends a PerformInteraction RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - * @param initPrompt -Intial prompt spoken to the user at the start of an interaction. - * @param displayText -Text to be displayed first. - * @param interactionChoiceSetID -Interaction choice set IDs to use with an interaction. - * @param helpPrompt -Help text that is spoken when a user speaks "help" during the interaction. - * @param timeoutPrompt -Timeout text that is spoken when a VR interaction times out. - * @param interactionMode - The method in which the user is notified and uses the interaction (Manual,VR,Both). - * @param timeout -Timeout in milliseconds. - * @param vrHelp -Suggested VR Help Items to display on-screen during Perform Interaction. - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse. - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void performInteraction(String initPrompt, - @NonNull String displayText, @NonNull Integer interactionChoiceSetID, - String helpPrompt, String timeoutPrompt, - @NonNull InteractionMode interactionMode, Integer timeout, Vector vrHelp, - Integer correlationID) throws SdlException { - - Vector interactionChoiceSetIDs = new Vector(); - interactionChoiceSetIDs.add(interactionChoiceSetID); - Vector initChunks = TTSChunkFactory.createSimpleTTSChunks(initPrompt); - Vector helpChunks = TTSChunkFactory.createSimpleTTSChunks(helpPrompt); - Vector timeoutChunks = TTSChunkFactory.createSimpleTTSChunks(timeoutPrompt); - PerformInteraction msg = new PerformInteraction(displayText, interactionMode, interactionChoiceSetIDs); - msg.setInitialPrompt(initChunks); - msg.setTimeout(timeout); - msg.setHelpPrompt(helpChunks); - msg.setTimeoutPrompt(timeoutChunks); - msg.setVrHelp(vrHelp); - msg.setCorrelationID(correlationID); - - sendRPCRequest(msg); - } - - /** - * Sends a PerformInteraction RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - * @param initPrompt -Intial prompt spoken to the user at the start of an interaction. - * @param displayText -Text to be displayed first. - * @param interactionChoiceSetIDList -A list of interaction choice set IDs to use with an interaction. - * @param helpPrompt -Help text that is spoken when a user speaks "help" during the interaction. - * @param timeoutPrompt -Timeout text that is spoken when a VR interaction times out. - * @param interactionMode - The method in which the user is notified and uses the interaction (Manual,VR,Both). - * @param timeout -Timeout in milliseconds. - * @param vrHelp -Suggested VR Help Items to display on-screen during Perform Interaction. - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse. - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void performInteraction(String initPrompt, - @NonNull String displayText, @NonNull Vector interactionChoiceSetIDList, - String helpPrompt, String timeoutPrompt, - @NonNull InteractionMode interactionMode, Integer timeout, Vector vrHelp, - Integer correlationID) throws SdlException { - - Vector initChunks = TTSChunkFactory.createSimpleTTSChunks(initPrompt); - Vector helpChunks = TTSChunkFactory.createSimpleTTSChunks(helpPrompt); - Vector timeoutChunks = TTSChunkFactory.createSimpleTTSChunks(timeoutPrompt); - PerformInteraction msg = new PerformInteraction(displayText, interactionMode, interactionChoiceSetIDList); - msg.setInitialPrompt(initChunks); - msg.setTimeout(timeout); - msg.setHelpPrompt(helpChunks); - msg.setTimeoutPrompt(timeoutChunks); - msg.setVrHelp(vrHelp); - msg.setCorrelationID(correlationID); - - sendRPCRequest(msg); - } - - /** - * Sends a PerformInteraction RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - * @param initChunks -A list of text/phonemes to speak for the initial prompt in the form of ttsChunks. - * @param displayText -Text to be displayed first. - * @param interactionChoiceSetIDList -A list of interaction choice set IDs to use with an interaction. - * @param helpChunks -A list of text/phonemes to speak for the help text that is spoken when a user speaks "help" during the interaction. - * @param timeoutChunks A list of text/phonems to speak for the timeout text that is spoken when a VR interaction times out. - * @param interactionMode - The method in which the user is notified and uses the interaction (Manual,VR,Both). - * @param timeout -Timeout in milliseconds. - * @param vrHelp -Suggested VR Help Items to display on-screen during Perform Interaction. - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse. - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void performInteraction( - Vector initChunks, @NonNull String displayText, - @NonNull Vector interactionChoiceSetIDList, - Vector helpChunks, Vector timeoutChunks, - @NonNull InteractionMode interactionMode, Integer timeout, Vector vrHelp, - Integer correlationID) throws SdlException { - - PerformInteraction msg = new PerformInteraction(displayText, interactionMode, interactionChoiceSetIDList); - msg.setInitialPrompt(initChunks); - msg.setTimeout(timeout); - msg.setHelpPrompt(helpChunks); - msg.setTimeoutPrompt(timeoutChunks); - msg.setVrHelp(vrHelp); - msg.setCorrelationID(correlationID); - - sendRPCRequest(msg); - } - - /*End V1 Enhanced*/ - - /** - * Sends a PerformInteraction RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - * @param initPrompt -Intial prompt spoken to the user at the start of an interaction. - * @param displayText -Text to be displayed first. - * @param interactionChoiceSetID -Interaction choice set IDs to use with an interaction. - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse. - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void performInteraction(String initPrompt, - @NonNull String displayText, @NonNull Integer interactionChoiceSetID, - Integer correlationID) throws SdlException { - - Vector interactionChoiceSetIDs = new Vector(); - interactionChoiceSetIDs.add(interactionChoiceSetID); - Vector initChunks = TTSChunkFactory.createSimpleTTSChunks(initPrompt); - PerformInteraction msg = new PerformInteraction(displayText, InteractionMode.BOTH, interactionChoiceSetIDs); - msg.setInitialPrompt(initChunks); - msg.setCorrelationID(correlationID); - - sendRPCRequest(msg); - } - - /** - * Sends a PerformInteraction RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - * @param initPrompt -Intial prompt spoken to the user at the start of an interaction. - * @param displayText -Text to be displayed first. - * @param interactionChoiceSetID -Interaction choice set IDs to use with an interaction. - * @param helpPrompt -Help text that is spoken when a user speaks "help" during the interaction. - * @param timeoutPrompt -Timeout text that is spoken when a VR interaction times out. - * @param interactionMode - The method in which the user is notified and uses the interaction (Manual,VR,Both). - * @param timeout -Timeout in milliseconds. - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse. - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void performInteraction(String initPrompt, - @NonNull String displayText, @NonNull Integer interactionChoiceSetID, - String helpPrompt, String timeoutPrompt, - @NonNull InteractionMode interactionMode, Integer timeout, - Integer correlationID) throws SdlException { - - Vector interactionChoiceSetIDs = new Vector(); - interactionChoiceSetIDs.add(interactionChoiceSetID); - Vector initChunks = TTSChunkFactory.createSimpleTTSChunks(initPrompt); - Vector helpChunks = TTSChunkFactory.createSimpleTTSChunks(helpPrompt); - Vector timeoutChunks = TTSChunkFactory.createSimpleTTSChunks(timeoutPrompt); - PerformInteraction msg = new PerformInteraction(displayText, interactionMode, interactionChoiceSetIDs); - msg.setInitialPrompt(initChunks); - msg.setTimeout(timeout); - msg.setHelpPrompt(helpChunks); - msg.setTimeoutPrompt(timeoutChunks); - msg.setCorrelationID(correlationID); - - sendRPCRequest(msg); - } - - /** - * Sends a PerformInteraction RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - * @param initPrompt -Intial prompt spoken to the user at the start of an interaction. - * @param displayText -Text to be displayed first. - * @param interactionChoiceSetIDList -A list of interaction choice set IDs to use with an interaction. - * @param helpPrompt -Help text that is spoken when a user speaks "help" during the interaction. - * @param timeoutPrompt -Timeout text that is spoken when a VR interaction times out. - * @param interactionMode - The method in which the user is notified and uses the interaction (Manual,VR,Both). - * @param timeout -Timeout in milliseconds. - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse. - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void performInteraction(String initPrompt, - @NonNull String displayText, @NonNull Vector interactionChoiceSetIDList, - String helpPrompt, String timeoutPrompt, - @NonNull InteractionMode interactionMode, Integer timeout, - Integer correlationID) throws SdlException { - - Vector initChunks = TTSChunkFactory.createSimpleTTSChunks(initPrompt); - Vector helpChunks = TTSChunkFactory.createSimpleTTSChunks(helpPrompt); - Vector timeoutChunks = TTSChunkFactory.createSimpleTTSChunks(timeoutPrompt); - PerformInteraction msg = new PerformInteraction(displayText, interactionMode, interactionChoiceSetIDList); - msg.setInitialPrompt(initChunks); - msg.setTimeout(timeout); - msg.setHelpPrompt(helpChunks); - msg.setTimeoutPrompt(timeoutChunks); - msg.setCorrelationID(correlationID); - - sendRPCRequest(msg); - } - - /** - * Sends a PerformInteraction RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - * @param initChunks -A list of text/phonemes to speak for the initial prompt in the form of ttsChunks. - * @param displayText -Text to be displayed first. - * @param interactionChoiceSetIDList -A list of interaction choice set IDs to use with an interaction. - * @param helpChunks -A list of text/phonemes to speak for the help text that is spoken when a user speaks "help" during the interaction. - * @param timeoutChunks A list of text/phonems to speak for the timeout text that is spoken when a VR interaction times out. - * @param interactionMode - The method in which the user is notified and uses the interaction (Manual,VR,Both). - * @param timeout -Timeout in milliseconds. - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse. - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void performInteraction( - Vector initChunks, @NonNull String displayText, - @NonNull Vector interactionChoiceSetIDList, - Vector helpChunks, Vector timeoutChunks, - @NonNull InteractionMode interactionMode, Integer timeout, - Integer correlationID) throws SdlException { - - PerformInteraction msg = new PerformInteraction(displayText, interactionMode, interactionChoiceSetIDList); - msg.setInitialPrompt(initChunks); - msg.setTimeout(timeout); - msg.setHelpPrompt(helpChunks); - msg.setTimeoutPrompt(timeoutChunks); - msg.setCorrelationID(correlationID); - - sendRPCRequest(msg); - } - - // Protected registerAppInterface used to ensure only non-ALM applications call - // reqisterAppInterface - protected void registerAppInterfacePrivate( - @NonNull SdlMsgVersion sdlMsgVersion, @NonNull String appName, Vector ttsName, - String ngnMediaScreenAppName, Vector vrSynonyms, @NonNull Boolean isMediaApp, - @NonNull Language languageDesired, @NonNull Language hmiDisplayLanguageDesired, Vector appType, - @NonNull String appID, TemplateColorScheme dayColorScheme, TemplateColorScheme nightColorScheme, Integer correlationID) - throws SdlException { - String carrierName = null; - if(telephonyManager != null){ - carrierName = telephonyManager.getNetworkOperatorName(); - } - - DeviceInfo deviceInfo = new DeviceInfo(); - deviceInfo.setHardware(android.os.Build.MODEL); - deviceInfo.setOs("Android"); - deviceInfo.setOsVersion(Build.VERSION.RELEASE); - deviceInfo.setCarrier(carrierName); - - if (sdlMsgVersion == null) { - sdlMsgVersion = new SdlMsgVersion(); - if(protocolVersion.getMajor() == 1) { - DebugTool.logInfo(TAG, "Connected to an older module, must send 1.0.0 as RPC spec"); - sdlMsgVersion.setMajorVersion(1); - sdlMsgVersion.setMinorVersion(0); - }else { - sdlMsgVersion.setMajorVersion(MAX_SUPPORTED_RPC_VERSION.getMajor()); - sdlMsgVersion.setMinorVersion(MAX_SUPPORTED_RPC_VERSION.getMinor()); - } - } - if (languageDesired == null) { - languageDesired = Language.EN_US; - } - if (hmiDisplayLanguageDesired == null) { - hmiDisplayLanguageDesired = Language.EN_US; - } - - RegisterAppInterface msg = new RegisterAppInterface(sdlMsgVersion, appName, isMediaApp, languageDesired, hmiDisplayLanguageDesired, appID); - - if (correlationID != null) { - msg.setCorrelationID(correlationID); - } - - msg.setDeviceInfo(deviceInfo); - - msg.setTtsName(ttsName); - - if (ngnMediaScreenAppName == null) { - ngnMediaScreenAppName = appName; - } - - msg.setNgnMediaScreenAppName(ngnMediaScreenAppName); - - if (vrSynonyms == null) { - vrSynonyms = new Vector(); - vrSynonyms.add(appName); - } - msg.setVrSynonyms(vrSynonyms); - - msg.setAppHMIType(appType); - - msg.setDayColorScheme(dayColorScheme); - msg.setNightColorScheme(nightColorScheme); - - if (_bAppResumeEnabled) - { - if (_lastHashID != null) - msg.setHashID(_lastHashID); - } - - Intent sendIntent = createBroadcastIntent(); - updateBroadcastIntent(sendIntent, "RPC_NAME", FunctionID.REGISTER_APP_INTERFACE.toString()); - updateBroadcastIntent(sendIntent, "TYPE", RPCMessage.KEY_REQUEST); - updateBroadcastIntent(sendIntent, "CORRID", msg.getCorrelationID()); - updateBroadcastIntent(sendIntent, "DATA",serializeJSON(msg)); - sendBroadcastIntent(sendIntent); - - sendRPCMessagePrivate(msg); - } - - /*Begin V1 Enhanced helper function*/ - - /** - * Sends a SetGlobalProperties RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - * @param helpPrompt that will be used for the VR screen - * @param timeoutPrompt string to be displayed after timeout - * @param vrHelpTitle string that may be displayed on VR prompt dialog - * @param vrHelp a list of VR synonyms that may be displayed to user - * @param correlationID to be attached to the request - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void setGlobalProperties( - String helpPrompt, String timeoutPrompt, String vrHelpTitle, Vector vrHelp, Integer correlationID) - throws SdlException { - - SetGlobalProperties req = new SetGlobalProperties(); - req.setCorrelationID(correlationID); - req.setHelpPrompt(TTSChunkFactory.createSimpleTTSChunks(helpPrompt)); - req.setTimeoutPrompt(TTSChunkFactory.createSimpleTTSChunks(timeoutPrompt)); - req.setVrHelpTitle(vrHelpTitle); - req.setVrHelp(vrHelp); - - sendRPCRequest(req); - } - - /** - * Sends a SetGlobalProperties RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - * @param helpChunks tts chunks that should be used when prompting the user - * @param timeoutChunks tts chunks that will be used when a timeout occurs - * @param vrHelpTitle string that may be displayed on VR prompt dialog - * @param vrHelp a list of VR synonyms that may be displayed to user - * @param correlationID ID to be attached to the RPCRequest that correlates the RPCResponse - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void setGlobalProperties( - Vector helpChunks, Vector timeoutChunks, String vrHelpTitle, Vector vrHelp, - Integer correlationID) throws SdlException { - - SetGlobalProperties req = new SetGlobalProperties(); - req.setCorrelationID(correlationID); - req.setHelpPrompt(helpChunks); - req.setTimeoutPrompt(timeoutChunks); - req.setVrHelpTitle(vrHelpTitle); - req.setVrHelp(vrHelp); - - sendRPCRequest(req); - } - - /*End V1 Enhanced helper function*/ - - /** - * Sends a SetGlobalProperties RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - * @param helpPrompt that will be used for the VR screen - * @param timeoutPrompt string to be displayed after timeout - * @param correlationID ID to be attached to the RPCRequest that correlates the RPCResponse - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void setGlobalProperties( - String helpPrompt, String timeoutPrompt, Integer correlationID) - throws SdlException { - - SetGlobalProperties req = new SetGlobalProperties(); - req.setCorrelationID(correlationID); - req.setHelpPrompt(TTSChunkFactory.createSimpleTTSChunks(helpPrompt)); - req.setTimeoutPrompt(TTSChunkFactory.createSimpleTTSChunks(timeoutPrompt)); - - sendRPCRequest(req); - } - - /** - * Sends a SetGlobalProperties RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - * @param helpChunks tts chunks that should be used when prompting the user - * @param timeoutChunks tts chunks that will be used when a timeout occurs - * @param correlationID ID to be attached to the RPCRequest that correlates the RPCResponse - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void setGlobalProperties( - Vector helpChunks, Vector timeoutChunks, - Integer correlationID) throws SdlException { - - SetGlobalProperties req = new SetGlobalProperties(); - req.setCorrelationID(correlationID); - req.setHelpPrompt(helpChunks); - req.setTimeoutPrompt(timeoutChunks); - - sendRPCRequest(req); - } - - @SuppressWarnings("unused") - public void resetGlobalProperties(Vector properties, - Integer correlationID) throws SdlException { - - ResetGlobalProperties req = new ResetGlobalProperties(); - - req.setCorrelationID(correlationID); - req.setProperties(properties); - - sendRPCRequest(req); - } - - - /** - * Sends a SetMediaClockTimer RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - * @param hours integer for hours - * @param minutes integer for minutes - * @param seconds integer for seconds - * @param updateMode mode in which the media clock timer should be updated - * @param correlationID ID to be attached to the RPCRequest that correlates the RPCResponse - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void setMediaClockTimer(Integer hours, - Integer minutes, Integer seconds, @NonNull UpdateMode updateMode, - Integer correlationID) throws SdlException { - - SetMediaClockTimer msg = new SetMediaClockTimer(updateMode); - if (hours != null || minutes != null || seconds != null) { - StartTime startTime = new StartTime(hours, minutes, seconds); - msg.setStartTime(startTime); - } - msg.setCorrelationID(correlationID); - - sendRPCRequest(msg); - } - - /** - * Pauses the media clock. Responses are captured through callback on IProxyListener. - * - * @param correlationID ID to be attached to the RPCRequest that correlates the RPCResponse - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void pauseMediaClockTimer(Integer correlationID) - throws SdlException { - - SetMediaClockTimer msg = new SetMediaClockTimer(UpdateMode.PAUSE); - StartTime startTime = new StartTime(0, 0, 0); - msg.setStartTime(startTime); - msg.setCorrelationID(correlationID); - - sendRPCRequest(msg); - } - - /** - * Resumes the media clock. Responses are captured through callback on IProxyListener. - * - * @param correlationID ID to be attached to the RPCRequest that correlates the RPCResponse - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void resumeMediaClockTimer(Integer correlationID) - throws SdlException { - - SetMediaClockTimer msg = new SetMediaClockTimer(UpdateMode.RESUME); - StartTime startTime = new StartTime(0, 0, 0); - msg.setStartTime(startTime); - msg.setCorrelationID(correlationID); - - sendRPCRequest(msg); - } - - /** - * Clears the media clock. Responses are captured through callback on IProxyListener. - * - * @param correlationID ID to be attached to the RPCRequest that correlates the RPCResponse - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void clearMediaClockTimer(Integer correlationID) - throws SdlException { - - Show msg = new Show(); - msg.setCorrelationID(correlationID); - msg.setMediaClock(" "); - - sendRPCRequest(msg); - } - - /*Begin V1 Enhanced helper*/ - /** - * Sends a Show RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - * @param mainText1 text displayed in a single or upper display line. - * @param mainText2 text displayed on the second display line. - * @param mainText3 text displayed on the second "page" first display line. - * @param mainText4 text displayed on the second "page" second display line. - * @param statusBar text is placed in the status bar area (Only valid for NAVIGATION apps) - * @param mediaClock text value for MediaClock field. - * @param mediaTrack text displayed in the track field. - * @param graphic image struct determining whether static or dynamic image to display in app. - * @param softButtons app defined SoftButtons. - * @param customPresets app labeled on-screen presets. - * @param alignment specifies how mainText1 and mainText2s texts should be aligned on display. - * @param correlationID ID to be attached to the RPCRequest that correlates the RPCResponse -A unique ID that correlates each RPCRequest and RPCResponse. - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("SameParameterValue") - public void show(String mainText1, String mainText2, String mainText3, String mainText4, - String statusBar, String mediaClock, String mediaTrack, - Image graphic, Vector softButtons, Vector customPresets, - TextAlignment alignment, Integer correlationID) - throws SdlException { - - Show msg = new Show(); - msg.setCorrelationID(correlationID); - msg.setMainField1(mainText1); - msg.setMainField2(mainText2); - msg.setStatusBar(statusBar); - msg.setMediaClock(mediaClock); - msg.setMediaTrack(mediaTrack); - msg.setAlignment(alignment); - msg.setMainField3(mainText3); - msg.setMainField4(mainText4); - msg.setGraphic(graphic); - msg.setSoftButtons(softButtons); - msg.setCustomPresets(customPresets); - - sendRPCRequest(msg); - } - - /** - * Sends a Show RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - * @param mainText1 -Text displayed in a single or upper display line. - * @param mainText2 -Text displayed on the second display line. - * @param mainText3 -Text displayed on the second "page" first display line. - * @param mainText4 -Text displayed on the second "page" second display line. - * @param graphic -Image struct determining whether static or dynamic image to display in app. - * @param softButtons -App defined SoftButtons. - * @param customPresets -App labeled on-screen presets. - * @param alignment -Specifies how mainText1 and mainText2s texts should be aligned on display. - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse. - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void show(String mainText1, String mainText2, String mainText3, String mainText4, - Image graphic, Vector softButtons, Vector customPresets, - TextAlignment alignment, Integer correlationID) - throws SdlException { - - show(mainText1, mainText2, mainText3, mainText4, null, null, null, graphic, softButtons, customPresets, alignment, correlationID); - } - /*End V1 Enhanced helper*/ - - /** - * Sends a Show RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - * @param mainText1 text displayed in a single or upper display line. - * @param mainText2 text displayed on the second display line. - * @param statusBar text is placed in the status bar area (Only valid for NAVIGATION apps) - * @param mediaClock text value for MediaClock field. - * @param mediaTrack text displayed in the track field. - * @param alignment specifies how mainText1 and mainText2s texts should be aligned on display. - * @param correlationID unique ID that correlates each RPCRequest and RPCResponse. - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("SameParameterValue") - public void show(String mainText1, String mainText2, - String statusBar, String mediaClock, String mediaTrack, - TextAlignment alignment, Integer correlationID) - throws SdlException { - - Show msg = new Show(); - msg.setCorrelationID(correlationID); - msg.setMainField1(mainText1); - msg.setMainField2(mainText2); - msg.setStatusBar(statusBar); - msg.setMediaClock(mediaClock); - msg.setMediaTrack(mediaTrack); - msg.setAlignment(alignment); - - sendRPCRequest(msg); - } - - /** - * Sends a Show RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - * @param mainText1 -Text displayed in a single or upper display line. - * @param mainText2 -Text displayed on the second display line. - * @param alignment -Specifies how mainText1 and mainText2s texts should be aligned on display. - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse. - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void show(String mainText1, String mainText2, - TextAlignment alignment, Integer correlationID) - throws SdlException { - - show(mainText1, mainText2, null, null, null, alignment, correlationID); - } - - /** - * Sends a Speak RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - * @param ttsText -The text to speech message in the form of a string. - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse. - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void speak(@NonNull String ttsText, Integer correlationID) - throws SdlException { - - Speak msg = new Speak(TTSChunkFactory.createSimpleTTSChunks(ttsText)); - msg.setCorrelationID(correlationID); - - sendRPCRequest(msg); - } - - /** - * Sends a Speak RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - * @param ttsChunks -Text/phonemes to speak in the form of ttsChunks. - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse. - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void speak(@NonNull Vector ttsChunks, - Integer correlationID) throws SdlException { - - Speak msg = new Speak(ttsChunks); - msg.setCorrelationID(correlationID); - - sendRPCRequest(msg); - } - - /** - * Sends a SubscribeButton RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - * @param buttonName -Name of the button to subscribe. - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse. - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void subscribeButton(@NonNull ButtonName buttonName, - Integer correlationID) throws SdlException { - - SubscribeButton msg = new SubscribeButton(buttonName); - msg.setCorrelationID(correlationID); - - sendRPCRequest(msg); - } - - // Protected unregisterAppInterface used to ensure no non-ALM app calls - // unregisterAppInterface. - protected void unregisterAppInterfacePrivate(Integer correlationID) - throws SdlException { - - UnregisterAppInterface msg = new UnregisterAppInterface(); - msg.setCorrelationID(correlationID); - - Intent sendIntent = createBroadcastIntent(); - - updateBroadcastIntent(sendIntent, "RPC_NAME", FunctionID.UNREGISTER_APP_INTERFACE.toString()); - updateBroadcastIntent(sendIntent, "TYPE", RPCMessage.KEY_REQUEST); - updateBroadcastIntent(sendIntent, "CORRID", msg.getCorrelationID()); - updateBroadcastIntent(sendIntent, "DATA",serializeJSON(msg)); - sendBroadcastIntent(sendIntent); - - sendRPCMessagePrivate(msg); - } - - /** - * Sends an UnsubscribeButton RPCRequest to SDL. Responses are captured through callback on IProxyListener. - * - * @param buttonName -Name of the button to unsubscribe. - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse. - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void unsubscribeButton(@NonNull ButtonName buttonName, - Integer correlationID) throws SdlException { - - UnsubscribeButton msg = new UnsubscribeButton(buttonName); - msg.setCorrelationID(correlationID); - - sendRPCRequest(msg); - } - - /** - * Creates a choice to be added to a choiceset. Choice has both a voice and a visual menu component. - * - * @param choiceID -Unique ID used to identify this choice (returned in callback). - * @param choiceMenuName -Text name displayed for this choice. - * @param choiceVrCommands -Vector of vrCommands used to select this choice by voice. Must contain - * at least one non-empty element. - * @return Choice created. - */ - @SuppressWarnings("unused") - public Choice createChoiceSetChoice(Integer choiceID, String choiceMenuName, - Vector choiceVrCommands) { - Choice returnChoice = new Choice(); - - returnChoice.setChoiceID(choiceID); - returnChoice.setMenuName(choiceMenuName); - returnChoice.setVrCommands(choiceVrCommands); - - return returnChoice; - } - - /** - * Starts audio pass thru session. Responses are captured through callback on IProxyListener. - * - * @param initialPrompt -SDL will speak this prompt before opening the audio pass thru session. - * @param audioPassThruDisplayText1 -First line of text displayed during audio capture. - * @param audioPassThruDisplayText2 -Second line of text displayed during audio capture. - * @param samplingRate -Allowable values of 8 khz or 16 or 22 or 44 khz. - * @param maxDuration -The maximum duration of audio recording in milliseconds. - * @param bitsPerSample -Specifies the quality the audio is recorded. Currently 8 bit or 16 bit. - * @param audioType -Specifies the type of audio data being requested. - * @param muteAudio -Defines if the current audio source should be muted during the APT session. - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse. - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void performaudiopassthru(String initialPrompt, String audioPassThruDisplayText1, String audioPassThruDisplayText2, - @NonNull SamplingRate samplingRate, @NonNull Integer maxDuration, @NonNull BitsPerSample bitsPerSample, - @NonNull AudioType audioType, Boolean muteAudio, Integer correlationID) throws SdlException { - Vector chunks = TTSChunkFactory.createSimpleTTSChunks(initialPrompt); - PerformAudioPassThru msg = new PerformAudioPassThru(samplingRate, maxDuration, bitsPerSample, audioType); - msg.setCorrelationID(correlationID); - msg.setInitialPrompt(chunks); - msg.setAudioPassThruDisplayText1(audioPassThruDisplayText1); - msg.setAudioPassThruDisplayText2(audioPassThruDisplayText2); - msg.setMuteAudio(muteAudio); - - sendRPCRequest(msg); - } - - /** - * Ends audio pass thru session. Responses are captured through callback on IProxyListener. - * - * @param correlationID ID to be attached to the RPCRequest that correlates the RPCResponse - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void endaudiopassthru(Integer correlationID) throws SdlException - { - EndAudioPassThru msg = new EndAudioPassThru(); - msg.setCorrelationID(correlationID); - - sendRPCRequest(msg); - } - - /** - * Subscribes for specific published data items. The data will be only sent if it has changed. - * Responses are captured through callback on IProxyListener. - * - * @param gps -Subscribes to GPS data. - * @param speed -Subscribes to vehicle speed data in kilometers per hour. - * @param rpm -Subscribes to number of revolutions per minute of the engine. - * @param fuelLevel -Subscribes to fuel level in the tank (percentage). - * @param fuelLevel_State -Subscribes to fuel level state. - * @param instantFuelConsumption -Subscribes to instantaneous fuel consumption in microlitres. - * @param externalTemperature -Subscribes to the external temperature in degrees celsius. - * @param prndl -Subscribes to PRNDL data that houses the selected gear. - * @param tirePressure -Subscribes to the TireStatus data containing status and pressure of tires. - * @param odometer -Subscribes to Odometer data in km. - * @param beltStatus -Subscribes to status of the seat belts. - * @param bodyInformation -Subscribes to body information including power modes. - * @param deviceStatus -Subscribes to device status including signal and battery strength. - * @param driverBraking -Subscribes to the status of the brake pedal. - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse. - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - @Deprecated - public void subscribevehicledata(boolean gps, boolean speed, boolean rpm, boolean fuelLevel, boolean fuelLevel_State, - boolean instantFuelConsumption, boolean externalTemperature, boolean prndl, boolean tirePressure, - boolean odometer, boolean beltStatus, boolean bodyInformation, boolean deviceStatus, - boolean driverBraking, Integer correlationID) throws SdlException - { - SubscribeVehicleData msg = new SubscribeVehicleData(); - msg.setGps(gps); - msg.setSpeed(speed); - msg.setRpm(rpm); - msg.setFuelLevel(fuelLevel); - msg.setFuelLevelState(fuelLevel_State); - msg.setInstantFuelConsumption(instantFuelConsumption); - msg.setExternalTemperature(externalTemperature); - msg.setPrndl(prndl); - msg.setTirePressure(tirePressure); - msg.setOdometer(odometer); - msg.setBeltStatus(beltStatus); - msg.setBodyInformation(bodyInformation); - msg.setDeviceStatus(deviceStatus); - msg.setDriverBraking(driverBraking); - msg.setCorrelationID(correlationID); - - sendRPCRequest(msg); - } - - - /** - * Subscribes for specific published data items. The data will be only sent if it has changed. - * Responses are captured through callback on IProxyListener. - * - * @param gps -Subscribes to GPS data. - * @param speed -Subscribes to vehicle speed data in kilometers per hour. - * @param rpm -Subscribes to number of revolutions per minute of the engine. - * @param fuelLevel -Subscribes to fuel level in the tank (percentage). - * @param fuelLevel_State -Subscribes to fuel level state. - * @param instantFuelConsumption -Subscribes to instantaneous fuel consumption in microlitres. - * @param externalTemperature -Subscribes to the external temperature in degrees celsius. - * @param prndl -Subscribes to PRNDL data that houses the selected gear. - * @param tirePressure -Subscribes to the TireStatus data containing status and pressure of tires. - * @param engineOilLife -Subscribes to Engine Oil Life data. - * @param odometer -Subscribes to Odometer data in km. - * @param beltStatus -Subscribes to status of the seat belts. - * @param bodyInformation -Subscribes to body information including power modes. - * @param deviceStatus -Subscribes to device status including signal and battery strength. - * @param driverBraking -Subscribes to the status of the brake pedal. - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse. - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void subscribevehicledata(boolean gps, boolean speed, boolean rpm, boolean fuelLevel, boolean fuelLevel_State, - boolean instantFuelConsumption, boolean externalTemperature, boolean prndl, boolean tirePressure, - boolean engineOilLife, boolean odometer, boolean beltStatus, boolean bodyInformation, boolean deviceStatus, - boolean driverBraking, Integer correlationID) throws SdlException - { - SubscribeVehicleData msg = new SubscribeVehicleData(); - msg.setGps(gps); - msg.setSpeed(speed); - msg.setRpm(rpm); - msg.setFuelLevel(fuelLevel); - msg.setFuelLevelState(fuelLevel_State); - msg.setInstantFuelConsumption(instantFuelConsumption); - msg.setExternalTemperature(externalTemperature); - msg.setPrndl(prndl); - msg.setTirePressure(tirePressure); - msg.setEngineOilLife(engineOilLife); - msg.setOdometer(odometer); - msg.setBeltStatus(beltStatus); - msg.setBodyInformation(bodyInformation); - msg.setDeviceStatus(deviceStatus); - msg.setDriverBraking(driverBraking); - msg.setCorrelationID(correlationID); - - sendRPCRequest(msg); - } - - - /** - * Unsubscribes for specific published data items. - * Responses are captured through callback on IProxyListener. - * - * @param gps -Unsubscribes to GPS data. - * @param speed -Unsubscribes to vehicle speed data in kilometers per hour. - * @param rpm -Unsubscribes to number of revolutions per minute of the engine. - * @param fuelLevel -Unsubscribes to fuel level in the tank (percentage). - * @param fuelLevel_State -Unsubscribes to fuel level state. - * @param instantFuelConsumption -Unsubscribes to instantaneous fuel consumption in microlitres. - * @param externalTemperature -Unsubscribes to the external temperature in degrees celsius. - * @param prndl -Unsubscribes to PRNDL data that houses the selected gear. - * @param tirePressure -Unsubscribes to the TireStatus data containing status and pressure of tires. - * @param odometer -Unsubscribes to Odometer data in km. - * @param beltStatus -Unsubscribes to status of the seat belts. - * @param bodyInformation -Unsubscribes to body information including power modes. - * @param deviceStatus -Unsubscribes to device status including signal and battery strength. - * @param driverBraking -Unsubscribes to the status of the brake pedal. - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse. - * @throws SdlException if an unrecoverable error is encountered - */ - - @SuppressWarnings("unused") - @Deprecated - public void unsubscribevehicledata(boolean gps, boolean speed, boolean rpm, boolean fuelLevel, boolean fuelLevel_State, - boolean instantFuelConsumption, boolean externalTemperature, boolean prndl, boolean tirePressure, - boolean odometer, boolean beltStatus, boolean bodyInformation, boolean deviceStatus, - boolean driverBraking, Integer correlationID) throws SdlException - { - UnsubscribeVehicleData msg = new UnsubscribeVehicleData(); - msg.setGps(gps); - msg.setSpeed(speed); - msg.setRpm(rpm); - msg.setFuelLevel(fuelLevel); - msg.setFuelLevelState(fuelLevel_State); - msg.setInstantFuelConsumption(instantFuelConsumption); - msg.setExternalTemperature(externalTemperature); - msg.setPrndl(prndl); - msg.setTirePressure(tirePressure); - msg.setOdometer(odometer); - msg.setBeltStatus(beltStatus); - msg.setBodyInformation(bodyInformation); - msg.setDeviceStatus(deviceStatus); - msg.setDriverBraking(driverBraking); - msg.setCorrelationID(correlationID); - - sendRPCRequest(msg); - } - - - /** - * Unsubscribes for specific published data items. - * Responses are captured through callback on IProxyListener. - * - * @param gps -Unsubscribes to GPS data. - * @param speed -Unsubscribes to vehicle speed data in kilometers per hour. - * @param rpm -Unsubscribes to number of revolutions per minute of the engine. - * @param fuelLevel -Unsubscribes to fuel level in the tank (percentage). - * @param fuelLevel_State -Unsubscribes to fuel level state. - * @param instantFuelConsumption -Unsubscribes to instantaneous fuel consumption in microlitres. - * @param externalTemperature -Unsubscribes to the external temperature in degrees celsius. - * @param prndl -Unsubscribes to PRNDL data that houses the selected gear. - * @param tirePressure -Unsubscribes to the TireStatus data containing status and pressure of tires. - * @param engineOilLife -Unsubscribes to Engine Oil Life data. - * @param odometer -Unsubscribes to Odometer data in km. - * @param beltStatus -Unsubscribes to status of the seat belts. - * @param bodyInformation -Unsubscribes to body information including power modes. - * @param deviceStatus -Unsubscribes to device status including signal and battery strength. - * @param driverBraking -Unsubscribes to the status of the brake pedal. - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse. - * @throws SdlException if an unrecoverable error is encountered - */ - - @SuppressWarnings("unused") - public void unsubscribevehicledata(boolean gps, boolean speed, boolean rpm, boolean fuelLevel, boolean fuelLevel_State, - boolean instantFuelConsumption, boolean externalTemperature, boolean prndl, boolean tirePressure, - boolean engineOilLife, boolean odometer, boolean beltStatus, boolean bodyInformation, boolean deviceStatus, - boolean driverBraking, Integer correlationID) throws SdlException - { - UnsubscribeVehicleData msg = new UnsubscribeVehicleData(); - msg.setGps(gps); - msg.setSpeed(speed); - msg.setRpm(rpm); - msg.setFuelLevel(fuelLevel); - msg.setFuelLevelState(fuelLevel_State); - msg.setInstantFuelConsumption(instantFuelConsumption); - msg.setExternalTemperature(externalTemperature); - msg.setPrndl(prndl); - msg.setTirePressure(tirePressure); - msg.setEngineOilLife(engineOilLife); - msg.setOdometer(odometer); - msg.setBeltStatus(beltStatus); - msg.setBodyInformation(bodyInformation); - msg.setDeviceStatus(deviceStatus); - msg.setDriverBraking(driverBraking); - msg.setCorrelationID(correlationID); - - sendRPCRequest(msg); - } - - - /** - * Performs a Non periodic vehicle data read request. - * Responses are captured through callback on IProxyListener. - * - * @param gps -Performs an ad-hoc request for GPS data. - * @param speed -Performs an ad-hoc request for vehicle speed data in kilometers per hour. - * @param rpm -Performs an ad-hoc request for number of revolutions per minute of the engine. - * @param fuelLevel -Performs an ad-hoc request for fuel level in the tank (percentage). - * @param fuelLevel_State -Performs an ad-hoc request for fuel level state. - * @param instantFuelConsumption -Performs an ad-hoc request for instantaneous fuel consumption in microlitres. - * @param externalTemperature -Performs an ad-hoc request for the external temperature in degrees celsius. - * @param vin -Performs an ad-hoc request for the Vehicle identification number - * @param prndl -Performs an ad-hoc request for PRNDL data that houses the selected gear. - * @param tirePressure -Performs an ad-hoc request for the TireStatus data containing status and pressure of tires. - * @param odometer -Performs an ad-hoc request for Odometer data in km. - * @param beltStatus -Performs an ad-hoc request for status of the seat belts. - * @param bodyInformation -Performs an ad-hoc request for body information including power modes. - * @param deviceStatus -Performs an ad-hoc request for device status including signal and battery strength. - * @param driverBraking -Performs an ad-hoc request for the status of the brake pedal. - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse. - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - @Deprecated - public void getvehicledata(boolean gps, boolean speed, boolean rpm, boolean fuelLevel, boolean fuelLevel_State, - boolean instantFuelConsumption, boolean externalTemperature, boolean vin, boolean prndl, boolean tirePressure, - boolean odometer, boolean beltStatus, boolean bodyInformation, boolean deviceStatus, - boolean driverBraking, Integer correlationID) throws SdlException - { - GetVehicleData msg = new GetVehicleData(); - msg.setGps(gps); - msg.setSpeed(speed); - msg.setRpm(rpm); - msg.setFuelLevel(fuelLevel); - msg.setFuelLevelState(fuelLevel_State); - msg.setInstantFuelConsumption(instantFuelConsumption); - msg.setExternalTemperature(externalTemperature); - msg.setVin(vin); - msg.setPrndl(prndl); - msg.setTirePressure(tirePressure); - msg.setOdometer(odometer); - msg.setBeltStatus(beltStatus); - msg.setBodyInformation(bodyInformation); - msg.setDeviceStatus(deviceStatus); - msg.setDriverBraking(driverBraking); - msg.setCorrelationID(correlationID); - - sendRPCRequest(msg); - } - - - /** - * Performs a Non periodic vehicle data read request. - * Responses are captured through callback on IProxyListener. - * - * @param gps -Performs an ad-hoc request for GPS data. - * @param speed -Performs an ad-hoc request for vehicle speed data in kilometers per hour. - * @param rpm -Performs an ad-hoc request for number of revolutions per minute of the engine. - * @param fuelLevel -Performs an ad-hoc request for fuel level in the tank (percentage). - * @param fuelLevel_State -Performs an ad-hoc request for fuel level state. - * @param instantFuelConsumption -Performs an ad-hoc request for instantaneous fuel consumption in microlitres. - * @param externalTemperature -Performs an ad-hoc request for the external temperature in degrees celsius. - * @param vin -Performs an ad-hoc request for the Vehicle identification number - * @param prndl -Performs an ad-hoc request for PRNDL data that houses the selected gear. - * @param tirePressure -Performs an ad-hoc request for the TireStatus data containing status and pressure of tires. - * @param engineOilLife -Performs an ad-hoc request for Engine Oil Life data. - * @param odometer -Performs an ad-hoc request for Odometer data in km. - * @param beltStatus -Performs an ad-hoc request for status of the seat belts. - * @param bodyInformation -Performs an ad-hoc request for body information including power modes. - * @param deviceStatus -Performs an ad-hoc request for device status including signal and battery strength. - * @param driverBraking -Performs an ad-hoc request for the status of the brake pedal. - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse. - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void getvehicledata(boolean gps, boolean speed, boolean rpm, boolean fuelLevel, boolean fuelLevel_State, - boolean instantFuelConsumption, boolean externalTemperature, boolean vin, boolean prndl, boolean tirePressure, - boolean engineOilLife, boolean odometer, boolean beltStatus, boolean bodyInformation, boolean deviceStatus, - boolean driverBraking, Integer correlationID) throws SdlException - { - GetVehicleData msg = new GetVehicleData(); - msg.setGps(gps); - msg.setSpeed(speed); - msg.setRpm(rpm); - msg.setFuelLevel(fuelLevel); - msg.setFuelLevelState(fuelLevel_State); - msg.setInstantFuelConsumption(instantFuelConsumption); - msg.setExternalTemperature(externalTemperature); - msg.setVin(vin); - msg.setPrndl(prndl); - msg.setTirePressure(tirePressure); - msg.setEngineOilLife(engineOilLife); - msg.setOdometer(odometer); - msg.setBeltStatus(beltStatus); - msg.setBodyInformation(bodyInformation); - msg.setDeviceStatus(deviceStatus); - msg.setDriverBraking(driverBraking); - msg.setCorrelationID(correlationID); - - sendRPCRequest(msg); - } - - - /** - * Creates a full screen overlay containing a large block of formatted text that can be scrolled with up to 8 SoftButtons defined. - * Responses are captured through callback on IProxyListener. - * - * @param scrollableMessageBody -Body of text that can include newlines and tabs. - * @param timeout -App defined timeout. Indicates how long of a timeout from the last action. - * @param softButtons -App defined SoftButtons. - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse. - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void scrollablemessage(@NonNull String scrollableMessageBody, Integer timeout, Vector softButtons, Integer correlationID) throws SdlException - { - ScrollableMessage msg = new ScrollableMessage(scrollableMessageBody); - msg.setCorrelationID(correlationID); - msg.setTimeout(timeout); - msg.setSoftButtons(softButtons); - - sendRPCRequest(msg); - } - - - /** - * Creates a full screen or pop-up overlay (depending on platform) with a single user controlled slider. - * Responses are captured through callback on IProxyListener. - * - * @param numTicks -Number of selectable items on a horizontal axis. - * @param position -Initial position of slider control (cannot exceed numTicks). - * @param sliderHeader -Text header to display. - * @param sliderFooter - Text footer to display (meant to display min/max threshold descriptors). - * @param timeout -App defined timeout. Indicates how long of a timeout from the last action. - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse. - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void slider(@NonNull Integer numTicks, @NonNull Integer position, @NonNull String sliderHeader, Vector sliderFooter, Integer timeout, Integer correlationID) throws SdlException - { - Slider msg = new Slider(numTicks, position, sliderHeader); - msg.setCorrelationID(correlationID); - msg.setSliderFooter(sliderFooter); - msg.setTimeout(timeout); - - sendRPCRequest(msg); - } - - /** - * Responses are captured through callback on IProxyListener. - * - * @param language requested SDL voice engine (VR+TTS) language registration - * @param hmiDisplayLanguage request display language registration. - * @param correlationID ID to be attached to the RPCRequest that correlates the RPCResponse - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void changeregistration(@NonNull Language language, @NonNull Language hmiDisplayLanguage, Integer correlationID) throws SdlException - { - ChangeRegistration msg = new ChangeRegistration(language, hmiDisplayLanguage); - msg.setCorrelationID(correlationID); - - sendRPCRequest(msg); - } - - /** - * Used to push a binary stream of file data onto the module from a mobile device. - * Responses are captured through callback on IProxyListener. - * - * @param is - The input stream of byte data that putFileStream will read from - * @param sdlFileName - The file reference name used by the putFile RPC. - * @param iOffset - The data offset in bytes, a value of zero is used to indicate data starting from the beginging of the file. - * A value greater than zero is used for resuming partial data chunks. - * @param iLength - The total length of the file being sent. - * @throws SdlException if an unrecoverable error is encountered - * @see #putFileStream(InputStream, String, Long, Long) - */ - @SuppressWarnings("unused") - @Deprecated - public void putFileStream(InputStream is, @NonNull String sdlFileName, Integer iOffset, Integer iLength) throws SdlException - { - PutFile msg = new PutFile(sdlFileName, FileType.BINARY); - msg.setCorrelationID(10000); - msg.setSystemFile(true); - msg.setOffset(iOffset); - msg.setLength(iLength); - - startRPCStream(is, msg); - } - - /** - * Used to push a binary stream of file data onto the module from a mobile - * device. Responses are captured through callback on IProxyListener. - * - * @param inputStream The input stream of byte data that will be read from. - * @param fileName The SDL file reference name used by the RPC. - * @param offset The data offset in bytes. A value of zero is used to - * indicate data starting from the beginning of the file and a value greater - * than zero is used for resuming partial data chunks. - * @param length The total length of the file being sent. - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void putFileStream(InputStream inputStream, @NonNull String fileName, Long offset, Long length) throws SdlException { - PutFile msg = new PutFile(fileName, FileType.BINARY); - msg.setCorrelationID(10000); - msg.setSystemFile(true); - msg.setOffset(offset); - msg.setLength(length); - - startRPCStream(inputStream, msg); - } - - /** - * Used to push a binary stream of file data onto the module from a mobile device. - * Responses are captured through callback on IProxyListener. - * - * @param sdlFileName - The file reference name used by the putFile RPC. - * @param iOffset - The data offset in bytes, a value of zero is used to indicate data starting from the beginging of a file. - * A value greater than zero is used for resuming partial data chunks. - * @param iLength - The total length of the file being sent. - * - * @return OutputStream - The output stream of byte data that is written to by the app developer - * @throws SdlException if an unrecoverable error is encountered - * @see #putFileStream(String, Long, Long) - */ - @SuppressWarnings("unused") - @Deprecated - public OutputStream putFileStream(@NonNull String sdlFileName, Integer iOffset, Integer iLength) throws SdlException - { - PutFile msg = new PutFile(sdlFileName, FileType.BINARY); - msg.setCorrelationID(10000); - msg.setSystemFile(true); - msg.setOffset(iOffset); - msg.setLength(iLength); - - return startRPCStream(msg); - } - - /** - * Used to push a binary stream of file data onto the module from a mobile - * device. Responses are captured through callback on IProxyListener. - * - * @param fileName The SDL file reference name used by the RPC. - * @param offset The data offset in bytes. A value of zero is used to - * indicate data starting from the beginning of the file and a value greater - * than zero is used for resuming partial data chunks. - * @param length The total length of the file being sent. - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public OutputStream putFileStream(@NonNull String fileName, Long offset, Long length) throws SdlException { - PutFile msg = new PutFile(fileName, FileType.BINARY); - msg.setCorrelationID(10000); - msg.setSystemFile(true); - msg.setOffset(offset); - msg.setLength(length); - - return startRPCStream(msg); - } - - /** - * Used to push a binary stream of file data onto the module from a mobile device. - * Responses are captured through callback on IProxyListener. - * - * @param is - The input stream of byte data that PutFileStream will read from - * @param sdlFileName - The file reference name used by the putFile RPC. - * @param iOffset - The data offset in bytes, a value of zero is used to indicate data starting from the beginging of the file. - * A value greater than zero is used for resuming partial data chunks. - * @param iLength - The total length of the file being sent. - * @param fileType - The selected file type -- see the FileType enumeration for details - * @param bPersistentFile - Indicates if the file is meant to persist between sessions / ignition cycles. - * @param bSystemFile - Indicates if the file is meant to be passed thru core to elsewhere on the system. - * @throws SdlException if an unrecoverable error is encountered - * @see #putFileStream(InputStream, String, Long, Long, FileType, Boolean, Boolean, OnPutFileUpdateListener) - */ - @SuppressWarnings("unused") - @Deprecated - public void putFileStream(InputStream is, @NonNull String sdlFileName, Integer iOffset, Integer iLength, @NonNull FileType fileType, Boolean bPersistentFile, Boolean bSystemFile) throws SdlException - { - PutFile msg = new PutFile(sdlFileName, fileType); - msg.setCorrelationID(10000); - msg.setPersistentFile(bPersistentFile); - msg.setSystemFile(bSystemFile); - msg.setOffset(iOffset); - msg.setLength(iLength); - - startRPCStream(is, msg); - } - - /** - * Used to push a binary stream of file data onto the module from a mobile - * device. Responses are captured through callback on IProxyListener. - * - * @param inputStream The input stream of byte data that will be read from. - * @param fileName The SDL file reference name used by the RPC. - * @param offset The data offset in bytes. A value of zero is used to - * indicate data starting from the beginning of the file and a value greater - * than zero is used for resuming partial data chunks. - * @param length The total length of the file being sent. - * @param fileType The selected file type. See the {@link FileType} enum for - * details. - * @param isPersistentFile Indicates if the file is meant to persist between - * sessions / ignition cycles. - * @param isSystemFile Indicates if the file is meant to be passed through - * core to elsewhere in the system. - * @throws SdlException if an unrecoverable error is encountered - */ -// @SuppressWarnings("unused") -// public void putFileStream(InputStream inputStream, @NonNull String fileName, Long offset, Long length, FileType fileType, Boolean isPersistentFile, Boolean isSystemFile, OnPutFileUpdateListener cb) throws SdlException { -// PutFile msg = new PutFile(fileName, FileType.BINARY); -// msg.setCorrelationID(10000); -// msg.setSystemFile(true); -// msg.setOffset(offset); -// msg.setLength(length); -// //msg.setOnPutFileUpdateListener(cb); -// startRPCStream(inputStream, msg); -// } -// - /** - * Used to push a binary stream of file data onto the module from a mobile device. - * Responses are captured through callback on IProxyListener. - * - * @param sdlFileName - The file reference name used by the putFile RPC. - * @param iOffset - The data offset in bytes, a value of zero is used to indicate data starting from the beginging of a file. - * A value greater than zero is used for resuming partial data chunks. - * @param iLength - The total length of the file being sent. - * @param fileType - The selected file type -- see the FileType enumeration for details - * @param bPersistentFile - Indicates if the file is meant to persist between sessions / ignition cycles. - * @param bSystemFile - Indicates if the file is meant to be passed thru core to elsewhere on the system. - * @return OutputStream - The output stream of byte data that is written to by the app developer - * @throws SdlException if an unrecoverable error is encountered - * @see #putFileStream(String, Long, Long, FileType, Boolean, Boolean, OnPutFileUpdateListener) - */ - @SuppressWarnings("unused") - @Deprecated - public OutputStream putFileStream(@NonNull String sdlFileName, Integer iOffset, Integer iLength, @NonNull FileType fileType, Boolean bPersistentFile, Boolean bSystemFile) throws SdlException - { - PutFile msg = new PutFile(sdlFileName, fileType); - msg.setCorrelationID(10000); - msg.setPersistentFile(bPersistentFile); - msg.setSystemFile(bSystemFile); - msg.setOffset(iOffset); - msg.setLength(iLength); - - return startRPCStream(msg); - } - - /** - * Used to push a binary stream of file data onto the module from a mobile - * device. Responses are captured through callback on IProxyListener. - * - * @param fileName The SDL file reference name used by the RPC. - * @param offset The data offset in bytes. A value of zero is used to - * indicate data starting from the beginning of the file and a value greater - * than zero is used for resuming partial data chunks. - * @param length The total length of the file being sent. - * @param fileType The selected file type. See the {@link FileType} enum for - * details. - * @param isPersistentFile Indicates if the file is meant to persist between - * sessions / ignition cycles. - * @param isSystemFile Indicates if the file is meant to be passed through - * core to elsewhere in the system. - * @throws SdlException if an unrecoverable error is encountered - */ -// @SuppressWarnings("unused") -// public OutputStream putFileStream(@NonNull String fileName, Long offset, Long length, FileType fileType, Boolean isPersistentFile, Boolean isSystemFile, OnPutFileUpdateListener cb) throws SdlException { -// PutFile msg = new PutFile(fileName, FileType.BINARY); -// msg.setCorrelationID(10000); -// msg.setSystemFile(true); -// msg.setOffset(offset); -// msg.setLength(length); -// //msg.setOnPutFileUpdateListener(cb); -// -// return startRPCStream(msg); -// } - - /** - * Used to push a stream of putfile RPC's containing binary data from a mobile device to the module. - * Responses are captured through callback on IProxyListener. - * - * @param sPath - The physical file path on the mobile device. - * @param sdlFileName - The file reference name used by the putFile RPC. - * @param iOffset - The data offset in bytes, a value of zero is used to indicate data starting from the beginging of a file. - * A value greater than zero is used for resuming partial data chunks. - * @param fileType - The selected file type -- see the FileType enumeration for details - * @param bPersistentFile - Indicates if the file is meant to persist between sessions / ignition cycles. - * @param bSystemFile - Indicates if the file is meant to be passed thru core to elsewhere on the system. - * @param iCorrelationID - A unique ID that correlates each RPCRequest and RPCResponse. - * @return RPCStreamController - If the putFileStream was not started successfully null is returned, otherwise a valid object reference is returned - * @throws SdlException if an unrecoverable error is encountered -// * @see #putFileStream(String, String, Long, FileType, Boolean, Boolean, Boolean, Integer, OnPutFileUpdateListener) - */ - @SuppressWarnings("unused") - @Deprecated - public RPCStreamController putFileStream(String sPath, @NonNull String sdlFileName, Integer iOffset, @NonNull FileType fileType, Boolean bPersistentFile, Boolean bSystemFile, Integer iCorrelationID) throws SdlException - { - PutFile msg = new PutFile(sdlFileName, fileType); - msg.setCorrelationID(iCorrelationID); - msg.setPersistentFile(bPersistentFile); - msg.setSystemFile(bSystemFile); - msg.setOffset(iOffset); - msg.setLength(0); - - return startPutFileStream(sPath, msg); - } - - /** - * Used to push a binary stream of file data onto the module from a mobile - * device. Responses are captured through callback on IProxyListener. - * - * @param path The physical file path on the mobile device. - * @param fileName The SDL file reference name used by the RPC. - * @param offset The data offset in bytes. A value of zero is used to - * indicate data starting from the beginning of the file and a value greater - * than zero is used for resuming partial data chunks. - * @param fileType The selected file type. See the {@link FileType} enum for - * details. - * @param isPersistentFile Indicates if the file is meant to persist between - * sessions / ignition cycles. - * @param isSystemFile Indicates if the file is meant to be passed through - * core to elsewhere in the system. - * @param correlationId A unique id that correlates each RPCRequest and - * RPCResponse. - * @return RPCStreamController If the putFileStream was not started - * successfully null is returned, otherwise a valid object reference is - * returned . - * @throws SdlException if an unrecoverable error is encountered - */ -// @SuppressWarnings("unused") -// public RPCStreamController putFileStream(String path, @NonNull String fileName, Long offset, @NonNull FileType fileType, Boolean isPersistentFile, Boolean isSystemFile, Boolean isPayloadProtected, Integer correlationId, OnPutFileUpdateListener cb ) throws SdlException { -// PutFile msg = new PutFile(fileName, fileType); -// msg.setCorrelationID(correlationId); -// msg.setPersistentFile(isPersistentFile); -// msg.setSystemFile(isSystemFile); -// msg.setOffset(offset); -// msg.setLength(0L); -// msg.setPayloadProtected(isPayloadProtected); -// //msg.setOnPutFileUpdateListener(cb); -// -// return startPutFileStream(path,msg); -// } - - /** - * Used to push a stream of putfile RPC's containing binary data from a mobile device to the module. - * Responses are captured through callback on IProxyListener. - * - * @param is - The input stream of byte data that putFileStream will read from. - * @param sdlFileName - The file reference name used by the putFile RPC. - * @param iOffset - The data offset in bytes, a value of zero is used to indicate data starting from the beginging of a file. - * A value greater than zero is used for resuming partial data chunks. - * @param fileType - The selected file type -- see the FileType enumeration for details - * @param bPersistentFile - Indicates if the file is meant to persist between sessions / ignition cycles. - * @param bSystemFile - Indicates if the file is meant to be passed thru core to elsewhere on the system. - * @param iCorrelationID - A unique ID that correlates each RPCRequest and RPCResponse. - * @return RPCStreamController - If the putFileStream was not started successfully null is returned, otherwise a valid object reference is returned - * @throws SdlException if an unrecoverable error is encountered - * @see #putFileStream(InputStream, String, Long, Long, FileType, Boolean, Boolean, Boolean, Integer) - */ - @SuppressWarnings("unused") - @Deprecated - public RPCStreamController putFileStream(InputStream is, @NonNull String sdlFileName, Integer iOffset, Integer iLength, @NonNull FileType fileType, Boolean bPersistentFile, Boolean bSystemFile, Integer iCorrelationID) throws SdlException - { - PutFile msg = new PutFile(sdlFileName, fileType); - msg.setCorrelationID(iCorrelationID); - msg.setPersistentFile(bPersistentFile); - msg.setSystemFile(bSystemFile); - msg.setOffset(Long.valueOf(iOffset)); - msg.setLength(Long.valueOf(iLength)); - - return startPutFileStream(is, msg); - } - - /** - * Used to push a binary stream of file data onto the module from a mobile - * device. Responses are captured through callback on IProxyListener. - * - * @param inputStream The input stream of byte data that will be read from. - * @param fileName The SDL file reference name used by the RPC. - * @param offset The data offset in bytes. A value of zero is used to - * indicate data starting from the beginning of the file and a value greater - * than zero is used for resuming partial data chunks. - * @param length The total length of the file being sent. - * @param fileType The selected file type. See the {@link FileType} enum for - * details. - * @param isPersistentFile Indicates if the file is meant to persist between - * sessions / ignition cycles. - * @param isSystemFile Indicates if the file is meant to be passed through - * core to elsewhere in the system. - * @param correlationId A unique id that correlates each RPCRequest and - * RPCResponse. - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public RPCStreamController putFileStream(InputStream inputStream, @NonNull String fileName, Long offset, Long length, @NonNull FileType fileType, Boolean isPersistentFile, Boolean isSystemFile, Boolean isPayloadProtected, Integer correlationId) throws SdlException { - PutFile msg = new PutFile(fileName, fileType); - msg.setCorrelationID(correlationId); - msg.setPersistentFile(isPersistentFile); - msg.setSystemFile(isSystemFile); - msg.setOffset(offset); - msg.setLength(length); - msg.setPayloadProtected(isPayloadProtected); - - return startPutFileStream(inputStream, msg); - } - - /** - * - * Used to end an existing putFileStream that was previously initiated with any putFileStream method. - * - */ - @SuppressWarnings("unused") - public void endPutFileStream() - { - endRPCStream(); - } - - - /** - * Used to push a binary data onto the SDL module from a mobile device, such as icons and album art. Not supported on first generation SDL vehicles. - * Responses are captured through callback on IProxyListener. - * - * @param sdlFileName -File reference name. - * @param fileType -Selected file type. - * @param persistentFile -Indicates if the file is meant to persist between sessions / ignition cycles. - * @param fileData byte array of data of the file that is to be sent - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse. - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void putfile(@NonNull String sdlFileName, @NonNull FileType fileType, Boolean persistentFile, byte[] fileData, Integer correlationID) throws SdlException - { - PutFile msg = new PutFile(sdlFileName, fileType); - msg.setCorrelationID(correlationID); - msg.setPersistentFile(persistentFile); - msg.setBulkData(fileData); - - sendRPCRequest(msg); - } - - /** - * Used to delete a file resident on the SDL module in the app's local cache. Not supported on first generation SDL vehicles. - * Responses are captured through callback on IProxyListener. - * - * @param sdlFileName -File reference name. - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse. - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void deletefile(@NonNull String sdlFileName, Integer correlationID) throws SdlException - { - DeleteFile msg = new DeleteFile(sdlFileName); - msg.setCorrelationID(correlationID); - - sendRPCRequest(msg); - } - - /** - * Requests the current list of resident filenames for the registered app. Not supported on first generation SDL vehicles. - * Responses are captured through callback on IProxyListener. - * - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse. - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void listfiles(Integer correlationID) throws SdlException - { - ListFiles msg = new ListFiles(); - msg.setCorrelationID(correlationID); - - sendRPCRequest(msg); - } - - /** - * Used to set existing local file on SDL as the app's icon. Not supported on first generation SDL vehicles. - * Responses are captured through callback on IProxyListener. - * - * @param sdlFileName -File reference name. - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse. - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void setappicon(@NonNull String sdlFileName, Integer correlationID) throws SdlException - { - SetAppIcon msg = new SetAppIcon(sdlFileName); - msg.setCorrelationID(correlationID); - - sendRPCRequest(msg); - } - - /** - * Set an alternate display layout. If not sent, default screen for given platform will be shown. - * Responses are captured through callback on IProxyListener. - * - * @param displayLayout -Predefined or dynamically created screen layout. - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse. - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void setdisplaylayout(@NonNull String displayLayout, Integer correlationID) throws SdlException - { - SetDisplayLayout msg = new SetDisplayLayout(displayLayout); - msg.setCorrelationID(correlationID); - - sendRPCRequest(msg); - } - - /** - * Set an alternate display layout. If not sent, default screen for given platform will be shown. - * Responses are captured through callback on IProxyListener. - * - * @param displayLayout -Predefined or dynamically created screen layout. - * @param dayColorScheme a TemplateColorScheme object representing the colors that will be used for day color scheme - * @param nightColorScheme a TemplateColorScheme object representing the colors that will be used for night color scheme - * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse. - * @throws SdlException if an unrecoverable error is encountered - */ - @SuppressWarnings("unused") - public void setdisplaylayout(String displayLayout, TemplateColorScheme dayColorScheme, TemplateColorScheme nightColorScheme, Integer correlationID) throws SdlException - { - SetDisplayLayout msg = new SetDisplayLayout(displayLayout); - msg.setCorrelationID(correlationID); - msg.setDayColorScheme(dayColorScheme); - msg.setNightColorScheme(nightColorScheme); - sendRPCRequest(msg); - } - - /** - * Gets the SystemCapabilityManager.
- * @return a SystemCapabilityManager object - */ - public SystemCapabilityManager getSystemCapabilityManager() { - return _systemCapabilityManager; - } - - @SuppressWarnings("unused") - public boolean isCapabilitySupported(SystemCapabilityType systemCapabilityType) { - return _systemCapabilityManager != null && _systemCapabilityManager.isCapabilitySupported(systemCapabilityType); - } - - @SuppressWarnings("unused") - public void getCapability(SystemCapabilityType systemCapabilityType, OnSystemCapabilityListener scListener){ - if(_systemCapabilityManager != null){ - _systemCapabilityManager.getCapability(systemCapabilityType, scListener); - } - } - - @SuppressWarnings("unused") - public Object getCapability(SystemCapabilityType systemCapabilityType){ - if(_systemCapabilityManager != null ){ - return _systemCapabilityManager.getCapability(systemCapabilityType); - }else{ - 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) { - if(_systemCapabilityManager != null){ - _systemCapabilityManager.addOnSystemCapabilityListener(systemCapabilityType, 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){ - if(_systemCapabilityManager != null){ - return _systemCapabilityManager.removeOnSystemCapabilityListener(systemCapabilityType, listener); - } - return false; - } - - /* ******************* END Public Helper Methods *************************/ - - /** - * Gets type of transport currently used by this SdlProxy. - * - * @return One of TransportType enumeration values. - * - * @see TransportType - */ - @SuppressWarnings("unused") - public TransportType getCurrentTransportType() throws IllegalStateException { - if (sdlSession == null) { - throw new IllegalStateException("Incorrect state of SdlProxyBase: Calling for getCurrentTransportType() while connection is not initialized"); - } - - return sdlSession.getCurrentTransportType(); - } - - @Deprecated - public void setSdlSecurityClassList(List> list) { - _secList = list; - } - - /** - * Sets the security libraries and a callback to notify caller when there is update to encryption service - * @param secList The list of security class(es) - * @param listener The callback object - */ - public void setSdlSecurity(@NonNull List> secList, ServiceEncryptionListener listener) { - _secList = secList; - serviceEncryptionListener = listener; - } - - private void setSdlSecurity(SdlSecurityBase sec) { - if (sdlSession != null) - { - sdlSession.setSdlSecurity(sec); - } - } - - /** - * Sets the minimum protocol version that will be permitted to connect. - * If the protocol version of the head unit connected is below this version, - * the app will disconnect with an EndService protocol message and will not register. - * @param minimumProtocolVersion - */ - public void setMinimumProtocolVersion(Version minimumProtocolVersion){ - this.minimumProtocolVersion = minimumProtocolVersion; - } - - /** - * The minimum RPC version that will be permitted to connect. - * If the RPC version of the head unit connected is below this version, an UnregisterAppInterface will be sent. - * @param minimumRPCVersion - */ - public void setMinimumRPCVersion(Version minimumRPCVersion){ - this.minimumRPCVersion = minimumRPCVersion; - } - - @SuppressWarnings("unused") - public boolean isServiceTypeProtected(SessionType sType) { - return sdlSession != null && sdlSession.isServiceProtected(sType); - - } - - - public void addServiceListener(SessionType serviceType, ISdlServiceListener sdlServiceListener){ - if(serviceType != null && sdlSession != null && sdlServiceListener != null){ - sdlSession.addServiceListener(serviceType, sdlServiceListener); - } - } - - public void removeServiceListener(SessionType serviceType, ISdlServiceListener sdlServiceListener){ - if(serviceType != null && sdlSession != null && sdlServiceListener != null){ - sdlSession.removeServiceListener(serviceType, sdlServiceListener); - } - } - - @SuppressWarnings("unused") - public VideoStreamingParameters getAcceptedVideoParams(){ - return sdlSession.getAcceptedVideoParams(); - } - - public IProxyListenerBase getProxyListener() - { - return _proxyListener; - } - - @SuppressWarnings("unused") - public String getAppName() - { - return _applicationName; - } - - @SuppressWarnings("unused") - public String getNgnAppName() - { - return _ngnMediaScreenAppName; - } - - @SuppressWarnings("unused") - public String getAppID() - { - return _appID; - } - @SuppressWarnings("unused") - public DeviceInfo getDeviceInfo() - { - return deviceInfo; - } - @SuppressWarnings("unused") - public long getInstanceDT() - { - return instanceDateTime; - } - @SuppressWarnings("unused") - public void setConnectionDetails(String sDetails) - { - sConnectionDetails = sDetails; - } - @SuppressWarnings("unused") - public String getConnectionDetails() - { - return sConnectionDetails; - } - //for testing only - @SuppressWarnings("unused") - public void setPoliciesURL(String sText) - { - sPoliciesURL = sText; - } - //for testing only - public String getPoliciesURL() - { - return sPoliciesURL; - } - - /** - * Tells developer whether or not their app icon has been resumed on core. - * @return boolean - true if icon was resumed, false if not - * @throws SdlException if proxy is disposed or app is not registered - */ - public boolean getIconResumed() throws SdlException { - // Test if proxy has been disposed - if (_proxyDisposed) { - throw new SdlException("This object has been disposed, it is no long capable of executing methods.", SdlExceptionCause.SDL_PROXY_DISPOSED); - } - - // Test SDL availability - if (!_appInterfaceRegisterd) { - throw new SdlException("SDL is not connected. Unable to determine if app icon was resumed.", SdlExceptionCause.SDL_UNAVAILABLE); - } - return _iconResumed; - } - - /** - * Method to retrieve the RegisterAppInterface Response message that was sent back from the - * module. It contains various attributes about the connected module and can be used to adapt - * to different module types and their supported features. - * - * @return RegisterAppInterfaceResponse received from the module or null if the app has not yet - * registered with the module. - */ - public RegisterAppInterfaceResponse getRegisterAppInterfaceResponse(){ - return this.raiResponse; - } - - /** - * Get the current OnHMIStatus - * @return OnHMIStatus object represents the current OnHMIStatus - */ - public OnHMIStatus getCurrentHMIStatus(){ - return lastHmiStatus; - } - - /** - * Retrieves the auth token, if any, that was attached to the StartServiceACK for the RPC - * service from the module. For example, this should be used to login to a user account. - * @return the string representation of the auth token - */ - public String getAuthToken(){ - return this.authToken; - } - - /** - * VideoStreamingManager houses all the elements needed to create a scoped, streaming manager for video projection. It is only a private, instance - * dependant class at the moment until it can become public. Once the class is public and API defined, it will be moved into the SdlSession class - */ - @TargetApi(19) - private class VideoStreamingManager implements ISdlServiceListener{ - Context context; - ISdl internalInterface; - volatile VirtualDisplayEncoder encoder; - private Class remoteDisplayClass = null; - SdlRemoteDisplay remoteDisplay; - IVideoStreamListener streamListener; - float[] touchScalar = {1.0f,1.0f}; //x, y - //private HapticInterfaceManager hapticManager; - SdlMotionEvent sdlMotionEvent = null; - VideoStreamingParameters videoStreamingParameters; - - public VideoStreamingManager(Context context,ISdl iSdl){ - this.context = context; - this.internalInterface = iSdl; - encoder = new VirtualDisplayEncoder(); - internalInterface.addServiceListener(SessionType.NAV,this); - //Take care of the touch events - internalInterface.addOnRPCNotificationListener(FunctionID.ON_TOUCH_EVENT, new OnRPCNotificationListener() { - @Override - public void onNotified(RPCNotification notification) { - if (notification != null && remoteDisplay != null) { - List events = convertTouchEvent((OnTouchEvent) notification); - if (events != null && !events.isEmpty()) { - for (MotionEvent ev : events) { - remoteDisplay.handleMotionEvent(ev); - } - } - } - } - }); - } - - /** - * Starts the video service, caches the supplied params and prepares for the stream to start. - * @param remoteDisplayClass the extension of SdlRemoteDisplay that will be streamed - * @param parameters desired video streaming params - * @param encrypted if the service is to be encrypted or not - */ - public void startVideoStreaming(Class remoteDisplayClass, VideoStreamingParameters parameters, boolean encrypted){ - this.remoteDisplayClass = remoteDisplayClass; - this.videoStreamingParameters = parameters; - //Make sure the service is started, allows multi transports to connect and register without timing out - internalInterface.startVideoService(parameters, encrypted); - //After this, look to the - } - - /** - * The video service should already be started at this point. Once called, it will start - * the encoders and fire up the remote display supplied by the user - * @param parameters - * @param encrypted - */ - private void startStream(VideoStreamingParameters parameters, boolean encrypted){ - //Start the service first - //streamListener = startVideoStream(encrypted,parameters);d - //streamListener = sdlSession.startVideoStream(); - if(streamListener == null){ - DebugTool.logError(TAG, "Error starting video service"); - return; - } - VideoStreamingCapability capability = (VideoStreamingCapability)_systemCapabilityManager.getCapability(SystemCapabilityType.VIDEO_STREAMING); - if(capability != null && Boolean.TRUE.equals(capability.getIsHapticSpatialDataSupported())){ - //hapticManager = new HapticInterfaceManager(internalInterface); - } - - try { - encoder.init(context, streamListener, parameters); - //We are all set so we can start streaming at at this point - encoder.start(); - //Encoder should be up and running - createRemoteDisplay(encoder.getVirtualDisplay()); - } catch (Exception e) { - e.printStackTrace(); - } - DebugTool.logInfo(TAG, parameters.toString()); - } - - public void stopStreaming(){ - if(remoteDisplay!=null){ - remoteDisplay.stop(); - remoteDisplay = null; - } - if(encoder!=null){ - encoder.shutDown(); - } - if(internalInterface!=null){ - internalInterface.stopVideoService(); - } - } - - public void dispose(){ - stopStreaming(); - internalInterface.removeServiceListener(SessionType.NAV,this); - } - - private void createRemoteDisplay(final Display disp){ - try{ - if (disp == null){ - return; - } - - // Dismiss the current presentation if the display has changed. - if (remoteDisplay != null && remoteDisplay.getDisplay() != disp) { - remoteDisplay.dismissPresentation(); - } - - FutureTask fTask = new FutureTask( new SdlRemoteDisplay.Creator(context, disp, remoteDisplay, remoteDisplayClass, new SdlRemoteDisplay.Callback(){ - @Override - public void onCreated(final SdlRemoteDisplay remoteDisplay) { - //Remote display has been created. - //Now is a good time to do parsing for spatial data - SdlProxyBase.VideoStreamingManager.this.remoteDisplay = remoteDisplay; -// if(hapticManager != null) { -// remoteDisplay.getMainView().post(new Runnable() { -// @Override -// public void run() { -// hapticManager.refreshHapticData(remoteDisplay.getMainView()); -// } -// }); -// } - //Get touch scalars - ImageResolution resolution = null; - if(protocolVersion!= null && protocolVersion.getMajor()>=5){ //At this point we should already have the capability - VideoStreamingCapability capability = (VideoStreamingCapability)_systemCapabilityManager.getCapability(SystemCapabilityType.VIDEO_STREAMING); - if (capability != null) { - resolution = capability.getPreferredResolution(); - } - } - - if(resolution == null){ //Either the protocol version is too low to access video streaming caps, or they were null - DisplayCapabilities dispCap = (DisplayCapabilities) internalInterface.getCapability(SystemCapabilityType.DISPLAY); - if (dispCap != null) { - resolution = (dispCap.getScreenParams().getImageResolution()); - } - } - - if(resolution != null){ - DisplayMetrics displayMetrics = new DisplayMetrics(); - disp.getMetrics(displayMetrics); - touchScalar[0] = ((float)displayMetrics.widthPixels) / resolution.getResolutionWidth(); - touchScalar[1] = ((float)displayMetrics.heightPixels) / resolution.getResolutionHeight(); - } - - } - - @Override - public void onInvalidated(final SdlRemoteDisplay remoteDisplay) { - //Our view has been invalidated - //A good time to refresh spatial data -// if(hapticManager != null) { -// remoteDisplay.getMainView().post(new Runnable() { -// @Override -// public void run() { -// hapticManager.refreshHapticData(remoteDisplay.getMainView()); -// } -// }); -// } - } - } )); - Thread showPresentation = new Thread(fTask); - - showPresentation.start(); - } catch (Exception ex) { - DebugTool.logError(TAG, "Unable to create Virtual Display."); - } - } - - @Override - public void onServiceStarted(SdlSession session, SessionType type, boolean isEncrypted) { - if(SessionType.NAV.equals(type) && session != null ){ - DebugTool.logInfo(TAG, "Video service has been started. Starting video stream from proxy"); - if(session.getAcceptedVideoParams() != null){ - videoStreamingParameters = session.getAcceptedVideoParams(); - } - startStream(videoStreamingParameters, isEncrypted); - } - } - - @Override - public void onServiceEnded(SdlSession session, SessionType type) { - if(SessionType.NAV.equals(type)){ - if(remoteDisplay!=null){ - stopStreaming(); - } - } - } - - @Override - public void onServiceError(SdlSession session, SessionType type, String reason) { - - } - - private List convertTouchEvent(OnTouchEvent onTouchEvent) { - List motionEventList = new ArrayList(); - - List touchEventList = onTouchEvent.getEvent(); - if (touchEventList == null || touchEventList.size() == 0) return null; - - TouchType touchType = onTouchEvent.getType(); - if (touchType == null) { - return null; - } - - if (sdlMotionEvent == null) { - if (touchType == TouchType.BEGIN) { - sdlMotionEvent = new SdlMotionEvent(); - } else { - return null; - } - } - - SdlMotionEvent.Pointer pointer; - MotionEvent motionEvent; - - for (TouchEvent touchEvent : touchEventList) { - if (touchEvent == null || touchEvent.getId() == null) { - continue; - } - - List touchCoordList = touchEvent.getTouchCoordinates(); - if (touchCoordList == null || touchCoordList.size() == 0) { - continue; - } - - TouchCoord touchCoord = touchCoordList.get(touchCoordList.size() - 1); - if (touchCoord == null) { - continue; - } - - int motionEventAction = sdlMotionEvent.getMotionEventAction(touchType, touchEvent); - long downTime = sdlMotionEvent.downTime; - long eventTime = sdlMotionEvent.eventTime; - pointer = sdlMotionEvent.getPointerById(touchEvent.getId()); - if (pointer != null) { - pointer.setCoords(touchCoord.getX() * touchScalar[0], touchCoord.getY() * touchScalar[1]); - } - - MotionEvent.PointerProperties[] pointerProperties = new MotionEvent.PointerProperties[sdlMotionEvent.pointers.size()]; - MotionEvent.PointerCoords[] pointerCoords = new MotionEvent.PointerCoords[sdlMotionEvent.pointers.size()]; - - for (int i = 0; i < sdlMotionEvent.pointers.size(); i++) { - pointerProperties[i] = new MotionEvent.PointerProperties(); - pointerProperties[i].id = sdlMotionEvent.getPointerByIndex(i).id; - pointerProperties[i].toolType = MotionEvent.TOOL_TYPE_FINGER; - - pointerCoords[i] = new MotionEvent.PointerCoords(); - pointerCoords[i].x = sdlMotionEvent.getPointerByIndex(i).x; - pointerCoords[i].y = sdlMotionEvent.getPointerByIndex(i).y; - pointerCoords[i].orientation = 0; - pointerCoords[i].pressure = 1.0f; - pointerCoords[i].size = 1; - } - - motionEvent = MotionEvent.obtain(downTime, eventTime, motionEventAction, - sdlMotionEvent.pointers.size(), pointerProperties, pointerCoords, 0, 0, 1, - 1, 0, 0, InputDevice.SOURCE_TOUCHSCREEN, 0); - motionEventList.add(motionEvent); - - if (motionEventAction == MotionEvent.ACTION_UP || motionEventAction == MotionEvent.ACTION_CANCEL) { - //If the motion event should be finished we should clear our reference - sdlMotionEvent.pointers.clear(); - sdlMotionEvent = null; - break; - } else if ((motionEventAction & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_POINTER_UP) { - sdlMotionEvent.removePointerById(touchEvent.getId()); - } - } - - return motionEventList; - } - } - - /** - * Keeps track of the current motion event for VPM - */ - private static class SdlMotionEvent { - class Pointer { - int id; - float x; - float y; - - Pointer(int id) { - this.id = id; - this.x = 0.0f; - this.y = 0.0f; - } - - void setCoords(float x, float y) { - this.x = x; - this.y = y; - } - } - - private CopyOnWriteArrayList pointers = new CopyOnWriteArrayList<>(); - private long downTime; - private long downTimeOnHMI; - private long eventTime; - - SdlMotionEvent() { - downTimeOnHMI = 0; - } - - /** - * Handles the SDL Touch Event to keep track of pointer status and returns the appropriate - * Android MotionEvent according to this events status - * - * @param touchType The SDL TouchType that was received from the module - * @param touchEvent The SDL TouchEvent that was received from the module - * @return the correct native Android MotionEvent action to dispatch - */ - synchronized int getMotionEventAction(TouchType touchType, TouchEvent touchEvent) { - eventTime = 0; - int motionEventAction = -1; - switch (touchType) { - case BEGIN: - if (pointers.size() == 0) { - //The motion event has just begun - motionEventAction = MotionEvent.ACTION_DOWN; - downTime = SystemClock.uptimeMillis(); - downTimeOnHMI = touchEvent.getTimestamps().get(touchEvent.getTimestamps().size() - 1); - eventTime = downTime; - } else { - motionEventAction = MotionEvent.ACTION_POINTER_DOWN | pointers.size() << MotionEvent.ACTION_POINTER_INDEX_SHIFT; - eventTime = downTime + touchEvent.getTimestamps().get(touchEvent.getTimestamps().size() - 1) - downTimeOnHMI; - } - pointers.add(new Pointer(touchEvent.getId())); - break; - case MOVE: - motionEventAction = MotionEvent.ACTION_MOVE; - eventTime = downTime + touchEvent.getTimestamps().get(touchEvent.getTimestamps().size() - 1) - downTimeOnHMI; - break; - case END: - if(pointers.size() <= 1){ - //The motion event has just ended - motionEventAction = MotionEvent.ACTION_UP; - } else { - int pointerIndex = pointers.indexOf(getPointerById(touchEvent.getId())); - if (pointerIndex != -1) { - motionEventAction = MotionEvent.ACTION_POINTER_UP | pointerIndex << MotionEvent.ACTION_POINTER_INDEX_SHIFT; - } else { - motionEventAction = MotionEvent.ACTION_UP; - } - } - eventTime = downTime + touchEvent.getTimestamps().get(touchEvent.getTimestamps().size() - 1) - downTimeOnHMI; - break; - case CANCEL: - //Assuming this cancels the entire event - motionEventAction = MotionEvent.ACTION_CANCEL; - eventTime = downTime + touchEvent.getTimestamps().get(touchEvent.getTimestamps().size() - 1) - downTimeOnHMI; - break; - default: - break; - } - return motionEventAction; - } - - Pointer getPointerById(int id) { - if (pointers != null && !pointers.isEmpty()) { - for (Pointer pointer : pointers) { - if (pointer.id == id) { - return pointer; - } - } - } - return null; - } - - Pointer getPointerByIndex(int index) { - return pointers.get(index); - } - - void removePointerById(int id) { - pointers.remove(getPointerById(id)); - } - } - -} // end-class diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBuilder.java b/android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBuilder.java deleted file mode 100644 index 5240c4813..000000000 --- a/android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBuilder.java +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ -package com.smartdevicelink.proxy; - -import android.app.Service; -import android.content.Context; - -import com.smartdevicelink.exception.SdlException; -import com.smartdevicelink.proxy.interfaces.IProxyListenerALM; -import com.smartdevicelink.proxy.rpc.SdlMsgVersion; -import com.smartdevicelink.proxy.rpc.TTSChunk; -import com.smartdevicelink.proxy.rpc.TemplateColorScheme; -import com.smartdevicelink.proxy.rpc.enums.AppHMIType; -import com.smartdevicelink.proxy.rpc.enums.Language; -import com.smartdevicelink.security.SdlSecurityBase; -import com.smartdevicelink.transport.BTTransportConfig; -import com.smartdevicelink.transport.BaseTransportConfig; -import com.smartdevicelink.transport.MultiplexTransportConfig; - -import java.util.List; -import java.util.Vector; - -@Deprecated -public class SdlProxyBuilder { - // Required parameters - private IProxyListenerALM listener; - private String appId; - private String appName; - private Boolean isMediaApp; - private Context context; - private BaseTransportConfig mTransport; - - // Optional parameters - private Service service; - private SdlProxyConfigurationResources sdlProxyConfigurationResources; - private Vector ttsChunks; - private String sShortAppName; - private Vector vrSynonyms; - private SdlMsgVersion sdlMessageVersion; - private Language lang; - private Language hmiLang; - private Vector vrAppHMITypes; - private String autoActivateID; - private boolean callbackToUIThread; - private boolean preRegister; - private String sAppResumeHash; - private List> sdlSecList; - private TemplateColorScheme dayColorScheme, nightColorScheme; - - private SdlProxyBuilder() { - service = null; - sdlProxyConfigurationResources = null; - ttsChunks = null; - sShortAppName = null; - vrSynonyms = null; - sdlMessageVersion = null; - lang = Language.EN_US; - hmiLang = Language.EN_US; - vrAppHMITypes = null; - autoActivateID = null; - callbackToUIThread = false; - preRegister = false; - sAppResumeHash = null; - sdlSecList = null; - dayColorScheme = null; - nightColorScheme = null; -} - - public static class Builder { - SdlProxyBuilder sdlProxyBuilder; - - /** - * @deprecated Use Builder(IProxyListenerALM, String, String, Boolean, Context) instead - */ - @Deprecated - public Builder(IProxyListenerALM listener, String appId, String appName, Boolean isMediaApp) { - sdlProxyBuilder = new SdlProxyBuilder(); - sdlProxyBuilder.listener = listener; - sdlProxyBuilder.appId = appId; - sdlProxyBuilder.appName = appName; - sdlProxyBuilder.isMediaApp = isMediaApp; - sdlProxyBuilder.mTransport = new BTTransportConfig(); - } - - public Builder(IProxyListenerALM listener, String appId, String appName, Boolean isMediaApp, Context context) { - sdlProxyBuilder = new SdlProxyBuilder(); - sdlProxyBuilder.listener = listener; - sdlProxyBuilder.appId = appId; - sdlProxyBuilder.appName = appName; - sdlProxyBuilder.isMediaApp = isMediaApp; - sdlProxyBuilder.context = context; - sdlProxyBuilder.mTransport = new MultiplexTransportConfig(context, appId); - } - - public Builder setService(Service val) { - sdlProxyBuilder.service = val; - return this; - } - - public Builder setSdlProxyConfigurationResources(SdlProxyConfigurationResources val) { - sdlProxyBuilder.sdlProxyConfigurationResources = val; - return this; - } - - public Builder setTtsName(Vector val) { - sdlProxyBuilder.ttsChunks = val; - return this; - } - - public Builder setShortAppName(String val) { - sdlProxyBuilder.sShortAppName = val; - return this; - } - - public Builder setVrSynonyms(Vector val) { - sdlProxyBuilder.vrSynonyms = val; - return this; - } - - public Builder setSdlMessageVersion(SdlMsgVersion val) { - sdlProxyBuilder.sdlMessageVersion = val; - return this; - } - - public Builder setLangDesired(Language val) { - sdlProxyBuilder.lang = val; - return this; - } - - public Builder setHMILangDesired(Language val) { - sdlProxyBuilder.hmiLang = val; - return this; - } - - public Builder setVrAppHMITypes(Vector val) { - sdlProxyBuilder.vrAppHMITypes = val; - return this; - } - - public Builder setAutoActivateID(String val) { - sdlProxyBuilder.autoActivateID = val; - return this; - } - - public Builder setCallbackToUIThread(boolean val) { - sdlProxyBuilder.callbackToUIThread = val; - return this; - } - - public Builder setPreRegister(boolean val) { - sdlProxyBuilder.preRegister = val; - return this; - } - - public Builder setAppResumeDataHash(String val) { - sdlProxyBuilder.sAppResumeHash = val; - return this; - } - - public Builder setTransportType(BaseTransportConfig val) { - sdlProxyBuilder.mTransport = val; - return this; - } - - public Builder setSdlSecurity(List> val) { - sdlProxyBuilder.sdlSecList = val; - return this; - } - public Builder setDayColorScheme(TemplateColorScheme val) { - sdlProxyBuilder.dayColorScheme = val; - return this; - } - - public Builder setNightColorScheme(TemplateColorScheme val) { - sdlProxyBuilder.nightColorScheme = val; - return this; - } - - public SdlProxyALM build() throws SdlException { - SdlProxyALM proxy = new SdlProxyALM(sdlProxyBuilder.service, sdlProxyBuilder.listener, - sdlProxyBuilder.sdlProxyConfigurationResources, sdlProxyBuilder.appName, - sdlProxyBuilder.ttsChunks, sdlProxyBuilder.sShortAppName, sdlProxyBuilder.vrSynonyms, - sdlProxyBuilder.isMediaApp, sdlProxyBuilder.sdlMessageVersion, sdlProxyBuilder.lang, - sdlProxyBuilder.hmiLang, sdlProxyBuilder.vrAppHMITypes, sdlProxyBuilder.appId, - sdlProxyBuilder.autoActivateID, sdlProxyBuilder.dayColorScheme, sdlProxyBuilder.nightColorScheme, - sdlProxyBuilder.callbackToUIThread, sdlProxyBuilder.preRegister, - sdlProxyBuilder.sAppResumeHash, sdlProxyBuilder.mTransport); - proxy.setSdlSecurityClassList(sdlProxyBuilder.sdlSecList); - return proxy; - } - } -} - - - diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyConfigurationResources.java b/android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyConfigurationResources.java deleted file mode 100644 index 6e76db82a..000000000 --- a/android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyConfigurationResources.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ -package com.smartdevicelink.proxy; - -import android.telephony.TelephonyManager; - -@Deprecated -public class SdlProxyConfigurationResources { - private String _sdlConfigurationFilePath; - private TelephonyManager _telephonyManager; - - public SdlProxyConfigurationResources() { - this(null, null); - } - - public SdlProxyConfigurationResources(String sdlConfigurationFilePath, - TelephonyManager telephonyManager) { - _sdlConfigurationFilePath = sdlConfigurationFilePath; - _telephonyManager = telephonyManager; - } - - public void setSdlConfigurationFilePath(String sdlConfigurationFilePath) { - _sdlConfigurationFilePath = sdlConfigurationFilePath; - } - - public String getSdlConfigurationFilePath() { - return _sdlConfigurationFilePath; - } - - public void setTelephonyManager(TelephonyManager telephonyManager) { - _telephonyManager = telephonyManager; - } - - public TelephonyManager getTelephonyManager() { - return _telephonyManager; - } -} diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/proxy/Version.java b/android/sdl_android/src/main/java/com/smartdevicelink/proxy/Version.java deleted file mode 100644 index 9b6f0d971..000000000 --- a/android/sdl_android/src/main/java/com/smartdevicelink/proxy/Version.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ -package com.smartdevicelink.proxy; - -import com.smartdevicelink.BuildConfig; - -@Deprecated -public class Version { - public static final String VERSION = BuildConfig.VERSION_NAME; -} diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/streaming/StreamRPCPacketizer.java b/android/sdl_android/src/main/java/com/smartdevicelink/streaming/StreamRPCPacketizer.java index 91623dd9d..6d93205c1 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/streaming/StreamRPCPacketizer.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/streaming/StreamRPCPacketizer.java @@ -39,8 +39,6 @@ import com.smartdevicelink.protocol.enums.MessageType; import com.smartdevicelink.protocol.enums.SessionType; import com.smartdevicelink.proxy.RPCRequest; import com.smartdevicelink.proxy.RPCResponse; -import com.smartdevicelink.proxy.SdlProxyBase; -import com.smartdevicelink.proxy.interfaces.IProxyListenerBase; import com.smartdevicelink.proxy.interfaces.IPutFileResponseListener; import com.smartdevicelink.proxy.rpc.PutFile; import com.smartdevicelink.proxy.rpc.PutFileResponse; @@ -57,8 +55,8 @@ public class StreamRPCPacketizer extends AbstractPacketizer implements IPutFileR private Thread thread = null; private long lFileSize = 0; private String sFileName; - private SdlProxyBase _proxy; - private IProxyListenerBase _proxyListener; + private Object _proxy; + private Object _proxyListener; private Object mPauseLock; private boolean mPaused; @@ -67,7 +65,7 @@ public class StreamRPCPacketizer extends AbstractPacketizer implements IPutFileR private Version rpcSpecVersion; - public StreamRPCPacketizer(SdlProxyBase proxy, IStreamListener streamListener, InputStream is, RPCRequest request, SessionType sType, byte rpcSessionID, byte wiproVersion, long lLength, SdlSession session) throws IOException { + public StreamRPCPacketizer(Object proxy, IStreamListener streamListener, InputStream is, RPCRequest request, SessionType sType, byte rpcSessionID, byte wiproVersion, long lLength, SdlSession session) throws IOException { super(streamListener, is, request, sType, rpcSessionID, wiproVersion, session); lFileSize = lLength; iInitialCorrID = request.getCorrelationID(); @@ -77,15 +75,15 @@ public class StreamRPCPacketizer extends AbstractPacketizer implements IPutFileR if (proxy != null) { _proxy = proxy; - _proxyListener = _proxy.getProxyListener(); - _proxy.addPutFileResponseListener(this); + //_proxyListener = _proxy.getProxyListener(); + //_proxy.addPutFileResponseListener(this); } if(_request.getFunctionName().equalsIgnoreCase(FunctionID.PUT_FILE.toString())){ //callBack = ((PutFile)_request).getOnPutFileUpdateListener(); } } - public StreamRPCPacketizer(SdlProxyBase proxy, IStreamListener streamListener, InputStream is, RPCRequest request, SessionType sType, byte rpcSessionID, Version wiproVersion, Version rpcSpecVersion, long lLength, SdlSession session) throws IOException { + public StreamRPCPacketizer(Object proxy, IStreamListener streamListener, InputStream is, RPCRequest request, SessionType sType, byte rpcSessionID, Version wiproVersion, Version rpcSpecVersion, long lLength, SdlSession session) throws IOException { super(streamListener, is, request, sType, rpcSessionID, wiproVersion, session); this.rpcSpecVersion = rpcSpecVersion; lFileSize = lLength; @@ -95,8 +93,8 @@ public class StreamRPCPacketizer extends AbstractPacketizer implements IPutFileR isRPCProtected = request.isPayloadProtected(); if (proxy != null) { _proxy = proxy; - _proxyListener = _proxy.getProxyListener(); - _proxy.addPutFileResponseListener(this); + //_proxyListener = _proxy.getProxyListener(); + //_proxy.addPutFileResponseListener(this); } if(_request.getFunctionName().equalsIgnoreCase(FunctionID.PUT_FILE.toString())){ //callBack = ((PutFile)_request).getOnPutFileUpdateListener(); diff --git a/base/src/main/java/com/smartdevicelink/proxy/IProxyListener.java b/base/src/main/java/com/smartdevicelink/proxy/IProxyListener.java deleted file mode 100644 index c8c2bbf42..000000000 --- a/base/src/main/java/com/smartdevicelink/proxy/IProxyListener.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ -package com.smartdevicelink.proxy; - -import com.smartdevicelink.proxy.interfaces.IProxyListenerBase; -import com.smartdevicelink.proxy.rpc.OnAppInterfaceUnregistered; -import com.smartdevicelink.proxy.rpc.RegisterAppInterfaceResponse; -import com.smartdevicelink.proxy.rpc.UnregisterAppInterfaceResponse; - -@Deprecated -public interface IProxyListener extends IProxyListenerBase{ - // Adds Legacy Life-cycle Management call-backs to the IProxyListenerAbstract interface - - public void onProxyOpened(); - - public void onRegisterAppInterfaceResponse(RegisterAppInterfaceResponse response); - - public void onOnAppInterfaceUnregistered(OnAppInterfaceUnregistered notification); - - public void onUnregisterAppInterfaceResponse(UnregisterAppInterfaceResponse response); - -} diff --git a/base/src/main/java/com/smartdevicelink/proxy/interfaces/IProxyListenerALM.java b/base/src/main/java/com/smartdevicelink/proxy/interfaces/IProxyListenerALM.java deleted file mode 100644 index eb3d00c6b..000000000 --- a/base/src/main/java/com/smartdevicelink/proxy/interfaces/IProxyListenerALM.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ -package com.smartdevicelink.proxy.interfaces; - -@Deprecated -public interface IProxyListenerALM extends IProxyListenerBase { - // All methods moved into base interface -} 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 e00309fb5..000000000 --- a/base/src/main/java/com/smartdevicelink/proxy/interfaces/IProxyListenerBase.java +++ /dev/null @@ -1,461 +0,0 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ -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.CancelInteractionResponse; -import com.smartdevicelink.proxy.rpc.ChangeRegistrationResponse; -import com.smartdevicelink.proxy.rpc.CloseApplicationResponse; -import com.smartdevicelink.proxy.rpc.CreateInteractionChoiceSetResponse; -import com.smartdevicelink.proxy.rpc.CreateWindowResponse; -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.DeleteWindowResponse; -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.GetAppServiceDataResponse; -import com.smartdevicelink.proxy.rpc.GetCloudAppPropertiesResponse; -import com.smartdevicelink.proxy.rpc.GetDTCsResponse; -import com.smartdevicelink.proxy.rpc.GetFileResponse; -import com.smartdevicelink.proxy.rpc.GetInteriorVehicleDataConsentResponse; -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.OnAppServiceData; -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.OnPermissionsChange; -import com.smartdevicelink.proxy.rpc.OnRCStatus; -import com.smartdevicelink.proxy.rpc.OnSystemCapabilityUpdated; -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.PerformAppServiceInteractionResponse; -import com.smartdevicelink.proxy.rpc.PerformAudioPassThruResponse; -import com.smartdevicelink.proxy.rpc.PerformInteractionResponse; -import com.smartdevicelink.proxy.rpc.PublishAppServiceResponse; -import com.smartdevicelink.proxy.rpc.PutFileResponse; -import com.smartdevicelink.proxy.rpc.ReadDIDResponse; -import com.smartdevicelink.proxy.rpc.ReleaseInteriorVehicleDataModuleResponse; -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.SetCloudAppPropertiesResponse; -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.ShowAppMenuResponse; -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.SubscribeButtonResponse; -import com.smartdevicelink.proxy.rpc.SubscribeVehicleDataResponse; -import com.smartdevicelink.proxy.rpc.SubscribeWayPointsResponse; -import com.smartdevicelink.proxy.rpc.SystemRequestResponse; -import com.smartdevicelink.proxy.rpc.UnpublishAppServiceResponse; -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; - -@Deprecated -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 onCreateWindowResponse(CreateWindowResponse response); - - public void onDeleteWindowResponse(DeleteWindowResponse 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); - - public void onSetCloudAppProperties(SetCloudAppPropertiesResponse response); - - public void onGetCloudAppProperties(GetCloudAppPropertiesResponse response); - - public void onPublishAppServiceResponse(PublishAppServiceResponse response); - - public void onGetAppServiceDataResponse(GetAppServiceDataResponse response); - - public void onGetFileResponse(GetFileResponse response); - - public void onPerformAppServiceInteractionResponse(PerformAppServiceInteractionResponse response); - - public void onOnAppServiceData(OnAppServiceData notification); - - public void onGetInteriorVehicleDataConsentResponse(GetInteriorVehicleDataConsentResponse response); - - public void onReleaseInteriorVehicleDataModuleResponse(ReleaseInteriorVehicleDataModuleResponse response); - - public void onOnSystemCapabilityUpdated(OnSystemCapabilityUpdated notification); - - /** - * onCloseApplicationResponse being called indicates that SDL has - * responded to a request to close the application on the module. - * - * @param response - Contains information about the response sent from SDL. - */ - public void onCloseApplicationResponse(CloseApplicationResponse response); - - /** - * onCancelInteractionResponse being called indicates that SDL has - * responded to a request to dismiss a modal view on the module. - * - * @param response - Contains information about the response sent from SDL. - */ - public void onCancelInteractionResponse(CancelInteractionResponse response); - - /** - * UnpublishAppServiceResponse being called indicates that SDL has - * responded to a request to close the application on the module. - * - * @param response - Contains information about the response sent from SDL. - */ - public void onUnpublishAppServiceResponse(UnpublishAppServiceResponse response); - - /** - * onShowAppMenuResponse being called indicates that SDL has - * responded to a request to close the application on the module. - * - * @param response - Contains information about the response sent from SDL. - */ - public void onShowAppMenuResponse(ShowAppMenuResponse response); -} -- cgit v1.2.1 From 17b352a54bec89bba496e9ef19a432b3e3b9e9f1 Mon Sep 17 00:00:00 2001 From: Joey Grover Date: Fri, 28 Aug 2020 11:41:45 -0400 Subject: Remove old transport classes --- .../test/streaming/AbstractPacketizerTests.java | 2 - .../test/streaming/StreamPacketizerTests.java | 2 - .../test/transport/BTTransportConfigTests.java | 43 - .../transport/MultiplexTransportTest.java | 22 - .../managers/lifecycle/LifecycleManager.java | 17 - .../transport/BTTransportConfig.java | 71 -- .../transport/SdlBroadcastReceiver.java | 4 +- .../smartdevicelink/transport/SdlTransport.java | 154 ---- .../smartdevicelink/transport/TCPTransport.java | 557 ------------- .../transport/USBAccessoryAttachmentActivity.java | 2 +- .../smartdevicelink/transport/USBTransport.java | 915 --------------------- .../transport/USBTransportConfig.java | 135 --- .../transport/ITransportListener.java | 48 -- .../transport/TransportConstants.java | 10 + 14 files changed, 13 insertions(+), 1969 deletions(-) delete mode 100644 android/sdl_android/src/androidTest/java/com/smartdevicelink/test/transport/BTTransportConfigTests.java delete mode 100644 android/sdl_android/src/main/java/com/smartdevicelink/transport/BTTransportConfig.java delete mode 100644 android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlTransport.java delete mode 100644 android/sdl_android/src/main/java/com/smartdevicelink/transport/TCPTransport.java delete mode 100644 android/sdl_android/src/main/java/com/smartdevicelink/transport/USBTransport.java delete mode 100644 android/sdl_android/src/main/java/com/smartdevicelink/transport/USBTransportConfig.java delete mode 100644 base/src/main/java/com/smartdevicelink/transport/ITransportListener.java diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/AbstractPacketizerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/AbstractPacketizerTests.java index e5e47f3a5..28b1520d2 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/AbstractPacketizerTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/AbstractPacketizerTests.java @@ -5,8 +5,6 @@ import com.smartdevicelink.protocol.enums.SessionType; import com.smartdevicelink.proxy.RPCRequest; import com.smartdevicelink.streaming.IStreamListener; import com.smartdevicelink.test.TestValues; -import com.smartdevicelink.transport.BTTransportConfig; -import com.smartdevicelink.transport.BaseTransportConfig; import com.smartdevicelink.transport.MultiplexTransportConfig; import com.smartdevicelink.util.Version; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/StreamPacketizerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/StreamPacketizerTests.java index 736798d67..bf6f6a850 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/StreamPacketizerTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/StreamPacketizerTests.java @@ -7,8 +7,6 @@ import com.smartdevicelink.proxy.interfaces.IVideoStreamListener; import com.smartdevicelink.streaming.IStreamListener; import com.smartdevicelink.streaming.StreamPacketizer; import com.smartdevicelink.test.TestValues; -import com.smartdevicelink.transport.BTTransportConfig; -import com.smartdevicelink.transport.BaseTransportConfig; import com.smartdevicelink.transport.MultiplexTransportConfig; import junit.framework.TestCase; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/transport/BTTransportConfigTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/transport/BTTransportConfigTests.java deleted file mode 100644 index edb932f62..000000000 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/transport/BTTransportConfigTests.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.smartdevicelink.test.transport; - -import com.smartdevicelink.test.TestValues; -import com.smartdevicelink.transport.BTTransportConfig; -import com.smartdevicelink.transport.enums.TransportType; - -import junit.framework.TestCase; - -/** - * This is a unit test class for the SmartDeviceLink library project class : - * {@link com.smartdevicelink.transport.BtTransportConfig} - */ -public class BTTransportConfigTests extends TestCase { - - /** - * This is a unit test for the following methods : - * {@link com.smartdevicelink.transport.BtTransportConfig#getTransportType()} - * {@link com.smartdevicelink.transport.BtTransportConfig#setKeepSocketActive(boolean)} - * {@link com.smartdevicelink.transport.BtTransportConfig#getKeepSocketActive} - */ - public void testConfigs () { - - // Test Values - boolean testBoolean = true; - BTTransportConfig testConfig1 = new BTTransportConfig(); - BTTransportConfig testConfig2 = new BTTransportConfig(testBoolean); - - // Comparison Values - TransportType expectedTransportType = TransportType.BLUETOOTH; - boolean actualShareConnection = testConfig2.shareConnection(); - TransportType actualTransportType = testConfig1.getTransportType(); - - // Valid Tests - assertEquals(TestValues.MATCH, expectedTransportType, actualTransportType); - assertTrue(TestValues.TRUE, actualShareConnection); - - - testConfig1.setKeepSocketActive(true); - assertTrue(TestValues.TRUE, testConfig1.getKeepSocketActive()); - testConfig1.setKeepSocketActive(false); - assertFalse(TestValues.FALSE, testConfig1.getKeepSocketActive()); - } -} \ No newline at end of file diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/MultiplexTransportTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/MultiplexTransportTest.java index 6f4f0231b..075f89a81 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/MultiplexTransportTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/MultiplexTransportTest.java @@ -6,7 +6,6 @@ import android.os.Looper; import android.os.Message; import androidx.test.ext.junit.runners.AndroidJUnit4; -import com.smartdevicelink.protocol.SdlPacket; import org.junit.Before; import org.junit.Test; @@ -15,13 +14,11 @@ import org.junit.runner.RunWith; import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; -import static junit.framework.TestCase.assertTrue; @RunWith(AndroidJUnit4.class) public class MultiplexTransportTest { RouterServiceValidator rsvp; - ITransportListener transportListener; @Before @@ -29,26 +26,7 @@ public class MultiplexTransportTest { rsvp = new RouterServiceValidator(getInstrumentation().getTargetContext()); rsvp.setFlags(RouterServiceValidator.FLAG_DEBUG_NONE); rsvp.validate(); - - transportListener = new ITransportListener(){ - - @Override - public void onTransportPacketReceived(SdlPacket packet) { - } - - @Override - public void onTransportConnected() { - } - - @Override - public void onTransportDisconnected(String info) { - } - @Override - public void onTransportError(String info, Exception e) { - } - - }; } // test for setting error state. diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java b/android/sdl_android/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java index 73757292b..2fe65b2fc 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java @@ -48,7 +48,6 @@ import com.smartdevicelink.streaming.video.VideoStreamingParameters; import com.smartdevicelink.transport.BaseTransportConfig; import com.smartdevicelink.transport.MultiplexTransportConfig; import com.smartdevicelink.transport.TCPTransportConfig; -import com.smartdevicelink.transport.USBTransportConfig; import com.smartdevicelink.transport.enums.TransportType; import com.smartdevicelink.util.DebugTool; @@ -76,22 +75,6 @@ public class LifecycleManager extends BaseLifecycleManager { void initialize() { super.initialize(); - //Handle legacy USB connections - if (_transportConfig != null && TransportType.USB.equals(_transportConfig.getTransportType())) { - //A USB transport config was provided - USBTransportConfig usbTransportConfig = (USBTransportConfig) _transportConfig; - if (usbTransportConfig.getUsbAccessory() == null) { - DebugTool.logInfo(TAG,"Legacy USB transport config was used, but received null for accessory. Attempting to connect with router service"); - //The accessory was null which means it came from a router service - MultiplexTransportConfig multiplexTransportConfig = new MultiplexTransportConfig(usbTransportConfig.getUSBContext(), appConfig.getAppID()); - multiplexTransportConfig.setRequiresHighBandwidth(true); - multiplexTransportConfig.setSecurityLevel(MultiplexTransportConfig.FLAG_MULTI_SECURITY_OFF); - multiplexTransportConfig.setPrimaryTransports(Collections.singletonList(TransportType.USB)); - multiplexTransportConfig.setSecondaryTransports(new ArrayList()); - _transportConfig = multiplexTransportConfig; - } - } - if (_transportConfig != null && _transportConfig.getTransportType().equals(TransportType.MULTIPLEX)) { this.session = new SdlSession(sdlSessionListener, (MultiplexTransportConfig) _transportConfig); } else if (_transportConfig != null && _transportConfig.getTransportType().equals(TransportType.TCP)) { diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/BTTransportConfig.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/BTTransportConfig.java deleted file mode 100644 index 3b4123b3a..000000000 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/BTTransportConfig.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ -package com.smartdevicelink.transport; - -import com.smartdevicelink.transport.enums.TransportType; - -/** - * Container of Bluetooth transport specific configuration. - */ -@Deprecated -public final class BTTransportConfig extends BaseTransportConfig { - - private boolean bKeepSocketActive = true; - - /** - * Overridden abstract method which returns specific type of this transport configuration. - * - * @return Constant value TransportType.BLUETOOTH. - * - * @see TransportType - */ - public TransportType getTransportType() { - return TransportType.BLUETOOTH; - } - - public BTTransportConfig() { - this(true); - } - - public BTTransportConfig(boolean shareConnection) { - super.shareConnection = shareConnection; - } - - public void setKeepSocketActive(boolean bValue) { - bKeepSocketActive = bValue; - } - - public boolean getKeepSocketActive() { - return bKeepSocketActive; - } - -} diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlBroadcastReceiver.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlBroadcastReceiver.java index 4ed1b85f4..1ad6a3e9a 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlBroadcastReceiver.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlBroadcastReceiver.java @@ -113,14 +113,14 @@ public abstract class SdlBroadcastReceiver extends BroadcastReceiver{ } if(!(action.equalsIgnoreCase(BluetoothDevice.ACTION_ACL_CONNECTED) - || action.equalsIgnoreCase(USBTransport.ACTION_USB_ACCESSORY_ATTACHED) + || action.equalsIgnoreCase(TransportConstants.ACTION_USB_ACCESSORY_ATTACHED) || action.equalsIgnoreCase(TransportConstants.START_ROUTER_SERVICE_ACTION))){ //We don't want anything else here if the child class called super and has different intent filters //Log.i(TAG, "Unwanted intent from child class"); return; } - if(action.equalsIgnoreCase(USBTransport.ACTION_USB_ACCESSORY_ATTACHED)){ + if(action.equalsIgnoreCase(TransportConstants.ACTION_USB_ACCESSORY_ATTACHED)){ DebugTool.logInfo(TAG,"Usb connected"); intent.setAction(null); onSdlEnabled(context, intent); diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlTransport.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlTransport.java deleted file mode 100644 index 32fe26fee..000000000 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlTransport.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ -package com.smartdevicelink.transport; - -import com.smartdevicelink.exception.SdlException; -import com.smartdevicelink.protocol.SdlPacket; -import com.smartdevicelink.trace.SdlTrace; -import com.smartdevicelink.trace.enums.InterfaceActivityDirection; -import com.smartdevicelink.transport.enums.TransportType; -import com.smartdevicelink.util.DebugTool; - -public abstract class SdlTransport { - private static final String TAG = "SdlTransport"; - private static final String SDL_LIB_TRACE_KEY = "42baba60-eb57-11df-98cf-0800200c9a66"; - - private final static String FailurePropagating_Msg = "Failure propagating "; - private Boolean isConnected = false; - - private String _sendLockObj = "lock"; - - - // Get status of transport connection - public Boolean getIsConnected() { - return isConnected; - } - - //protected SdlTransport(String endpointName, String param2, ITransportListener transportListener) - protected SdlTransport(ITransportListener transportListener) { - if (transportListener == null) { - throw new IllegalArgumentException("Provided transport listener interface reference is null"); - } // end-if - _transportListener = transportListener; - } // end-method - - // This method is called by the subclass to indicate that data has arrived from - // the transport. - protected void handleReceivedPacket(SdlPacket packet) { - try { - // Trace received data - if (packet!=null) { - // Send transport data to the siphon server - //FIXME SiphonServer.sendBytesFromSDL(receivedBytes, 0, receivedBytesLength); - //SdlTrace.logTransportEvent("", null, InterfaceActivityDirection.Receive, receivedBytes, receivedBytesLength, SDL_LIB_TRACE_KEY); - - _transportListener.onTransportPacketReceived(packet); - } // end-if - } catch (Exception excp) { - DebugTool.logError(TAG, FailurePropagating_Msg + "handleBytesFromTransport: " + excp.toString(), excp); - handleTransportError(FailurePropagating_Msg, excp); - } // end-catch - } // end-method - - // This method must be implemented by transport subclass, and is called by this - // base class to actually send an array of bytes out over the transport. This - // method is meant to only be callable within the class hierarchy. - protected abstract boolean sendBytesOverTransport(SdlPacket packet); - - // This method is called by whomever has reference to transport to have bytes - // sent out over transport. - /* public boolean sendBytes(byte[] message) { - return sendBytes(message, 0, message.length); - }*/ // end-method - - // This method is called by whomever has reference to transport to have bytes - // sent out over transport. - public boolean sendBytes(SdlPacket packet) { - boolean bytesWereSent = false; - synchronized (_sendLockObj) { - bytesWereSent = sendBytesOverTransport(packet);//message, offset, length); - } // end-lock - // Send transport data to the siphon server - //FIXME SiphonServer.sendBytesFromAPP(message, offset, length); - - //FIXME SdlTrace.logTransportEvent("", null, InterfaceActivityDirection.Transmit, message, offset, length, SDL_LIB_TRACE_KEY); - return bytesWereSent; - } // end-method - - private ITransportListener _transportListener = null; - - // This method is called by the subclass to indicate that transport connection - // has been established. - protected void handleTransportConnected() { - isConnected = true; - try { - SdlTrace.logTransportEvent("Transport.connected", null, InterfaceActivityDirection.Receive, null, 0, SDL_LIB_TRACE_KEY); - _transportListener.onTransportConnected(); - } catch (Exception excp) { - DebugTool.logError(TAG, FailurePropagating_Msg + "onTransportConnected: " + excp.toString(), excp); - handleTransportError(FailurePropagating_Msg + "onTransportConnected", excp); - } // end-catch - } // end-method - - // This method is called by the subclass to indicate that transport disconnection - // has occurred. - protected void handleTransportDisconnected(final String info) { - isConnected = false; - - try { - SdlTrace.logTransportEvent("Transport.disconnect: " + info, null, InterfaceActivityDirection.Transmit, null, 0, SDL_LIB_TRACE_KEY); - _transportListener.onTransportDisconnected(info); - } catch (Exception excp) { - DebugTool.logError(TAG, FailurePropagating_Msg + "onTransportDisconnected: " + excp.toString(), excp); - } // end-catch - } // end-method - - // This method is called by the subclass to indicate a transport error has occurred. - protected void handleTransportError(final String message, final Exception ex) { - isConnected = false; - _transportListener.onTransportError(message, ex); - } - - public abstract void openConnection() throws SdlException; - public abstract void disconnect(); - - /** - * Abstract method which should be implemented by subclasses in order to return actual type of the transport. - * - * @return One of {@link TransportType} enumeration values. - * - * @see TransportType - */ - public abstract TransportType getTransportType(); - - public abstract String getBroadcastComment(); -} // end-class diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/TCPTransport.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/TCPTransport.java deleted file mode 100644 index cc123d041..000000000 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/TCPTransport.java +++ /dev/null @@ -1,557 +0,0 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ -package com.smartdevicelink.transport; - -import android.annotation.SuppressLint; -import android.os.NetworkOnMainThreadException; - -import com.smartdevicelink.exception.SdlException; -import com.smartdevicelink.exception.SdlExceptionCause; -import com.smartdevicelink.protocol.SdlPacket; -import com.smartdevicelink.transport.enums.TransportType; -import com.smartdevicelink.util.DebugTool; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.InetSocketAddress; -import java.net.Socket; - -/** - * General comments: - * - * 1) Transport layer can be reorganized to properly incapsulate thread-related code according to Android OS guidelines - * 2) Currently there are different cases when transport error information sent to listener components - * a) when there are some errors during writing data to transport - * b) when there are errors during connection establishing/reading data - * But information about transport disconnection is sent only if disconnection was successful. So we have following - * sequences: - * a) handleTransportConnected -> read without errors -> handleTransportDisconnected - * b) handleTransportConnected -> handleTransportError(write with errors) -> handleTransportDisconnected - * c) handleTransportConnected -> handleTransportError(read with errors) -> handleTransportError(socket closed) - * - * They can be changed to be more natural and easy to use. - * - * 3) Public api is inconsistent. During single call of some api method (for example "openConnection") some of the - * following result can appears: - * a) SdlException thrown - * b) onTransportError callback called on listeners - * - * 4) Handling of connection must be more stable - * 5) General solution in case of reconnecting must be implemented - * 6) It must be common and same solution for handling information about physical device adapters (BT, WiFi etc.) - */ - -/** - * Class that implements TCP transport - */ -public class TCPTransport extends SdlTransport { - private static final String TAG = "TCPTransport"; - /** - * Size of the read buffer. - */ - private static final int READ_BUFFER_SIZE = 4096; - - /** - * Delay between reconnect attempts - */ - private static final int RECONNECT_DELAY = 5000; - - /** - * Count of the reconnect retries - */ - private static final int RECONNECT_RETRY_COUNT = 30; - - /** - * Instance of TCP transport configuration - */ - private TCPTransportConfig mConfig = null; - - /** - * Instance of the client socket - */ - private Socket mSocket = null; - - /** - * Instance of the input stream. Used to read data from SmartDeviceLinkCore - */ - private InputStream mInputStream = null; - - /** - * Instance of the output stream. Used to send data to SmartDeviceLinkCore - */ - private OutputStream mOutputStream = null; - - /** - * Instance of the separate thread, that does actual work, related to connecting/reading/writing data - */ - private TCPTransportThread mThread = null; - - /** - * Initial internal state of the component. Used like a simple lightweight FSM replacement while component - * must behave differently in response to it's public function calls depending of it's current state - */ - private TCPTransportState mCurrentState = TCPTransportState.IDLE; - - /** - * Constructs TCP transport component instance - * - * @param tcpTransportConfig Instance of the TCP transport configuration - * @param transportListener Listener that will be notified on different TCP transport activities - */ - public TCPTransport(TCPTransportConfig tcpTransportConfig, ITransportListener transportListener) { - super(transportListener); - this.mConfig = tcpTransportConfig; - } - - /** - * Performs actual work of sending array of bytes over the transport - * @param packet The SdlPacket that should be sent over the transport - * @return True if data was sent successfully, False otherwise - */ - @SuppressLint("DefaultLocale") - @Override - protected boolean sendBytesOverTransport(SdlPacket packet) { - TCPTransportState currentState = getCurrentState(); - byte[] msgBytes = packet.constructPacket(); - logInfo(String.format("TCPTransport: sendBytesOverTransport requested. Size: %d, Offset: %d, Length: %d, Current state is: %s" - , msgBytes.length, 0, msgBytes.length, currentState.name())); - - boolean bResult = false; - - if(currentState == TCPTransportState.CONNECTED) { - if (mOutputStream != null) { - logInfo("TCPTransport: sendBytesOverTransport request accepted. Trying to send data"); - try { - mOutputStream.write(msgBytes, 0, msgBytes.length); - bResult = true; - logInfo("TCPTransport.sendBytesOverTransport: successfully send data"); - } catch (IOException | NetworkOnMainThreadException e) { - logError("TCPTransport.sendBytesOverTransport: error during sending data: " + e.getMessage()); - bResult = false; - } - } else { - logError("TCPTransport: sendBytesOverTransport request accepted, but output stream is null"); - } - } - else { - logInfo("TCPTransport: sendBytesOverTransport request rejected. Transport is not connected"); - bResult = false; - } - - return bResult; - } - - /** - * Tries to open connection to SmartDeviceLinkCore. - * Actual try will be performed only if no actual connection is available - * @throws SdlException - */ - @Override - public void openConnection() throws SdlException { - TCPTransportState currentState = getCurrentState(); - logInfo(String.format("TCPTransport: openConnection requested. Current state is: %s", currentState.name())); - - if(currentState == TCPTransportState.IDLE) { - synchronized (this) { - setCurrentState(TCPTransportState.CONNECTING); - logInfo("TCPTransport: openConnection request accepted. Starting transport thread"); - try { - mThread = new TCPTransportThread(); - mThread.setDaemon(true); - mThread.start(); - - // Initialize the SiphonServer - if (SiphonServer.getSiphonEnabledStatus()) { - SiphonServer.init(); - } - - } catch (Exception e) { - logError("TCPTransport: Exception during transport thread starting", e); - throw new SdlException(e); - } - } - } else { - logInfo("TCPTransport: openConnection request rejected. Another connection is not finished"); - } - } - - - /** - * Tries to disconnect from SmartDeviceLinkCore. - * Actual try will be performed only if connection is available - */ - @Override - public void disconnect() { - TCPTransportState currentState = getCurrentState(); - logInfo(String.format("TCPTransport: disconnect requested from client. Current state is: %s", currentState.name())); - - if(currentState == TCPTransportState.CONNECTED) { - logInfo("TCPTransport: disconnect request accepted."); - synchronized (this) { - disconnect(null, null, true); - } - } else { - logInfo("TCPTransport: disconnect request rejected. Transport is not connected"); - } - } - - /** - * Performs actual work related to disconnecting from SmartDeviceLinkCore. - * - * @param message Message that describes disconnect reason - * @param exception Some of the possible exceptions that was the reason of disconnecting - * @param stopThread True if not only disconnection must be done but also thread that handles connection must be - * also stopped so no reconnect attempts will be made - */ - private synchronized void disconnect(String message, Exception exception, boolean stopThread) { - - if(getCurrentState() == TCPTransportState.DISCONNECTING) { - logInfo("TCPTransport: disconnecting already in progress"); - return; - } - - setCurrentState(TCPTransportState.DISCONNECTING); - - String disconnectMsg = (message == null ? "" : message); - if (exception != null) { - disconnectMsg += ", " + exception.toString(); - } - - try { - if(mThread != null && stopThread) { - mThread.halt(); - mThread.interrupt(); - } - - if(mSocket != null){ - mSocket.close(); - } - mSocket = null; - } catch (IOException e) { - logError("TCPTransport.disconnect: Exception during disconnect: " + e.getMessage()); - } - - if (exception == null) { - // This disconnect was not caused by an error, notify the proxy that - // the transport has been disconnected. - logInfo("Disconnect is correct. Handling it"); - handleTransportDisconnected(disconnectMsg); - } else { - // This disconnect was caused by an error, notify the proxy - // that there was a transport error. - logError("Disconnect is incorrect. Handling it as error"); - handleTransportError(disconnectMsg, exception); - } - } - - /** - * Overridden abstract method which returns specific type of this transport. - * - * @return Constant value - TransportType.TCP. - * - * @see TransportType - */ - public TransportType getTransportType() { - return TransportType.TCP; - } - - /** - * Internal method for logging information messages - * @param message Message to log - */ - protected void logInfo(String message) { - DebugTool.logInfo(TAG, message); - } - - /** - * Internal method for logging error messages - * @param message Message to log - */ - protected void logError(String message) { - DebugTool.logError(TAG, message); - } - - /** - * Internal method for logging warning messages - * @param message Message to log - */ - protected void logWarning(String message) { - DebugTool.logWarning(TAG, message); - } - - /** - * Internal method for logging error message together with information about exception that was the reason of it - * @param message Message to log - * @param throwable Exception, that was the main reason for logged error message - */ - protected void logError(String message, Throwable throwable) { - DebugTool.logError(TAG, message, throwable); - } - - /** - * Internal class that represents separate thread, that does actual work, related to connecting/reading/writing data - */ - private class TCPTransportThread extends Thread { - SdlPsm psm; - public TCPTransportThread(){ - psm = new SdlPsm(); - } - /** - * Represents current thread state - halted or not. This flag is used to change internal behavior depending - * on current state. - */ - private Boolean isHalted = false; - - /** - * Method that marks thread as halted. - */ - public void halt() { - isHalted = true; - } - - /** - * Tries to connect to the SmartDeviceLink core. Behavior depends autoReconnect configuration param: - * a) If autoReconnect is false, then only one connect try will be performed. - * b) If autoReconnect is true, then in case of connection error continuous reconnect will be performed - * after short delay until connection will be established or retry count will be reached - * - * @return true if connection established and false otherwise - */ - @SuppressLint("DefaultLocale") - private boolean connect() { - boolean bConnected; - int remainingRetry = RECONNECT_RETRY_COUNT; - - synchronized (TCPTransport.this) { - do { - try { - - if ((null != mSocket) && (!mSocket.isClosed())) { - logInfo("TCPTransport.connect: Socket is not closed. Trying to close it"); - mSocket.close(); - } - - logInfo(String.format("TCPTransport.connect: Socket is closed. Trying to connect to %s", mConfig)); - mSocket = new Socket(); - mSocket.connect(new InetSocketAddress(mConfig.getIPAddress(), mConfig.getPort())); - mOutputStream = mSocket.getOutputStream(); - mInputStream = mSocket.getInputStream(); - - } catch (IOException e) { - logError("TCPTransport.connect: Exception during connect stage: " + e.getMessage()); - } - - bConnected = (null != mSocket) && mSocket.isConnected(); - - if(bConnected){ - logInfo("TCPTransport.connect: Socket connected"); - }else{ - if(mConfig.getAutoReconnect()){ - remainingRetry--; - logInfo(String.format("TCPTransport.connect: Socket not connected. AutoReconnect is ON. retryCount is: %d. Waiting for reconnect delay: %d" - , remainingRetry, RECONNECT_DELAY)); - waitFor(RECONNECT_DELAY); - } else { - logInfo("TCPTransport.connect: Socket not connected. AutoReconnect is OFF"); - } - } - } while ((!bConnected) && (mConfig.getAutoReconnect()) && (remainingRetry > 0) && (!isHalted)); - - return bConnected; - } - } - - /** - * Performs actual thread work - */ - @Override - public void run() { - logInfo("TCPTransport.run: transport thread created. Starting connect stage"); - psm.reset(); - while(!isHalted) { - setCurrentState(TCPTransportState.CONNECTING); - if(!connect()){ - if (isHalted) { - logInfo("TCPTransport.run: Connection failed, but thread already halted"); - } else { - disconnect("Failed to connect to Sdl", new SdlException("Failed to connect to Sdl" - , SdlExceptionCause.SDL_CONNECTION_FAILED), true); - } - break; - } - - synchronized (TCPTransport.this) { - setCurrentState(TCPTransportState.CONNECTED); - handleTransportConnected(); - } - - byte input; - byte[] buffer = new byte[READ_BUFFER_SIZE]; - int bytesRead; - boolean stateProgress = false; - while (!isHalted) { - //logInfo("TCPTransport.run: Waiting for data..."); - try { - //input = (byte) mInputStream.read(); - bytesRead = mInputStream.read(buffer); - } catch (IOException e) { - internalHandleStreamReadError(); - break; - } - - synchronized (TCPTransport.this) { - if (mThread.isInterrupted()) { - logInfo("TCPTransport.run: Got new data but thread is interrupted"); - break; - } - } - for (int i = 0; i < bytesRead; i++) { - //logInfo("TCPTransport.run: Got new data"); - // Send the response of what we received - input = buffer[i]; - stateProgress = psm.handleByte(input); - if (!stateProgress) {//We are trying to weed through the bad packet info until we get something - - //Log.w(TAG, "Packet State Machine did not move forward from state - "+ psm.getState()+". PSM being Reset."); - psm.reset(); - } - - if (psm.getState() == SdlPsm.FINISHED_STATE) - { - synchronized (TCPTransport.this) { - //Log.d(TAG, "Packet formed, sending off"); - handleReceivedPacket((SdlPacket) psm.getFormedPacket()); - } - //We put a trace statement in the message read so we can avoid all the extra bytes - psm.reset(); - } - //FIXME logInfo(String.format("TCPTransport.run: Received %d bytes", bytesRead)); - } - } - } - - logInfo("TCPTransport.run: Thread terminated"); - setCurrentState(TCPTransportState.IDLE); - } - - /** - * Internal handling of Tcp disconnection - */ - private void internalHandleTCPDisconnect() { - if(isHalted){ - logInfo("TCPTransport.run: TCP disconnect received, but thread already halted"); - } else { - logInfo("TCPTransport.run: TCP disconnect received"); - disconnect("TCPTransport.run: End of stream reached", null, false); - } - } - - /** - * Internal handling of reading data from input stream - */ - private void internalHandleStreamReadError() { - if(isHalted){ - logError("TCPTransport.run: Exception during reading data, but thread already halted"); - } else { - logError("TCPTransport.run: Exception during reading data"); - disconnect("Failed to read data from Sdl", new SdlException("Failed to read data from Sdl" - , SdlExceptionCause.SDL_CONNECTION_FAILED), false); - } - } - } - - /** - * Returns current TCP transport state - * - * @return current state - */ - private synchronized TCPTransportState getCurrentState() { - return mCurrentState; - } - - /** - * Sets current TCP transport state - * @param currentState New state - */ - private synchronized void setCurrentState(TCPTransportState currentState) { - logInfo(String.format("Current state changed to: %s", currentState)); - this.mCurrentState = currentState; - } - - /** - * Implementation of waiting required delay that cannot be interrupted - * @param timeMs Time in milliseconds of required delay - */ - private void waitFor(long timeMs) { - long endTime = System.currentTimeMillis() +timeMs; - while (System.currentTimeMillis() < endTime) { - synchronized (this) { - try { - wait(endTime - System.currentTimeMillis()); - } catch (Exception e) { - // Nothing To Do, simple wait - } - } - } - } - - /** - * Defines available states of the TCP transport - */ - private enum TCPTransportState { - /** - * TCP transport is created. No connection opened - */ - IDLE, - - /** - * TCP transport is in progress of establishing connection. - */ - CONNECTING, - - /** - * TCP transport is connected to SmartDeviceLink core - */ - CONNECTED, - - /** - * TCP transport is in progress of disconnecting - */ - DISCONNECTING - } - - @Override - public String getBroadcastComment() { - return ""; - } -} // end-class diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/USBAccessoryAttachmentActivity.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/USBAccessoryAttachmentActivity.java index 17942b49d..dbe7898ef 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/USBAccessoryAttachmentActivity.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/USBAccessoryAttachmentActivity.java @@ -222,7 +222,7 @@ public class USBAccessoryAttachmentActivity extends Activity { private void attemptLegacyUsbConnection(UsbAccessory usbAccessory){ if(usbAccessory != null) { DebugTool.logInfo(TAG, "Attempting to send USB connection intent using legacy method"); - Intent usbAccessoryAttachedIntent = new Intent(USBTransport.ACTION_USB_ACCESSORY_ATTACHED); + Intent usbAccessoryAttachedIntent = new Intent(TransportConstants.ACTION_USB_ACCESSORY_ATTACHED); usbAccessoryAttachedIntent.putExtra(UsbManager.EXTRA_ACCESSORY, usbAccessory); usbAccessoryAttachedIntent.putExtra(UsbManager.EXTRA_PERMISSION_GRANTED, permissionGranted); AndroidTools.sendExplicitBroadcast(getApplicationContext(), usbAccessoryAttachedIntent, null); diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/USBTransport.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/USBTransport.java deleted file mode 100644 index 0ab2f2fcf..000000000 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/USBTransport.java +++ /dev/null @@ -1,915 +0,0 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ -package com.smartdevicelink.transport; - -import android.annotation.SuppressLint; -import android.app.PendingIntent; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.hardware.usb.UsbAccessory; -import android.hardware.usb.UsbManager; -import android.os.ParcelFileDescriptor; - -import com.smartdevicelink.exception.SdlException; -import com.smartdevicelink.exception.SdlExceptionCause; -import com.smartdevicelink.protocol.SdlPacket; -import com.smartdevicelink.trace.SdlTrace; -import com.smartdevicelink.trace.enums.InterfaceActivityDirection; -import com.smartdevicelink.transport.enums.TransportType; -import com.smartdevicelink.util.DebugTool; - -import java.io.FileDescriptor; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -/** - * Class that implements USB transport. - * - * A note about USB Accessory protocol. If the device is already in the USB - * accessory mode, any side (computer or Android) can open connection even if - * the other side is not connected. Conversely, if one side simply disconnects, - * the other side will NOT be notified and unblocked from reading data until - * some data is sent again or the USB is physically disconnected. - */ -@SuppressLint("NewApi") -@Deprecated -public class USBTransport extends SdlTransport { - - // Boolean to monitor if the transport is in a disconnecting state - private boolean _disconnecting = false; - /** - * Broadcast action: sent when a USB accessory is attached. - * - * UsbManager.EXTRA_ACCESSORY extra contains UsbAccessory object that has - * been attached. - */ - public static final String ACTION_USB_ACCESSORY_ATTACHED = - "com.smartdevicelink.USB_ACCESSORY_ATTACHED"; - /** - * String tag for logging. - */ - private static final String TAG = USBTransport.class.getSimpleName(); - /** - * Key for SdlTrace. - */ - private static final String SDL_LIB_TRACE_KEY = - "42baba60-eb57-11df-98cf-0800200c9a66"; - /** - * Broadcast action: sent when the user has granted access to the USB - * accessory. - */ - private static final String ACTION_USB_PERMISSION = - "com.smartdevicelink.USB_PERMISSION"; - /** - * Manufacturer name of the accessory we want to connect to. Must be the - * same as in accessory_filter.xml to work properly. - */ - private final static String ACCESSORY_MANUFACTURER = "SDL"; - /** - * Model name of the accessory we want to connect to. Must be the same as - * in accessory_filter.xml to work properly. - */ - private final static String ACCESSORY_MODEL = "Core"; - /** - * Version of the accessory we want to connect to. Must be the same as in - * accessory_filter.xml to work properly. - */ - private final static String ACCESSORY_VERSION = "1.0"; - /** - * Prefix string to indicate debug output. - */ - private static final String DEBUG_PREFIX = "DEBUG: "; - /** - * String to prefix exception output. - */ - private static final String EXCEPTION_STRING = " Exception String: "; - /** - * Broadcast receiver that receives different USB-related intents: USB - * accessory connected, disconnected, and permission granted. - */ - private final BroadcastReceiver mUSBReceiver = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - logD("USBReceiver Action: " + action); - - UsbAccessory accessory = - intent.getParcelableExtra(UsbManager.EXTRA_ACCESSORY); - if (accessory != null) { - if (ACTION_USB_ACCESSORY_ATTACHED.equals(action)) { - logI("Accessory " + accessory + " attached"); - if (isAccessorySupported(accessory)) { - connectToAccessory(accessory); - } else { - logW("Attached accessory is not supported!"); - } - } else if (UsbManager.ACTION_USB_ACCESSORY_DETACHED - .equals(action)) { - logI("Accessory " + accessory + " detached"); - final String msg = "USB accessory has been detached"; - disconnect(msg, new SdlException(msg, - SdlExceptionCause.SDL_USB_DETACHED)); - } else if (ACTION_USB_PERMISSION.equals(action)) { - boolean permissionGranted = intent.getBooleanExtra( - UsbManager.EXTRA_PERMISSION_GRANTED, false); - if (permissionGranted) { - logI("Permission granted for accessory " + accessory); - openAccessory(accessory); - } else { - final String msg = - "Permission denied for accessory " + accessory; - logW(msg); - disconnect(msg, new SdlException(msg, - SdlExceptionCause.SDL_USB_PERMISSION_DENIED)); - } - } - } else { - logW("Accessory is null"); - } - } - }; - /** - * USB config object. - */ - private USBTransportConfig mConfig = null; - /** - * Current state of transport. - * - * Use setter and getter to access it. - */ - private State mState = State.IDLE; - /** - * Current accessory the transport is working with if any. - */ - private UsbAccessory mAccessory = null; - /** - * FileDescriptor that owns the input and output streams. We have to keep - * it, otherwise it will be garbage collected and the streams will become - * invalid. - */ - private ParcelFileDescriptor mParcelFD = null; - /** - * Data input stream to read data from USB accessory. - */ - private InputStream mInputStream = null; - /** - * Data output stream to write data to USB accessory. - */ - private OutputStream mOutputStream = null; - /** - * Thread that connects and reads data from USB accessory. - * - * @see USBTransportReader - */ - private Thread mReaderThread = null; - - /** - * Constructs the USBTransport instance. - * - * @param usbTransportConfig Config object for the USB transport - * @param transportListener Listener that gets notified on different - * transport events - */ - public USBTransport(USBTransportConfig usbTransportConfig, - ITransportListener transportListener) { - super(transportListener); - this.mConfig = usbTransportConfig; - registerReciever(); - } - - /** - * Returns the current state of transport. - * - * @return Current state of transport - */ - public State getState() { - return this.mState; - } - - /** - * Changes current state of transport. - * - * @param state New state - */ - private void setState(State state) { - logD("Changing state " + this.mState + " to " + state); - this.mState = state; - } - - /** - * Sends the array of bytes over USB. - * - * @param packet The packet that is to be written out on the USB transport - * @return true if the bytes are sent successfully - */ - @Override - protected boolean sendBytesOverTransport(SdlPacket packet) { - byte[] msgBytes = packet.constructPacket(); - logD("SendBytes: array size " + msgBytes.length + ", offset " + 0 + - ", length " + msgBytes.length); - - boolean result = false; - final State state = getState(); - switch (state) { - case CONNECTED: - if (mOutputStream != null) { - try { - mOutputStream.write(msgBytes, 0, msgBytes.length); - result = true; - - logI("Bytes successfully sent"); - SdlTrace.logTransportEvent(TAG + ": bytes sent", - null, InterfaceActivityDirection.Transmit, - msgBytes, 0, msgBytes.length, - SDL_LIB_TRACE_KEY); - } catch (IOException e) { - final String msg = "Failed to send bytes over USB"; - logW(msg, e); - disconnect(msg, e); - } - } else { - final String msg = - "Can't send bytes when output stream is null"; - logW(msg); - disconnect(msg, null); - } - break; - - default: - logW("Can't send bytes from " + state + " state"); - break; - } - - return result; - } - - - public void registerReciever() - { - IntentFilter filter = new IntentFilter(); - filter.addAction(ACTION_USB_ACCESSORY_ATTACHED); - filter.addAction(UsbManager.ACTION_USB_ACCESSORY_DETACHED); - filter.addAction(ACTION_USB_PERMISSION); - filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED); - getContext().registerReceiver(mUSBReceiver, filter); - } - - /** - * Opens a USB connection if not open yet. - * - * @throws SdlException - */ - @Override - public void openConnection() throws SdlException { - final State state = getState(); - switch (state) { - case IDLE: - synchronized (this) { - logI("openConnection()"); - setState(State.LISTENING); - } - - logD("Registering receiver"); - try { - IntentFilter filter = new IntentFilter(); - filter.addAction(ACTION_USB_ACCESSORY_ATTACHED); - filter.addAction(UsbManager.ACTION_USB_ACCESSORY_DETACHED); - filter.addAction(ACTION_USB_PERMISSION); - getContext().registerReceiver(mUSBReceiver, filter); - initializeAccessory(); - } catch (Exception e) { - String msg = "Couldn't start opening connection"; - logE(msg, e); - throw new SdlException(msg, e, - SdlExceptionCause.SDL_CONNECTION_FAILED); - } - - break; - - default: - logW("openConnection() called from state " + state + - "; doing nothing"); - break; - } - } - - /** - * Closes the USB connection if open. - */ - @Override - public void disconnect() { - disconnect(null, null); - } - - /** - * Asks the reader thread to stop while it's possible. If it's blocked on - * read(), there is no way to stop it except for physical USB disconnect. - */ - //@Override - public void stopReading() { - DebugTool.logInfo(TAG, "USBTransport: stop reading requested, doing nothing"); - // TODO - put back stopUSBReading(); @see SmartDeviceLink-3450 - } - - @SuppressWarnings("unused") - private void stopUSBReading() { - final State state = getState(); - switch (state) { - case CONNECTED: - logI("Stopping reading"); - synchronized (this) { - stopReaderThread(); - } - break; - - default: - logW("Stopping reading called from state " + state + - "; doing nothing"); - break; - } - } - - /** - * Actually asks the reader thread to interrupt. - */ - private void stopReaderThread() { - if (mReaderThread != null) { - logI("Interrupting USB reader"); - mReaderThread.interrupt(); - // don't join() now - mReaderThread = null; - } else { - logD("USB reader is null"); - } - } - - /** - * Closes the USB connection from inside the transport with some extra info. - * - * @param msg Disconnect reason message, if any - * @param ex Disconnect exception, if any - */ - private void disconnect(String msg, Exception ex) { - - // If already disconnecting, return - if (_disconnecting) { - // No need to recursively call - return; - } - _disconnecting = true; - - mConfig.setUsbAccessory(null); - - final State state = getState(); - switch (state) { - case LISTENING: - case CONNECTED: - synchronized (this) { - logI("Disconnect from state " + getState() + "; message: " + - msg + "; exception: " + ex); - setState(State.IDLE); - - SdlTrace.logTransportEvent(TAG + ": disconnect", null, - InterfaceActivityDirection.None, null, 0, - SDL_LIB_TRACE_KEY); - - stopReaderThread(); - - if (mAccessory != null) { - if (mOutputStream != null) { - try { - mOutputStream.close(); - mOutputStream = null; - } catch (IOException e) { - logW("Can't close output stream", e); - mOutputStream = null; - } - } - if (mInputStream != null) { - try { - mInputStream.close(); - mInputStream = null; - } catch (IOException e) { - logW("Can't close input stream", e); - mInputStream = null; - } - } - if (mParcelFD != null) { - try { - mParcelFD.close(); - mParcelFD = null; - } catch (IOException e) { - logW("Can't close file descriptor", e); - mParcelFD = null; - } - } - - mAccessory = null; - } - } - - logD("Unregistering receiver"); - try { - getContext().unregisterReceiver(mUSBReceiver); - } catch (IllegalArgumentException e) { - logW("Receiver was already unregistered", e); - } - - String disconnectMsg = (msg == null ? "" : msg); - if (ex != null) { - disconnectMsg += ", " + ex.toString(); - - if(ex instanceof SdlException - && SdlExceptionCause.SDL_USB_PERMISSION_DENIED.equals(((SdlException)ex).getSdlExceptionCause())){ - //If the USB device disconnected we don't want to cycle the proxy ourselves - ex = null; - } - } - - if (ex == null) { - // This disconnect was not caused by an error, notify the - // proxy that the transport has been disconnected. - logI("Disconnect is correct. Handling it"); - handleTransportDisconnected(disconnectMsg); - } else { - // This disconnect was caused by an error, notify the proxy - // that there was a transport error. - logI("Disconnect is incorrect. Handling it as error"); - handleTransportError(disconnectMsg, ex); - } - break; - - default: - logW("Disconnect called from state " + state + - "; doing nothing"); - break; - } - _disconnecting = false; - } - - /** - * Returns the type of the transport. - * - * @return TransportType.USB - * @see com.smartdevicelink.transport.enums.TransportType - */ - @Override - public TransportType getTransportType() { - return TransportType.USB; - } - - /** - * Looks for an already connected compatible accessory and connect to it. - */ - private void initializeAccessory() { - UsbAccessory acc = mConfig.getUsbAccessory(); - - if (!mConfig.getQueryUsbAcc() && acc == null){ - logI("Query for accessory is disabled and accessory in config was null."); - return; - } - logI("Looking for connected accessories"); - - if( acc == null || !isAccessorySupported(acc)){ //Check to see if our config included an accessory and that it is supported. If not, see if there are any other accessories connected. - UsbManager usbManager = getUsbManager(); - UsbAccessory[] accessories = usbManager.getAccessoryList(); - if (accessories != null) { - logD("Found total " + accessories.length + " accessories"); - for (UsbAccessory accessory : accessories) { - if (isAccessorySupported(accessory)) { - acc = accessory; - break; - } - } - } else { - logI("No connected accessories found"); - return; - } - } - connectToAccessory(acc); - } - - /** - * Checks if the specified connected USB accessory is what we expect. - * - * @param accessory Accessory to check - * @return true if the accessory is right - */ - public static boolean isAccessorySupported(final UsbAccessory accessory) { - if (accessory == null) { - return false; - } - - boolean manufacturerMatches = - ACCESSORY_MANUFACTURER.equals(accessory.getManufacturer()); - boolean modelMatches = ACCESSORY_MODEL.equals(accessory.getModel()); - boolean versionMatches = - ACCESSORY_VERSION.equals(accessory.getVersion()); - return manufacturerMatches && modelMatches && versionMatches; - } - - /** - * Attempts to connect to the specified accessory. - * - * If the permission is already granted, opens the accessory. Otherwise, - * requests permission to use it. - * - * @param accessory Accessory to connect to - */ - private void connectToAccessory(UsbAccessory accessory) { - - if (accessory == null) { - handleTransportError("Can't connect to null accessory", null); - } - - final State state = getState(); - switch (state) { - case LISTENING: - UsbManager usbManager = getUsbManager(); - if (usbManager.hasPermission(accessory)) { - logI("Already have permission to use " + accessory); - openAccessory(accessory); - } else { - logI("Requesting permission to use " + accessory); - - PendingIntent permissionIntent = PendingIntent - .getBroadcast(getContext(), 0, - new Intent(ACTION_USB_PERMISSION), 0); - usbManager.requestPermission(accessory, permissionIntent); - } - - break; - - default: - logW("connectToAccessory() called from state " + state + - "; doing nothing"); - } - } - - /** - * Returns the UsbManager to use with accessories. - * - * @return System UsbManager - */ - private UsbManager getUsbManager() { - return (UsbManager) getContext().getSystemService(Context.USB_SERVICE); - } - - /** - * Opens a connection to the accessory. - * - * When this function is called, the permission to use it must have already - * been granted. - * - * @param accessory Accessory to open connection to - */ - private void openAccessory(UsbAccessory accessory) { - final State state = getState(); - switch (state) { - case LISTENING: - synchronized (this) { - logI("Opening accessory " + accessory); - mAccessory = accessory; - - mReaderThread = new Thread(new USBTransportReader()); - mReaderThread.setDaemon(true); - mReaderThread - .setName(USBTransportReader.class.getSimpleName()); - mReaderThread.start(); - - // Initialize the SiphonServer - if (SiphonServer.getSiphonEnabledStatus()) { - SiphonServer.init(); - } - } - - break; - - default: - logW("openAccessory() called from state " + state + - "; doing nothing"); - } - } - - /** - * Logs the string and the throwable with ERROR level. - * - * @param s string to log - * @param tr throwable to log - */ - private void logE(String s, Throwable tr) { - DebugTool.logError(TAG, s, tr); - } - - /** - * Logs the string with WARN level. - * - * @param s string to log - */ - private void logW(String s) { - DebugTool.logWarning(TAG, s); - } - - /** - * Logs the string and the throwable with WARN level. - * - * @param s string to log - * @param tr throwable to log - */ - private void logW(String s, Throwable tr) { - StringBuilder res = new StringBuilder(s); - if (tr != null) { - res.append(EXCEPTION_STRING); - res.append(tr.toString()); - } - logW(res.toString()); - } - - /** - * Logs the string with INFO level. - * - * @param s string to log - */ - private void logI(String s) { - DebugTool.logInfo(TAG, s); - } - - /** - * Logs the string with DEBUG level. - * - * @param s string to log - */ - private void logD(String s) { - // DebugTool doesn't support DEBUG level, so we use INFO instead - DebugTool.logInfo(TAG, DEBUG_PREFIX + s); - } - - /** - * Returns Context to communicate with the OS. - * - * @return current context to be used by the USB transport - */ - private Context getContext() { - return mConfig.getUSBContext(); - } - - /** - * Possible states of the USB transport. - */ - private enum State { - /** - * Transport initialized; no connections. - */ - IDLE, - - /** - * USB accessory not attached; SdlProxy wants connection as soon as - * accessory is attached. - */ - LISTENING, - - /** - * USB accessory attached; permission granted; data IO in progress. - */ - CONNECTED - } - - /** - * Internal task that connects to and reads data from a USB accessory. - * - * Since the class has to have access to the parent class' variables, - * synchronization must be taken in consideration! For now, all access - * to variables of USBTransport must be surrounded with - * synchronized (USBTransport.this) { … } - */ - private class USBTransportReader implements Runnable { - /** - * String tag for logging inside the task. - */ - private final String TAG = USBTransportReader.class.getSimpleName(); - - SdlPsm psm; - - /** - * Checks if the thread has been interrupted. - * - * @return true if the thread has been interrupted - */ - private boolean isInterrupted() { - return Thread.interrupted(); - } - - /** - * Entry function that is called when the task is started. It attempts - * to connect to the accessory, then starts a read loop until - * interrupted. - */ - @Override - public void run() { - logD("USB reader started!"); - psm = new SdlPsm(); - psm.reset(); - if (connect()) { - readFromTransport(); - } - - logD("USB reader finished!"); - } - - /** - * Attemps to open connection to USB accessory. - * - * @return true if connected successfully - */ - private boolean connect() { - if (isInterrupted()) { - logI("Thread is interrupted, not connecting"); - return false; - } - - final State state = getState(); - switch (state) { - case LISTENING: - - synchronized (USBTransport.this) { - try { - mParcelFD = - getUsbManager().openAccessory(mAccessory); - } catch (Exception e) { - final String msg = - "Have no permission to open the accessory"; - logE(msg, e); - disconnect(msg, e); - return false; - } - if (mParcelFD == null) { - if (isInterrupted()) { - logW("Can't open accessory, and thread is interrupted"); - } else { - logW("Can't open accessory, disconnecting!"); - String msg = "Failed to open USB accessory"; - disconnect(msg, new SdlException(msg, - SdlExceptionCause.SDL_CONNECTION_FAILED)); - } - return false; - } - FileDescriptor fd = mParcelFD.getFileDescriptor(); - mInputStream = new FileInputStream(fd); - mOutputStream = new FileOutputStream(fd); - } - - logI("Accessory opened!"); - - synchronized (USBTransport.this) { - setState(State.CONNECTED); - handleTransportConnected(); - } - break; - - default: - logW("connect() called from state " + state + - ", will not try to connect"); - return false; - } - - return true; - } - - /** - * Continuously reads data from the transport's input stream, blocking - * when no data is available. - */ - private void readFromTransport() { - final int READ_BUFFER_SIZE = 4096; - byte[] buffer = new byte[READ_BUFFER_SIZE]; - int bytesRead; - // byte input; - boolean stateProgress = false; - - // read loop - while (!isInterrupted()) { - try { - if (mInputStream == null) - continue; - - bytesRead = mInputStream.read(buffer); - if (bytesRead == -1) { - if (isInterrupted()) { - logI("EOF reached, and thread is interrupted"); - } else { - logI("EOF reached, disconnecting!"); - disconnect("EOF reached", null); - } - return; - } - } catch (IOException e) { - if (isInterrupted()) { - logW("Can't read data, and thread is interrupted", e); - } else { - logW("Can't read data, disconnecting!", e); - disconnect("Can't read data from USB", e); - } - return; - } - - logD("Read " + bytesRead + " bytes"); - //FIXME SdlTrace.logTransportEvent(TAG + ": read bytes", null, - // InterfaceActivityDirection.Receive, buffer, bytesRead, - // SDL_LIB_TRACE_KEY); - - if (isInterrupted()) { - logI("Read some data, but thread is interrupted"); - return; - } - byte input; - for(int i=0;iNOTE: This should no longer be used. See the MultplexTransportConfig and guides to - * understand how to implement USB multiplexing. This class and method of USB connection will be - * removed in the next major release. If a router service is available to handle multiplexing of the - * usb transport it will be used, and this app will connect to whatever router service hosts the USB - * connection. - * @see MultiplexTransportConfig - */ -@Deprecated -public class USBTransportConfig extends BaseTransportConfig { - - private Context mainActivity = null; - private UsbAccessory usbAccessory = null; - private Boolean queryUsbAcc = true; - - /** - * NOTE: This should no longer be used. See the MultplexTransportConfig and guides to - * understand how to implement USB multiplexing. This class and method of USB connection will be - * removed in the next major release. If a router service is available to handle multiplexing of the - * usb transport it will be used, and this app will connect to whatever router service hosts the USB - * connection. - * @param mainActivity context used to start USB transport - * @see MultiplexTransportConfig - */ - public USBTransportConfig (Context mainActivity) { - this.mainActivity = mainActivity; - } - - /** - * NOTE: This should no longer be used. See the MultplexTransportConfig and guides to - * understand how to implement USB multiplexing. This class and method of USB connection will be - * removed in the next major release. If a router service is available to handle multiplexing of the - * usb transport it will be used, and this app will connect to whatever router service hosts the USB - * connection. - * @param mainActivity context used to start USB transport - * @param usbAccessory the accessory that was given to this app - * @see MultiplexTransportConfig - */ - public USBTransportConfig (Context mainActivity, UsbAccessory usbAccessory) { - this.mainActivity = mainActivity; - this.usbAccessory = usbAccessory; - } - - /** - * NOTE: This should no longer be used. See the MultplexTransportConfig and guides to - * understand how to implement USB multiplexing. This class and method of USB connection will be - * removed in the next major release. If a router service is available to handle multiplexing of the - * usb transport it will be used, and this app will connect to whatever router service hosts the USB - * connection. - * @param mainActivity context used to start USB transport - * @param shareConnection enable other sessions on this app to use this USB connection - * @param queryUsbAcc attempt to query the USB accessory if none is provided - * @see MultiplexTransportConfig - */ - public USBTransportConfig (Context mainActivity, boolean shareConnection, boolean queryUsbAcc) { - this.mainActivity = mainActivity; - this.queryUsbAcc = queryUsbAcc; - super.shareConnection = shareConnection; - } - - /** - * NOTE: This should no longer be used. See the MultplexTransportConfig and guides to - * understand how to implement USB multiplexing. This class and method of USB connection will be - * removed in the next major release. If a router service is available to handle multiplexing of the - * usb transport it will be used, and this app will connect to whatever router service hosts the USB - * connection. - * @param mainActivity context used to start USB transport - * @param usbAccessory the accessory that was given to this app - * @param shareConnection enable other sessions on this app to use this USB connection - * @param queryUsbAcc attempt to query the USB accessory if none is provided - * @see MultiplexTransportConfig - */ - public USBTransportConfig (Context mainActivity, UsbAccessory usbAccessory, boolean shareConnection, boolean queryUsbAcc) { - this.mainActivity = mainActivity; - this.queryUsbAcc = queryUsbAcc; - this.usbAccessory = usbAccessory; - super.shareConnection = shareConnection; - } - - public Boolean getQueryUsbAcc () { - return queryUsbAcc; - } - - public Context getUSBContext () { - return mainActivity; - } - - public UsbAccessory getUsbAccessory () { - return usbAccessory; - } - - public void setUsbAccessory (UsbAccessory value) { usbAccessory = value; } - - public TransportType getTransportType() { - return TransportType.USB; - } -} \ No newline at end of file diff --git a/base/src/main/java/com/smartdevicelink/transport/ITransportListener.java b/base/src/main/java/com/smartdevicelink/transport/ITransportListener.java deleted file mode 100644 index 46baf5296..000000000 --- a/base/src/main/java/com/smartdevicelink/transport/ITransportListener.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ -package com.smartdevicelink.transport; - -import com.smartdevicelink.protocol.SdlPacket; - -public interface ITransportListener { - // Called to indicate and deliver a packet received from transport - void onTransportPacketReceived(SdlPacket packet); - - // Called to indicate that transport connection was established - void onTransportConnected(); - - // Called to indicate that transport was disconnected (by either side) - void onTransportDisconnected(String info); - - // Called to indicate that some error occurred on the transport - void onTransportError(String info, Exception e); -} // end-interface \ No newline at end of file diff --git a/base/src/main/java/com/smartdevicelink/transport/TransportConstants.java b/base/src/main/java/com/smartdevicelink/transport/TransportConstants.java index 9b2eba9ed..19579c19b 100644 --- a/base/src/main/java/com/smartdevicelink/transport/TransportConstants.java +++ b/base/src/main/java/com/smartdevicelink/transport/TransportConstants.java @@ -294,4 +294,14 @@ public class TransportConstants { public static final String AOA_USB = "AOA_USB"; public static final String TCP_WIFI = "TCP_WIFI"; + + /** + * Broadcast action: sent when a USB accessory is attached. + * + * UsbManager.EXTRA_ACCESSORY extra contains UsbAccessory object that has + * been attached. + */ + public static final String ACTION_USB_ACCESSORY_ATTACHED = "com.smartdevicelink.USB_ACCESSORY_ATTACHED"; + + } -- cgit v1.2.1 From 5997af206c7e12b41468778fc961098e9a27f1ad Mon Sep 17 00:00:00 2001 From: RHenigan Date: Fri, 28 Aug 2020 13:32:56 -0400 Subject: Update Max Protocol Version --- base/src/main/java/com/smartdevicelink/protocol/SdlProtocolBase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/src/main/java/com/smartdevicelink/protocol/SdlProtocolBase.java b/base/src/main/java/com/smartdevicelink/protocol/SdlProtocolBase.java index d54f2de3a..106e358f4 100644 --- a/base/src/main/java/com/smartdevicelink/protocol/SdlProtocolBase.java +++ b/base/src/main/java/com/smartdevicelink/protocol/SdlProtocolBase.java @@ -83,7 +83,7 @@ public class SdlProtocolBase { public static final int V2_HEADER_SIZE = 12; //If increasing MAX PROTOCOL VERSION major version, make sure to alter it in SdlPsm - private static final Version MAX_PROTOCOL_VERSION = new Version(5, 2, 0); + private static final Version MAX_PROTOCOL_VERSION = new Version(5, 3, 0); public static final int V1_V2_MTU_SIZE = 1500; public static final int V3_V4_MTU_SIZE = 131072; -- cgit v1.2.1 From d07884cf42098c4a85c36f8091e36fe156475128 Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Fri, 28 Aug 2020 13:42:15 -0400 Subject: Fixed shouldUpdateSecondaryImage to be more precise --- .../managers/screen/TextAndGraphicUpdateOperation.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java index bac8fa8bc..6f0e38fee 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java @@ -569,12 +569,16 @@ class TextAndGraphicUpdateOperation extends Task { * @return true if secondaryGraphic should be updated, false if not */ private boolean shouldUpdateSecondaryImage() { - boolean templateSupportsSecondaryArtwork = (templateSupportsImageField(ImageFieldName.graphic) || templateSupportsImageField(ImageFieldName.secondaryGraphic)); + boolean templateSupportsSecondaryArtwork = templateSupportsImageField(ImageFieldName.secondaryGraphic); String currentScreenDataSecondaryGraphicName = (currentScreenData != null && currentScreenData.getSecondaryGraphic() != null) ? currentScreenData.getSecondaryGraphic().getValue() : null; String secondaryGraphicName = updatedState.getSecondaryGraphic() != null ? updatedState.getSecondaryGraphic().getName() : null; - return templateSupportsSecondaryArtwork - && !CompareUtils.areStringsEqual(currentScreenDataSecondaryGraphicName, secondaryGraphicName, true, true); + // Cannot detect if there is a secondary image below v5.0, so we'll just try to detect if the primary image is allowed and allow the secondary image if it is. + if (internalInterface.get().getSdlMsgVersion().getMajorVersion() > 5) { + return templateSupportsSecondaryArtwork && !CompareUtils.areStringsEqual(currentScreenDataSecondaryGraphicName, secondaryGraphicName, true, true); + } else { + return templateSupportsImageField(ImageFieldName.graphic); + } } /** -- cgit v1.2.1 From ff2c6e907c385674e267c1a0cf17d4512290a97b Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Fri, 28 Aug 2020 13:53:08 -0400 Subject: Fixed logic --- .../smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java index 6f0e38fee..f7a2c7b89 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java @@ -574,7 +574,7 @@ class TextAndGraphicUpdateOperation extends Task { String currentScreenDataSecondaryGraphicName = (currentScreenData != null && currentScreenData.getSecondaryGraphic() != null) ? currentScreenData.getSecondaryGraphic().getValue() : null; String secondaryGraphicName = updatedState.getSecondaryGraphic() != null ? updatedState.getSecondaryGraphic().getName() : null; // Cannot detect if there is a secondary image below v5.0, so we'll just try to detect if the primary image is allowed and allow the secondary image if it is. - if (internalInterface.get().getSdlMsgVersion().getMajorVersion() > 5) { + if (internalInterface.get().getSdlMsgVersion().getMajorVersion() >= 5) { return templateSupportsSecondaryArtwork && !CompareUtils.areStringsEqual(currentScreenDataSecondaryGraphicName, secondaryGraphicName, true, true); } else { return templateSupportsImageField(ImageFieldName.graphic); -- cgit v1.2.1 From 494fee526cfd274ccba47c8c9122a8db1e9b131c Mon Sep 17 00:00:00 2001 From: Kostiantyn Boskin Date: Mon, 31 Aug 2020 17:33:57 +0300 Subject: [0253] New vehicle data StabilityControlsStatus (#1394) * [0253] - VehicleDataType - Add StabilityControlsStatus - Implement changes in proper requests responses related to new structs * [0253] - Fix tests - Add new tests for StabilityControlsStatus - Fix updated Structs according to specification * [0253] - Add specific struct tests * [0253] - Rename StabilityControlStatus --> StabilityControlsStatus - Update missing tests - Remove useless constructor * [0266] - Test --> TestValues in multiple files * [0253] - Regenerate using generator - Fix formatting * [0253] - Rollback formatting changes - Change order of methods to make the diff clear * [0253] - Rollback of UnsubscribeVehicleDataResponse * [0253] - Rollback of UnsubscribeVehicleData * [0253] - Rollback of SubscribeVehicleDataResponse * [0253] - Rollback of SubscribeVehicleData * [0253] - Rollback of OnVehicleData * [0253] - Rollback of GetVehicleDataResponse * [0253] - Rollback of GetVehicleData * [0253] - Rollback of VehicleDataType * [0253] - Rollback of UnsubscribeVehicleData * [0253] - Fix VehicleDataType * [0253] - Fix compilation errors on merge * Revert LF to CRLF line separators * [0253] - Fix errors after merging dev * Update base/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleData.java Co-authored-by: Julian Kast * Update base/src/main/java/com/smartdevicelink/proxy/rpc/StabilityControlsStatus.java Co-authored-by: Julian Kast * Update base/src/main/java/com/smartdevicelink/proxy/rpc/StabilityControlsStatus.java Co-authored-by: Julian Kast * Update base/src/main/java/com/smartdevicelink/proxy/rpc/StabilityControlsStatus.java Co-authored-by: Julian Kast * Update base/src/main/java/com/smartdevicelink/proxy/rpc/StabilityControlsStatus.java Co-authored-by: Julian Kast * Update base/src/main/java/com/smartdevicelink/proxy/rpc/StabilityControlsStatus.java Co-authored-by: Julian Kast * Update base/src/main/java/com/smartdevicelink/proxy/rpc/StabilityControlsStatus.java Co-authored-by: Julian Kast * Update base/src/main/java/com/smartdevicelink/proxy/rpc/StabilityControlsStatus.java Co-authored-by: Julian Kast * [0253] - Rename trailerSWayControl -> trailersWayControl Co-authored-by: kboskin Co-authored-by: Vladyslav Mustafin Co-authored-by: Julian Kast --- .../androidTest/assets/json/GetVehicleData.json | 7 +- .../assets/json/SubscribeVehicleData.json | 5 + .../assets/json/UnsubscribeVehicleData.json | 5 + .../java/com/smartdevicelink/test/TestValues.java | 6 + .../java/com/smartdevicelink/test/Validator.java | 20 ++++ .../smartdevicelink/test/VehicleDataHelper.java | 12 ++ .../datatypes/StabilityControlsStatusTests.java | 58 ++++++++++ .../test/rpc/enums/VehicleDataTypeTests.java | 4 + .../test/rpc/notifications/OnVehicleDataTests.java | 28 ++++- .../test/rpc/requests/GetVehicleDataTests.java | 5 + .../rpc/requests/SubscribeVehicleDataTests.java | 5 + .../rpc/requests/UnsubscribeVehicleDataTests.java | 5 + .../rpc/responses/GetVehicleDataResponseTests.java | 34 +++++- .../SubscribeVehicleDataResponseTest.java | 9 ++ .../UnsubscribeVehicleDataResponseTest.java | 11 ++ .../smartdevicelink/proxy/rpc/GetVehicleData.java | 28 +++++ .../proxy/rpc/GetVehicleDataResponse.java | 21 ++++ .../smartdevicelink/proxy/rpc/OnVehicleData.java | 28 +++++ .../proxy/rpc/StabilityControlsStatus.java | 125 +++++++++++++++++++++ .../proxy/rpc/SubscribeVehicleData.java | 28 +++++ .../proxy/rpc/SubscribeVehicleDataResponse.java | 21 ++++ .../proxy/rpc/UnsubscribeVehicleData.java | 30 +++++ .../proxy/rpc/UnsubscribeVehicleDataResponse.java | 21 ++++ .../proxy/rpc/enums/VehicleDataType.java | 5 + 24 files changed, 516 insertions(+), 5 deletions(-) create mode 100644 android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/StabilityControlsStatusTests.java create mode 100644 base/src/main/java/com/smartdevicelink/proxy/rpc/StabilityControlsStatus.java diff --git a/android/sdl_android/src/androidTest/assets/json/GetVehicleData.json b/android/sdl_android/src/androidTest/assets/json/GetVehicleData.json index e75de1d3b..085cfedce 100644 --- a/android/sdl_android/src/androidTest/assets/json/GetVehicleData.json +++ b/android/sdl_android/src/androidTest/assets/json/GetVehicleData.json @@ -34,7 +34,8 @@ "electronicParkBrakeStatus":true, "gearStatus": true, "oemCustomVehicleDataName":true, - "windowStatus": true + "windowStatus": true, + "stabilityControlsStatus": true } }, "response":{ @@ -172,6 +173,10 @@ "range":10.0 } ], + "stabilityControlsStatus": { + "escSystem": "ON", + "trailerSwayControl": "OFF" + }, "oemCustomVehicleDataName":"oemCustomVehicleDataState", "gearStatus": { "userSelectedGear": "PARK", diff --git a/android/sdl_android/src/androidTest/assets/json/SubscribeVehicleData.json b/android/sdl_android/src/androidTest/assets/json/SubscribeVehicleData.json index c61da0661..a876a8a10 100644 --- a/android/sdl_android/src/androidTest/assets/json/SubscribeVehicleData.json +++ b/android/sdl_android/src/androidTest/assets/json/SubscribeVehicleData.json @@ -31,6 +31,7 @@ "fuelRange":true, "turnSignal":true, "electronicParkBrakeStatus":true, + "stabilityControlsStatus": true, "gearStatus": true, "oemCustomVehicleDataName":true, "windowStatus": true, @@ -157,6 +158,10 @@ "dataType":"VEHICLEDATA_HANDSOFFSTEERING", "resultCode":"SUCCESS" }, + "stabilityControlsStatus":{ + "dataType":"VEHICLEDATA_STABILITYCONTROLSSTATUS", + "resultCode":"SUCCESS" + }, "gearStatus":{ "dataType":"VEHICLEDATA_GEARSTATUS", "resultCode":"SUCCESS" diff --git a/android/sdl_android/src/androidTest/assets/json/UnsubscribeVehicleData.json b/android/sdl_android/src/androidTest/assets/json/UnsubscribeVehicleData.json index dd00502e5..e57dea0c8 100644 --- a/android/sdl_android/src/androidTest/assets/json/UnsubscribeVehicleData.json +++ b/android/sdl_android/src/androidTest/assets/json/UnsubscribeVehicleData.json @@ -31,6 +31,7 @@ "fuelRange":true, "turnSignal":true, "electronicParkBrakeStatus":true, + "stabilityControlsStatus": true, "handsOffSteering": true, "gearStatus": true, "oemCustomVehicleDataName":true, @@ -161,6 +162,10 @@ "dataType":"VEHICLEDATA_GEARSTATUS", "resultCode":"SUCCESS" }, + "stabilityControlsStatus":{ + "dataType":"VEHICLEDATA_STABILITYCONTROLSSTATUS", + "resultCode":"SUCCESS" + }, "oemCustomVehicleDataName":{ "oemCustomDataType":"oemCustomVehicleDataName", "resultCode":"SUCCESS" diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/TestValues.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/TestValues.java index caa9f1e7f..05de9258a 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/TestValues.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/TestValues.java @@ -89,6 +89,7 @@ import com.smartdevicelink.proxy.rpc.SingleTireStatus; import com.smartdevicelink.proxy.rpc.SisData; import com.smartdevicelink.proxy.rpc.SoftButton; import com.smartdevicelink.proxy.rpc.SoftButtonCapabilities; +import com.smartdevicelink.proxy.rpc.StabilityControlsStatus; import com.smartdevicelink.proxy.rpc.StartTime; import com.smartdevicelink.proxy.rpc.StationIDNumber; import com.smartdevicelink.proxy.rpc.SystemCapability; @@ -446,6 +447,9 @@ public class TestValues { public static final Grid GENERAL_GRID = new Grid(); public static final SeatLocation GENERAL_SEAT_LOCATION = new SeatLocation(); public static final ModuleInfo GENERAL_MODULE_INFO = new ModuleInfo(); + public static final StabilityControlsStatus GENERAL_STABILITY_CONTROL_STATUS = new StabilityControlsStatus(); + public static final VehicleDataStatus GENERAL_ESC_SYSTEM = VehicleDataStatus.ON; + public static final VehicleDataStatus GENERAL_S_WAY_CONTROL = VehicleDataStatus.OFF; public static final WindowType GENERAL_WINDOWTYPE = WindowType.MAIN; public static final GearStatus GENERAL_GEAR_STATUS = new GearStatus(); public static final PRNDL GENERAL_USER_SELECTED_GEAR = PRNDL.NEUTRAL; @@ -1145,6 +1149,8 @@ public class TestValues { GENERAL_WINDOW_STATUS.setLocation(TestValues.GENERAL_GRID); GENERAL_WINDOW_STATUS.setState(TestValues.GENERAL_WINDOW_STATE); + GENERAL_STABILITY_CONTROL_STATUS.setEscSystem(GENERAL_ESC_SYSTEM); + GENERAL_STABILITY_CONTROL_STATUS.setTrailerSwayControl(GENERAL_S_WAY_CONTROL); try { JSON_HMIPERMISSIONS.put(HMIPermissions.KEY_ALLOWED, GENERAL_HMILEVEL_LIST); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/Validator.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/Validator.java index 4fa61368f..da99ac3fd 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/Validator.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/Validator.java @@ -3907,4 +3907,24 @@ public class Validator{ return approxPosition1.equals(approxPosition2) && deviation1.equals(deviation2); } + + public static boolean validateStabilityControlStatus(StabilityControlsStatus status1, StabilityControlsStatus status2) { + if (status1 == null) { + return (status2 == null); + } + if (status2 == null) { + return (status2 == null); + } + return status1.getEscSystem().equals(status2.getEscSystem()) && status1.getTrailerSwayControl().equals(status2.getTrailerSwayControl()); + } + + public static boolean validateStabilityControlStatus(VehicleDataResult status1, VehicleDataResult status2) { + if (status1 == null) { + return (status2 == null); + } + if (status2 == null) { + return (status2 == null); + } + return status1.getDataType().equals(status2.getDataType()) && status1.getResultCode().equals(status2.getResultCode()); + } } diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/VehicleDataHelper.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/VehicleDataHelper.java index c314c7f9b..569b13b13 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/VehicleDataHelper.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/VehicleDataHelper.java @@ -16,6 +16,7 @@ import com.smartdevicelink.proxy.rpc.HeadLampStatus; import com.smartdevicelink.proxy.rpc.MyKey; import com.smartdevicelink.proxy.rpc.OnVehicleData; import com.smartdevicelink.proxy.rpc.SingleTireStatus; +import com.smartdevicelink.proxy.rpc.StabilityControlsStatus; import com.smartdevicelink.proxy.rpc.TireStatus; import com.smartdevicelink.proxy.rpc.WindowState; import com.smartdevicelink.proxy.rpc.WindowStatus; @@ -85,6 +86,7 @@ public class VehicleDataHelper{ public static final List FUEL_RANGE_LIST = new ArrayList(1); public static final TurnSignal TURN_SIGNAL = TurnSignal.OFF; public static final ElectronicParkBrakeStatus ELECTRONIC_PARK_BRAKE_STATUS = ElectronicParkBrakeStatus.CLOSED; + public static final StabilityControlsStatus STABILITY_CONTROLS_STATUS = new StabilityControlsStatus(); public static final String OEM_CUSTOM_VEHICLE_DATA_STATE = "oemCustomVehicleDataState"; public static final Boolean HANDS_OFF_STEERING = Boolean.TRUE; @@ -213,6 +215,10 @@ public class VehicleDataHelper{ public static final Grid LOCATION_GRID = TestValues.GENERAL_LOCATION_GRID; public static final WindowState WINDOW_STATE = TestValues.GENERAL_WINDOW_STATE; + // stability control status + public static final VehicleDataStatus ESC_SYSTEM = VehicleDataStatus.ON; + public static final VehicleDataStatus S_WAY_TRAILER = VehicleDataStatus.OFF; + public static final JSONArray JSON_FUEL_RANGE = new JSONArray(); //the OnVehicleData which stores all the information above @@ -358,6 +364,10 @@ public class VehicleDataHelper{ e.printStackTrace(); } + // STABILITY_CONTROLS_STATUS + STABILITY_CONTROLS_STATUS.setEscSystem(VehicleDataStatus.ON); + STABILITY_CONTROLS_STATUS.setTrailerSwayControl(VehicleDataStatus.OFF); + // GEAR_STATUS GEAR_STATUS.setTransmissionType(TRANSMISSION_TYPE); GEAR_STATUS.setUserSelectedGear(USER_SELECTED_GEAR); @@ -395,6 +405,7 @@ public class VehicleDataHelper{ VEHICLE_DATA.setElectronicParkBrakeStatus(ELECTRONIC_PARK_BRAKE_STATUS); VEHICLE_DATA.setGearStatus(GEAR_STATUS); VEHICLE_DATA.setWindowStatus(WINDOW_STATUS_LIST); + VEHICLE_DATA.setStabilityControlsStatus(STABILITY_CONTROLS_STATUS); VEHICLE_DATA.setOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, OEM_CUSTOM_VEHICLE_DATA_STATE); VEHICLE_DATA.setHandsOffSteering(HANDS_OFF_STEERING); //set up the GetVehicleDataResponse object @@ -429,6 +440,7 @@ public class VehicleDataHelper{ VEHICLE_DATA_RESPONSE.setElectronicParkBrakeStatus(ELECTRONIC_PARK_BRAKE_STATUS); VEHICLE_DATA_RESPONSE.setGearStatus(GEAR_STATUS); VEHICLE_DATA_RESPONSE.setWindowStatus(WINDOW_STATUS_LIST); + VEHICLE_DATA_RESPONSE.setStabilityControlsStatus(STABILITY_CONTROLS_STATUS); VEHICLE_DATA_RESPONSE.setOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, OEM_CUSTOM_VEHICLE_DATA_STATE); VEHICLE_DATA_RESPONSE.setHandsOffSteering(HANDS_OFF_STEERING); } diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/StabilityControlsStatusTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/StabilityControlsStatusTests.java new file mode 100644 index 000000000..1de8abfdf --- /dev/null +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/StabilityControlsStatusTests.java @@ -0,0 +1,58 @@ +package com.smartdevicelink.test.rpc.datatypes; + +import com.smartdevicelink.proxy.rpc.StabilityControlsStatus; +import com.smartdevicelink.proxy.rpc.enums.VehicleDataStatus; +import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.TestValues; + +import junit.framework.TestCase; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.Iterator; + +public class StabilityControlsStatusTests extends TestCase { + private StabilityControlsStatus msg; + + @Override + public void setUp() { + msg = new StabilityControlsStatus(); + + msg.setEscSystem(TestValues.GENERAL_ESC_SYSTEM); + msg.setTrailerSwayControl(TestValues.GENERAL_S_WAY_CONTROL); + } + + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Test Values + VehicleDataStatus esc = msg.getEscSystem(); + VehicleDataStatus sTrailer = msg.getTrailerSwayControl(); + + // Valid Tests + assertEquals(TestValues.MATCH, TestValues.GENERAL_ESC_SYSTEM, esc); + assertEquals(TestValues.MATCH, TestValues.GENERAL_S_WAY_CONTROL, sTrailer); + } + + public void testJson() { + JSONObject reference = new JSONObject(); + + try { + reference.put(StabilityControlsStatus.KEY_TRAILER_SWAY_CONTROL, TestValues.GENERAL_S_WAY_CONTROL); + reference.put(StabilityControlsStatus.KEY_ESC_SYSTEM, TestValues.GENERAL_ESC_SYSTEM); + + JSONObject underTest = msg.serializeJSON(); + assertEquals(TestValues.MATCH, reference.length(), underTest.length()); + + Iterator iterator = reference.keys(); + while (iterator.hasNext()) { + String key = (String) iterator.next(); + assertEquals(TestValues.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key)); + } + } catch (JSONException e) { + fail(TestValues.JSON_FAIL); + } + } +} \ No newline at end of file diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/VehicleDataTypeTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/VehicleDataTypeTests.java index 37793b489..a337058f9 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/VehicleDataTypeTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/VehicleDataTypeTests.java @@ -88,6 +88,8 @@ public class VehicleDataTypeTests extends TestCase { VehicleDataType enumVehicleDataGearStatus= VehicleDataType.valueForString(example); example = "VEHICLEDATA_WINDOWSTATUS"; VehicleDataType enumVehicleDataTypeWindowStatus= VehicleDataType.valueForString(example); + example = "VEHICLEDATA_STABILITYCONTROLSSTATUS"; + VehicleDataType enumVehicleDataStabilityControlsStatus = VehicleDataType.valueForString(example); assertNotNull("VEHICLEDATA_GPS returned null", enumVehicleDataGps); assertNotNull("VEHICLEDATA_SPEED returned null", enumVehicleDataSpeed); @@ -124,6 +126,7 @@ public class VehicleDataTypeTests extends TestCase { assertNotNull("VEHICLEDATA_HANDSOFFSTEERING returned null", enumVehicleDataHandsOffSteeringType); assertNotNull("VEHICLEDATA_WINDOWSTATUS returned null", enumVehicleDataTypeWindowStatus); assertNotNull("VEHICLEDATA_GEARSTATUS returned null", enumVehicleDataGearStatus); + assertNotNull("VEHICLEDATA_STABILITYCONTROLSSTATUS returned null", enumVehicleDataStabilityControlsStatus); } /** @@ -196,6 +199,7 @@ public class VehicleDataTypeTests extends TestCase { enumTestList.add(VehicleDataType.VEHICLEDATA_HANDSOFFSTEERING); enumTestList.add(VehicleDataType.VEHICLEDATA_WINDOWSTATUS); enumTestList.add(VehicleDataType.VEHICLEDATA_GEARSTATUS); + enumTestList.add(VehicleDataType.VEHICLEDATA_STABILITYCONTROLSSTATUS); assertTrue("Enum value list does not match enum class list", enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList)); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnVehicleDataTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnVehicleDataTests.java index 00718929c..409ad1dd1 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnVehicleDataTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnVehicleDataTests.java @@ -13,10 +13,12 @@ import com.smartdevicelink.proxy.rpc.EmergencyEvent; import com.smartdevicelink.proxy.rpc.FuelRange; import com.smartdevicelink.proxy.rpc.GPSData; import com.smartdevicelink.proxy.rpc.GearStatus; +import com.smartdevicelink.proxy.rpc.GetVehicleDataResponse; import com.smartdevicelink.proxy.rpc.HeadLampStatus; import com.smartdevicelink.proxy.rpc.MyKey; import com.smartdevicelink.proxy.rpc.OnVehicleData; import com.smartdevicelink.proxy.rpc.SingleTireStatus; +import com.smartdevicelink.proxy.rpc.StabilityControlsStatus; import com.smartdevicelink.proxy.rpc.TireStatus; import com.smartdevicelink.proxy.rpc.WindowStatus; import com.smartdevicelink.proxy.rpc.enums.ComponentVolumeStatus; @@ -104,6 +106,7 @@ public class OnVehicleDataTests extends BaseRpcTests{ result.put(OnVehicleData.KEY_HANDS_OFF_STEERING, VehicleDataHelper.HANDS_OFF_STEERING); result.put(OnVehicleData.KEY_GEAR_STATUS, VehicleDataHelper.GEAR_STATUS); result.put(OnVehicleData.KEY_WINDOW_STATUS, VehicleDataHelper.WINDOW_STATUS_LIST); + result.put(OnVehicleData.KEY_STABILITY_CONTROLS_STATUS, VehicleDataHelper.STABILITY_CONTROLS_STATUS); result.put(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, VehicleDataHelper.OEM_CUSTOM_VEHICLE_DATA_STATE); } catch(JSONException e) { fail(TestValues.JSON_FAIL); @@ -149,6 +152,7 @@ public class OnVehicleDataTests extends BaseRpcTests{ TurnSignal turnSignal = ( (OnVehicleData) msg).getTurnSignal(); ElectronicParkBrakeStatus electronicParkBrakeStatus = ( (OnVehicleData) msg).getElectronicParkBrakeStatus(); GearStatus gearStatus = ( (OnVehicleData) msg).getGearStatus(); + StabilityControlsStatus stabilityControlsStatus = ( (OnVehicleData) msg).getStabilityControlsStatus(); Object oemCustomVehicleData = ( (OnVehicleData) msg).getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME); Boolean handsOffSteering = ( (OnVehicleData) msg).getHandsOffSteering(); // Valid Tests @@ -183,6 +187,7 @@ public class OnVehicleDataTests extends BaseRpcTests{ assertEquals(TestValues.MATCH, VehicleDataHelper.TURN_SIGNAL, turnSignal); assertEquals(TestValues.MATCH, VehicleDataHelper.ELECTRONIC_PARK_BRAKE_STATUS, electronicParkBrakeStatus); assertEquals(TestValues.MATCH, VehicleDataHelper.GEAR_STATUS, gearStatus); + assertEquals(TestValues.MATCH, VehicleDataHelper.STABILITY_CONTROLS_STATUS, stabilityControlsStatus); assertEquals(TestValues.MATCH, VehicleDataHelper.OEM_CUSTOM_VEHICLE_DATA_STATE, oemCustomVehicleData); assertEquals(TestValues.MATCH, VehicleDataHelper.HANDS_OFF_STEERING, handsOffSteering); // Invalid/Null Tests @@ -222,6 +227,7 @@ public class OnVehicleDataTests extends BaseRpcTests{ assertNull(TestValues.NULL, msg.getHandsOffSteering()); assertNull(TestValues.NULL, msg.getWindowStatus()); assertNull(TestValues.NULL, msg.getGearStatus()); + assertNull(TestValues.NULL, msg.getStabilityControlsStatus()); assertNull(TestValues.NULL, msg.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); } @@ -244,8 +250,9 @@ public class OnVehicleDataTests extends BaseRpcTests{ JSONObject fuelRangeObj = new JSONObject(); JSONObject windowStatusObj = new JSONObject(); JSONObject gearStatusObj = new JSONObject(); + JSONObject stabilityControlStatusObj = new JSONObject(); JSONArray fuelRangeArrayObj = new JSONArray(); - JSONArray windowStatusArrayObj = new JSONArray(); + JSONArray windowStatusArrayObj = new JSONArray(); try { //Set up the JSONObject to represent OnVehicleData: @@ -376,6 +383,10 @@ public class OnVehicleDataTests extends BaseRpcTests{ fuelRangeObj.put(FuelRange.KEY_LEVEL_STATE, VehicleDataHelper.FUEL_RANGE_LEVEL_STATE); fuelRangeArrayObj.put(fuelRangeObj); + // STABILITY_CONTROLS_STATU + stabilityControlStatusObj.put(StabilityControlsStatus.KEY_ESC_SYSTEM, VehicleDataHelper.ESC_SYSTEM); + stabilityControlStatusObj.put(StabilityControlsStatus.KEY_TRAILER_SWAY_CONTROL, VehicleDataHelper.S_WAY_TRAILER); + // WINDOW_STATUS windowStatusObj.put(WindowStatus.KEY_LOCATION, VehicleDataHelper.LOCATION_GRID); windowStatusObj.put(WindowStatus.KEY_STATE, VehicleDataHelper.WINDOW_STATE); @@ -418,6 +429,7 @@ public class OnVehicleDataTests extends BaseRpcTests{ reference.put(OnVehicleData.KEY_HANDS_OFF_STEERING, VehicleDataHelper.HANDS_OFF_STEERING); reference.put(OnVehicleData.KEY_WINDOW_STATUS, windowStatusArrayObj); reference.put(OnVehicleData.KEY_GEAR_STATUS, gearStatusObj); + reference.put(OnVehicleData.KEY_STABILITY_CONTROLS_STATUS, stabilityControlStatusObj); reference.put(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, VehicleDataHelper.OEM_CUSTOM_VEHICLE_DATA_STATE); JSONObject underTest = msg.serializeJSON(); @@ -565,6 +577,20 @@ public class OnVehicleDataTests extends BaseRpcTests{ windowStatusReferenceList, windowStatusUnderTestList)); } + else if (key.equals(GetVehicleDataResponse.KEY_STABILITY_CONTROLS_STATUS)) { + JSONObject myKeyObjReference = JsonUtils.readJsonObjectFromJsonObject(reference, key); + JSONObject myKeyObjTest = JsonUtils.readJsonObjectFromJsonObject(underTest, key); + + StabilityControlsStatus status1 = new StabilityControlsStatus(JsonRPCMarshaller.deserializeJSONObject(myKeyObjReference)); + StabilityControlsStatus status2 = new StabilityControlsStatus(JsonRPCMarshaller.deserializeJSONObject(myKeyObjTest)); + + assertTrue("JSON value didn't match expected value for key \"" + key + "\".", + Validator.validateStabilityControlStatus( + status1, + status2 + ) + ); + } else { assertEquals(TestValues.TRUE, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key)); } diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetVehicleDataTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetVehicleDataTests.java index f3b4b564e..467c37b2e 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetVehicleDataTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetVehicleDataTests.java @@ -64,6 +64,7 @@ public class GetVehicleDataTests extends BaseRpcTests { msg.setHandsOffSteering(TestValues.GENERAL_BOOLEAN); msg.setWindowStatus(TestValues.GENERAL_BOOLEAN); msg.setGearStatus(TestValues.GENERAL_BOOLEAN); + msg.setStabilityControlsStatus(TestValues.GENERAL_BOOLEAN); msg.setOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, TestValues.GENERAL_BOOLEAN); return msg; @@ -116,6 +117,7 @@ public class GetVehicleDataTests extends BaseRpcTests { result.put(GetVehicleData.KEY_HANDS_OFF_STEERING, TestValues.GENERAL_BOOLEAN); result.put(GetVehicleData.KEY_GEAR_STATUS, TestValues.GENERAL_BOOLEAN); result.put(GetVehicleData.KEY_WINDOW_STATUS, TestValues.GENERAL_BOOLEAN); + result.put(GetVehicleData.KEY_STABILITY_CONTROLS_STATUS, TestValues.GENERAL_BOOLEAN); result.put(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, TestValues.GENERAL_BOOLEAN); }catch(JSONException e){ fail(TestValues.JSON_FAIL); @@ -163,6 +165,7 @@ public class GetVehicleDataTests extends BaseRpcTests { assertTrue(TestValues.TRUE, ( (GetVehicleData) msg ).getHandsOffSteering()); assertTrue(TestValues.TRUE, ( (GetVehicleData) msg ).getWindowStatus()); assertTrue(TestValues.TRUE, ( (GetVehicleData) msg ).getGearStatus()); + assertTrue(TestValues.TRUE, ( (GetVehicleData) msg ).getStabilityControlsStatus()); assertTrue(TestValues.TRUE, ( (GetVehicleData) msg ).getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); // Invalid/Null Tests @@ -202,6 +205,7 @@ public class GetVehicleDataTests extends BaseRpcTests { assertNull(TestValues.NULL, msg.getHandsOffSteering()); assertNull(TestValues.NULL, msg.getWindowStatus()); assertNull(TestValues.NULL, msg.getGearStatus()); + assertNull(TestValues.NULL, msg.getStabilityControlsStatus()); assertNull(TestValues.NULL, msg.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); } @@ -257,6 +261,7 @@ public class GetVehicleDataTests extends BaseRpcTests { assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, GetVehicleData.KEY_HANDS_OFF_STEERING), cmd.getHandsOffSteering()); assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, GetVehicleData.KEY_WINDOW_STATUS), cmd.getWindowStatus()); assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, GetVehicleData.KEY_GEAR_STATUS), cmd.getGearStatus()); + assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, GetVehicleData.KEY_STABILITY_CONTROLS_STATUS), cmd.getStabilityControlsStatus()); assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME), cmd.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); } catch (JSONException e) { fail(TestValues.JSON_FAIL); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SubscribeVehicleDataTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SubscribeVehicleDataTests.java index fee5ddd25..7f5113fc7 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SubscribeVehicleDataTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SubscribeVehicleDataTests.java @@ -63,6 +63,7 @@ public class SubscribeVehicleDataTests extends BaseRpcTests { msg.setHandsOffSteering(TestValues.GENERAL_BOOLEAN); msg.setWindowStatus(TestValues.GENERAL_BOOLEAN); msg.setGearStatus(TestValues.GENERAL_BOOLEAN); + msg.setStabilityControlsStatus(TestValues.GENERAL_BOOLEAN); msg.setOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, TestValues.GENERAL_BOOLEAN); return msg; @@ -114,6 +115,7 @@ public class SubscribeVehicleDataTests extends BaseRpcTests { result.put(SubscribeVehicleData.KEY_HANDS_OFF_STEERING, TestValues.GENERAL_BOOLEAN); result.put(SubscribeVehicleData.KEY_WINDOW_STATUS, TestValues.GENERAL_BOOLEAN); result.put(SubscribeVehicleData.KEY_GEAR_STATUS, TestValues.GENERAL_BOOLEAN); + result.put(SubscribeVehicleData.KEY_STABILITY_CONTROLS_STATUS, TestValues.GENERAL_BOOLEAN); result.put(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, TestValues.GENERAL_BOOLEAN); } catch (JSONException e) { fail(TestValues.JSON_FAIL); @@ -160,6 +162,7 @@ public class SubscribeVehicleDataTests extends BaseRpcTests { assertTrue(TestValues.MATCH,( (SubscribeVehicleData) msg ).getHandsOffSteering()); assertTrue(TestValues.MATCH,( (SubscribeVehicleData) msg ).getWindowStatus()); assertTrue(TestValues.MATCH,( (SubscribeVehicleData) msg ).getGearStatus()); + assertTrue(TestValues.MATCH,( (SubscribeVehicleData) msg ).getStabilityControlsStatus()); assertTrue(TestValues.MATCH,( (SubscribeVehicleData) msg ).getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); // Invalid/Null Tests @@ -198,6 +201,7 @@ public class SubscribeVehicleDataTests extends BaseRpcTests { assertNull(TestValues.NULL, msg.getHandsOffSteering()); assertNull(TestValues.NULL, msg.getWindowStatus()); assertNull(TestValues.NULL, msg.getGearStatus()); + assertNull(TestValues.NULL, msg.getStabilityControlsStatus()); assertNull(TestValues.NULL, msg.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); } @@ -251,6 +255,7 @@ public class SubscribeVehicleDataTests extends BaseRpcTests { assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, SubscribeVehicleData.KEY_ELECTRONIC_PARK_BRAKE_STATUS), cmd.getElectronicParkBrakeStatus()); assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, SubscribeVehicleData.KEY_HANDS_OFF_STEERING), cmd.getHandsOffSteering()); assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, SubscribeVehicleData.KEY_WINDOW_STATUS), cmd.getWindowStatus()); + assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, SubscribeVehicleData.KEY_STABILITY_CONTROLS_STATUS), cmd.getStabilityControlsStatus()); assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME), cmd.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); } catch (JSONException e) { fail(TestValues.JSON_FAIL); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnsubscribeVehicleDataTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnsubscribeVehicleDataTests.java index 747b61563..9ca309030 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnsubscribeVehicleDataTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnsubscribeVehicleDataTests.java @@ -66,6 +66,7 @@ public class UnsubscribeVehicleDataTests extends BaseRpcTests { msg.setGearStatus(TestValues.GENERAL_BOOLEAN); msg.setHandsOffSteering(TestValues.GENERAL_BOOLEAN); msg.setWindowStatus(TestValues.GENERAL_BOOLEAN); + msg.setStabilityControlsStatus(TestValues.GENERAL_BOOLEAN); msg.setOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, TestValues.GENERAL_BOOLEAN); return msg; @@ -118,6 +119,7 @@ public class UnsubscribeVehicleDataTests extends BaseRpcTests { result.put(UnsubscribeVehicleData.KEY_HANDS_OFF_STEERING, TestValues.GENERAL_BOOLEAN); result.put(UnsubscribeVehicleData.KEY_WINDOW_STATUS, TestValues.GENERAL_BOOLEAN); result.put(UnsubscribeVehicleData.KEY_GEAR_STATUS, TestValues.GENERAL_BOOLEAN); + result.put(UnsubscribeVehicleData.KEY_STABILITY_CONTROLS_STATUS, TestValues.GENERAL_BOOLEAN); result.put(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, TestValues.GENERAL_BOOLEAN); } catch (JSONException e) { fail(TestValues.JSON_FAIL); @@ -164,6 +166,7 @@ public class UnsubscribeVehicleDataTests extends BaseRpcTests { assertTrue(TestValues.TRUE,( (UnsubscribeVehicleData) msg ).getHandsOffSteering()); assertTrue(TestValues.TRUE,( (UnsubscribeVehicleData) msg ).getWindowStatus()); assertTrue(TestValues.TRUE,( (UnsubscribeVehicleData) msg ).getGearStatus()); + assertTrue(TestValues.TRUE,( (UnsubscribeVehicleData) msg ).getStabilityControlsStatus()); assertTrue(TestValues.TRUE,( (UnsubscribeVehicleData) msg ).getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); // Invalid/Null Tests UnsubscribeVehicleData msg = new UnsubscribeVehicleData(); @@ -202,6 +205,7 @@ public class UnsubscribeVehicleDataTests extends BaseRpcTests { assertNull(TestValues.NULL, msg.getHandsOffSteering()); assertNull(TestValues.NULL, msg.getWindowStatus()); assertNull(TestValues.NULL, msg.getGearStatus()); + assertNull(TestValues.NULL, msg.getStabilityControlsStatus()); assertNull(TestValues.NULL, msg.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); } @@ -257,6 +261,7 @@ public class UnsubscribeVehicleDataTests extends BaseRpcTests { assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, UnsubscribeVehicleData.KEY_HANDS_OFF_STEERING), cmd.getHandsOffSteering()); assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, UnsubscribeVehicleData.KEY_WINDOW_STATUS), cmd.getWindowStatus()); assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, UnsubscribeVehicleData.KEY_GEAR_STATUS), cmd.getGearStatus()); + assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, UnsubscribeVehicleData.KEY_STABILITY_CONTROLS_STATUS), cmd.getStabilityControlsStatus()); assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME), cmd.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); } diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetVehicleDataResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetVehicleDataResponseTests.java index 896694f53..818c9b4ce 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetVehicleDataResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetVehicleDataResponseTests.java @@ -17,6 +17,7 @@ import com.smartdevicelink.proxy.rpc.GetVehicleDataResponse; import com.smartdevicelink.proxy.rpc.HeadLampStatus; import com.smartdevicelink.proxy.rpc.MyKey; import com.smartdevicelink.proxy.rpc.SingleTireStatus; +import com.smartdevicelink.proxy.rpc.StabilityControlsStatus; import com.smartdevicelink.proxy.rpc.TireStatus; import com.smartdevicelink.proxy.rpc.WindowStatus; import com.smartdevicelink.proxy.rpc.enums.TurnSignal; @@ -100,10 +101,11 @@ public class GetVehicleDataResponseTests extends BaseRpcTests{ result.put(GetVehicleDataResponse.KEY_FUEL_RANGE, VehicleDataHelper.JSON_FUEL_RANGE); result.put(GetVehicleDataResponse.KEY_TURN_SIGNAL, VehicleDataHelper.TURN_SIGNAL); result.put(GetVehicleDataResponse.KEY_ELECTRONIC_PARK_BRAKE_STATUS, VehicleDataHelper.ELECTRONIC_PARK_BRAKE_STATUS); - result.put(GetVehicleDataResponse.KEY_WINDOW_STATUS, VehicleDataHelper.WINDOW_STATUS_LIST); + result.put(GetVehicleDataResponse.KEY_WINDOW_STATUS, VehicleDataHelper.WINDOW_STATUS_LIST); result.put(GetVehicleDataResponse.KEY_HANDS_OFF_STEERING, VehicleDataHelper.HANDS_OFF_STEERING); result.put(GetVehicleDataResponse.KEY_GEAR_STATUS, VehicleDataHelper.GEAR_STATUS); - result.put(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, VehicleDataHelper.OEM_CUSTOM_VEHICLE_DATA_STATE); + result.put(GetVehicleDataResponse.KEY_STABILITY_CONTROLS_STATUS, VehicleDataHelper.STABILITY_CONTROLS_STATUS); + result.put(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, VehicleDataHelper.OEM_CUSTOM_VEHICLE_DATA_STATE); } catch(JSONException e){ fail(TestValues.JSON_FAIL); } @@ -127,6 +129,7 @@ public class GetVehicleDataResponseTests extends BaseRpcTests{ JSONObject emergencyEventObj = new JSONObject(); JSONObject clusterModeStatusObj = new JSONObject(); JSONObject myKeyObj = new JSONObject(); + JSONObject stabilityControlsStatusObj = new JSONObject(); JSONObject fuelRangeObj = new JSONObject(); JSONObject windowStatusObj = new JSONObject(); JSONObject gearStatusObj = new JSONObject(); @@ -248,7 +251,11 @@ public class GetVehicleDataResponseTests extends BaseRpcTests{ clusterModeStatusObj.put(ClusterModeStatus.KEY_POWER_MODE_QUALIFICATION_STATUS, VehicleDataHelper.CLUSTER_MODE_STATUS_POWER_MODE_QUALIFICATION_STATUS); clusterModeStatusObj.put(ClusterModeStatus.KEY_CAR_MODE_STATUS, VehicleDataHelper.CLUSTER_MODE_STATUS_CAR_MODE_STATUS); clusterModeStatusObj.put(ClusterModeStatus.KEY_POWER_MODE_STATUS, VehicleDataHelper.CLUSTER_MODE_STATUS_POWER_MODE_STATUS); - + + // STABILITY_CONTROL_STATUS + stabilityControlsStatusObj.put(StabilityControlsStatus.KEY_ESC_SYSTEM, VehicleDataHelper.ESC_SYSTEM); + stabilityControlsStatusObj.put(StabilityControlsStatus.KEY_TRAILER_SWAY_CONTROL, VehicleDataHelper.S_WAY_TRAILER); + //MY_KEY myKeyObj.put(MyKey.KEY_E_911_OVERRIDE, VehicleDataHelper.MY_KEY_E_911_OVERRIDE); @@ -303,6 +310,7 @@ public class GetVehicleDataResponseTests extends BaseRpcTests{ reference.put(GetVehicleDataResponse.KEY_ELECTRONIC_PARK_BRAKE_STATUS, VehicleDataHelper.ELECTRONIC_PARK_BRAKE_STATUS); reference.put(GetVehicleDataResponse.KEY_WINDOW_STATUS, windowStatusArrayObj); reference.put(GetVehicleDataResponse.KEY_HANDS_OFF_STEERING, VehicleDataHelper.HANDS_OFF_STEERING); + reference.put(GetVehicleDataResponse.KEY_STABILITY_CONTROLS_STATUS, stabilityControlsStatusObj); reference.put(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, VehicleDataHelper.OEM_CUSTOM_VEHICLE_DATA_STATE); JSONObject underTest = msg.serializeJSON(); @@ -429,6 +437,20 @@ public class GetVehicleDataResponseTests extends BaseRpcTests{ new GearStatus(JsonRPCMarshaller.deserializeJSONObject(myKeyObjReference)), new GearStatus(JsonRPCMarshaller.deserializeJSONObject(myKeyObjTest)))); } + else if (key.equals(GetVehicleDataResponse.KEY_STABILITY_CONTROLS_STATUS)) { + JSONObject myKeyObjReference = JsonUtils.readJsonObjectFromJsonObject(reference, key); + JSONObject myKeyObjTest = JsonUtils.readJsonObjectFromJsonObject(underTest, key); + + StabilityControlsStatus status1 = new StabilityControlsStatus(JsonRPCMarshaller.deserializeJSONObject(myKeyObjReference)); + StabilityControlsStatus status2 = new StabilityControlsStatus(JsonRPCMarshaller.deserializeJSONObject(myKeyObjTest)); + + assertTrue("JSON value didn't match expected value for key \"" + key + "\".", + Validator.validateStabilityControlStatus( + status1, + status2 + ) + ); + } else if (key.equals(GetVehicleDataResponse.KEY_FUEL_RANGE)) { JSONArray fuelRangeArrayObjReference = JsonUtils.readJsonArrayFromJsonObject(reference, key); List fuelRangeRefereceList = new ArrayList(); @@ -518,6 +540,7 @@ public class GetVehicleDataResponseTests extends BaseRpcTests{ assertEquals(TestValues.MATCH, VehicleDataHelper.WINDOW_STATUS_LIST, ( (GetVehicleDataResponse) msg ).getWindowStatus()); assertEquals(TestValues.MATCH, VehicleDataHelper.GEAR_STATUS, ( (GetVehicleDataResponse) msg ).getGearStatus()); assertEquals(TestValues.MATCH, VehicleDataHelper.HANDS_OFF_STEERING, ( (GetVehicleDataResponse) msg ).getHandsOffSteering()); + assertEquals(TestValues.MATCH, VehicleDataHelper.STABILITY_CONTROLS_STATUS, ( (GetVehicleDataResponse) msg ).getStabilityControlsStatus()); assertEquals(TestValues.MATCH, VehicleDataHelper.OEM_CUSTOM_VEHICLE_DATA_STATE, ( (GetVehicleDataResponse) msg ).getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); // Invalid/Null Tests @@ -554,6 +577,7 @@ public class GetVehicleDataResponseTests extends BaseRpcTests{ assertNull(TestValues.NULL, msg.getElectronicParkBrakeStatus()); assertNull(TestValues.NULL, msg.getGearStatus()); assertNull(TestValues.NULL, msg.getHandsOffSteering()); + assertNull(TestValues.NULL, msg.getStabilityControlsStatus()); assertNull(TestValues.NULL, msg.getWindowStatus()); assertNull(TestValues.NULL, msg.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); } @@ -660,6 +684,10 @@ public class GetVehicleDataResponseTests extends BaseRpcTests{ assertEquals(TestValues.MATCH, JsonUtils.readStringFromJsonObject(parameters, GetVehicleDataResponse.KEY_TURN_SIGNAL), cmd.getTurnSignal().toString()); assertEquals(TestValues.MATCH, JsonUtils.readStringFromJsonObject(parameters, GetVehicleDataResponse.KEY_ELECTRONIC_PARK_BRAKE_STATUS), cmd.getElectronicParkBrakeStatus().toString()); assertEquals(TestValues.MATCH, JsonUtils.readStringFromJsonObject(parameters, TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME), cmd.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); + + JSONObject stabilityControlStatusObj = JsonUtils.readJsonObjectFromJsonObject(parameters, GetVehicleDataResponse.KEY_STABILITY_CONTROLS_STATUS); + StabilityControlsStatus stabilityControlsStatus = new StabilityControlsStatus(JsonRPCMarshaller.deserializeJSONObject(stabilityControlStatusObj)); + assertTrue(TestValues.TRUE, Validator.validateStabilityControlStatus(stabilityControlsStatus, cmd.getStabilityControlsStatus())); } catch (JSONException e) { e.printStackTrace(); } diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SubscribeVehicleDataResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SubscribeVehicleDataResponseTest.java index 643935a02..79af1baa8 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SubscribeVehicleDataResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SubscribeVehicleDataResponseTest.java @@ -68,6 +68,7 @@ public class SubscribeVehicleDataResponseTest extends BaseRpcTests { msg.setGearStatus(TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_GEARSTATUS.ordinal())); msg.setHandsOffSteering(TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_HANDSOFFSTEERING.ordinal())); msg.setWindowStatus(TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_WINDOWSTATUS.ordinal())); + msg.setStabilityControlsStatus(TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_STABILITYCONTROLSSTATUS.ordinal())); msg.setOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA); return msg; @@ -122,6 +123,7 @@ public class SubscribeVehicleDataResponseTest extends BaseRpcTests { result.put(SubscribeVehicleDataResponse.KEY_TURN_SIGNAL, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_TURNSIGNAL.ordinal()).serializeJSON()); result.put(SubscribeVehicleDataResponse.KEY_WINDOW_STATUS, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_WINDOWSTATUS.ordinal()).serializeJSON()); result.put(SubscribeVehicleDataResponse.KEY_GEAR_STATUS, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_GEARSTATUS.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_STABILITY_CONTROLS_STATUS, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_STABILITYCONTROLSSTATUS.ordinal()).serializeJSON()); result.put(SubscribeVehicleDataResponse.KEY_ELECTRONIC_PARK_BRAKE_STATUS, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_ELECTRONICPARKBRAKESTATUS.ordinal()).serializeJSON()); result.put(SubscribeVehicleDataResponse.KEY_HANDS_OFF_STEERING, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_HANDSOFFSTEERING.ordinal()).serializeJSON()); result.put(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA.serializeJSON()); @@ -169,6 +171,7 @@ public class SubscribeVehicleDataResponseTest extends BaseRpcTests { VehicleDataResult testHOffSteering = ( (SubscribeVehicleDataResponse) msg ).getHandsOffSteering(); VehicleDataResult testWindowStatus = ( (SubscribeVehicleDataResponse) msg ).getWindowStatus(); VehicleDataResult testGearStatus = ( (SubscribeVehicleDataResponse) msg ).getGearStatus(); + VehicleDataResult testStabilityControlStatus = ( (SubscribeVehicleDataResponse) msg ).getStabilityControlsStatus(); VehicleDataResult testOEMCustomVehicleData = ( (SubscribeVehicleDataResponse) msg ).getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME); // Valid Tests @@ -203,6 +206,7 @@ public class SubscribeVehicleDataResponseTest extends BaseRpcTests { assertTrue(TestValues.TRUE, testHOffSteering.getDataType().equals(VehicleDataType.VEHICLEDATA_HANDSOFFSTEERING)); assertTrue(TestValues.TRUE, testGearStatus.getDataType().equals(VehicleDataType.VEHICLEDATA_GEARSTATUS)); assertTrue(TestValues.TRUE, testWindowStatus.getDataType().equals(VehicleDataType.VEHICLEDATA_WINDOWSTATUS)); + assertTrue(TestValues.TRUE, testStabilityControlStatus.getDataType().equals(VehicleDataType.VEHICLEDATA_STABILITYCONTROLSSTATUS)); assertTrue(TestValues.TRUE, testOEMCustomVehicleData.getOEMCustomVehicleDataType().equals(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); // Invalid/Null Tests @@ -241,6 +245,7 @@ public class SubscribeVehicleDataResponseTest extends BaseRpcTests { assertNull(TestValues.NULL, msg.getHandsOffSteering()); assertNull(TestValues.NULL, msg.getWindowStatus()); assertNull(TestValues.NULL, msg.getGearStatus()); + assertNull(TestValues.NULL, msg.getStabilityControlsStatus()); assertNull(TestValues.NULL, msg.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); } @@ -389,6 +394,10 @@ public class SubscribeVehicleDataResponseTest extends BaseRpcTests { VehicleDataResult referenceGearStatus = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(gearStatus)); assertTrue(TestValues.TRUE, Validator.validateVehicleDataResult(referenceGearStatus, cmd.getGearStatus())); + JSONObject stabilityControlStatus = JsonUtils.readJsonObjectFromJsonObject(parameters, SubscribeVehicleDataResponse.KEY_STABILITY_CONTROLS_STATUS); + VehicleDataResult referenceStabilityControlStatus = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(stabilityControlStatus)); + assertTrue(TestValues.TRUE, Validator.validateStabilityControlStatus(referenceStabilityControlStatus, cmd.getStabilityControlsStatus())); + JSONObject oemCustomVehicleDataName = JsonUtils.readJsonObjectFromJsonObject(parameters, TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME); VehicleDataResult referenceOemCustomData = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(oemCustomVehicleDataName)); assertTrue(TestValues.TRUE, Validator.validateVehicleDataResult(referenceOemCustomData, cmd.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME))); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnsubscribeVehicleDataResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnsubscribeVehicleDataResponseTest.java index dc69b66ae..284090cd5 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnsubscribeVehicleDataResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnsubscribeVehicleDataResponseTest.java @@ -70,6 +70,7 @@ public class UnsubscribeVehicleDataResponseTest extends BaseRpcTests { msg.setWindowStatus(TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_WINDOWSTATUS.ordinal())); msg.setHandsOffSteering(TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_HANDSOFFSTEERING.ordinal())); msg.setGearStatus(TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_GEARSTATUS.ordinal())); + msg.setStabilityControlsStatus(TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_STABILITYCONTROLSSTATUS.ordinal())); msg.setOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA); return msg; @@ -124,6 +125,8 @@ public class UnsubscribeVehicleDataResponseTest extends BaseRpcTests { result.put(SubscribeVehicleDataResponse.KEY_TURN_SIGNAL, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_TURNSIGNAL.ordinal()).serializeJSON()); result.put(SubscribeVehicleDataResponse.KEY_GEAR_STATUS, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_GEARSTATUS.ordinal()).serializeJSON()); result.put(SubscribeVehicleDataResponse.KEY_ELECTRONIC_PARK_BRAKE_STATUS, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_ELECTRONICPARKBRAKESTATUS.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_STABILITY_CONTROLS_STATUS, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_STABILITYCONTROLSSTATUS.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_ELECTRONIC_PARK_BRAKE_STATUS, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_ELECTRONICPARKBRAKESTATUS.ordinal()).serializeJSON()); result.put(SubscribeVehicleDataResponse.KEY_HANDS_OFF_STEERING, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_HANDSOFFSTEERING.ordinal()).serializeJSON()); result.put(SubscribeVehicleDataResponse.KEY_WINDOW_STATUS, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_WINDOWSTATUS.ordinal()).serializeJSON()); result.put(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA.serializeJSON()); @@ -171,6 +174,7 @@ public class UnsubscribeVehicleDataResponseTest extends BaseRpcTests { VehicleDataResult testHOffSteering = ( (UnsubscribeVehicleDataResponse) msg ).getHandsOffSteering(); VehicleDataResult testGearStatus = ( (UnsubscribeVehicleDataResponse) msg ).getGearStatus(); VehicleDataResult testWindowStatus = ( (UnsubscribeVehicleDataResponse) msg ).getWindowStatus(); + VehicleDataResult testStabilityControlStatus = ( (UnsubscribeVehicleDataResponse) msg ).getStabilityControlsStatus(); VehicleDataResult testOemCustomData = ( (UnsubscribeVehicleDataResponse) msg ).getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME); // Valid Tests @@ -204,6 +208,7 @@ public class UnsubscribeVehicleDataResponseTest extends BaseRpcTests { assertTrue(TestValues.TRUE, testEBrakeStatus.getDataType().equals(VehicleDataType.VEHICLEDATA_ELECTRONICPARKBRAKESTATUS)); assertTrue(TestValues.TRUE, testHOffSteering.getDataType().equals(VehicleDataType.VEHICLEDATA_HANDSOFFSTEERING)); assertTrue(TestValues.TRUE, testWindowStatus.getDataType().equals(VehicleDataType.VEHICLEDATA_WINDOWSTATUS)); + assertTrue(TestValues.TRUE, testStabilityControlStatus.getDataType().equals(VehicleDataType.VEHICLEDATA_STABILITYCONTROLSSTATUS)); assertTrue(TestValues.TRUE, testOemCustomData.getOEMCustomVehicleDataType().equals(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); assertTrue(TestValues.TRUE, testGearStatus.getDataType().equals(VehicleDataType.VEHICLEDATA_GEARSTATUS)); @@ -243,6 +248,8 @@ public class UnsubscribeVehicleDataResponseTest extends BaseRpcTests { assertNull(TestValues.NULL, msg.getGearStatus()); assertNull(TestValues.NULL, msg.getHandsOffSteering()); assertNull(TestValues.NULL, msg.getWindowStatus()); + assertNull(TestValues.NULL, msg.getHandsOffSteering()); + assertNull(TestValues.NULL, msg.getStabilityControlsStatus()); assertNull(TestValues.NULL, msg.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); } @@ -394,6 +401,10 @@ public class UnsubscribeVehicleDataResponseTest extends BaseRpcTests { JSONObject oemCustomData = JsonUtils.readJsonObjectFromJsonObject(parameters, TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME); VehicleDataResult referenceOemCustomData = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(oemCustomData)); assertTrue(TestValues.TRUE, Validator.validateVehicleDataResult(referenceOemCustomData, cmd.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME))); + + JSONObject stabilityControlsStatus = JsonUtils.readJsonObjectFromJsonObject(parameters, UnsubscribeVehicleDataResponse.KEY_STABILITY_CONTROLS_STATUS); + VehicleDataResult referenceStabilityControlStatus = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(stabilityControlsStatus)); + assertTrue(TestValues.TRUE, Validator.validateStabilityControlStatus(referenceStabilityControlStatus, cmd.getStabilityControlsStatus())); } catch (JSONException e) { e.printStackTrace(); } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleData.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleData.java index b08a18e5f..d1400d8f3 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleData.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleData.java @@ -247,6 +247,13 @@ import java.util.Hashtable; * N * Subscribable * SmartDeviceLink 5.1 + * + * stabilityControlsStatus + * Boolean + * See StabilityControlsStatus + * N + * SmartDeviceLink 7.0.0 + * * * * handsOffSteering @@ -328,6 +335,7 @@ public class GetVehicleData extends RPCRequest { */ @Deprecated public static final String KEY_FUEL_LEVEL_STATE = "fuelLevel_State"; + public static final String KEY_STABILITY_CONTROLS_STATUS = "stabilityControlsStatus"; /** * Constructs a new GetVehicleData object @@ -675,4 +683,24 @@ public class GetVehicleData extends RPCRequest { public Boolean getGearStatus() { return getBoolean(KEY_GEAR_STATUS); } + + /** + * Sets the stabilityControlsStatus. + * + * @param stabilityControlsStatus See StabilityControlsStatus + * @since SmartDeviceLink 7.0.0 + */ + public void setStabilityControlsStatus(Boolean stabilityControlsStatus) { + setParameters(KEY_STABILITY_CONTROLS_STATUS, stabilityControlsStatus); + } + + /** + * Gets the stabilityControlsStatus. + * + * @return Boolean See StabilityControlsStatus + * @since SmartDeviceLink 7.0.0 + */ + public Boolean getStabilityControlsStatus() { + return getBoolean(KEY_STABILITY_CONTROLS_STATUS); + } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleDataResponse.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleDataResponse.java index 6c619c010..2e7df80a9 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleDataResponse.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleDataResponse.java @@ -95,6 +95,7 @@ public class GetVehicleDataResponse extends RPCResponse { public static final String KEY_WINDOW_STATUS = "windowStatus"; public static final String KEY_GEAR_STATUS = "gearStatus"; public static final String KEY_HANDS_OFF_STEERING = "handsOffSteering"; + public static final String KEY_STABILITY_CONTROLS_STATUS = "stabilityControlsStatus"; /** * Constructs a new GetVehicleDataResponse object @@ -500,4 +501,24 @@ public class GetVehicleDataResponse extends RPCResponse { public GearStatus getGearStatus() { return (GearStatus) getObject(GearStatus.class, KEY_GEAR_STATUS); } + + /** + * Gets the stabilityControlsStatus. + * + * @return StabilityControlsStatus See StabilityControlsStatus + * @since SmartDeviceLink 7.0.0 + */ + public StabilityControlsStatus getStabilityControlsStatus() { + return (StabilityControlsStatus) getObject(StabilityControlsStatus.class, KEY_STABILITY_CONTROLS_STATUS); + } + + /** + * Sets the stabilityControlsStatus. + * + * @param stabilityControlsStatus See StabilityControlsStatus + * @since SmartDeviceLink 7.0.0 + */ + public void setStabilityControlsStatus(StabilityControlsStatus stabilityControlsStatus) { + setParameters(KEY_STABILITY_CONTROLS_STATUS, stabilityControlsStatus); + } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnVehicleData.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnVehicleData.java index a54aebdd5..a5cbb162c 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnVehicleData.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnVehicleData.java @@ -319,6 +319,13 @@ import java.util.List; * N * SmartDeviceLink 7.0.0 * + * + * stabilityControlsStatus + * StabilityControlsStatus + * See StabilityControlsStatus + * N + * SmartDeviceLink 7.0.0 + * * * * @since SmartDeviceLink 1.0 @@ -371,6 +378,7 @@ public class OnVehicleData extends RPCNotification { @Deprecated public static final String KEY_FUEL_LEVEL_STATE = "fuelLevel_State"; + public static final String KEY_STABILITY_CONTROLS_STATUS = "stabilityControlsStatus"; public OnVehicleData() { super(FunctionID.ON_VEHICLE_DATA.toString()); @@ -707,6 +715,26 @@ public class OnVehicleData extends RPCNotification { return (List) getObject(WindowStatus.class, KEY_WINDOW_STATUS); } + /** + * Gets the stabilityControlsStatus. + * + * @return StabilityControlsStatus See StabilityControlsStatus + * @since SmartDeviceLink 7.0.0 + */ + public StabilityControlsStatus getStabilityControlsStatus() { + return (StabilityControlsStatus) getObject(StabilityControlsStatus.class, KEY_STABILITY_CONTROLS_STATUS); + } + + /** + * Sets the stabilityControlsStatus. + * + * @param stabilityControlsStatus See StabilityControlsStatus + * @since SmartDeviceLink 7.0.0 + */ + public void setStabilityControlsStatus(StabilityControlsStatus stabilityControlsStatus) { + setParameters(KEY_STABILITY_CONTROLS_STATUS, stabilityControlsStatus); + } + /** * Sets the handsOffSteering. * diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/StabilityControlsStatus.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/StabilityControlsStatus.java new file mode 100644 index 000000000..5ee5eb0b4 --- /dev/null +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/StabilityControlsStatus.java @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2017 - 2020, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium 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. + */ +package com.smartdevicelink.proxy.rpc; + +import com.smartdevicelink.proxy.RPCStruct; +import com.smartdevicelink.proxy.rpc.enums.VehicleDataStatus; + +import java.util.Hashtable; + +/** + * + *

Parameter List

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Param NameTypeDescriptionRequiredNotesVersion Available
escSystemVehicleDataStatustrue if vehicle stability control is ON, else falseN
trailerSwayControlVehicleDataStatustrue if vehicle trailer sway control is ON, else falseN
+ * @since SmartDeviceLink 7.0.0 + */ +public class StabilityControlsStatus extends RPCStruct { + public static final String KEY_ESC_SYSTEM = "escSystem"; + public static final String KEY_TRAILER_SWAY_CONTROL = "trailerSwayControl"; + + + /** + * Constructs a new StabilityControlsStatus object + */ + public StabilityControlsStatus() { } + + /** + * Constructs a new StabilityControlsStatus object indicated by the Hashtable parameter + * + * @param hash The Hashtable to use + */ + public StabilityControlsStatus(Hashtable hash) { + super(hash); + } + + /** + * Gets the escSystem. + * + * @return VehicleDataStatus true if vehicle stability control is ON, else false + */ + public VehicleDataStatus getEscSystem() { + return (VehicleDataStatus) getObject(VehicleDataStatus.class, KEY_ESC_SYSTEM); + } + + /** + * Sets the escSystem. + * + * @param escSystem true if vehicle stability control is ON, else false + */ + public void setEscSystem(VehicleDataStatus escSystem) { + setValue(KEY_ESC_SYSTEM, escSystem); + } + + /** + * Sets the trailerSwayControl. + * + * @param trailerSwayControl true if vehicle trailer sway control is ON, else false + */ + public void setTrailerSwayControl(VehicleDataStatus trailerSwayControl) { + setValue(KEY_TRAILER_SWAY_CONTROL, trailerSwayControl); + } + + /** + * Gets the trailerSwayControl. + * + * @return VehicleDataStatus true if vehicle trailer sway control is ON, else false + */ + public VehicleDataStatus getTrailerSwayControl() { + return (VehicleDataStatus) getObject(VehicleDataStatus.class, KEY_TRAILER_SWAY_CONTROL); + } +} diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeVehicleData.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeVehicleData.java index 89e30c6df..20822e451 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeVehicleData.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeVehicleData.java @@ -301,6 +301,13 @@ import java.util.Hashtable; * N * SmartDeviceLink 7.0.0 * + * + * stabilityControlsStatus + * Boolean + * See StabilityControlsStatus + * N + * SmartDeviceLink 7.0.0 + * * * *

Response

@@ -361,6 +368,7 @@ public class SubscribeVehicleData extends RPCRequest { */ @Deprecated public static final String KEY_FUEL_LEVEL_STATE = "fuelLevel_State"; + public static final String KEY_STABILITY_CONTROLS_STATUS = "stabilityControlsStatus"; /** * Constructs a new SubscribeVehicleData object @@ -961,4 +969,24 @@ public class SubscribeVehicleData extends RPCRequest { public Boolean getHandsOffSteering() { return getBoolean(KEY_HANDS_OFF_STEERING); } + + /** + * Gets the stabilityControlsStatus. + * + * @return Boolean See StabilityControlsStatus + * @since SmartDeviceLink 7.0.0 + */ + public Boolean getStabilityControlsStatus() { + return getBoolean(KEY_STABILITY_CONTROLS_STATUS); + } + + /** + * Sets the stabilityControlsStatus. + * + * @param stabilityControlsStatus See StabilityControlsStatus + * @since SmartDeviceLink 7.0.0 + */ + public void setStabilityControlsStatus(Boolean stabilityControlsStatus) { + setParameters(KEY_STABILITY_CONTROLS_STATUS, stabilityControlsStatus); + } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeVehicleDataResponse.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeVehicleDataResponse.java index 95609469f..670687814 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeVehicleDataResponse.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeVehicleDataResponse.java @@ -85,6 +85,7 @@ public class SubscribeVehicleDataResponse extends RPCResponse { */ @Deprecated public static final String KEY_FUEL_LEVEL_STATE = "fuelLevel_State"; + public static final String KEY_STABILITY_CONTROLS_STATUS = "stabilityControlsStatus"; /** * Constructs a new SubscribeVehicleDataResponse object @@ -606,4 +607,24 @@ public class SubscribeVehicleDataResponse extends RPCResponse { public VehicleDataResult getWindowStatus() { return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_WINDOW_STATUS); } + + /** + * Gets the stabilityControlsStatus. + * + * @return VehicleDataResult See StabilityControlsStatus + * @since SmartDeviceLink 7.0.0 + */ + public VehicleDataResult getStabilityControlsStatus() { + return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_STABILITY_CONTROLS_STATUS); + } + + /** + * Sets the stabilityControlsStatus. + * + * @param stabilityControlsStatus See StabilityControlsStatus + * @since SmartDeviceLink 7.0.0 + */ + public void setStabilityControlsStatus(VehicleDataResult stabilityControlsStatus) { + setParameters(KEY_STABILITY_CONTROLS_STATUS, stabilityControlsStatus); + } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleData.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleData.java index ea2822a35..663f8fbf8 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleData.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleData.java @@ -288,6 +288,15 @@ import java.util.Hashtable; * N * SmartDeviceLink 7.0.0 * + * + * stabilityControlsStatus + * Boolean + * See StabilityControlsStatus + * N + * SmartDeviceLink 7.0.0 + * + * + * *

Response

*

Non-default Result Codes:

@@ -346,6 +355,7 @@ public class UnsubscribeVehicleData extends RPCRequest { */ @Deprecated public static final String KEY_FUEL_LEVEL_STATE = "fuelLevel_State"; + public static final String KEY_STABILITY_CONTROLS_STATUS = "stabilityControlsStatus"; /** * Constructs a new UnsubscribeVehicleData object @@ -948,4 +958,24 @@ public class UnsubscribeVehicleData extends RPCRequest { public Boolean getWindowStatus() { return getBoolean(KEY_WINDOW_STATUS); } + + /** + * Sets the stabilityControlsStatus. + * + * @param stabilityControlsStatus See StabilityControlsStatus + * @since SmartDeviceLink 7.0.0 + */ + public void setStabilityControlsStatus(Boolean stabilityControlsStatus) { + setParameters(KEY_STABILITY_CONTROLS_STATUS, stabilityControlsStatus); + } + + /** + * Gets the stabilityControlsStatus. + * + * @return Boolean See StabilityControlsStatus + * @since SmartDeviceLink 7.0.0 + */ + public Boolean getStabilityControlsStatus() { + return getBoolean(KEY_STABILITY_CONTROLS_STATUS); + } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleDataResponse.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleDataResponse.java index 68def6a87..5abf391d1 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleDataResponse.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleDataResponse.java @@ -85,6 +85,7 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse { */ @Deprecated public static final String KEY_FUEL_LEVEL_STATE = "fuelLevel_State"; + public static final String KEY_STABILITY_CONTROLS_STATUS = "stabilityControlsStatus"; /** * Constructs a new UnsubscribeVehicleDataResponse object @@ -608,4 +609,24 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse { public VehicleDataResult getGearStatus(){ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_GEAR_STATUS); } + + /** + * Gets the stabilityControlsStatus. + * + * @return VehicleDataResult See StabilityControlsStatus + * @since SmartDeviceLink 7.0.0 + */ + public VehicleDataResult getStabilityControlsStatus() { + return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_STABILITY_CONTROLS_STATUS); + } + + /** + * Sets the stabilityControlsStatus. + * + * @param stabilityControlsStatus See StabilityControlsStatus + * @since SmartDeviceLink 7.0.0 + */ + public void setStabilityControlsStatus(VehicleDataResult stabilityControlsStatus) { + setParameters(KEY_STABILITY_CONTROLS_STATUS, stabilityControlsStatus); + } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/enums/VehicleDataType.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/enums/VehicleDataType.java index 5a7155427..294d50f1e 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/enums/VehicleDataType.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/enums/VehicleDataType.java @@ -174,6 +174,11 @@ public enum VehicleDataType { * @since SmartDeviceLink 7.0.0 */ VEHICLEDATA_HANDSOFFSTEERING, + + /** + * @since SmartDeviceLink 7.0.0 + */ + VEHICLEDATA_STABILITYCONTROLSSTATUS, /** * @since SmartDeviceLink 7.0.0 */ -- cgit v1.2.1 From 04ead8f26713a3ff954c3fb9c945eeaba4a55af2 Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Tue, 1 Sep 2020 10:34:49 -0400 Subject: Fixed Error with shouldUpdateSecondaryImage and made change to shouldUpdatePrimaryImage to be consistent --- .../managers/screen/TextAndGraphicUpdateOperation.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java index f7a2c7b89..5f29e0cf9 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java @@ -556,11 +556,12 @@ class TextAndGraphicUpdateOperation extends Task { */ private boolean shouldUpdatePrimaryImage() { boolean templateSupportsPrimaryArtwork = templateSupportsImageField(ImageFieldName.graphic); - String currentScreenDataPrimaryGraphicName = (currentScreenData != null && currentScreenData.getGraphic() != null) ? currentScreenData.getGraphic().getValue() : null; String primaryGraphicName = updatedState.getPrimaryGraphic() != null ? updatedState.getPrimaryGraphic().getName() : null; - return templateSupportsPrimaryArtwork - && !CompareUtils.areStringsEqual(currentScreenDataPrimaryGraphicName, primaryGraphicName, true, true); + + boolean graphicMatchesExisting = CompareUtils.areStringsEqual(currentScreenDataPrimaryGraphicName, primaryGraphicName, true, true); + + return templateSupportsPrimaryArtwork && !graphicMatchesExisting; } /** @@ -570,14 +571,16 @@ class TextAndGraphicUpdateOperation extends Task { */ private boolean shouldUpdateSecondaryImage() { boolean templateSupportsSecondaryArtwork = templateSupportsImageField(ImageFieldName.secondaryGraphic); - String currentScreenDataSecondaryGraphicName = (currentScreenData != null && currentScreenData.getSecondaryGraphic() != null) ? currentScreenData.getSecondaryGraphic().getValue() : null; String secondaryGraphicName = updatedState.getSecondaryGraphic() != null ? updatedState.getSecondaryGraphic().getName() : null; + + boolean graphicMatchesExisting = CompareUtils.areStringsEqual(currentScreenDataSecondaryGraphicName, secondaryGraphicName, true, true); + // Cannot detect if there is a secondary image below v5.0, so we'll just try to detect if the primary image is allowed and allow the secondary image if it is. if (internalInterface.get().getSdlMsgVersion().getMajorVersion() >= 5) { - return templateSupportsSecondaryArtwork && !CompareUtils.areStringsEqual(currentScreenDataSecondaryGraphicName, secondaryGraphicName, true, true); + return templateSupportsSecondaryArtwork && !graphicMatchesExisting; } else { - return templateSupportsImageField(ImageFieldName.graphic); + return templateSupportsImageField(ImageFieldName.graphic) && !graphicMatchesExisting; } } -- cgit v1.2.1 From 95da6a22ed1f539f775f2e77d350f116c7d28b94 Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Tue, 1 Sep 2020 11:06:37 -0400 Subject: Fixed unit test --- .../managers/screen/TextAndGraphicUpdateOperationTest.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java index 292e828fd..cdfab186c 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java @@ -16,6 +16,7 @@ import com.smartdevicelink.proxy.RPCRequest; import com.smartdevicelink.proxy.interfaces.ISdl; import com.smartdevicelink.proxy.rpc.ImageField; import com.smartdevicelink.proxy.rpc.MetadataTags; +import com.smartdevicelink.proxy.rpc.SdlMsgVersion; import com.smartdevicelink.proxy.rpc.Show; import com.smartdevicelink.proxy.rpc.ShowResponse; import com.smartdevicelink.proxy.rpc.TextField; @@ -261,6 +262,7 @@ public class TextAndGraphicUpdateOperationTest { public void testUploads() { doAnswer(onShowSuccess).when(internalInterface).sendRPC(any(Show.class)); doAnswer(onArtworkUploadSuccess).when(fileManager).uploadArtworks(any(List.class), any(MultipleFileCompletionListener.class)); + when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(4, 0)); // Test Images need to be uploaded, sending text and uploading images textAndGraphicUpdateOperation.onExecute(); @@ -303,6 +305,7 @@ public class TextAndGraphicUpdateOperationTest { public void testTaskCanceledAfterImageUpload() { doAnswer(onShowSuccess).when(internalInterface).sendRPC(any(Show.class)); doAnswer(onImageUploadSuccessTaskCanceled).when(fileManager).uploadArtworks(any(List.class), any(MultipleFileCompletionListener.class)); + when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(5, 0)); // Test Canceled after Image upload textAndGraphicUpdateOperation.onExecute(); @@ -314,6 +317,8 @@ public class TextAndGraphicUpdateOperationTest { @Test public void testTaskCanceledAfterTextSent() { doAnswer(onShowSuccessCanceled).when(internalInterface).sendRPC(any(Show.class)); + when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(5, 0)); + textAndGraphicUpdateOperation.onExecute(); verify(fileManager, times(0)).uploadArtworks(any(List.class), any(MultipleFileCompletionListener.class)); -- cgit v1.2.1 From 2322f536be99597296b1c9dd85c9392c1f8ef9bc Mon Sep 17 00:00:00 2001 From: Joey Grover Date: Tue, 1 Sep 2020 16:08:06 -0400 Subject: Fix formatObject method to handle null values --- .../smartdevicelink/test/rpc/RPCStructTests.java | 48 ++++++++++++++++++++++ .../java/com/smartdevicelink/proxy/RPCStruct.java | 18 +++++++- 2 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/RPCStructTests.java diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/RPCStructTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/RPCStructTests.java new file mode 100644 index 000000000..970c3c8ba --- /dev/null +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/RPCStructTests.java @@ -0,0 +1,48 @@ +package com.smartdevicelink.test.rpc; + +import androidx.test.ext.junit.runners.AndroidJUnit4; + +import com.smartdevicelink.proxy.RPCStruct; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.util.ArrayList; +import java.util.List; + +import static junit.framework.TestCase.assertNotNull; + +@RunWith(AndroidJUnit4.class) +public class RPCStructTests { + + @Test + public void testFormatObject() { + final String KEY = "LIST"; + RPCStruct struct = new RPCStruct(); + List structs = new ArrayList<>(); + struct.setValue(KEY, structs); + assertNotNull(struct.getObject(RPCStruct.class, KEY)); + + structs.add(new RPCStruct()); + struct.setValue(KEY, structs); + assertNotNull(struct.getObject(RPCStruct.class, KEY)); + + structs.clear(); + structs.add(null); + struct.setValue(KEY, structs); + assertNotNull(struct.getObject(RPCStruct.class, KEY)); + + structs.clear(); + structs.add(null); + structs.add(new RPCStruct()); + struct.setValue(KEY, structs); + assertNotNull(struct.getObject(RPCStruct.class, KEY)); + + structs.clear(); + structs.add(new RPCStruct()); + structs.add(null); + structs.add(new RPCStruct()); + struct.setValue(KEY, structs); + assertNotNull(struct.getObject(RPCStruct.class, KEY)); + } +} diff --git a/base/src/main/java/com/smartdevicelink/proxy/RPCStruct.java b/base/src/main/java/com/smartdevicelink/proxy/RPCStruct.java index 5eb293ba2..402866291 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/RPCStruct.java +++ b/base/src/main/java/com/smartdevicelink/proxy/RPCStruct.java @@ -275,8 +275,18 @@ public class RPCStruct { } else if (obj instanceof List) { List list = (List) obj; if (list != null && list.size() > 0) { - Object item = list.get(0); - if (tClass.isInstance(item)) { + Object item = null; + //Iterate through list to find first non-null object + for(Object object: list){ + if(object != null) { + item = object; + break; + } + } + + if (item == null) { + return list; + } else if (tClass.isInstance(item)) { return list; } else if (item instanceof Hashtable) { List newList = new ArrayList(); @@ -307,6 +317,10 @@ public class RPCStruct { } return newList; } + } else { + //If the list is either null or empty it should be returned. It will keep the same + //behavior as it does today with null lists, but empty ones will now also be returned. + return list; } } return null; -- cgit v1.2.1 From 4007e253b4958a89cfd5f7d4c7904d45a81fa78e Mon Sep 17 00:00:00 2001 From: RHenigan Date: Tue, 1 Sep 2020 17:05:51 -0400 Subject: Add logging and remove redundent reason --- base/src/main/java/com/smartdevicelink/protocol/SdlProtocolBase.java | 4 ++++ .../java/com/smartdevicelink/protocol/enums/ControlFrameTags.java | 4 +--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/base/src/main/java/com/smartdevicelink/protocol/SdlProtocolBase.java b/base/src/main/java/com/smartdevicelink/protocol/SdlProtocolBase.java index 106e358f4..59364f2cd 100644 --- a/base/src/main/java/com/smartdevicelink/protocol/SdlProtocolBase.java +++ b/base/src/main/java/com/smartdevicelink/protocol/SdlProtocolBase.java @@ -1417,6 +1417,8 @@ public class SdlProtocolBase { } else if (frameInfo == FrameDataControlFrameType.StartSessionNACK.getValue()) { + String reason = (String) packet.getTag(ControlFrameTags.RPC.StartServiceNAK.REASON); + DebugTool.logWarning(TAG, reason); handleProtocolSessionNAKed(packet, serviceType); } else if (frameInfo == FrameDataControlFrameType.EndSession.getValue() @@ -1426,6 +1428,8 @@ public class SdlProtocolBase { } else if (frameInfo == FrameDataControlFrameType.EndSessionNACK.getValue()) { + String reason = (String) packet.getTag(ControlFrameTags.RPC.EndServiceNAK.REASON); + DebugTool.logWarning(TAG, reason); handleServiceEndedNAK(packet, serviceType); } else if (frameInfo == FrameDataControlFrameType.ServiceDataACK.getValue()) { diff --git a/base/src/main/java/com/smartdevicelink/protocol/enums/ControlFrameTags.java b/base/src/main/java/com/smartdevicelink/protocol/enums/ControlFrameTags.java index b2c27d10c..1b2595e2a 100644 --- a/base/src/main/java/com/smartdevicelink/protocol/enums/ControlFrameTags.java +++ b/base/src/main/java/com/smartdevicelink/protocol/enums/ControlFrameTags.java @@ -91,9 +91,7 @@ public class ControlFrameTags { **/ public static class RegisterSecondaryTransport {} public static class RegisterSecondaryTransportACK {} - public static class RegisterSecondaryTransportNAK extends NAKBase { - public static final String REASON = "reason"; - } + public static class RegisterSecondaryTransportNAK extends NAKBase {} } /** -- cgit v1.2.1 From c8f087ca9c9186f436a7843274c303eb3f7761f7 Mon Sep 17 00:00:00 2001 From: Bilal Alsharifi Date: Wed, 2 Sep 2020 10:46:10 -0400 Subject: Delete deprecated security code --- .../managers/lifecycle/LifecycleManager.java | 6 -- .../smartdevicelink/security/SdlSecurityBase.java | 75 +++++++++------------- 2 files changed, 31 insertions(+), 50 deletions(-) diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java b/android/sdl_android/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java index 2fe65b2fc..4aed87cd4 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java @@ -111,15 +111,9 @@ public class LifecycleManager extends BaseLifecycleManager { super.setSdlSecurityStaticVars(); Context context = null; - Service service = null; - if(this.contextWeakReference != null){ context = contextWeakReference.get(); } - if (context != null && context instanceof Service) { - service = (Service) context; - } - SdlSecurityBase.setAppService(service); SdlSecurityBase.setContext(context); } diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/security/SdlSecurityBase.java b/android/sdl_android/src/main/java/com/smartdevicelink/security/SdlSecurityBase.java index 0323beb21..55ce677c1 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/security/SdlSecurityBase.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/security/SdlSecurityBase.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.security; import android.app.Service; @@ -39,19 +39,6 @@ public abstract class SdlSecurityBase extends AbstractSdlSecurityBase{ protected static Service appService = null; protected static Context context; - @Deprecated - public static Service getAppService() { - return appService; - } - - @Deprecated - public static void setAppService(Service val) { - appService = val; - if (val != null && val.getApplicationContext() != null){ - setContext(val.getApplicationContext()); - } - } - public static Context getContext() { return context; } -- cgit v1.2.1 From 9b441778ddc7b6e4dc10e704e9dc7fbee44e5da7 Mon Sep 17 00:00:00 2001 From: Bilal Alsharifi Date: Wed, 2 Sep 2020 10:46:38 -0400 Subject: Delete deprecated util code --- .../java/com/smartdevicelink/util/HttpUtils.java | 48 ---------------------- .../managers/lifecycle/BaseLifecycleManager.java | 2 +- .../java/com/smartdevicelink/util/DebugTool.java | 25 ----------- 3 files changed, 1 insertion(+), 74 deletions(-) delete mode 100644 android/sdl_android/src/main/java/com/smartdevicelink/util/HttpUtils.java diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/util/HttpUtils.java b/android/sdl_android/src/main/java/com/smartdevicelink/util/HttpUtils.java deleted file mode 100644 index ad43c40f5..000000000 --- a/android/sdl_android/src/main/java/com/smartdevicelink/util/HttpUtils.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ -package com.smartdevicelink.util; - -import android.graphics.Bitmap; - -import java.io.IOException; - -/** - * @see AndroidTools - */ -@Deprecated -public class HttpUtils{ - - public static Bitmap downloadImage(String urlStr) throws IOException{ - return AndroidTools.downloadImage(urlStr); - } - -} diff --git a/base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseLifecycleManager.java b/base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseLifecycleManager.java index 77fac4cfe..b8c3c7631 100644 --- a/base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseLifecycleManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseLifecycleManager.java @@ -622,7 +622,7 @@ abstract class BaseLifecycleManager { @SuppressWarnings("UnusedReturnValue") private boolean onRPCRequestReceived(RPCRequest request) { if (request == null) { - DebugTool.logError("onRPCRequestReceived - request was null"); + DebugTool.logError(TAG, "onRPCRequestReceived - request was null"); return false; } DebugTool.logInfo(TAG, "onRPCRequestReceived - " + request.getFunctionName()); diff --git a/base/src/main/java/com/smartdevicelink/util/DebugTool.java b/base/src/main/java/com/smartdevicelink/util/DebugTool.java index d073fc654..f36e9ca7c 100644 --- a/base/src/main/java/com/smartdevicelink/util/DebugTool.java +++ b/base/src/main/java/com/smartdevicelink/util/DebugTool.java @@ -97,11 +97,6 @@ public class DebugTool { } } - @Deprecated - public static void logError(String msg) { - logError(TAG, msg); - } - public static void logError(String tag, String msg, Throwable ex) { Boolean wasWritten = false; @@ -119,11 +114,6 @@ public class DebugTool { } } - @Deprecated - public static void logError(String msg, Throwable ex) { - logError(TAG, msg, ex); - } - public static void logWarning(String tag, String msg) { Boolean wasWritten = false; @@ -137,11 +127,6 @@ public class DebugTool { } } - @Deprecated - public static void logWarning(String msg) { - logWarning(TAG, msg); - } - public static void logInfo(String tag, String msg) { Boolean wasWritten = false; @@ -155,11 +140,6 @@ public class DebugTool { } } - @Deprecated - public static void logInfo(String msg) { - logInfo(TAG, msg); - } - public static void logInfo(String tag, String msg, Boolean bPrependVersion) { Boolean wasWritten = false; @@ -173,11 +153,6 @@ public class DebugTool { } } - @Deprecated - public static void logInfo(String msg, boolean bPrependVersion) { - logInfo(TAG, msg, bPrependVersion); - } - protected static Boolean logToSiphon(String msg) { if (SiphonServer.getSiphonEnabledStatus()) { // Initialize the SiphonServer, will be ignored if already initialized -- cgit v1.2.1 From 7bd7f283b72b84e87230de735d8249a2194099cd Mon Sep 17 00:00:00 2001 From: Bilal Alsharifi Date: Wed, 2 Sep 2020 10:47:17 -0400 Subject: delete deprecated dispatcher code --- .../transport/SdlBroadcastReceiver.java | 4 +- .../Dispatcher/IDispatchingStrategy.java | 41 --------- .../Dispatcher/ProxyMessageDispatcher.java | 96 ---------------------- 3 files changed, 2 insertions(+), 139 deletions(-) delete mode 100644 base/src/main/java/com/smartdevicelink/Dispatcher/IDispatchingStrategy.java delete mode 100644 base/src/main/java/com/smartdevicelink/Dispatcher/ProxyMessageDispatcher.java diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlBroadcastReceiver.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlBroadcastReceiver.java index 1ad6a3e9a..62a4b682c 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlBroadcastReceiver.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlBroadcastReceiver.java @@ -237,7 +237,7 @@ public abstract class SdlBroadcastReceiver extends BroadcastReceiver{ context.startService(serviceIntent); } else { serviceIntent.putExtra(FOREGROUND_EXTRA, true); - DebugTool.logInfo("Attempting to startForegroundService - " + System.currentTimeMillis()); + DebugTool.logInfo(TAG, "Attempting to startForegroundService - " + System.currentTimeMillis()); setForegroundExceptionHandler(); //Prevent ANR in case the OS takes too long to start the service context.startForegroundService(serviceIntent); @@ -297,7 +297,7 @@ public abstract class SdlBroadcastReceiver extends BroadcastReceiver{ } else { //There are currently running services if(DebugTool.isDebugEnabled()){ for(ComponentName service : runningBluetoothServicePackage){ - DebugTool.logInfo("Currently running router service: " + service.getPackageName()); + DebugTool.logInfo(TAG, "Currently running router service: " + service.getPackageName()); } } if (altTransportWake) { diff --git a/base/src/main/java/com/smartdevicelink/Dispatcher/IDispatchingStrategy.java b/base/src/main/java/com/smartdevicelink/Dispatcher/IDispatchingStrategy.java deleted file mode 100644 index f6f3b1cc2..000000000 --- a/base/src/main/java/com/smartdevicelink/Dispatcher/IDispatchingStrategy.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ -package com.smartdevicelink.Dispatcher; - -@Deprecated -public interface IDispatchingStrategy { - public void dispatch(T message); - - public void handleDispatchingError(String info, Exception ex); - - public void handleQueueingError(String info, Exception ex); -} diff --git a/base/src/main/java/com/smartdevicelink/Dispatcher/ProxyMessageDispatcher.java b/base/src/main/java/com/smartdevicelink/Dispatcher/ProxyMessageDispatcher.java deleted file mode 100644 index 16681e600..000000000 --- a/base/src/main/java/com/smartdevicelink/Dispatcher/ProxyMessageDispatcher.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ -package com.smartdevicelink.Dispatcher; - -import com.smartdevicelink.util.DebugTool; - -import java.util.concurrent.LinkedBlockingQueue; - -@Deprecated -public class ProxyMessageDispatcher { - private static final String TAG = "ProxyMessageDispatcher"; - LinkedBlockingQueue _queue = null; - private Thread _messageDispatchingThread = null; - IDispatchingStrategy _strategy = null; - - // Boolean to track if disposed - private Boolean dispatcherDisposed = false; - - public ProxyMessageDispatcher(String THREAD_NAME, IDispatchingStrategy strategy) { - _queue = new LinkedBlockingQueue(); - - _strategy = strategy; - - // Create dispatching thread - _messageDispatchingThread = new Thread(new Runnable() {public void run(){handleMessages();}}); - _messageDispatchingThread.setName(THREAD_NAME); - _messageDispatchingThread.setDaemon(true); - _messageDispatchingThread.start(); - } - - public void dispose() { - dispatcherDisposed = true; - - if(_messageDispatchingThread != null) { - _messageDispatchingThread.interrupt(); - _messageDispatchingThread = null; - } - } - - private void handleMessages() { - - try { - T thisMessage; - - while(dispatcherDisposed == false) { - thisMessage = _queue.take(); - _strategy.dispatch(thisMessage); - } - } catch (InterruptedException e) { - // Thread was interrupted by dispose() method, no action required - return; - } catch (Exception e) { - DebugTool.logError(TAG, "Error occurred dispating message.", e); - _strategy.handleDispatchingError("Error occurred dispating message.", e); - } - } - - public void queueMessage(T message) { - try { - _queue.put(message); - } catch(ClassCastException e) { - _strategy.handleQueueingError("ClassCastException encountered when queueing message.", e); - } catch(Exception e) { - _strategy.handleQueueingError("Exception encountered when queueing message.", e); - } - } -} -- cgit v1.2.1 From 58153cbe2ad2a586cc47650714ea4bc2b113dd02 Mon Sep 17 00:00:00 2001 From: Bilal Alsharifi Date: Wed, 2 Sep 2020 11:12:11 -0400 Subject: Remove deprecated HttpRequestTask.java --- .../com/smartdevicelink/util/HttpRequestTask.java | 183 --------------------- 1 file changed, 183 deletions(-) delete mode 100644 javaSE/src/main/java/com/smartdevicelink/util/HttpRequestTask.java diff --git a/javaSE/src/main/java/com/smartdevicelink/util/HttpRequestTask.java b/javaSE/src/main/java/com/smartdevicelink/util/HttpRequestTask.java deleted file mode 100644 index 77c9f4f7a..000000000 --- a/javaSE/src/main/java/com/smartdevicelink/util/HttpRequestTask.java +++ /dev/null @@ -1,183 +0,0 @@ -package com.smartdevicelink.util; - -import android.os.AsyncTask; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.io.Writer; -import java.net.HttpURLConnection; -import java.net.URL; - - -@Deprecated -public class HttpRequestTask extends AsyncTask { - private static final String TAG = "Http Request Task"; - - public static final String REQUEST_TYPE_POST = "POST"; - public static final String REQUEST_TYPE_GET = "GET"; - public static final String REQUEST_TYPE_DELETE = "DELETE"; - - HttpRequestTaskCallback cb; - - /** - * @param hcb callback for when this task finishes - *

- When calling execute, params as followed:
- * 1. Url String
- * 2. Request type (Defined in this class) REQUEST_TYPE_POST, REQUEST_TYPE_GET, REQUEST_TYPE_DELETE
- * 3. (Optional) Data to be sent.
- * 4. (Optional) Content Type Default will be application/json
- * 5. (Optional) Accept Type default will be application/json - * - */ - @Deprecated - public HttpRequestTask( HttpRequestTaskCallback hcb){ - this.cb = hcb; - } - - @Deprecated - protected String doInBackground(String... params) { - int length = params.length; - String urlString = params[0]; - String request_type = params[1]; - - //Grab and set data to be written if included - String data; - if(length>2){ - data = params[2]; - }else{ - data = null; - } - - //Grab and set content type for the header if included - String contentType; - if(length>3){ - contentType = params[3]; - }else{ - contentType = "application/json"; - } - //Grab and set accept type for the header if included - String acceptType; - if(length>4){ - acceptType = params[4]; - }else{ - acceptType = "application/json"; - } - - if(urlString == null || request_type == null){ - DebugTool.logError(TAG, "Can't process request, param error"); - if(cb!=null){ - cb.httpFailure(-1); - cb = null; - } - return "Error"; - } - - HttpURLConnection urlConnection = null; - BufferedReader reader = null; - try { - URL url = new URL(urlString); - urlConnection = (HttpURLConnection) url.openConnection(); - urlConnection.setDoOutput(true); - urlConnection.setRequestMethod(request_type); - urlConnection.setRequestProperty("Content-Type", contentType); - urlConnection.setRequestProperty("Accept", acceptType); - //If we have data, we should write it out - if(data !=null){ - Writer writer = new BufferedWriter(new OutputStreamWriter(urlConnection.getOutputStream(), "UTF-8")); - writer.write(data); - writer.close(); - } - InputStream inputStream = urlConnection.getInputStream(); - - int responseCode = urlConnection.getResponseCode(); - if (responseCode == 200) { //Success - //input stream - StringBuffer buffer = new StringBuffer(); - if (inputStream == null) { - // Nothing to do. - if(cb!=null){ - cb.httpCallComplete(null); - cb = null; - } - return null; - } - reader = new BufferedReader(new InputStreamReader(inputStream)); - - String inputLine; - while ((inputLine = reader.readLine()) != null) - buffer.append(inputLine).append("\n"); - if (buffer.length() == 0) { - // Stream was empty. No point in parsing. - if(cb!=null){ - cb.httpCallComplete(null); - cb = null; - } - return null; - } - String response = null; - - response = buffer.toString(); - //send to post execute - if(cb!=null){ - cb.httpCallComplete(response); - cb = null; - } - return response; - }else{ - if(cb!=null){ - cb.httpFailure(responseCode); - cb = null; - } - DebugTool.logError(TAG, "Failed to download file - " + responseCode); - return null; - } - - - } catch (IOException e) { - e.printStackTrace(); - } catch (NullPointerException e){ // Only to catch error in urlConnection.getOutputStream() - when servers are down - e.printStackTrace(); - urlConnection = null; - } - finally { - if (urlConnection != null) { - urlConnection.disconnect(); - } - if (reader != null) { - try { - reader.close(); - } catch (final IOException e) { - DebugTool.logError(TAG, "Error closing stream", e); - } - } - if(cb!=null){ - cb.httpFailure(-1); - } - } - return null; - } - - /** - * Callback interface for HTTP requests. - * @author Joey Grover - * - */ - @Deprecated - public interface HttpRequestTaskCallback{ - /** - * Called when HTTP request is successfully completed. - * @param response The response to the HTTP request. - */ - public abstract void httpCallComplete(String response); - /** - * Called when HTTP request failed. - * @param statusCode The HTTP failure code. - */ - public abstract void httpFailure(int statusCode); - } - -} -- cgit v1.2.1 From 59137d5ab5b8ee9bc876af43b2ed35b530dca245 Mon Sep 17 00:00:00 2001 From: Bilal Alsharifi Date: Wed, 2 Sep 2020 11:12:27 -0400 Subject: Remove deprecated method from BaseSdlSession --- .../java/com/smartdevicelink/SdlConnection/BaseSdlSession.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/base/src/main/java/com/smartdevicelink/SdlConnection/BaseSdlSession.java b/base/src/main/java/com/smartdevicelink/SdlConnection/BaseSdlSession.java index c3e6158dd..09e959b90 100644 --- a/base/src/main/java/com/smartdevicelink/SdlConnection/BaseSdlSession.java +++ b/base/src/main/java/com/smartdevicelink/SdlConnection/BaseSdlSession.java @@ -375,12 +375,4 @@ public abstract class BaseSdlSession implements ISdlProtocol, ISecurityInitializ public boolean isTransportForServiceAvailable(SessionType sessionType){ return sdlProtocol!=null && sdlProtocol.isTransportForServiceAvailable(sessionType); } - - - @Deprecated - public void clearConnection(){/* Not supported */} - - - - } -- cgit v1.2.1 From eca0fcadd27814002ff2d57a266421c788715240 Mon Sep 17 00:00:00 2001 From: Bilal Alsharifi Date: Wed, 2 Sep 2020 11:21:05 -0400 Subject: Remove deprecated Parcel & Parcelable classes --- javaSE/src/main/java/android/os/Parcel.java | 59 ---------------------- javaSE/src/main/java/android/os/Parcelable.java | 31 ------------ .../com/smartdevicelink/protocol/SdlPacket.java | 26 ---------- .../transport/utl/TransportRecord.java | 36 ------------- 4 files changed, 152 deletions(-) delete mode 100644 javaSE/src/main/java/android/os/Parcel.java delete mode 100644 javaSE/src/main/java/android/os/Parcelable.java diff --git a/javaSE/src/main/java/android/os/Parcel.java b/javaSE/src/main/java/android/os/Parcel.java deleted file mode 100644 index b99dbc671..000000000 --- a/javaSE/src/main/java/android/os/Parcel.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2006 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Note: This file has been modified from its original form. - */ - -package android.os; - -@Deprecated -public class Parcel { - - public void writeInt(int data){ - - } - - public void writeByteArray(byte[] bytes){ - - } - - public void writeString(String data){ - - } - - public void writeParcelable(Parcelable p, int flags){ - - } - - public int readInt(){ - return 0; - } - - public String readString(){ - return "hello"; - } - - public byte[] readByteArray(byte[] array){ - return array; - } - - public Parcelable readParcelable(ClassLoader loader){ - return null; - } - - public int dataAvail(){ - return 0; - } -} diff --git a/javaSE/src/main/java/android/os/Parcelable.java b/javaSE/src/main/java/android/os/Parcelable.java deleted file mode 100644 index e09a1754c..000000000 --- a/javaSE/src/main/java/android/os/Parcelable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2006 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Note: This file has been modified from its original form. - */ -package android.os; - -@Deprecated -public interface Parcelable { - - int describeContents(); - void writeToParcel(Parcel dest, int flags); - - - abstract class Creator{ - public abstract T[] newArray(int size); - } - -} diff --git a/javaSE/src/main/java/com/smartdevicelink/protocol/SdlPacket.java b/javaSE/src/main/java/com/smartdevicelink/protocol/SdlPacket.java index d9a14b6f7..4f37da493 100644 --- a/javaSE/src/main/java/com/smartdevicelink/protocol/SdlPacket.java +++ b/javaSE/src/main/java/com/smartdevicelink/protocol/SdlPacket.java @@ -31,8 +31,6 @@ */ package com.smartdevicelink.protocol; -import android.os.Parcel; -import android.os.Parcelable; public class SdlPacket extends BaseSdlPacket { @@ -55,28 +53,4 @@ public class SdlPacket extends BaseSdlPacket { protected SdlPacket(BaseSdlPacket packet) { super(packet); } - - @Deprecated - public SdlPacket(Parcel p){} - - @Deprecated - public int describeContents() { - return 0; - } - - @Deprecated - public void writeToParcel(Parcel dest, int flags) {} - - @Deprecated - public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { - public SdlPacket createFromParcel(Parcel in) { - return new SdlPacket(in); - } - - @Override - public SdlPacket[] newArray(int size) { - return new SdlPacket[size]; - } - - }; } diff --git a/javaSE/src/main/java/com/smartdevicelink/transport/utl/TransportRecord.java b/javaSE/src/main/java/com/smartdevicelink/transport/utl/TransportRecord.java index 7bc15e2ab..d8155c2fd 100644 --- a/javaSE/src/main/java/com/smartdevicelink/transport/utl/TransportRecord.java +++ b/javaSE/src/main/java/com/smartdevicelink/transport/utl/TransportRecord.java @@ -31,8 +31,6 @@ */ package com.smartdevicelink.transport.utl; -import android.os.Parcel; -import android.os.Parcelable; import com.smartdevicelink.transport.enums.TransportType; public class TransportRecord extends BaseTransportRecord { @@ -40,38 +38,4 @@ public class TransportRecord extends BaseTransportRecord { public TransportRecord(TransportType transportType, String address) { super(transportType, address); } - - @Deprecated - public TransportRecord(Parcel p) {} - - @Deprecated - public int describeContents() { - return 0; - }; - - @Deprecated - public void writeToParcel(Parcel dest, int flags) { - dest.writeInt(type!=null? 1 : 0); - if(type != null){ - dest.writeString(type.name()); - } - - dest.writeInt(address !=null? 1 : 0); - if(address != null){ - dest.writeString(address); - } - } - - @Deprecated - public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { - public TransportRecord createFromParcel(Parcel in) { - return new TransportRecord(in); - } - - @Override - public TransportRecord[] newArray(int size) { - return new TransportRecord[size]; - } - - }; } -- cgit v1.2.1 From e321032de647c4b86747189e225c109c44e5e70c Mon Sep 17 00:00:00 2001 From: Bilal Alsharifi Date: Wed, 2 Sep 2020 11:21:29 -0400 Subject: Remove deprecated AsyncTask class --- javaSE/src/main/java/android/os/AsyncTask.java | 27 -------------------------- 1 file changed, 27 deletions(-) delete mode 100644 javaSE/src/main/java/android/os/AsyncTask.java diff --git a/javaSE/src/main/java/android/os/AsyncTask.java b/javaSE/src/main/java/android/os/AsyncTask.java deleted file mode 100644 index db6b69a8e..000000000 --- a/javaSE/src/main/java/android/os/AsyncTask.java +++ /dev/null @@ -1,27 +0,0 @@ - /* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Note: This file has been modified from its original form. - */ - -package android.os; - -@Deprecated -public abstract class AsyncTask { - - - abstract protected Result doInBackground(Params...params); - -} -- cgit v1.2.1 From 6fd0fe42f2df9eb7895222566ee68a2223c97f79 Mon Sep 17 00:00:00 2001 From: Bilal Alsharifi Date: Wed, 2 Sep 2020 11:21:46 -0400 Subject: Remove deprecated Log class --- javaSE/src/main/java/android/util/Log.java | 71 ------------------------------ 1 file changed, 71 deletions(-) delete mode 100644 javaSE/src/main/java/android/util/Log.java diff --git a/javaSE/src/main/java/android/util/Log.java b/javaSE/src/main/java/android/util/Log.java deleted file mode 100644 index 7374ff04c..000000000 --- a/javaSE/src/main/java/android/util/Log.java +++ /dev/null @@ -1,71 +0,0 @@ - /* - * Copyright (C) 2006 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Note: This file has been modified from its original form. - */ - -package android.util; - -@Deprecated -public class Log { - - - public static int i(String tag, String message){ - System.out.print("\r\nINFO: " + tag+ " - " + message); - return 10; - - - } - public static int v(String tag, String message){ - System.out.print("\r\nVERBOSE: " + tag+ " - " + message); - return 10; - - - } - public static int d(String tag, String message){ - System.out.print("\r\nDEBUG: " + tag+ " - " + message); - return 10; - - - } - public static int w(String tag, String message){ - System.out.print("\r\nWARN: " + tag+ " - " + message); - return 10; - - - } - public static int e(String tag, String message){ - System.out.print("\r\nERROR: " + tag+ " - " + message); - return 10; - - } - public static int e(String tag, String message, Exception e){ - if(e != null){ - System.out.print("\r\nERROR: " + tag+ " - " + message + " - " + e.getMessage()); - }else{ - System.out.print("\r\nERROR: " + tag+ " - " + message); - } - return 10; - } - public static int e(String tag, String message, Throwable t){ - if(t != null){ - System.out.print("\r\nERROR: " + tag+ " - " + message + " - " + t.getMessage()); - }else{ - System.out.print("\r\nERROR: " + tag+ " - " + message); - } - return 10; - } - -} -- cgit v1.2.1 From 9829fb3228e8bd8a38a67a32a3666fcc45acf066 Mon Sep 17 00:00:00 2001 From: Joey Grover Date: Wed, 2 Sep 2020 12:08:17 -0400 Subject: Fix potential NPEs in ManagerUtility class Also added unit tests for class --- .../managers/ManagerUtilityTests.java | 206 +++++++++++++++++++++ .../smartdevicelink/managers/ManagerUtility.java | 52 +++--- 2 files changed, 236 insertions(+), 22 deletions(-) create mode 100644 android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/ManagerUtilityTests.java diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/ManagerUtilityTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/ManagerUtilityTests.java new file mode 100644 index 000000000..ac8d9eb75 --- /dev/null +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/ManagerUtilityTests.java @@ -0,0 +1,206 @@ +package com.smartdevicelink.managers; + +import androidx.test.ext.junit.runners.AndroidJUnit4; + +import com.smartdevicelink.proxy.rpc.ImageField; +import com.smartdevicelink.proxy.rpc.TextField; +import com.smartdevicelink.proxy.rpc.WindowCapability; +import com.smartdevicelink.proxy.rpc.enums.CharacterSet; +import com.smartdevicelink.proxy.rpc.enums.FileType; +import com.smartdevicelink.proxy.rpc.enums.ImageFieldName; +import com.smartdevicelink.proxy.rpc.enums.TextFieldName; + + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; + + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import static junit.framework.TestCase.assertEquals; +import static junit.framework.TestCase.assertNotNull; +import static junit.framework.TestCase.assertTrue; +import static junit.framework.TestCase.assertFalse; + +/** + * This is a unit test class for the SmartDeviceLink library manager class : + * {@link ManagerUtility} + */ +@RunWith(AndroidJUnit4.class) +public class ManagerUtilityTests { + + + @Before + public void setUp() throws Exception{ + + } + + // TESTS + + @Test + public void testGetAllImageFields(){ + + List fields = ManagerUtility.WindowCapabilityUtility.getAllImageFields(); + assertNotNull(fields); + int size = fields.size(); + assertEquals(ImageFieldName.values().length, size); + + ImageFieldName[] names = ImageFieldName.values(); + + boolean found; + for (ImageFieldName name : names) { + found = false; + for(ImageField field : fields) { + if(field != null + && field.getName() != null + && field.getName().equals(name)) { + found = true; + break; + } + } + assertTrue(found); + } + + } + + @Test + public void testGetAllTextFields(){ + + List fields = ManagerUtility.WindowCapabilityUtility.getAllTextFields(); + assertNotNull(fields); + int size = fields.size(); + assertEquals(TextFieldName.values().length, size); + + TextFieldName[] names = TextFieldName.values(); + + boolean found; + for (TextFieldName name : names) { + found = false; + for(TextField field : fields) { + if(field != null + && field.getName() != null + && field.getName().equals(name)) { + found = true; + break; + } + } + assertTrue(found); + } + + } + + @Test + public void testHasTextFieldOfName() { + WindowCapability capability = new WindowCapability(); + List textFieldList = new ArrayList<>(); + textFieldList.add(new TextField(TextFieldName.mainField1, CharacterSet.UTF_8, 500, 8)); + capability.setTextFields(textFieldList); + + assertTrue(ManagerUtility.WindowCapabilityUtility.hasTextFieldOfName(capability, TextFieldName.mainField1)); + assertFalse(ManagerUtility.WindowCapabilityUtility.hasTextFieldOfName(capability, TextFieldName.alertText3)); + + textFieldList.add(new TextField(TextFieldName.alertText3, CharacterSet.UTF_8, 500, 8)); + capability.setTextFields(textFieldList); + assertTrue(ManagerUtility.WindowCapabilityUtility.hasTextFieldOfName(capability, TextFieldName.mainField1)); + assertTrue(ManagerUtility.WindowCapabilityUtility.hasTextFieldOfName(capability, TextFieldName.alertText3)); + + textFieldList.clear(); + textFieldList.add(null); + capability.setTextFields(textFieldList); + assertFalse(ManagerUtility.WindowCapabilityUtility.hasTextFieldOfName(capability, TextFieldName.mainField1)); + assertFalse(ManagerUtility.WindowCapabilityUtility.hasTextFieldOfName(capability, TextFieldName.alertText3)); + + textFieldList.add(new TextField(TextFieldName.alertText3, CharacterSet.UTF_8, 500, 8)); + capability.setTextFields(textFieldList); + assertFalse(ManagerUtility.WindowCapabilityUtility.hasTextFieldOfName(capability, TextFieldName.mainField1)); + assertTrue(ManagerUtility.WindowCapabilityUtility.hasTextFieldOfName(capability, TextFieldName.alertText3)); + + } + + @Test + public void testHasImageFieldOfName() { + + WindowCapability capability = new WindowCapability(); + List allImageFileTypes = Arrays.asList(FileType.GRAPHIC_BMP, FileType.GRAPHIC_JPEG, FileType.GRAPHIC_PNG); + + List imageFieldList = new ArrayList<>(); + imageFieldList.add(new ImageField(ImageFieldName.graphic, allImageFileTypes)); + capability.setImageFields(imageFieldList); + + assertTrue(ManagerUtility.WindowCapabilityUtility.hasImageFieldOfName(capability, ImageFieldName.graphic)); + assertFalse(ManagerUtility.WindowCapabilityUtility.hasImageFieldOfName(capability, ImageFieldName.alertIcon)); + + imageFieldList.add(new ImageField(ImageFieldName.alertIcon, allImageFileTypes)); + capability.setImageFields(imageFieldList); + assertTrue(ManagerUtility.WindowCapabilityUtility.hasImageFieldOfName(capability, ImageFieldName.graphic)); + assertTrue(ManagerUtility.WindowCapabilityUtility.hasImageFieldOfName(capability, ImageFieldName.alertIcon));; + + imageFieldList.clear(); + imageFieldList.add(null); + capability.setImageFields(imageFieldList); + assertFalse(ManagerUtility.WindowCapabilityUtility.hasImageFieldOfName(capability, ImageFieldName.graphic)); + assertFalse(ManagerUtility.WindowCapabilityUtility.hasImageFieldOfName(capability, ImageFieldName.alertIcon)); + + imageFieldList.add(new ImageField(ImageFieldName.alertIcon, allImageFileTypes)); + capability.setImageFields(imageFieldList); + assertFalse(ManagerUtility.WindowCapabilityUtility.hasImageFieldOfName(capability, ImageFieldName.graphic)); + assertTrue(ManagerUtility.WindowCapabilityUtility.hasImageFieldOfName(capability, ImageFieldName.alertIcon)); + + } + + + @Test + public void testGetMaxNumberOfMainFieldLines() { + + WindowCapability capability = new WindowCapability(); + capability.setTextFields(ManagerUtility.WindowCapabilityUtility.getAllTextFields()); + + int maxNumerOfLines = ManagerUtility.WindowCapabilityUtility.getMaxNumberOfMainFieldLines(capability); + + assertEquals(4, maxNumerOfLines); + + //Single line + List singleLineList = new ArrayList<>(); + singleLineList.add(new TextField(TextFieldName.mainField1, CharacterSet.UTF_8, 500, 8)); + capability.setTextFields(singleLineList); + maxNumerOfLines = ManagerUtility.WindowCapabilityUtility.getMaxNumberOfMainFieldLines(capability); + assertEquals(1, maxNumerOfLines); + + singleLineList.add(new TextField(TextFieldName.mainField2, CharacterSet.UTF_8, 500, 8)); + capability.setTextFields(singleLineList); + maxNumerOfLines = ManagerUtility.WindowCapabilityUtility.getMaxNumberOfMainFieldLines(capability); + assertEquals(2, maxNumerOfLines); + + singleLineList.add(new TextField(TextFieldName.mainField3, CharacterSet.UTF_8, 500, 8)); + capability.setTextFields(singleLineList); + maxNumerOfLines = ManagerUtility.WindowCapabilityUtility.getMaxNumberOfMainFieldLines(capability); + assertEquals(3, maxNumerOfLines); + + singleLineList.add(new TextField(TextFieldName.mainField4, CharacterSet.UTF_8, 500, 8)); + capability.setTextFields(singleLineList); + maxNumerOfLines = ManagerUtility.WindowCapabilityUtility.getMaxNumberOfMainFieldLines(capability); + assertEquals(4, maxNumerOfLines); + + List nullList = new ArrayList<>(); + nullList.add(null); + assertNotNull(nullList); + capability.setTextFields(nullList); + assertNotNull(capability); + assertNotNull(capability.getTextFields()); //Fails + + maxNumerOfLines = ManagerUtility.WindowCapabilityUtility.getMaxNumberOfMainFieldLines(capability); + assertEquals(0, maxNumerOfLines); + + nullList.add(new TextField(TextFieldName.mainField4, CharacterSet.UTF_8, 500, 8)); + assertNotNull(nullList); + capability.setTextFields(nullList); + assertNotNull(capability); + assertNotNull(capability.getTextFields()); + maxNumerOfLines = ManagerUtility.WindowCapabilityUtility.getMaxNumberOfMainFieldLines(capability); + assertEquals(4, maxNumerOfLines); + + } +} diff --git a/base/src/main/java/com/smartdevicelink/managers/ManagerUtility.java b/base/src/main/java/com/smartdevicelink/managers/ManagerUtility.java index 2bac81e42..f9910032c 100644 --- a/base/src/main/java/com/smartdevicelink/managers/ManagerUtility.java +++ b/base/src/main/java/com/smartdevicelink/managers/ManagerUtility.java @@ -28,14 +28,17 @@ public class ManagerUtility { * @param name ImageFieldName representing a name of a given Image field that would be stored in WindowCapability * @return true if name exist in WindowCapability else false */ - public static boolean hasImageFieldOfName(WindowCapability windowCapability, ImageFieldName name) { + public static boolean hasImageFieldOfName(final WindowCapability windowCapability, final ImageFieldName name) { if (windowCapability == null || name == null) { return false; } if (windowCapability.getImageFields() != null) { - for (ImageField field : windowCapability.getImageFields()) { - if (field != null && name.equals(field.getName())) { - return true; + List imageFields = windowCapability.getImageFields(); + if(imageFields != null && imageFields.size() > 0) { + for (ImageField field : imageFields) { + if (field != null && name.equals(field.getName())) { + return true; + } } } } @@ -49,14 +52,17 @@ public class ManagerUtility { * @param name TextFieldName representing a name of a given text field that would be stored in WindowCapability * @return true if name exist in WindowCapability else false */ - public static boolean hasTextFieldOfName(WindowCapability windowCapability, TextFieldName name) { + public static boolean hasTextFieldOfName(final WindowCapability windowCapability, final TextFieldName name) { if (windowCapability == null || name == null) { return false; } if (windowCapability.getTextFields() != null) { - for (TextField field : windowCapability.getTextFields()) { - if (field != null && name.equals(field.getName())) { - return true; + List textFields = windowCapability.getTextFields(); + if (textFields != null && textFields.size() > 0) { + for (TextField field : textFields) { + if (field != null && name.equals(field.getName())) { + return true; + } } } } @@ -69,24 +75,26 @@ public class ManagerUtility { * @param windowCapability WindowCapability representing the capabilities of the desired window * @return linesFound Number of textFields found in WindowCapability */ - public static int getMaxNumberOfMainFieldLines(WindowCapability windowCapability) { + public static int getMaxNumberOfMainFieldLines(final WindowCapability windowCapability) { int highestFound = 0; if (windowCapability != null && windowCapability.getTextFields() != null) { for (TextField field : windowCapability.getTextFields()) { int fieldNumber = 0; - switch (field.getName()) { - case mainField1: - fieldNumber = 1; - break; - case mainField2: - fieldNumber = 2; - break; - case mainField3: - fieldNumber = 3; - break; - case mainField4: - fieldNumber = 4; - break; + if(field != null) { + switch (field.getName()) { + case mainField1: + fieldNumber = 1; + break; + case mainField2: + fieldNumber = 2; + break; + case mainField3: + fieldNumber = 3; + break; + case mainField4: + fieldNumber = 4; + break; + } } if (fieldNumber > 0) { highestFound = Math.max(highestFound, fieldNumber); -- cgit v1.2.1 From ddc42d9702e59aec552fa1f6d7c8bb61cc9be18d Mon Sep 17 00:00:00 2001 From: Joey Grover Date: Wed, 2 Sep 2020 12:36:31 -0400 Subject: Remove incorrect fails comment in unit tests --- .../java/com/smartdevicelink/managers/ManagerUtilityTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/ManagerUtilityTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/ManagerUtilityTests.java index ac8d9eb75..fe7d402b9 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/ManagerUtilityTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/ManagerUtilityTests.java @@ -189,7 +189,7 @@ public class ManagerUtilityTests { assertNotNull(nullList); capability.setTextFields(nullList); assertNotNull(capability); - assertNotNull(capability.getTextFields()); //Fails + assertNotNull(capability.getTextFields()); maxNumerOfLines = ManagerUtility.WindowCapabilityUtility.getMaxNumberOfMainFieldLines(capability); assertEquals(0, maxNumerOfLines); -- cgit v1.2.1 From 707a0a9a0620c79e6e8cfb8c269591c5e4cd9c55 Mon Sep 17 00:00:00 2001 From: Robert Henigan Date: Wed, 2 Sep 2020 13:42:45 -0400 Subject: Refactor/streaming calls (#1468) * Refactor Streaming Calls to manager classes * Fix Unit Tests * Make methods protected * Remove stopAudioService References --- .../managers/audio/AudioStreamManagerTest.java | 42 ++++----- .../lifecycle/SystemCapabilityManagerTests.java | 6 -- .../smartdevicelink/SdlConnection/SdlSession.java | 104 --------------------- .../managers/audio/AudioStreamManager.java | 43 ++++++++- .../managers/lifecycle/LifecycleManager.java | 38 -------- .../managers/video/VideoStreamManager.java | 70 +++++++++++++- .../com/smartdevicelink/proxy/SdlProxyBase.java | 0 .../managers/lifecycle/BaseLifecycleManager.java | 16 ---- .../com/smartdevicelink/proxy/interfaces/ISdl.java | 10 -- 9 files changed, 124 insertions(+), 205 deletions(-) create mode 100644 android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/audio/AudioStreamManagerTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/audio/AudioStreamManagerTest.java index 3fd5cd943..4cfa806ad 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/audio/AudioStreamManagerTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/audio/AudioStreamManagerTest.java @@ -5,9 +5,10 @@ import android.media.AudioFormat; import android.media.MediaFormat; import android.media.MediaPlayer; import android.os.Build; -import androidx.test.platform.app.InstrumentationRegistry; import android.util.Log; +import androidx.test.platform.app.InstrumentationRegistry; + import com.smartdevicelink.SdlConnection.SdlSession; import com.smartdevicelink.managers.CompletionListener; import com.smartdevicelink.managers.audio.AudioStreamManager.SampleType; @@ -93,10 +94,6 @@ public class AudioStreamManagerTest extends TestCase { Boolean encrypted = (Boolean) args[0]; serviceListener.onServiceStarted(mockSession, SessionType.PCM, encrypted); break; - case "stopAudioService": - // parameters () - serviceListener.onServiceEnded(mockSession, SessionType.PCM); - break; } return null; @@ -109,7 +106,6 @@ public class AudioStreamManagerTest extends TestCase { doReturn(audioCapabilities).when(internalInterface).getCapability(SystemCapabilityType.PCM_STREAMING); doAnswer(audioServiceAnswer).when(internalInterface).addServiceListener(any(SessionType.class), any(ISdlServiceListener.class)); doAnswer(audioServiceAnswer).when(internalInterface).startAudioService(any(Boolean.class)); - doAnswer(audioServiceAnswer).when(internalInterface).stopAudioService(); CompletionListener completionListener = new CompletionListener() { @Override @@ -228,7 +224,7 @@ public class AudioStreamManagerTest extends TestCase { testFullAudioManagerDecodeFlowCorrectCounter = 0; testFullAudioManagerDecodeFlowWrongCounter = 0; - IAudioStreamListener audioStreamListener = new IAudioStreamListener() { + final IAudioStreamListener audioStreamListener = new IAudioStreamListener() { @Override public void sendAudio(byte[] data, int offset, int length, long presentationTimeUs) throws ArrayIndexOutOfBoundsException { ByteBuffer buffer = ByteBuffer.wrap(data, offset, length); @@ -270,7 +266,6 @@ public class AudioStreamManagerTest extends TestCase { }; final SdlSession mockSession = mock(SdlSession.class); - doReturn(audioStreamListener).when(mockSession).startAudioStream(); Answer audioServiceAnswer = new Answer() { ISdlServiceListener serviceListener = null; @@ -292,10 +287,6 @@ public class AudioStreamManagerTest extends TestCase { Boolean encrypted = (Boolean) args[0]; serviceListener.onServiceStarted(mockSession, SessionType.PCM, encrypted); break; - case "stopAudioService": - // parameters () - serviceListener.onServiceEnded(mockSession, SessionType.PCM); - break; } return null; @@ -307,7 +298,6 @@ public class AudioStreamManagerTest extends TestCase { doReturn(audioCapabilities).when(internalInterface).getCapability(any(SystemCapabilityType.class)); doAnswer(audioServiceAnswer).when(internalInterface).addServiceListener(any(SessionType.class), any(ISdlServiceListener.class)); doAnswer(audioServiceAnswer).when(internalInterface).startAudioService(any(Boolean.class)); - doAnswer(audioServiceAnswer).when(internalInterface).stopAudioService(); CompletionListener fileCompletionListener = new CompletionListener() { @Override @@ -325,7 +315,12 @@ public class AudioStreamManagerTest extends TestCase { final CompletionListener mockFileListener = spy(fileCompletionListener); - final AudioStreamManager manager = new AudioStreamManager(internalInterface, mContext); + final AudioStreamManager manager = new AudioStreamManager(internalInterface, mContext) { + @Override + public IAudioStreamListener startAudioStream(SdlSession session) { + return audioStreamListener; + } + }; manager.startAudioStream(false, new CompletionListener() { @Override public void onComplete(boolean success) { @@ -504,7 +499,6 @@ public class AudioStreamManagerTest extends TestCase { }; final SdlSession mockSession = mock(SdlSession.class); - doReturn(audioStreamListener).when(mockSession).startAudioStream(); Answer audioServiceAnswer = new Answer() { ISdlServiceListener serviceListener = null; @@ -526,10 +520,6 @@ public class AudioStreamManagerTest extends TestCase { Boolean encrypted = (Boolean) args[0]; serviceListener.onServiceStarted(mockSession, SessionType.PCM, encrypted); break; - case "stopAudioService": - // parameters () - serviceListener.onServiceEnded(mockSession, SessionType.PCM); - break; } return null; @@ -541,7 +531,6 @@ public class AudioStreamManagerTest extends TestCase { doReturn(audioCapabilities).when(internalInterface).getCapability(any(SystemCapabilityType.class)); doAnswer(audioServiceAnswer).when(internalInterface).addServiceListener(any(SessionType.class), any(ISdlServiceListener.class)); doAnswer(audioServiceAnswer).when(internalInterface).startAudioService(any(Boolean.class)); - doAnswer(audioServiceAnswer).when(internalInterface).stopAudioService(); final MediaPlayer.OnCompletionListener mockPlayerCompletionListener = mock(MediaPlayer.OnCompletionListener.class); final MediaPlayer player = new MediaPlayer(); @@ -583,14 +572,11 @@ public class AudioStreamManagerTest extends TestCase { public void testPlayRawAudio() { AudioPassThruCapabilities audioCapabilities = new AudioPassThruCapabilities(SamplingRate._16KHZ, BitsPerSample._16_BIT, AudioType.PCM); - IAudioStreamListener audioStreamListener = mock(IAudioStreamListener.class); - + final IAudioStreamListener audioStreamListener = mock(IAudioStreamListener.class); final CompletionListener completionListener = mock(CompletionListener.class); final SdlSession mockSession = mock(SdlSession.class); - doReturn(audioStreamListener).when(mockSession).startAudioStream(); - Answer audioServiceAnswer = new Answer() { ISdlServiceListener serviceListener = null; @@ -623,7 +609,13 @@ public class AudioStreamManagerTest extends TestCase { doAnswer(audioServiceAnswer).when(internalInterface).addServiceListener(any(SessionType.class), any(ISdlServiceListener.class)); doAnswer(audioServiceAnswer).when(internalInterface).startAudioService(any(Boolean.class)); - final AudioStreamManager manager = new AudioStreamManager(internalInterface, mContext); + final AudioStreamManager manager = new AudioStreamManager(internalInterface, mContext) { + @Override + public IAudioStreamListener startAudioStream(SdlSession session) { + return audioStreamListener; + } + }; + manager.startAudioStream(false, new CompletionListener() { @Override public void onComplete(boolean success) { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lifecycle/SystemCapabilityManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lifecycle/SystemCapabilityManagerTests.java index 4c1981099..d99e3e228 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lifecycle/SystemCapabilityManagerTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lifecycle/SystemCapabilityManagerTests.java @@ -959,12 +959,6 @@ public class SystemCapabilityManagerTests { @Override public void startVideoService(VideoStreamingParameters parameters, boolean encrypted) { } - @Override - public void stopVideoService() {} - - @Override - public void stopAudioService() {} - @Override public void sendRPCRequest(RPCRequest message) {} diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java b/android/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java index f4bdb7136..d9017bd69 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java @@ -35,21 +35,11 @@ package com.smartdevicelink.SdlConnection; import android.content.Context; import com.smartdevicelink.exception.SdlException; -import com.smartdevicelink.protocol.ProtocolMessage; import com.smartdevicelink.protocol.SdlPacket; import com.smartdevicelink.protocol.SdlProtocol; import com.smartdevicelink.protocol.SdlProtocolBase; import com.smartdevicelink.protocol.enums.SessionType; -import com.smartdevicelink.proxy.interfaces.IAudioStreamListener; import com.smartdevicelink.proxy.interfaces.ISdlServiceListener; -import com.smartdevicelink.proxy.interfaces.IVideoStreamListener; -import com.smartdevicelink.proxy.rpc.VideoStreamingFormat; -import com.smartdevicelink.proxy.rpc.enums.VideoStreamingProtocol; -import com.smartdevicelink.streaming.AbstractPacketizer; -import com.smartdevicelink.streaming.IStreamListener; -import com.smartdevicelink.streaming.StreamPacketizer; -import com.smartdevicelink.streaming.video.RTPH264Packetizer; -import com.smartdevicelink.streaming.video.VideoStreamingParameters; import com.smartdevicelink.transport.MultiplexTransportConfig; import com.smartdevicelink.transport.TCPTransportConfig; import com.smartdevicelink.transport.enums.TransportType; @@ -57,7 +47,6 @@ import com.smartdevicelink.util.DebugTool; import com.smartdevicelink.util.MediaStreamingStatus; import com.smartdevicelink.util.Version; -import java.io.IOException; import java.lang.ref.WeakReference; import java.util.concurrent.CopyOnWriteArrayList; @@ -178,13 +167,8 @@ public class SdlSession extends BaseSdlSession { @Override public void onServiceEnded(SdlPacket packet, SessionType serviceType, int sessionID) { - if (SessionType.RPC.equals(serviceType)) { this.sessionListener.onSessionEnded(sessionID); - } else if (SessionType.NAV.equals(serviceType)) { - stopVideoStream(); - } else if (SessionType.PCM.equals(serviceType)) { - stopAudioStream(); } if (serviceListeners != null && serviceListeners.containsKey(serviceType)) { @@ -198,12 +182,6 @@ public class SdlSession extends BaseSdlSession { @Override public void onServiceError(SdlPacket packet, SessionType serviceType, int sessionID, String error) { - if (SessionType.NAV.equals(serviceType)) { - stopVideoStream(); - } else if (SessionType.PCM.equals(serviceType)) { - stopAudioStream(); - } - if (serviceListeners != null && serviceListeners.containsKey(serviceType)) { CopyOnWriteArrayList listeners = serviceListeners.get(serviceType); for (ISdlServiceListener listener : listeners) { @@ -215,86 +193,4 @@ public class SdlSession extends BaseSdlSession { @Override public void onAuthTokenReceived(String authToken) {/* Do nothing */ } - /* *********************************************************************************************************************************************************************** - * ***************************************************************** Fix after initial refactor ********************************************************************************* - *************************************************************************************************************************************************************************/ - //FIXME there is a lot of spaghetti code here that needs to be addressed. For first refactor the - // the goal is to only refactor SdlSession. Another PR should be opened to fix all the packetizer - // classes and method calls. - - //FIXME Move this logic to the related streaming manager - private AbstractPacketizer videoPacketizer; - private StreamPacketizer audioPacketizer; - - IStreamListener streamListener = new IStreamListener() { - @Override - public void sendStreamPacket(ProtocolMessage pm) { - sendMessage(pm); - } - }; - - private VideoStreamingProtocol getAcceptedProtocol() { - if (acceptedVideoParams != null) { - VideoStreamingFormat format = acceptedVideoParams.getFormat(); - if (format != null && format.getProtocol() != null) { - return format.getProtocol(); - } - } - //Returns default protocol if none are found - return new VideoStreamingParameters().getFormat().getProtocol(); - - } - - public IVideoStreamListener startVideoStream() { - VideoStreamingProtocol protocol = getAcceptedProtocol(); - try { - switch (protocol) { - case RAW: { - videoPacketizer = new StreamPacketizer(streamListener, null, SessionType.NAV, (byte) this.sessionId, this); - videoPacketizer.start(); - return (IVideoStreamListener) videoPacketizer; - } - case RTP: { - //FIXME why is this not an extension of StreamPacketizer? - videoPacketizer = new RTPH264Packetizer(streamListener, SessionType.NAV, (byte) this.sessionId, this); - videoPacketizer.start(); - return (IVideoStreamListener) videoPacketizer; - } - default: - DebugTool.logError(TAG, "Protocol " + protocol + " is not supported."); - return null; - } - } catch (IOException e) { - return null; - } - } - - public IAudioStreamListener startAudioStream() { - try { - audioPacketizer = new StreamPacketizer(streamListener, null, SessionType.PCM, (byte) this.sessionId, this); - audioPacketizer.start(); - return audioPacketizer; - } catch (IOException e) { - return null; - } - - } - - - public boolean stopVideoStream() { - if (videoPacketizer != null) { - videoPacketizer.stop(); - return true; - } - return false; - } - - public boolean stopAudioStream() { - if (audioPacketizer != null) { - audioPacketizer.stop(); - return true; - } - return false; - } - } diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/managers/audio/AudioStreamManager.java b/android/sdl_android/src/main/java/com/smartdevicelink/managers/audio/AudioStreamManager.java index 38bc357b6..f7cc7b7a5 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/managers/audio/AudioStreamManager.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/managers/audio/AudioStreamManager.java @@ -45,6 +45,7 @@ import com.smartdevicelink.SdlConnection.SdlSession; import com.smartdevicelink.managers.CompletionListener; import com.smartdevicelink.managers.StreamingStateMachine; import com.smartdevicelink.managers.lifecycle.OnSystemCapabilityListener; +import com.smartdevicelink.protocol.ProtocolMessage; import com.smartdevicelink.protocol.enums.FunctionID; import com.smartdevicelink.protocol.enums.SessionType; import com.smartdevicelink.proxy.RPCNotification; @@ -57,10 +58,13 @@ import com.smartdevicelink.proxy.rpc.enums.HMILevel; import com.smartdevicelink.proxy.rpc.enums.PredefinedWindows; import com.smartdevicelink.proxy.rpc.enums.SystemCapabilityType; import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener; +import com.smartdevicelink.streaming.IStreamListener; +import com.smartdevicelink.streaming.StreamPacketizer; import com.smartdevicelink.transport.utl.TransportRecord; import com.smartdevicelink.util.DebugTool; import com.smartdevicelink.util.Version; +import java.io.IOException; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.ref.WeakReference; @@ -91,6 +95,9 @@ public class AudioStreamManager extends BaseAudioStreamManager { private CompletionListener serviceCompletionListener; // As the internal interface does not provide timeout we need to use a future task private final Handler serviceCompletionHandler; + private StreamPacketizer audioPacketizer; + private SdlSession sdlSession = null; + private SessionType sessionType = null; private final Runnable serviceCompletionTimeoutCallback = new Runnable() { @Override @@ -106,10 +113,12 @@ public class AudioStreamManager extends BaseAudioStreamManager { private final ISdlServiceListener serviceListener = new ISdlServiceListener() { @Override public void onServiceStarted(SdlSession session, SessionType type, boolean isEncrypted) { + sdlSession = session; + sessionType = type; if (SessionType.PCM.equals(type)) { serviceCompletionHandler.removeCallbacks(serviceCompletionTimeoutCallback); - sdlAudioStream = session.startAudioStream(); + sdlAudioStream = startAudioStream(session); streamingStateMachine.transitionToState(StreamingStateMachine.STARTED); if (serviceCompletionListener != null) { @@ -125,7 +134,7 @@ public class AudioStreamManager extends BaseAudioStreamManager { if (SessionType.PCM.equals(type)) { serviceCompletionHandler.removeCallbacks(serviceCompletionTimeoutCallback); - session.stopAudioStream(); + stopAudioStream(); sdlAudioStream = null; streamingStateMachine.transitionToState(StreamingStateMachine.NONE); @@ -142,6 +151,7 @@ public class AudioStreamManager extends BaseAudioStreamManager { if (SessionType.PCM.equals(type)) { serviceCompletionHandler.removeCallbacks(serviceCompletionTimeoutCallback); + stopAudioStream(); streamingStateMachine.transitionToState(StreamingStateMachine.ERROR); DebugTool.logError(TAG, "OnServiceError: " + reason); streamingStateMachine.transitionToState(StreamingStateMachine.NONE); @@ -338,7 +348,8 @@ public class AudioStreamManager extends BaseAudioStreamManager { streamingStateMachine.transitionToState(StreamingStateMachine.STOPPED); serviceCompletionListener = completionListener; serviceCompletionHandler.postDelayed(serviceCompletionTimeoutCallback, COMPLETION_TIMEOUT); - internalInterface.stopAudioService(); + stopAudioStream(); + serviceListener.onServiceEnded(sdlSession, sessionType); } /** @@ -490,4 +501,30 @@ public class AudioStreamManager extends BaseAudioStreamManager { // range of ENCODING_PCM_FLOAT audio data is [-1.0, 1.0]. int FLOAT = Float.SIZE >> 3; } + + protected IAudioStreamListener startAudioStream(final SdlSession session) { + + IStreamListener streamListener = new IStreamListener() { + @Override + public void sendStreamPacket(ProtocolMessage pm) { + session.sendMessage(pm); + } + }; + + try { + audioPacketizer = new StreamPacketizer(streamListener, null, SessionType.PCM, (byte) session.getSessionId(), session); + audioPacketizer.start(); + return audioPacketizer; + } catch (IOException e) { + return null; + } + } + + protected boolean stopAudioStream() { + if (audioPacketizer != null) { + audioPacketizer.stop(); + return true; + } + return false; + } } diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java b/android/sdl_android/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java index 2fe65b2fc..ed3f5f219 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java @@ -225,25 +225,6 @@ public class LifecycleManager extends BaseLifecycleManager { } } - /** - * Closes the opened video service (serviceType 11) - * - * @return true if the video service is closed successfully, return false otherwise - */ - @Override - void endVideoStream() { - if (session == null) { - DebugTool.logWarning(TAG, "SdlSession is not created yet."); - return; - } - if (!session.getIsConnected()) { - DebugTool.logWarning(TAG, "Connection is not available."); - return; - } - - session.stopVideoStream(); - } - @Override void startAudioService(boolean isEncrypted) { if (session == null) { @@ -256,23 +237,4 @@ public class LifecycleManager extends BaseLifecycleManager { } session.startService(SessionType.PCM, isEncrypted); } - - /** - * Closes the opened audio service (serviceType 10) - * - * @return true if the audio service is closed successfully, return false otherwise - */ - @Override - void endAudioStream() { - if (session == null) { - DebugTool.logWarning(TAG, "SdlSession is not created yet."); - return; - } - if (!session.getIsConnected()) { - DebugTool.logWarning(TAG, "Connection is not available."); - return; - } - - session.stopAudioStream(); - } } diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/managers/video/VideoStreamManager.java b/android/sdl_android/src/main/java/com/smartdevicelink/managers/video/VideoStreamManager.java index 81db89049..a55cecb4d 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/managers/video/VideoStreamManager.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/managers/video/VideoStreamManager.java @@ -46,6 +46,7 @@ import com.smartdevicelink.managers.BaseSubManager; import com.smartdevicelink.managers.CompletionListener; import com.smartdevicelink.managers.StreamingStateMachine; import com.smartdevicelink.managers.lifecycle.OnSystemCapabilityListener; +import com.smartdevicelink.protocol.ProtocolMessage; import com.smartdevicelink.protocol.enums.FunctionID; import com.smartdevicelink.protocol.enums.SessionType; import com.smartdevicelink.proxy.RPCNotification; @@ -59,18 +60,25 @@ import com.smartdevicelink.proxy.rpc.OnTouchEvent; import com.smartdevicelink.proxy.rpc.TouchCoord; import com.smartdevicelink.proxy.rpc.TouchEvent; import com.smartdevicelink.proxy.rpc.VideoStreamingCapability; +import com.smartdevicelink.proxy.rpc.VideoStreamingFormat; import com.smartdevicelink.proxy.rpc.enums.HMILevel; import com.smartdevicelink.proxy.rpc.enums.PredefinedWindows; import com.smartdevicelink.proxy.rpc.enums.SystemCapabilityType; import com.smartdevicelink.proxy.rpc.enums.TouchType; +import com.smartdevicelink.proxy.rpc.enums.VideoStreamingProtocol; import com.smartdevicelink.proxy.rpc.enums.VideoStreamingState; import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener; +import com.smartdevicelink.streaming.AbstractPacketizer; +import com.smartdevicelink.streaming.IStreamListener; +import com.smartdevicelink.streaming.StreamPacketizer; +import com.smartdevicelink.streaming.video.RTPH264Packetizer; import com.smartdevicelink.streaming.video.SdlRemoteDisplay; import com.smartdevicelink.streaming.video.VideoStreamingParameters; import com.smartdevicelink.transport.utl.TransportRecord; import com.smartdevicelink.util.DebugTool; import com.smartdevicelink.util.Version; +import java.io.IOException; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.List; @@ -95,6 +103,7 @@ public class VideoStreamManager extends BaseVideoStreamManager { private boolean isTransportAvailable = false; private boolean hasStarted; private String vehicleMake = null; + private AbstractPacketizer videoPacketizer; // INTERNAL INTERFACES @@ -104,7 +113,7 @@ public class VideoStreamManager extends BaseVideoStreamManager { if(SessionType.NAV.equals(type)){ if (session != null && session.getAcceptedVideoParams() != null) { parameters = session.getAcceptedVideoParams(); - VideoStreamManager.this.streamListener = session.startVideoStream(); + VideoStreamManager.this.streamListener = startVideoStream(session.getAcceptedVideoParams(), session); } if (VideoStreamManager.this.streamListener == null) { @@ -125,6 +134,7 @@ public class VideoStreamManager extends BaseVideoStreamManager { @Override public void onServiceEnded(SdlSession session, SessionType type) { if(SessionType.NAV.equals(type)){ + stopVideoStream(); if(remoteDisplay!=null){ stopStreaming(); } @@ -136,6 +146,7 @@ public class VideoStreamManager extends BaseVideoStreamManager { @Override public void onServiceError(SdlSession session, SessionType type, String reason) { DebugTool.logError(TAG, "Unable to start video service: " + reason); + stopVideoStream(); stateMachine.transitionToState(StreamingStateMachine.ERROR); transitionToState(BaseSubManager.ERROR); } @@ -156,7 +167,7 @@ public class VideoStreamManager extends BaseVideoStreamManager { } checkState(); if (hasStarted && (isHMIStateVideoStreamCapable(prevOnHMIStatus)) && (!isHMIStateVideoStreamCapable(currentOnHMIStatus))) { - internalInterface.stopVideoService(); + stopVideoStream(); } } } @@ -375,13 +386,13 @@ public class VideoStreamManager extends BaseVideoStreamManager { parameters = null; virtualDisplayEncoder = null; if (internalInterface != null) { - internalInterface.stopVideoService(); // Remove listeners internalInterface.removeServiceListener(SessionType.NAV, serviceListener); internalInterface.removeOnRPCNotificationListener(FunctionID.ON_TOUCH_EVENT, touchListener); internalInterface.removeOnRPCNotificationListener(FunctionID.ON_HMI_STATUS, hmiListener); } + stopVideoStream(); stateMachine.transitionToState(StreamingStateMachine.NONE); @@ -704,4 +715,57 @@ public class VideoStreamManager extends BaseVideoStreamManager { } } + private VideoStreamingProtocol getAcceptedProtocol(VideoStreamingParameters params) { + if (params != null) { + VideoStreamingFormat format = params.getFormat(); + if (format != null && format.getProtocol() != null) { + return format.getProtocol(); + } + } + //Returns default protocol if none are found + return new VideoStreamingParameters().getFormat().getProtocol(); + + } + + protected IVideoStreamListener startVideoStream(VideoStreamingParameters params, final SdlSession session) { + VideoStreamingProtocol protocol = getAcceptedProtocol(params); + + IStreamListener iStreamListener = new IStreamListener() { + @Override + public void sendStreamPacket(ProtocolMessage pm) { + session.sendMessage(pm); + } + }; + + try { + switch (protocol) { + case RAW: { + videoPacketizer = new StreamPacketizer(iStreamListener, null, SessionType.NAV, (byte) session.getSessionId(), session); + videoPacketizer.start(); + return (IVideoStreamListener) videoPacketizer; + } + case RTP: { + //FIXME why is this not an extension of StreamPacketizer? + videoPacketizer = new RTPH264Packetizer(iStreamListener, SessionType.NAV, (byte) session.getSessionId(), session); + videoPacketizer.start(); + return (IVideoStreamListener) videoPacketizer; + } + default: + DebugTool.logError(TAG, "Protocol " + protocol + " is not supported."); + return null; + } + } catch (IOException e) { + return null; + } + + } + + protected boolean stopVideoStream() { + if (videoPacketizer != null) { + videoPacketizer.stop(); + return true; + } + return false; + } + } diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java b/android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java new file mode 100644 index 000000000..e69de29bb diff --git a/base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseLifecycleManager.java b/base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseLifecycleManager.java index 77fac4cfe..e83c0e843 100644 --- a/base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseLifecycleManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseLifecycleManager.java @@ -946,11 +946,6 @@ abstract class BaseLifecycleManager { BaseLifecycleManager.this.startVideoService(encrypted, parameters); } - @Override - public void stopVideoService() { - BaseLifecycleManager.this.endVideoStream(); - } - @Override public IVideoStreamListener startVideoStream(boolean isEncrypted, VideoStreamingParameters parameters) { DebugTool.logWarning(TAG, "startVideoStream is not currently implemented"); @@ -967,11 +962,6 @@ abstract class BaseLifecycleManager { BaseLifecycleManager.this.startAudioService(encrypted); } - @Override - public void stopAudioService() { - BaseLifecycleManager.this.endAudioStream(); - } - @Override public IAudioStreamListener startAudioStream(boolean isEncrypted, AudioStreamingCodec codec, AudioStreamingParams params) { DebugTool.logWarning(TAG, "startAudioStream is not currently implemented"); @@ -1273,15 +1263,9 @@ abstract class BaseLifecycleManager { void startVideoService(boolean encrypted, VideoStreamingParameters parameters) { } - void endVideoStream() { - } - void startAudioService(boolean encrypted) { } - void endAudioStream() { - } - void setSdlSecurityStaticVars() { } diff --git a/base/src/main/java/com/smartdevicelink/proxy/interfaces/ISdl.java b/base/src/main/java/com/smartdevicelink/proxy/interfaces/ISdl.java index 6a1b1b97d..0c46e3743 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/interfaces/ISdl.java +++ b/base/src/main/java/com/smartdevicelink/proxy/interfaces/ISdl.java @@ -93,11 +93,6 @@ public interface ISdl { */ 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 @@ -119,11 +114,6 @@ public interface ISdl { */ void startAudioService(boolean encrypted); - /** - * Stops the audio service if open - */ - void stopAudioService(); - /** * Start Audio Stream and return IAudioStreamListener * @param isEncrypted whether or not the audio stream should be encrypted -- cgit v1.2.1 From 61937baae44938e43a06b67a708cb78f235a2028 Mon Sep 17 00:00:00 2001 From: Bilal Alsharifi Date: Wed, 2 Sep 2020 16:08:56 -0400 Subject: Remove deprecated shareConnection method --- .../transport/BaseTransportConfig.java | 77 +++++++++------------- 1 file changed, 32 insertions(+), 45 deletions(-) diff --git a/base/src/main/java/com/smartdevicelink/transport/BaseTransportConfig.java b/base/src/main/java/com/smartdevicelink/transport/BaseTransportConfig.java index 57237d0bc..b037e2b1b 100644 --- a/base/src/main/java/com/smartdevicelink/transport/BaseTransportConfig.java +++ b/base/src/main/java/com/smartdevicelink/transport/BaseTransportConfig.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.transport; import com.smartdevicelink.transport.enums.TransportType; @@ -37,26 +37,13 @@ import com.smartdevicelink.transport.enums.TransportType; * Defines base abstract class for transport configurations. */ public abstract class BaseTransportConfig { - - protected boolean shareConnection = true; protected int iHeartBeatTimeout = Integer.MAX_VALUE; /** * Gets transport type for this transport configuration. * * @return One of {@link TransportType} enumeration values that represents type of this transport configuration. */ - public abstract TransportType getTransportType(); - - /** - * @deprecated - * Indicate whether the application want to share connection with others. - * - * @return a boolean if this conneciton should be shared - */ - @Deprecated - public boolean shareConnection() { - return shareConnection; - } + public abstract TransportType getTransportType(); public int getHeartBeatTimeout() { return iHeartBeatTimeout; -- cgit v1.2.1 From bda523e62089bb9e48598ee48936e916be5949e2 Mon Sep 17 00:00:00 2001 From: Bilal Alsharifi Date: Wed, 2 Sep 2020 16:19:59 -0400 Subject: Remove unsed appService var in SdlSecurityBase --- .../src/main/java/com/smartdevicelink/security/SdlSecurityBase.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/security/SdlSecurityBase.java b/android/sdl_android/src/main/java/com/smartdevicelink/security/SdlSecurityBase.java index 55ce677c1..2e1ac540c 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/security/SdlSecurityBase.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/security/SdlSecurityBase.java @@ -31,12 +31,10 @@ */ package com.smartdevicelink.security; -import android.app.Service; import android.content.Context; public abstract class SdlSecurityBase extends AbstractSdlSecurityBase{ - protected static Service appService = null; protected static Context context; public static Context getContext() { -- cgit v1.2.1 From 925a0a2fa9af8904c9c5c49afa4f3f64fb64a34d Mon Sep 17 00:00:00 2001 From: Bilal Alsharifi Date: Wed, 2 Sep 2020 16:24:15 -0400 Subject: Fix BaseTransportConfigTests --- .../com/smartdevicelink/test/transport/BaseTransportConfigTests.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/transport/BaseTransportConfigTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/transport/BaseTransportConfigTests.java index d5f6629bd..8fcde0456 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/transport/BaseTransportConfigTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/transport/BaseTransportConfigTests.java @@ -15,7 +15,6 @@ public class BaseTransportConfigTests extends TestCase { /** * This is a unit test for the following methods : * {@link com.smartdevicelink.transport.BaseTransportConfig#getTransportType()} - * {@link com.smartdevicelink.transport.BaseTransportConfig#shareConnection()} * {@link com.smartdevicelink.transport.BaseTransportConfig#getHeartBeatTimeout()} * {@link com.smartdevicelink.transport.BaseTransportConfig#setHeartBeatTimeout(int)} */ @@ -27,14 +26,12 @@ public class BaseTransportConfigTests extends TestCase { // Comparison Values int expectedMaxValue = Integer.MAX_VALUE; - boolean actualShareConnection = testBaseTransportConfig.shareConnection(); int actualMaxValue = testBaseTransportConfig.getHeartBeatTimeout(); // Valid Tests assertNotNull(TestValues.NOT_NULL, testBaseTransportConfig); assertEquals(TestValues.MATCH, expectedMaxValue, actualMaxValue); - assertTrue(TestValues.TRUE, actualShareConnection); - + testBaseTransportConfig.setHeartBeatTimeout(testInt); assertEquals(TestValues.MATCH, testInt, testBaseTransportConfig.getHeartBeatTimeout()); } -- cgit v1.2.1 From 9bc55c7ceeb230c427df34dfee68ca77884e0d12 Mon Sep 17 00:00:00 2001 From: Bilal Alsharifi Date: Wed, 2 Sep 2020 16:43:50 -0400 Subject: Remove deprecated code from some transport classes --- .../com/smartdevicelink/transport/RouterServiceValidator.java | 5 ----- .../com/smartdevicelink/transport/SdlBroadcastReceiver.java | 5 ----- .../java/com/smartdevicelink/transport/TransportBroker.java | 5 ----- .../transport/utl/ByteArrayMessageSpliter.java | 11 ----------- 4 files changed, 26 deletions(-) diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/RouterServiceValidator.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/RouterServiceValidator.java index f86caa699..0cc4cf853 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/RouterServiceValidator.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/RouterServiceValidator.java @@ -638,11 +638,6 @@ public class RouterServiceValidator { return createTrustedListRequest(context,forceRefresh,null,listCallback); } - @Deprecated - protected static boolean createTrustedListRequest(final Context context, boolean forceRefresh,HttpRequestTask.HttpRequestTaskCallback cb ){ - return createTrustedListRequest(context,forceRefresh,cb,null); - } - protected static boolean createTrustedListRequest(final Context context, boolean forceRefresh,HttpRequestTask.HttpRequestTaskCallback cb, final TrustedListCallback listCallback ){ if(context == null){ return false; diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlBroadcastReceiver.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlBroadcastReceiver.java index 1ad6a3e9a..a12fcb590 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlBroadcastReceiver.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlBroadcastReceiver.java @@ -462,11 +462,6 @@ public abstract class SdlBroadcastReceiver extends BroadcastReceiver{ * @param context A context to access Android system services through. If null is passed, this will always return false * @param callback Use this callback to find out if the router service is connected or not. */ - @Deprecated - public static void requestTransportStatus(Context context, final SdlRouterStatusProvider.ConnectedStatusCallback callback){ - requestTransportStatus(context,callback,false, true); - } - private static void requestTransportStatus(Context context, final SdlRouterStatusProvider.ConnectedStatusCallback callback, final boolean triggerRouterServicePing, final boolean lookForServices){ if(context == null){ if(callback!=null){ diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/TransportBroker.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/TransportBroker.java index acf84462f..3851ab563 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/TransportBroker.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/TransportBroker.java @@ -752,11 +752,6 @@ public class TransportBroker { /** * Use this method to let the router service know that you are requesting a new session from the head unit. */ - @Deprecated - public void requestNewSession() { - requestNewSession(null); - } - public void requestNewSession(TransportRecord transportRecord) { Message msg = Message.obtain(); msg.what = TransportConstants.ROUTER_REQUEST_NEW_SESSION; diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/utl/ByteArrayMessageSpliter.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/utl/ByteArrayMessageSpliter.java index c7333fb08..9ab93aea9 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/utl/ByteArrayMessageSpliter.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/utl/ByteArrayMessageSpliter.java @@ -68,17 +68,6 @@ public class ByteArrayMessageSpliter { this.priorityCoef = priorityCoef; } - @Deprecated - public ByteArrayMessageSpliter(Long appId,int what, byte[] bytes, int priorityCoef){ - this.appId = appId+""; - this.what = what; - stream = new ByteArrayInputStream(bytes); - orginalSize = stream.available(); - bytesRead = 0; - firstPacket = true; - this.priorityCoef = priorityCoef; - } - public void setRouterServiceVersion(int version){ this.routerServiceVersion = version; } -- cgit v1.2.1 From 3dfa6ed3022623e05d3669b1b2934c70b31caadd Mon Sep 17 00:00:00 2001 From: Bilal Alsharifi Date: Wed, 2 Sep 2020 16:44:32 -0400 Subject: Remove deprecated code from multiplex transort classes --- .../transport/MultiplexBaseTransport.java | 2 -- .../transport/MultiplexBluetoothTransport.java | 35 ---------------------- 2 files changed, 37 deletions(-) diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexBaseTransport.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexBaseTransport.java index 10c1c9880..e1f138978 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexBaseTransport.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexBaseTransport.java @@ -61,8 +61,6 @@ public abstract class MultiplexBaseTransport { protected final TransportType transportType; protected TransportRecord transportRecord; - @Deprecated - public static String currentlyConnectedDevice = null; protected String connectedDeviceName = null; public String connectedDeviceAddress = null; diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexBluetoothTransport.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexBluetoothTransport.java index 01251f61f..138b1adb2 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexBluetoothTransport.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexBluetoothTransport.java @@ -89,41 +89,6 @@ public class MultiplexBluetoothTransport extends MultiplexBaseTransport{ mBluetoothLevel = SdlRouterService.getBluetoothPrefs(SHARED_PREFS); } - - /** - * This method has been deprecated. It will return an instance of MultiplexBluetoothTransport but should not be used. - * @param handler for receiving status messages from the transport - * @return an instance of MultiplexBluetoothTransport - * @deprecated - */ - @Deprecated - public synchronized static MultiplexBluetoothTransport getBluetoothSerialServerInstance(Handler handler){ - return new MultiplexBluetoothTransport(handler); - } - /** - * This method has been deprecated. It will return an instance of MultiplexBluetoothTransport but should not be used. - * @param handler for receiving status messages from the transport - * @param keepSocketAlive Flag for keeping the socket alive - * @return an instance of MultiplexBluetoothTransport - * @deprecated - */ - @Deprecated - public synchronized static MultiplexBluetoothTransport getBluetoothSerialServerInstance(Handler handler, boolean keepSocketAlive){ - MultiplexBluetoothTransport transport = new MultiplexBluetoothTransport(handler); - transport.setKeepSocketAlive(keepSocketAlive); - return transport; - } - - /** - * This method has been deprecated. It will always return null. - * @return always null - * @deprecated - */ - @Deprecated - public synchronized static MultiplexBluetoothTransport getBluetoothSerialServerInstance(){ - return null; - } - //These methods are used so we can have a semi-static reference to the Accept Thread (Static reference inherited by housing class) private synchronized AcceptThread getAcceptThread(){ return mSecureAcceptThread; -- cgit v1.2.1 From 86a00105cd234822b7a6eeec036e841754ea3501 Mon Sep 17 00:00:00 2001 From: Bilal Alsharifi Date: Wed, 2 Sep 2020 16:45:13 -0400 Subject: Fix unit tests --- .../test/transport/MultiplexBluetoothTransportTest.java | 6 +----- .../androidTest/java/com/smartdevicelink/transport/RSVTestCase.java | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/transport/MultiplexBluetoothTransportTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/transport/MultiplexBluetoothTransportTest.java index cdf83079c..51916ea16 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/transport/MultiplexBluetoothTransportTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/transport/MultiplexBluetoothTransportTest.java @@ -47,11 +47,7 @@ public class MultiplexBluetoothTransportTest extends TestCase { }; - //TODO test for more than the two states - bluetooth = MultiplexBluetoothTransport.getBluetoothSerialServerInstance(); - assertNull(bluetooth); - - bluetooth = MultiplexBluetoothTransport.getBluetoothSerialServerInstance(stateChangeHandler); + bluetooth = new MultiplexBluetoothTransport(stateChangeHandler); assertEquals(bluetooth.getState(), MultiplexBluetoothTransport.STATE_NONE); bluetooth.start(); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/RSVTestCase.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/RSVTestCase.java index 91aea6432..557e0592d 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/RSVTestCase.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/RSVTestCase.java @@ -371,7 +371,7 @@ public class RSVTestCase { } }; - assertTrue(RouterServiceValidator.createTrustedListRequest(getInstrumentation().getTargetContext(),true, cb)); + assertTrue(RouterServiceValidator.createTrustedListRequest(getInstrumentation().getTargetContext(),true, cb, null)); //Now wait for call to finish synchronized(REQUEST_LOCK){ try { -- cgit v1.2.1 From 62185b20f482d53df1b294126f4483f7d8cf392d Mon Sep 17 00:00:00 2001 From: Bilal Alsharifi Date: Wed, 2 Sep 2020 16:53:36 -0400 Subject: Remove proxy dir in android --- .../sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java b/android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java deleted file mode 100644 index e69de29bb..000000000 -- cgit v1.2.1 From 797bf0d4299768a55e9de691a52a9a918d05786b Mon Sep 17 00:00:00 2001 From: Bilal Alsharifi Date: Wed, 2 Sep 2020 16:57:54 -0400 Subject: Update ChoiceSet to remove the usage of TTSChunkFactory --- .../managers/screen/choiceset/ChoiceSet.java | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSet.java b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSet.java index 6585ad810..668f7da77 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSet.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSet.java @@ -35,15 +35,16 @@ package com.smartdevicelink.managers.screen.choiceset; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import com.smartdevicelink.proxy.TTSChunkFactory; import com.smartdevicelink.proxy.rpc.KeyboardProperties; import com.smartdevicelink.proxy.rpc.TTSChunk; import com.smartdevicelink.proxy.rpc.VrHelpItem; +import com.smartdevicelink.proxy.rpc.enums.SpeechCapabilities; import com.smartdevicelink.util.DebugTool; import java.util.ArrayList; import java.util.Hashtable; import java.util.List; +import java.util.Vector; public class ChoiceSet { private static final String TAG = "ChoiceSet"; @@ -108,15 +109,15 @@ public class ChoiceSet { // Help the dev by creating TTS chunks for them if (initialPrompt != null){ - setInitialPrompt(TTSChunkFactory.createSimpleTTSChunks(initialPrompt)); + setInitialPrompt(createSimpleTTSChunks(initialPrompt)); } if (timeoutPrompt != null){ - setTimeoutPrompt(TTSChunkFactory.createSimpleTTSChunks(timeoutPrompt)); + setTimeoutPrompt(createSimpleTTSChunks(timeoutPrompt)); } if (helpPrompt != null){ - setHelpPrompt(TTSChunkFactory.createSimpleTTSChunks(helpPrompt)); + setHelpPrompt(createSimpleTTSChunks(helpPrompt)); } // things to do @@ -398,4 +399,15 @@ public class ChoiceSet { return clonedHelpItems; } + private Vector createSimpleTTSChunks(String simple) { + if (simple == null) { + return null; + } + Vector chunks = new Vector(); + TTSChunk chunk = new TTSChunk(); + chunk.setType(SpeechCapabilities.TEXT); + chunk.setText(simple); + chunks.add(chunk); + return chunks; + } } -- cgit v1.2.1 From efc3a92d92c09182084b72a0ac1dcbbbdb5fd383 Mon Sep 17 00:00:00 2001 From: Bilal Alsharifi Date: Wed, 2 Sep 2020 17:10:10 -0400 Subject: Remove deprecated TTSChunkFactory class --- .../java/com/smartdevicelink/test/TestValues.java | 7 +- .../test/proxy/TTSChunkFactoryTests.java | 100 --------------------- .../managers/screen/choiceset/ChoiceSet.java | 7 +- .../com/smartdevicelink/proxy/TTSChunkFactory.java | 71 --------------- 4 files changed, 5 insertions(+), 180 deletions(-) delete mode 100644 android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/TTSChunkFactoryTests.java delete mode 100644 base/src/main/java/com/smartdevicelink/proxy/TTSChunkFactory.java diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/TestValues.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/TestValues.java index bd82d2d5d..b609015b5 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/TestValues.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/TestValues.java @@ -16,7 +16,6 @@ import com.smartdevicelink.managers.screen.menu.VoiceCommand; import com.smartdevicelink.managers.screen.menu.VoiceCommandSelectionListener; import com.smartdevicelink.protocol.SdlProtocol; import com.smartdevicelink.protocol.enums.FunctionID; -import com.smartdevicelink.proxy.TTSChunkFactory; import com.smartdevicelink.proxy.rpc.AppInfo; import com.smartdevicelink.proxy.rpc.AppServiceCapability; import com.smartdevicelink.proxy.rpc.AppServiceData; @@ -494,7 +493,7 @@ public class TestValues { public static final List GENERAL_CLIMATECONTROLCAPABILITIES_LIST = new ArrayList(1); public static final List GENERAL_RADIOCONTROLCAPABILITIES_LIST = new ArrayList(1); public static final Vector GENERAL_VECTOR_STRING = new Vector<>(Arrays.asList(new String[] { "a", "b"})); - public static final Vector GENERAL_VECTOR_TTS_CHUNKS = new Vector<>(Arrays.asList(TTSChunkFactory.createChunk(SpeechCapabilities.TEXT, "Welcome to the jungle"))); + public static final Vector GENERAL_VECTOR_TTS_CHUNKS = new Vector<>(Arrays.asList(new TTSChunk("Welcome to the jungle", SpeechCapabilities.TEXT))); public static final List GENERAL_SEATCONTROLCAPABILITIES_LIST = new ArrayList(1); public static final List GENERAL_EQUALIZERSETTINGS_LIST = new ArrayList(1); public static final List GENERAL_LIGHTCAPABILITIES_LIST = new ArrayList(1); @@ -794,8 +793,8 @@ public class TestValues { GENERAL_VRHELPITEM.setPosition(100); GENERAL_VRHELPITEM_LIST.add(GENERAL_VRHELPITEM); - GENERAL_TTSCHUNK_LIST.add(TTSChunkFactory.createChunk(SpeechCapabilities.TEXT, "Welcome to the jungle")); - GENERAL_TTSCHUNK_LIST.add(TTSChunkFactory.createChunk(SpeechCapabilities.TEXT, "Say a command")); + GENERAL_TTSCHUNK_LIST.add(new TTSChunk("Welcome to the jungle", SpeechCapabilities.TEXT)); + GENERAL_TTSCHUNK_LIST.add(new TTSChunk("Say a command", SpeechCapabilities.TEXT)); GENERAL_KEYBOARDPROPERTIES.setAutoCompleteText(GENERAL_STRING); GENERAL_KEYBOARDPROPERTIES.setKeypressMode(KeypressMode.SINGLE_KEYPRESS); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/TTSChunkFactoryTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/TTSChunkFactoryTests.java deleted file mode 100644 index ad1976cb1..000000000 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/TTSChunkFactoryTests.java +++ /dev/null @@ -1,100 +0,0 @@ -package com.smartdevicelink.test.proxy; - -import com.smartdevicelink.proxy.TTSChunkFactory; -import com.smartdevicelink.proxy.rpc.TTSChunk; -import com.smartdevicelink.proxy.rpc.enums.SpeechCapabilities; -import com.smartdevicelink.test.TestValues; - -import junit.framework.TestCase; - -import java.util.Vector; - -/** - * This is a unit test class for the SmartDeviceLink library project class : - * {@link com.smartdevicelink.proxy.TTSChunkFactory} - */ -public class TTSChunkFactoryTests extends TestCase { - - private TTSChunk testChunk; - - /** - * This is a unit test for the following methods : - * {@link com.smartdevicelink.proxy.TTSChunkFactory#createChunk(SpeechCapabilities, String)} - */ - public void testCreateChunk () { - // Valid Tests - SpeechCapabilities testType = SpeechCapabilities.TEXT; - testChunk = TTSChunkFactory.createChunk(testType, TestValues.GENERAL_STRING); - assertNotNull(TestValues.NOT_NULL, testChunk); - assertEquals(TestValues.MATCH, testType, testChunk.getType()); - assertEquals(TestValues.MATCH, TestValues.GENERAL_STRING, testChunk.getText()); - - testType = SpeechCapabilities.SILENCE; - testChunk = TTSChunkFactory.createChunk(testType, TestValues.GENERAL_STRING); - assertNotNull(TestValues.NOT_NULL, testChunk); - assertEquals(TestValues.MATCH, testType, testChunk.getType()); - assertEquals(TestValues.MATCH, TestValues.GENERAL_STRING, testChunk.getText()); - - testType = SpeechCapabilities.SAPI_PHONEMES; - testChunk = TTSChunkFactory.createChunk(testType, TestValues.GENERAL_STRING); - assertNotNull(TestValues.NOT_NULL, testChunk); - assertEquals(TestValues.MATCH, testType, testChunk.getType()); - assertEquals(TestValues.MATCH, TestValues.GENERAL_STRING, testChunk.getText()); - - testType = SpeechCapabilities.PRE_RECORDED; - testChunk = TTSChunkFactory.createChunk(testType, TestValues.GENERAL_STRING); - assertNotNull(TestValues.NOT_NULL, testChunk); - assertEquals(TestValues.MATCH, testType, testChunk.getType()); - assertEquals(TestValues.MATCH, TestValues.GENERAL_STRING, testChunk.getText()); - - testType = SpeechCapabilities.LHPLUS_PHONEMES; - testChunk = TTSChunkFactory.createChunk(testType, TestValues.GENERAL_STRING); - assertNotNull(TestValues.NOT_NULL, testChunk); - assertEquals(TestValues.MATCH, testType, testChunk.getType()); - assertEquals(TestValues.MATCH, TestValues.GENERAL_STRING, testChunk.getText()); - - // Invalid/Null Tests - testChunk = TTSChunkFactory.createChunk(null, null); - assertNotNull(TestValues.NOT_NULL, testChunk); - assertNull(TestValues.NULL, testChunk.getType()); - assertNull(TestValues.NULL, testChunk.getText()); - } - - /** - * This is a unit test for the following methods : - * {@link com.smartdevicelink.proxy.TTSChunkFactory#createSimpleTTSChunks(String)} - */ - public void testCreateSimpleTTSChunks () { - // Test Values - Vector testChunks; - testChunks = TTSChunkFactory.createSimpleTTSChunks(TestValues.GENERAL_STRING); - - // Valid Tests - assertNotNull(TestValues.NOT_NULL, testChunks); - assertEquals(TestValues.MATCH, SpeechCapabilities.TEXT, testChunks.get(0).getType()); - assertEquals(TestValues.MATCH, TestValues.GENERAL_STRING, testChunks.get(0).getText()); - - // Invalid/Null Tests - testChunks = TTSChunkFactory.createSimpleTTSChunks(null); - assertNull(TestValues.NULL, testChunks); - } - - /** - * This is a unit test for the following methods : - * {@link com.smartdevicelink.proxy.TTSChunkFactory#createPrerecordedTTSChunks(String)} - */ - public void testCreatePrerecordedTTSChunks () { - // Test Values - Vector testChunks; - testChunks = TTSChunkFactory.createPrerecordedTTSChunks(TestValues.GENERAL_STRING); - - // Valid Tests - assertNotNull(TestValues.NOT_NULL, testChunks); - assertEquals(TestValues.MATCH, SpeechCapabilities.PRE_RECORDED, testChunks.get(0).getType()); - assertEquals(TestValues.MATCH, TestValues.GENERAL_STRING, testChunks.get(0).getText()); - - // Invalid/Null Tests - testChunks = TTSChunkFactory.createPrerecordedTTSChunks(null); - assertNull(TestValues.NULL, testChunks); - } -} \ No newline at end of file diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSet.java b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSet.java index 668f7da77..3ada6368d 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSet.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSet.java @@ -403,11 +403,8 @@ public class ChoiceSet { if (simple == null) { return null; } - Vector chunks = new Vector(); - TTSChunk chunk = new TTSChunk(); - chunk.setType(SpeechCapabilities.TEXT); - chunk.setText(simple); - chunks.add(chunk); + Vector chunks = new Vector<>(); + chunks.add(new TTSChunk(simple, SpeechCapabilities.TEXT)); return chunks; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/TTSChunkFactory.java b/base/src/main/java/com/smartdevicelink/proxy/TTSChunkFactory.java deleted file mode 100644 index d338a8f19..000000000 --- a/base/src/main/java/com/smartdevicelink/proxy/TTSChunkFactory.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ -package com.smartdevicelink.proxy; - -import com.smartdevicelink.proxy.rpc.TTSChunk; -import com.smartdevicelink.proxy.rpc.enums.SpeechCapabilities; - -import java.util.Vector; - -@Deprecated -public class TTSChunkFactory { - - public static TTSChunk createChunk(SpeechCapabilities type, String text) { - TTSChunk ret = new TTSChunk(); - ret.setType(type); - ret.setText(text); - return ret; - } - - public static Vector createSimpleTTSChunks(String simple) { - if (simple == null) { - return null; - } - - Vector chunks = new Vector(); - - TTSChunk chunk = createChunk(SpeechCapabilities.TEXT, simple); - chunks.add(chunk); - return chunks; - } - - public static Vector createPrerecordedTTSChunks(String prerecorded) { - if (prerecorded == null) { - return null; - } - - Vector chunks = new Vector(); - TTSChunk chunk = createChunk(SpeechCapabilities.PRE_RECORDED, prerecorded); - chunks.add(chunk); - return chunks; - } -} -- cgit v1.2.1 From 262fadd61a3051c7b511774916f27523f68946d6 Mon Sep 17 00:00:00 2001 From: Bilal Alsharifi Date: Wed, 2 Sep 2020 17:22:45 -0400 Subject: Update SdlService to remove the usage of TTSChunkFactory --- .../main/java/com/sdl/hellosdlandroid/SdlService.java | 18 ++++++++++++++---- .../main/java/com/smartdevicelink/java/SdlService.java | 16 ++++++++++++---- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlService.java b/android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlService.java index 893525b97..4818423ab 100755 --- a/android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlService.java +++ b/android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlService.java @@ -26,12 +26,12 @@ import com.smartdevicelink.managers.screen.menu.VoiceCommand; import com.smartdevicelink.managers.screen.menu.VoiceCommandSelectionListener; import com.smartdevicelink.protocol.enums.FunctionID; import com.smartdevicelink.proxy.RPCNotification; -import com.smartdevicelink.proxy.TTSChunkFactory; import com.smartdevicelink.proxy.rpc.Alert; import com.smartdevicelink.proxy.rpc.OnButtonEvent; import com.smartdevicelink.proxy.rpc.OnButtonPress; import com.smartdevicelink.proxy.rpc.OnHMIStatus; import com.smartdevicelink.proxy.rpc.Speak; +import com.smartdevicelink.proxy.rpc.TTSChunk; import com.smartdevicelink.proxy.rpc.enums.AppHMIType; import com.smartdevicelink.proxy.rpc.enums.ButtonName; import com.smartdevicelink.proxy.rpc.enums.FileType; @@ -40,6 +40,7 @@ import com.smartdevicelink.proxy.rpc.enums.InteractionMode; import com.smartdevicelink.proxy.rpc.enums.Language; import com.smartdevicelink.proxy.rpc.enums.MenuLayout; import com.smartdevicelink.proxy.rpc.enums.PredefinedWindows; +import com.smartdevicelink.proxy.rpc.enums.SpeechCapabilities; import com.smartdevicelink.proxy.rpc.enums.TriggerSource; import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener; import com.smartdevicelink.transport.BaseTransportConfig; @@ -237,7 +238,7 @@ public class SdlService extends Service { break; } if (isNeedUpdate) { - return new LifecycleConfigurationUpdate(appName, null, TTSChunkFactory.createSimpleTTSChunks(ttsName), null); + return new LifecycleConfigurationUpdate(appName, null, createSimpleTTSChunks(ttsName), null); } else { return null; } @@ -352,7 +353,7 @@ public class SdlService extends Service { * Will speak a sample welcome message */ private void performWelcomeSpeak(){ - sdlManager.sendRPC(new Speak(TTSChunkFactory.createSimpleTTSChunks(WELCOME_SPEAK))); + sdlManager.sendRPC(new Speak(createSimpleTTSChunks(WELCOME_SPEAK))); } /** @@ -414,7 +415,7 @@ public class SdlService extends Service { sdlManager.getScreenManager().setTextField2(""); sdlManager.getScreenManager().commit(null); - sdlManager.sendRPC(new Speak(TTSChunkFactory.createSimpleTTSChunks(TEST_COMMAND_NAME))); + sdlManager.sendRPC(new Speak(createSimpleTTSChunks(TEST_COMMAND_NAME))); } private void showAlert(String text){ @@ -450,4 +451,13 @@ public class SdlService extends Service { sdlManager.getScreenManager().presentChoiceSet(choiceSet, InteractionMode.MANUAL_ONLY); } } + + private Vector createSimpleTTSChunks(String simple) { + if (simple == null) { + return null; + } + Vector chunks = new Vector<>(); + chunks.add(new TTSChunk(simple, SpeechCapabilities.TEXT)); + return chunks; + } } diff --git a/hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java b/hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java index 0c1b87c6a..0abd4ad81 100644 --- a/hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java +++ b/hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java @@ -47,7 +47,6 @@ import com.smartdevicelink.managers.screen.menu.VoiceCommand; import com.smartdevicelink.managers.screen.menu.VoiceCommandSelectionListener; import com.smartdevicelink.protocol.enums.FunctionID; import com.smartdevicelink.proxy.RPCNotification; -import com.smartdevicelink.proxy.TTSChunkFactory; import com.smartdevicelink.proxy.rpc.*; import com.smartdevicelink.proxy.rpc.enums.*; import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener; @@ -170,7 +169,7 @@ public class SdlService { break; } if (isNeedUpdate) { - return new LifecycleConfigurationUpdate(appName, null, TTSChunkFactory.createSimpleTTSChunks(ttsName), null); + return new LifecycleConfigurationUpdate(appName, null, createSimpleTTSChunks(ttsName), null); } else { return null; } @@ -302,7 +301,7 @@ public class SdlService { * Will speak a sample welcome message */ private void performWelcomeSpeak(){ - sdlManager.sendRPC(new Speak(TTSChunkFactory.createSimpleTTSChunks(WELCOME_SPEAK))); + sdlManager.sendRPC(new Speak(createSimpleTTSChunks(WELCOME_SPEAK))); } /** @@ -365,7 +364,7 @@ public class SdlService { sdlManager.getScreenManager().setTextField2(""); sdlManager.getScreenManager().commit(null); - sdlManager.sendRPC(new Speak(TTSChunkFactory.createSimpleTTSChunks(TEST_COMMAND_NAME))); + sdlManager.sendRPC(new Speak(createSimpleTTSChunks(TEST_COMMAND_NAME))); } private void showAlert(String text){ @@ -405,4 +404,13 @@ public class SdlService { sdlManager.getScreenManager().presentChoiceSet(choiceSet, InteractionMode.MANUAL_ONLY); } } + + private Vector createSimpleTTSChunks(String simple) { + if (simple == null) { + return null; + } + Vector chunks = new Vector<>(); + chunks.add(new TTSChunk(simple, SpeechCapabilities.TEXT)); + return chunks; + } } -- cgit v1.2.1 From 5c780fa534a917c51703bd1e93a1fdba05cc5f59 Mon Sep 17 00:00:00 2001 From: Bilal Alsharifi Date: Wed, 2 Sep 2020 17:23:13 -0400 Subject: Remove deprecated shareConnection from WebSocketServerConfig --- .../main/java/com/smartdevicelink/transport/WebSocketServerConfig.java | 1 - 1 file changed, 1 deletion(-) diff --git a/javaSE/src/main/java/com/smartdevicelink/transport/WebSocketServerConfig.java b/javaSE/src/main/java/com/smartdevicelink/transport/WebSocketServerConfig.java index 6add5ae71..23e0b25c1 100644 --- a/javaSE/src/main/java/com/smartdevicelink/transport/WebSocketServerConfig.java +++ b/javaSE/src/main/java/com/smartdevicelink/transport/WebSocketServerConfig.java @@ -46,7 +46,6 @@ public class WebSocketServerConfig extends BaseTransportConfig{ */ public WebSocketServerConfig(int port, int connectionLostTimeout){ this.port = port; - this.shareConnection = false; this.connectionLostTimeout = connectionLostTimeout; } -- cgit v1.2.1 From f055df322856937f1ff4f0c28ade5e7959f72d8f Mon Sep 17 00:00:00 2001 From: Bilal Alsharifi Date: Wed, 2 Sep 2020 17:24:02 -0400 Subject: Remove deprecated classes in proxy.callbacks package --- .../test/proxy/InternalProxyMessageTests.java | 35 ------------ .../test/rpc/notifications/OnErrorTests.java | 40 ------------- .../test/rpc/notifications/OnProxyClosedTests.java | 44 --------------- .../test/rpc/notifications/OnProxyOpenedTests.java | 29 ---------- .../proxy/callbacks/InternalProxyMessage.java | 51 ----------------- .../smartdevicelink/proxy/callbacks/OnError.java | 57 ------------------- .../proxy/callbacks/OnProxyClosed.java | 65 ---------------------- .../proxy/callbacks/OnProxyOpened.java | 40 ------------- .../proxy/callbacks/OnServiceEnded.java | 53 ------------------ .../proxy/callbacks/OnServiceNACKed.java | 53 ------------------ 10 files changed, 467 deletions(-) delete mode 100644 android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/InternalProxyMessageTests.java delete mode 100644 android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnErrorTests.java delete mode 100644 android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnProxyClosedTests.java delete mode 100644 android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnProxyOpenedTests.java delete mode 100644 base/src/main/java/com/smartdevicelink/proxy/callbacks/InternalProxyMessage.java delete mode 100644 base/src/main/java/com/smartdevicelink/proxy/callbacks/OnError.java delete mode 100644 base/src/main/java/com/smartdevicelink/proxy/callbacks/OnProxyClosed.java delete mode 100644 base/src/main/java/com/smartdevicelink/proxy/callbacks/OnProxyOpened.java delete mode 100644 base/src/main/java/com/smartdevicelink/proxy/callbacks/OnServiceEnded.java delete mode 100644 base/src/main/java/com/smartdevicelink/proxy/callbacks/OnServiceNACKed.java diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/InternalProxyMessageTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/InternalProxyMessageTests.java deleted file mode 100644 index ec64ed99d..000000000 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/InternalProxyMessageTests.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.smartdevicelink.test.proxy; - -import com.smartdevicelink.proxy.callbacks.InternalProxyMessage; -import com.smartdevicelink.test.TestValues; - -import junit.framework.TestCase; - -/** - * This is a unit test class for the SmartDeviceLink library project class : - * {@link com.smartdevicelink.proxy.callbacks.InternalProxyMessage} - */ -public class InternalProxyMessageTests extends TestCase { - - /** - * This is a unit test for the following methods : - * {@link com.smartdevicelink.proxy.callbacks.InternalProxyMessage#InternalProxyMessage(String)} - */ - public void testValues () { - // Valid Tests - String test = "functionName"; - InternalProxyMessage testIPM = new InternalProxyMessage(test); - assertEquals(TestValues.MATCH, test, testIPM.getFunctionName()); - - test = "OnProxyError"; - assertEquals(TestValues.MATCH, test, InternalProxyMessage.OnProxyError); - test = "OnProxyOpened"; - assertEquals(TestValues.MATCH, test, InternalProxyMessage.OnProxyOpened); - test = "OnProxyClosed"; - assertEquals(TestValues.MATCH, test, InternalProxyMessage.OnProxyClosed); - - // Invalid/Null Tests - testIPM = new InternalProxyMessage(null); - assertNull(TestValues.NULL, testIPM.getFunctionName()); - } -} \ No newline at end of file diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnErrorTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnErrorTests.java deleted file mode 100644 index f0c542894..000000000 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnErrorTests.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.smartdevicelink.test.rpc.notifications; - -import com.smartdevicelink.proxy.callbacks.InternalProxyMessage; -import com.smartdevicelink.proxy.callbacks.OnError; -import com.smartdevicelink.test.TestValues; - -import junit.framework.TestCase; - -import org.junit.Test; - -/** - * This is a unit test class for the SmartDeviceLink library project class : - * {@link com.smartdevicelink.proxy.callbacks.OnError} - */ -public class OnErrorTests extends TestCase { - - /** - * This is a unit test for the following methods : - * {@link com.smartdevicelink.proxy.callbacks.OnError#OnError()} - * {@link com.smartdevicelink.proxy.callbacks.OnError#OnError(String, Exception)} - */ - @Test - public void testValues () { - // Valid Tests - OnError testOnError = new OnError(); - assertEquals(TestValues.MATCH, InternalProxyMessage.OnProxyError, testOnError.getFunctionName()); - - Exception testE = new Exception(); - testOnError = new OnError(TestValues.GENERAL_STRING, testE); - assertEquals(TestValues.MATCH, InternalProxyMessage.OnProxyError, testOnError.getFunctionName()); - assertEquals(TestValues.MATCH, TestValues.GENERAL_STRING, testOnError.getInfo()); - assertEquals(TestValues.MATCH, testE, testOnError.getException()); - - // Invalid/Null Tests - testOnError = new OnError(null, null); - assertEquals(TestValues.MATCH, InternalProxyMessage.OnProxyError, testOnError.getFunctionName()); - assertNull(TestValues.NULL, testOnError.getInfo()); - assertNull(TestValues.NULL, testOnError.getException()); - } -} \ No newline at end of file diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnProxyClosedTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnProxyClosedTests.java deleted file mode 100644 index 1ef639029..000000000 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnProxyClosedTests.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.smartdevicelink.test.rpc.notifications; - -import com.smartdevicelink.proxy.callbacks.InternalProxyMessage; -import com.smartdevicelink.proxy.callbacks.OnProxyClosed; -import com.smartdevicelink.proxy.rpc.enums.SdlDisconnectedReason; -import com.smartdevicelink.test.TestValues; - -import junit.framework.TestCase; - -import org.junit.Test; - -/** - * This is a unit test class for the SmartDeviceLink library project class : - * {@link com.smartdevicelink.proxy.callbacks.OnProxyClosed} - */ -public class OnProxyClosedTests extends TestCase { - - /** - * This is a unit test for the following methods : - * {@link com.smartdevicelink.proxy.callbacks.OnProxyClosed#OnProxyClosed()} - * {@link com.smartdevicelink.proxy.callbacks.OnProxyClosed#OnProxyClosed(String, Exception, SdlDisconnectedReason)} - */ - @Test - public void testValues () { - // Valid Tests - OnProxyClosed testOnProxyClosed = new OnProxyClosed(); - assertEquals(TestValues.MATCH, InternalProxyMessage.OnProxyClosed, testOnProxyClosed.getFunctionName()); - - Exception testE = new Exception(); - SdlDisconnectedReason testReason = SdlDisconnectedReason.DEFAULT; - testOnProxyClosed = new OnProxyClosed(TestValues.GENERAL_STRING, testE, testReason); - assertEquals(TestValues.MATCH, InternalProxyMessage.OnProxyClosed, testOnProxyClosed.getFunctionName()); - assertEquals(TestValues.MATCH, TestValues.GENERAL_STRING, testOnProxyClosed.getInfo()); - assertEquals(TestValues.MATCH, testE, testOnProxyClosed.getException()); - assertEquals(TestValues.MATCH, testReason, testOnProxyClosed.getReason()); - - // Invalid/Null Tests - testOnProxyClosed = new OnProxyClosed(null, null, null); - assertEquals(TestValues.MATCH, InternalProxyMessage.OnProxyClosed, testOnProxyClosed.getFunctionName()); - assertNull(TestValues.NULL, testOnProxyClosed.getInfo()); - assertNull(TestValues.NULL, testOnProxyClosed.getException()); - assertNull(TestValues.NULL, testOnProxyClosed.getReason()); - } -} \ No newline at end of file diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnProxyOpenedTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnProxyOpenedTests.java deleted file mode 100644 index 3f76fd4cb..000000000 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnProxyOpenedTests.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.smartdevicelink.test.rpc.notifications; - -import com.smartdevicelink.proxy.callbacks.InternalProxyMessage; -import com.smartdevicelink.proxy.callbacks.OnProxyOpened; -import com.smartdevicelink.test.TestValues; - -import junit.framework.TestCase; - -import org.junit.Test; - -/** - * This is a unit test class for the SmartDeviceLink library project class : - * {@link com.smartdevicelink.proxy.callbacks.OnProxyOpened} - */ -public class OnProxyOpenedTests extends TestCase { - - - /** - * This is a unit test for the following methods : - * {@link com.smartdevicelink.proxy.callbacks.OnProxyOpened#OnProxyOpened()} - * {@link com.smartdevicelink.proxy.callbacks.OnProxyOpened#getFunctionName()} - */ - @Test - public void testMethods () { - OnProxyOpened testOnProxyOpened = new OnProxyOpened(); - assertNotNull(TestValues.NOT_NULL, testOnProxyOpened); - assertEquals(TestValues.MATCH, InternalProxyMessage.OnProxyOpened, testOnProxyOpened.getFunctionName()); - } -} \ No newline at end of file diff --git a/base/src/main/java/com/smartdevicelink/proxy/callbacks/InternalProxyMessage.java b/base/src/main/java/com/smartdevicelink/proxy/callbacks/InternalProxyMessage.java deleted file mode 100644 index f05e3d49f..000000000 --- a/base/src/main/java/com/smartdevicelink/proxy/callbacks/InternalProxyMessage.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ -package com.smartdevicelink.proxy.callbacks; - -@Deprecated -public class InternalProxyMessage { - private String _functionName; - public static final String OnProxyError = "OnProxyError"; - public static final String OnProxyOpened = "OnProxyOpened"; - public static final String OnProxyClosed = "OnProxyClosed"; - public static final String OnServiceEnded = "OnServiceEnded"; - public static final String OnServiceNACKed = "OnServiceNACKed"; - - public InternalProxyMessage(String functionName) { - //this(functionName, null, null); - this._functionName = functionName; - } - - public String getFunctionName() { - return _functionName; - } -} \ No newline at end of file diff --git a/base/src/main/java/com/smartdevicelink/proxy/callbacks/OnError.java b/base/src/main/java/com/smartdevicelink/proxy/callbacks/OnError.java deleted file mode 100644 index 3992f4a31..000000000 --- a/base/src/main/java/com/smartdevicelink/proxy/callbacks/OnError.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ -package com.smartdevicelink.proxy.callbacks; - -@Deprecated -public class OnError extends InternalProxyMessage { - - private String _info; - private Exception _e; - - public OnError() { - super(InternalProxyMessage.OnProxyError); - } - - public OnError(String info, Exception e) { - super(InternalProxyMessage.OnProxyError); - this._info = info; - this._e = e; - } - - public String getInfo() { - return _info; - } - - public Exception getException() { - return _e; - } -} \ No newline at end of file diff --git a/base/src/main/java/com/smartdevicelink/proxy/callbacks/OnProxyClosed.java b/base/src/main/java/com/smartdevicelink/proxy/callbacks/OnProxyClosed.java deleted file mode 100644 index 27c621a07..000000000 --- a/base/src/main/java/com/smartdevicelink/proxy/callbacks/OnProxyClosed.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ -package com.smartdevicelink.proxy.callbacks; - -import com.smartdevicelink.proxy.rpc.enums.SdlDisconnectedReason; - -@Deprecated -public class OnProxyClosed extends InternalProxyMessage { - - private String _info; - private Exception _e; - private SdlDisconnectedReason _reason; - - public OnProxyClosed() { - super(InternalProxyMessage.OnProxyClosed); - } - - public OnProxyClosed(String info, Exception e, SdlDisconnectedReason reason) { - super(InternalProxyMessage.OnProxyClosed); - this._info = info; - this._e = e; - this._reason = reason; - } - - public String getInfo() { - return _info; - } - - public SdlDisconnectedReason getReason() { - return _reason; - } - - public Exception getException() { - return _e; - } -} \ No newline at end of file diff --git a/base/src/main/java/com/smartdevicelink/proxy/callbacks/OnProxyOpened.java b/base/src/main/java/com/smartdevicelink/proxy/callbacks/OnProxyOpened.java deleted file mode 100644 index f56eff415..000000000 --- a/base/src/main/java/com/smartdevicelink/proxy/callbacks/OnProxyOpened.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ -package com.smartdevicelink.proxy.callbacks; - -@Deprecated -public class OnProxyOpened extends InternalProxyMessage { - - public OnProxyOpened() { - super(InternalProxyMessage.OnProxyOpened); - } -} diff --git a/base/src/main/java/com/smartdevicelink/proxy/callbacks/OnServiceEnded.java b/base/src/main/java/com/smartdevicelink/proxy/callbacks/OnServiceEnded.java deleted file mode 100644 index cad213ca8..000000000 --- a/base/src/main/java/com/smartdevicelink/proxy/callbacks/OnServiceEnded.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ -package com.smartdevicelink.proxy.callbacks; - -import com.smartdevicelink.protocol.enums.SessionType; - -@Deprecated -public class OnServiceEnded extends InternalProxyMessage { - private SessionType sessionType; - - public OnServiceEnded() { - super(InternalProxyMessage.OnServiceEnded); - } - - public OnServiceEnded(SessionType sessionType) { - super(InternalProxyMessage.OnServiceEnded); - this.sessionType = sessionType; - } - - public SessionType getSessionType() { - return this.sessionType; - } - -} diff --git a/base/src/main/java/com/smartdevicelink/proxy/callbacks/OnServiceNACKed.java b/base/src/main/java/com/smartdevicelink/proxy/callbacks/OnServiceNACKed.java deleted file mode 100644 index 6f719f615..000000000 --- a/base/src/main/java/com/smartdevicelink/proxy/callbacks/OnServiceNACKed.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ -package com.smartdevicelink.proxy.callbacks; - -import com.smartdevicelink.protocol.enums.SessionType; - -@Deprecated -public class OnServiceNACKed extends InternalProxyMessage { - private SessionType sessionType; - - public OnServiceNACKed() { - super(InternalProxyMessage.OnServiceNACKed); - } - - public OnServiceNACKed(SessionType sessionType) { - super(InternalProxyMessage.OnServiceNACKed); - this.sessionType = sessionType; - } - - public SessionType getSessionType() { - return this.sessionType; - } - -} -- cgit v1.2.1 From 434b09975f0012fa1f8b8b3efde6b5068b407efd Mon Sep 17 00:00:00 2001 From: Bilal Alsharifi Date: Wed, 2 Sep 2020 17:29:30 -0400 Subject: Remove deprecated classes in proxy.constants package --- .../smartdevicelink/proxy/constants/Jingles.java | 46 -- .../com/smartdevicelink/proxy/constants/Names.java | 537 --------------------- 2 files changed, 583 deletions(-) delete mode 100644 base/src/main/java/com/smartdevicelink/proxy/constants/Jingles.java delete mode 100644 base/src/main/java/com/smartdevicelink/proxy/constants/Names.java diff --git a/base/src/main/java/com/smartdevicelink/proxy/constants/Jingles.java b/base/src/main/java/com/smartdevicelink/proxy/constants/Jingles.java deleted file mode 100644 index 73f7adeeb..000000000 --- a/base/src/main/java/com/smartdevicelink/proxy/constants/Jingles.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ -package com.smartdevicelink.proxy.constants; - -@Deprecated -public class Jingles { - public static final String POSITIVE_JINGLE = "POSITIVE_JINGLE"; - - public static final String NEGATIVE_JINGLE = "NEGATIVE_JINGLE"; - - public static final String INITIAL_JINGLE = "INITIAL_JINGLE"; - - public static final String LISTEN_JINGLE = "LISTEN_JINGLE"; - - public static final String HELP_JINGLE = "HELP_JINGLE"; - -} \ No newline at end of file diff --git a/base/src/main/java/com/smartdevicelink/proxy/constants/Names.java b/base/src/main/java/com/smartdevicelink/proxy/constants/Names.java deleted file mode 100644 index fe63db715..000000000 --- a/base/src/main/java/com/smartdevicelink/proxy/constants/Names.java +++ /dev/null @@ -1,537 +0,0 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ -package com.smartdevicelink.proxy.constants; - -@Deprecated -public class Names { - public static final String request = "request"; - public static final String response = "response"; - public static final String notification = "notification"; - public static final String function_name = "name"; - public static final String parameters = "parameters"; - public static final String bulkData = "bulkData"; - - public static final String RegisterAppInterface = "RegisterAppInterface"; - public static final String UnregisterAppInterface = "UnregisterAppInterface"; - public static final String Alert = "Alert"; - public static final String Show = "Show"; - public static final String Speak = "Speak"; - public static final String AddCommand = "AddCommand"; - public static final String DeleteCommand = "DeleteCommand"; - public static final String AddSubMenu = "AddSubMenu"; - public static final String DeleteSubMenu = "DeleteSubMenu"; - public static final String CreateInteractionChoiceSet = "CreateInteractionChoiceSet"; - public static final String DeleteInteractionChoiceSet = "DeleteInteractionChoiceSet"; - public static final String PerformInteraction = "PerformInteraction"; - public static final String DialNumber = "DialNumber"; - public static final String EncodedSyncPData = "EncodedSyncPData"; - public static final String SyncPData = "SyncPData"; - public static final String SubscribeButton = "SubscribeButton"; - public static final String UnsubscribeButton = "UnsubscribeButton"; - public static final String SubscribeVehicleData = "SubscribeVehicleData"; - public static final String UnsubscribeVehicleData = "UnsubscribeVehicleData"; - public static final String SetMediaClockTimer = "SetMediaClockTimer"; - public static final String SetGlobalProperties = "SetGlobalProperties"; - public static final String GenericResponse = "GenericResponse"; - public static final String ScrollableMessage = "ScrollableMessage"; - public static final String GetDID = "GetDID"; - public static final String GetDTCs = "GetDTCs"; - public static final String DiagnosticMessage = "DiagnosticMessage"; - public static final String SystemRequest = "SystemRequest"; - public static final String ReadDID = "ReadDID"; - public static final String OnVehicleData = "OnVehicleData"; - public static final String GetFile = "GetFile"; - public static final String PutFile = "PutFile"; - public static final String DeleteFile = "DeleteFile"; - public static final String ListFiles = "ListFiles"; - public static final String EndAudioCapture = "EndAudioCapture"; - public static final String GetVehicleData = "GetVehicleData"; - public static final String ResetGlobalProperties = "ResetGlobalProperties"; - public static final String PerformAudioCapture = "PerformAudioCapture"; - public static final String SetAppIcon = "SetAppIcon"; - public static final String ChangeRegistration = "ChangeRegistration"; - public static final String SetDisplayLayout = "SetDisplayLayout"; - public static final String keypressMode = "keypressMode"; - public static final String keyboardLayout = "keyboardLayout"; - public static final String limitedCharacterList = "limitedCharacterList"; - public static final String autoCompleteText = "autoCompleteText"; - public static final String OnLanguageChange = "OnLanguageChange"; - public static final String hmiDisplayLanguage = "hmiDisplayLanguage"; - public static final String displayLayout = "displayLayout"; - public static final String ttsName = "ttsName"; - public static final String hmiDisplayLanguageDesired = "hmiDisplayLanguageDesired"; - public static final String appHMIType = "appHMIType"; - public static final String hashID = "hashID"; - public static final String appID = "appID"; - public static final String vrHelpTitle = "vrHelpTitle"; - public static final String graphic = "graphic"; - public static final String customPresets = "customPresets"; - public static final String softButtonCapabilities = "softButtonCapabilities"; - public static final String presetBankCapabilities = "presetBankCapabilities"; - public static final String vehicleType = "vehicleType"; - public static final String make = "make"; - public static final String model = "model"; - public static final String modelYear = "modelYear"; - public static final String trim = "trim"; - public static final String allowed = "allowed"; - public static final String userDisallowed = "userDisallowed"; - public static final String rpcName = "rpcName"; - public static final String hmiPermissions = "hmiPermissions"; - public static final String parameterPermissions = "parameterPermissions"; - public static final String permissionItem = "permissionItem"; - public static final String numTicks = "numTicks"; - public static final String sliderHeader = "sliderHeader"; - public static final String sliderFooter = "sliderFooter"; - public static final String PerformAudioPassThru = "PerformAudioPassThru"; - public static final String PerformAudioPassThruResponse = "PerformAudioPassThruResponse"; - public static final String EndAudioPassThru = "EndAudioPassThru"; - public static final String EndAudioPassThruResponse = "EndAudioPassThruResponse"; - public static final String OnAudioPassThru = "OnAudioPassThru"; - public static final String ShowConstantTBT = "ShowConstantTBT"; - public static final String AlertManeuver = "AlertManeuver"; - public static final String UpdateTurnList = "UpdateTurnList"; - - public static final String OnCommand = "OnCommand"; - public static final String OnDataPublished = "OnDataPublished"; - public static final String OnButtonPress = "OnButtonPress"; - public static final String OnButtonEvent = "OnButtonEvent"; - public static final String OnHMIStatus = "OnHMIStatus"; - public static final String OnTBTClientState = "OnTBTClientState"; - public static final String OnEncodedSyncPData = "OnEncodedSyncPData"; - public static final String onEncodedSyncPDataResponse = "onEncodedSyncPDataResponse"; - public static final String OnSyncPData = "OnSyncPData"; - public static final String onOnSyncPData = "onOnSyncPData"; - public static final String OnDriverDistraction = "OnDriverDistraction"; - public static final String OnAppInterfaceUnregistered = "OnAppInterfaceUnregistered"; - public static final String OnKeyboardInput = "OnKeyboardInput"; - public static final String OnTouchEvent = "OnTouchEvent"; - public static final String OnSystemRequest = "OnSystemRequest"; - public static final String OnHashChange = "OnHashChange"; - public static final String OnProxyClosed = "OnProxyClosed"; - public static final String OnProxyError = "OnProxyError"; - public static final String OnProxyOpened = "OnProxyOpened"; - public static final String OnProxyUnusable = "OnProxyUnusable"; - public static final String OnHMILevelChange = "OnHMILevelChange"; - public static final String OnSdlChoiceChosen = "OnSdlChoiceChosen"; - public static final String OnPermissionsChange = "OnPermissionsChange"; - public static final String OnScreenPresetsAvailable = "OnScreenPresetsAvailable"; - public static final String isHighlighted = "isHighlighted"; - public static final String softButtonID = "softButtonID"; - public static final String fileType = "fileType"; - public static final String url = "url"; - public static final String requestType = "requestType"; - public static final String fileName = "fileName"; - public static final String persistentFile = "persistentFile"; - public static final String spaceAvailable = "spaceAvailable"; - public static final String filenames = "filenames"; - public static final String cmdIcon = "cmdIcon"; - public static final String Slider = "Slider"; - public static final String sliderPosition = "sliderPosition"; - public static final String samplingRate = "samplingRate"; - public static final String audioType = "audioType"; - public static final String satRadioESN = "satRadioESN"; - public static final String dtc = "dtc"; - public static final String tryAgainTime = "tryAgainTime"; - - public static final String success = "success"; - public static final String resultCode = "resultCode"; - public static final String info = "info"; - - public static final String payload = "payload"; - public static final String reason = "reason"; - public static final String state = "state"; - public static final String cmdID = "cmdID"; - public static final String menuParams = "menuParams"; - public static final String parentID = "parentID"; - public static final String position = "position"; - public static final String menuName = "menuName"; - public static final String vrCommands = "vrCommands"; - public static final String language = "language"; - public static final String languageDesired = "languageDesired"; - public static final String triggerSource = "triggerSource"; - public static final String subscriptionType = "subscriptionType"; - public static final String data = "data"; - public static final String event = "event"; - public static final String correlationID = "correlationID"; - public static final String sdlMsgVersion = "syncMsgVersion"; - public static final String deviceInfo = "deviceInfo"; - public static final String majorVersion = "majorVersion"; - public static final String minorVersion = "minorVersion"; - public static final String appName = "appName"; - public static final String ngnMediaScreenAppName = "ngnMediaScreenAppName"; - public static final String isMediaApplication = "isMediaApplication"; - public static final String vrSynonyms = "vrSynonyms"; - public static final String usesVehicleData = "usesVehicleData"; - public static final String text = "text"; - public static final String type = "type"; - public static final String ttsChunks = "ttsChunks"; - public static final String playTone = "playTone"; - public static final String duration = "duration"; - public static final String mainField1 = "mainField1"; - public static final String mainField2 = "mainField2"; - public static final String mainField3 = "mainField3"; - public static final String mainField4 = "mainField4"; - public static final String statusBar = "statusBar"; - public static final String name = "name"; - public static final String menuID = "menuID"; - public static final String longPress = "longPress"; - public static final String shortPress = "shortPress"; - public static final String buttonName = "buttonName"; - public static final String buttonPressMode = "buttonPressMode"; - public static final String buttonEventMode = "buttonEventMode"; - public static final String minutes = "minutes"; - public static final String seconds = "seconds"; - public static final String startTime = "startTime"; - public static final String endTime = "endTime"; - public static final String updateMode = "updateMode"; - public static final String mediaClock = "mediaClock"; - public static final String initialText = "initialText"; - public static final String initialPrompt = "initialPrompt"; - public static final String helpPrompt = "helpPrompt"; - public static final String timeoutPrompt = "timeoutPrompt"; - public static final String timeout = "timeout"; - public static final String choiceSet = "choiceSet"; - public static final String interactionMode = "interactionMode"; - public static final String result = "result"; - public static final String alertText1 = "alertText1"; - public static final String alertText2 = "alertText2"; - public static final String alertText3 = "alertText3"; - public static final String shortPressAvailable = "shortPressAvailable"; - public static final String longPressAvailable = "longPressAvailable"; - public static final String upDownAvailable = "upDownAvailable"; - public static final String width = "width"; - public static final String height = "height"; - public static final String resolutionWidth = "resolutionWidth"; - public static final String resolutionHeight = "resolutionHeight"; - public static final String characterSet = "characterSet"; - public static final String displayType = "displayType"; - public static final String mediaClockFormats = "mediaClockFormats"; - public static final String textFields = "textFields"; - public static final String imageFields = "imageFields"; - public static final String autoActivateID = "autoActivateID"; - public static final String vehicleDataCapabilities = "vehicleDataCapabilities"; - public static final String speechCapabilities = "speechCapabilities"; - public static final String vrCapabilities = "vrCapabilities"; - public static final String audioPassThruCapabilities = "audioPassThruCapabilities"; - public static final String buttonCapabilities = "buttonCapabilities"; - public static final String displayCapabilities = "displayCapabilities"; - public static final String hmiZoneCapabilities = "hmiZoneCapabilities"; - public static final String interactionChoiceSetID = "interactionChoiceSetID"; - public static final String interactionChoiceSetIDList = "interactionChoiceSetIDList"; - public static final String audioFileName = "audioFileName"; - public static final String gpsPositionValid = "gpsPositionValid"; - public static final String longitudeDegrees = "longitudeDegrees"; - public static final String latitudeDegrees = "latitudeDegrees"; - public static final String utcYear = "utcYear"; - public static final String utcMonth = "utcMonth"; - public static final String utcDay = "utcDay"; - public static final String utcHours = "utcHours"; - public static final String utcMinutes = "utcMinutes"; - public static final String utcSeconds = "utcSeconds"; - public static final String compassDirection = "compassDirection"; - public static final String pdop = "pdop"; - public static final String vdop = "vdop"; - public static final String hdop = "hdop"; - public static final String actual = "actual"; - public static final String satellites = "satellites"; - public static final String dimension = "dimension"; - public static final String altitude = "altitude"; - public static final String heading = "heading"; - public static final String speed = "speed"; - public static final String number = "number"; - public static final String smartDeviceLinkFileName = "syncFileName"; - public static final String localFileName = "localFileName"; - public static final String maxDuration = "maxDuration"; - public static final String timerMode = "timerMode"; - public static final String status = "status"; - public static final String pressure = "pressure"; - public static final String hours = "hours"; - public static final String rows = "rows"; - public static final String pressureTellTale = "pressureTellTale"; - public static final String leftFront = "leftFront"; - public static final String rightFront = "rightFront"; - public static final String leftRear = "leftRear"; - public static final String rightRear = "rightRear"; - public static final String innerLeftRear = "innerLeftRear"; - public static final String innerRightRear = "innerRightRear"; - public static final String VehicleData = "VehicleData"; - public static final String alignment = "alignment"; - public static final String mediaTrack = "mediaTrack"; - public static final String properties = "properties"; - public static final String choiceID = "choiceID"; - public static final String bitsPerSample = "bitsPerSample"; - public static final String hmiLevel = "hmiLevel"; - public static final String audioStreamingState = "audioStreamingState"; - public static final String systemContext = "systemContext"; - public static final String sdlChoice = "sdlChoice"; - public static final String sdlCommand = "sdlCommand"; - public static final String URL = "URL"; - public static final String Timeout = "Timeout"; - public static final String PermissionGroupName = "PermissionGroupName"; - public static final String PermissionGroupStatus = "PermissionGroupStatus"; - public static final String PermissionGroupItems = "PermissionGroupItems"; - public static final String audioPacket = "audioPacket"; - public static final String audioPassThruDisplayText1 = "audioPassThruDisplayText1"; - public static final String audioPassThruDisplayText2 = "audioPassThruDisplayText2"; - public static final String bitRate = "bitRate"; - public static final String rpm = "rpm"; - public static final String fuelLevel = "fuelLevel"; - public static final String avgFuelEconomy = "avgFuelEconomy"; - public static final String batteryVoltage = "batteryVoltage"; - public static final String externalTemperature = "externalTemperature"; - public static final String vin = "vin"; - public static final String prndl = "prndl"; - public static final String tirePressure = "tirePressure"; - public static final String batteryPackVoltage = "batteryPackVoltage"; - public static final String batteryPackCurrent = "batteryPackCurrent"; - public static final String batteryPackTemperature = "batteryPackTemperature"; - public static final String engineTorque = "engineTorque"; - public static final String odometer = "odometer"; - public static final String tripOdometer = "tripOdometer"; - public static final String genericbinary = "genericbinary"; - public static final String GPSData = "GPSData"; - public static final String gps = "gps"; - public static final String fuelLevel_State = "fuelLevel_State"; - public static final String instantFuelConsumption = "instantFuelConsumption"; - public static final String beltStatus = "beltStatus"; - public static final String bodyInformation = "bodyInformation"; - public static final String deviceStatus = "deviceStatus"; - public static final String driverBraking = "driverBraking"; - public static final String wiperStatus = "wiperStatus"; - public static final String fuelEconomy = "fuelEconomy"; - public static final String engineOilLife = "engineOilLife"; - public static final String headLampStatus = "headLampStatus"; - public static final String brakeTorque = "brakeTorque"; - public static final String turboBoost = "turboBoost"; - public static final String coolantTemp = "coolantTemp"; - public static final String airFuelRatio = "airFuelRatio"; - public static final String coolingHeadTemp = "coolingHeadTemp"; - public static final String oilTemp = "oilTemp"; - public static final String intakeAirTemp = "intakeAirTemp"; - public static final String gearShiftAdvice = "gearShiftAdvice"; - public static final String acceleration = "acceleration"; - public static final String accPedalPosition = "accPedalPosition"; - public static final String clutchPedalPosition = "clutchPedalPosition"; - public static final String reverseGearStatus = "reverseGearStatus"; - public static final String accTorque = "accTorque"; - public static final String ambientLightStatus = "ambientLightStatus"; - public static final String ambientLightSensorStatus = "ambientLightSensorStatus"; - public static final String dataType = "dataType"; - public static final String identifier = "identifier"; - public static final String statusByte = "statusByte"; - public static final String didResult = "didResult"; - public static final String ecuName = "ecuName"; - public static final String didLocation = "didLocation"; - public static final String value = "value"; - public static final String softButtonName = "softButtonName"; - public static final String imageSupported = "imageSupported"; - public static final String systemAction = "systemAction"; - public static final String image = "image"; - public static final String secondaryText = "secondaryText"; - public static final String tertiaryText = "tertiaryText"; - public static final String secondaryImage = "secondaryImage"; - public static final String imageType = "imageType"; - public static final String fileData = "fileData"; - public static final String scrollableMessageBody = "scrollableMessageBody"; - public static final String softButtons = "softButtons"; - public static final String customButtonID = "customButtonID"; - public static final String vrHelp = "vrHelp"; - public static final String interactionLayout = "interactionLayout"; - public static final String customButtonName = "customButtonName"; - public static final String navigationText = "navigationText"; - public static final String turnIcon = "turnIcon"; - public static final String nextTurnIcon = "nextTurnIcon"; - public static final String navigationText1 = "navigationText1"; - public static final String navigationText2 = "navigationText2"; - public static final String eta = "eta"; - public static final String totalDistance = "totalDistance"; - public static final String distanceToManeuver = "distanceToManeuver"; - public static final String distanceToManeuverScale = "distanceToManeuverScale"; - public static final String maneuverComplete = "maneuverComplete"; - public static final String turnList = "turnList"; - public static final String steeringWheelAngle = "steeringWheelAngle"; - public static final String menuTitle = "menuTitle"; - public static final String menuIcon = "menuIcon"; - public static final String keyboardProperties = "keyboardProperties"; - public static final String driverBeltDeployed = "driverBeltDeployed"; - public static final String passengerBeltDeployed = "passengerBeltDeployed"; - public static final String passengerBuckleBelted = "passengerBuckleBelted"; - public static final String driverBuckleBelted = "driverBuckleBelted"; - public static final String leftRow2BuckleBelted = "leftRow2BuckleBelted"; - public static final String passengerChildDetected = "passengerChildDetected"; - public static final String rightRow2BuckleBelted = "rightRow2BuckleBelted"; - public static final String middleRow2BuckleBelted = "middleRow2BuckleBelted"; - public static final String middleRow3BuckleBelted = "middleRow3BuckleBelted"; - public static final String leftRow3BuckleBelted = "leftRow3BuckleBelted"; - public static final String rightRow3BuckleBelted = "rightRow3BuckleBelted"; - public static final String rearInflatableBelted = "rearInflatableBelted"; - public static final String leftRearInflatableBelted = "leftRearInflatableBelted"; - public static final String rightRearInflatableBelted = "rightRearInflatableBelted"; - public static final String middleRow1BeltDeployed = "middleRow1BeltDeployed"; - public static final String middleRow1BuckleBelted = "middleRow1BuckleBelted"; - - public static final String graphicSupported = "graphicSupported"; - public static final String screenParams = "screenParams"; - public static final String muteAudio = "muteAudio"; - public static final String parkBrakeActive = "parkBrakeActive"; - public static final String ignitionStableStatus = "ignitionStableStatus"; - public static final String ignitionStatus = "ignitionStatus"; - public static final String driverDoorAjar = "driverDoorAjar"; - public static final String passengerDoorAjar = "passengerDoorAjar"; - public static final String rearLeftDoorAjar = "rearLeftDoorAjar"; - public static final String rearRightDoorAjar = "rearRightDoorAjar"; - public static final String systemFile = "systemFile"; - - public static final String voiceRecOn = "voiceRecOn"; - public static final String btIconOn = "btIconOn"; - public static final String callActive = "callActive"; - public static final String phoneRoaming = "phoneRoaming"; - public static final String textMsgAvailable = "textMsgAvailable"; - public static final String battLevelStatus = "battLevelStatus"; - public static final String stereoAudioOutputMuted = "stereoAudioOutputMuted"; - public static final String monoAudioOutputMuted = "monoAudioOutputMuted"; - public static final String signalLevelStatus = "signalLevelStatus"; - public static final String primaryAudioSource = "primaryAudioSource"; - public static final String eCallEventActive = "eCallEventActive"; - - public static final String fuelEconomySinceLastReset = "fuelEconomySinceLastReset"; - public static final String currentTripFuelEconomy = "currentTripFuelEconomy"; - public static final String averageTripFuelEconomy = "averageTripFuelEconomy"; - public static final String currentCycleFuelEconomy = "currentCycleFuelEconomy"; - - public static final String lightSwitchStatus = "lightSwitchStatus"; - public static final String highBeamsOn = "highBeamsOn"; - public static final String lowBeamsOn = "lowBeamsOn"; - - public static final String electricFuelConsumption = "electricFuelConsumption"; - public static final String stateOfCharge = "stateOfCharge"; - public static final String fuelMaintenanceMode = "fuelMaintenanceMode"; - public static final String distanceToEmpty = "distanceToEmpty"; - - public static final String dtcMask = "dtcMask"; - public static final String targetID = "targetID"; - public static final String messageLength = "messageLength"; - public static final String messageData = "messageData"; - public static final String messageDataResult = "messageDataResult"; - - public static final String imageTypeSupported = "imageTypeSupported"; - public static final String imageResolution = "imageResolution"; - public static final String x = "x"; - public static final String y = "y"; - public static final String id = "id"; - public static final String ts = "ts"; - public static final String c = "c"; - public static final String resolution = "resolution"; - public static final String touchEventAvailable = "touchEventAvailable"; - - public static final String pressAvailable = "pressAvailable"; - public static final String multiTouchAvailable = "multiTouchAvailable"; - public static final String doublePressAvailable = "doublePressAvailable"; - public static final String templatesAvailable = "templatesAvailable"; - public static final String numCustomPresetsAvailable = "numCustomPresetsAvailable"; - public static final String prerecordedSpeech = "prerecordedSpeech"; - public static final String manualTextEntry = "manualTextEntry"; - public static final String progressIndicator = "progressIndicator"; - public static final String secondaryGraphic = "secondaryGraphic"; - public static final String offset = "offset"; - public static final String length = "length"; - - public static final String hardware = "hardware"; - public static final String firmwareRev = "firmwareRev"; - public static final String os = "os"; - public static final String osVersion = "osVersion"; - public static final String carrier = "carrier"; - public static final String maxNumberRFCOMMPorts = "maxNumberRFCOMMPorts"; - - public static final String onReadDIDResponse = "onReadDIDResponse"; - public static final String onGetDTCsResponse = "onGetDTCsResponse"; - public static final String onOnKeyboardInput = "onOnKeyboardInput"; - public static final String onOnTouchEvent = "onOnTouchEvent"; - public static final String onOnSystemRequest = "onOnSystemRequest"; - - public static final String onDiagnosticMessageResponse = "onDiagnosticMessageResponse"; - public static final String onSystemRequestResponse = "onSystemRequestResponse"; - public static final String onGetVehicleDataResponse = "onGetVehicleDataResponse"; - public static final String getSupportedDiagModes = "getSupportedDiagModes"; - public static final String supportedDiagModes = "supportedDiagModes"; - - public static final String driverAirbagDeployed = "driverAirbagDeployed"; - public static final String driverSideAirbagDeployed = "driverSideAirbagDeployed"; - public static final String driverCurtainAirbagDeployed = "driverCurtainAirbagDeployed"; - public static final String passengerAirbagDeployed = "passengerAirbagDeployed"; - public static final String passengerCurtainAirbagDeployed = "passengerCurtainAirbagDeployed"; - public static final String driverKneeAirbagDeployed = "driverKneeAirbagDeployed"; - public static final String passengerSideAirbagDeployed = "passengerSideAirbagDeployed"; - public static final String passengerKneeAirbagDeployed = "passengerKneeAirbagDeployed"; - - public static final String powerModeActive = "powerModeActive"; - public static final String powerModeQualificationStatus = "powerModeQualificationStatus"; - public static final String carModeStatus = "carModeStatus"; - public static final String powerModeStatus = "powerModeStatus"; - - public static final String eCallNotificationStatus = "eCallNotificationStatus"; - public static final String auxECallNotificationStatus = "auxECallNotificationStatus"; - public static final String eCallConfirmationStatus = "eCallConfirmationStatus"; - public static final String e911Override = "e911Override"; - - public static final String emergencyEventType = "emergencyEventType"; - public static final String fuelCutoffStatus = "fuelCutoffStatus"; - public static final String rolloverEvent = "rolloverEvent"; - public static final String maximumChangeVelocity = "maximumChangeVelocity"; - public static final String multipleEvents = "multipleEvents"; - - public static final String eCallInfo = "eCallInfo"; - public static final String airbagStatus = "airbagStatus"; - public static final String emergencyEvent = "emergencyEvent"; - public static final String clusterModeStatus = "clusterModeStatus"; - public static final String myKey = "myKey"; - public static final String timeToDestination = "timeToDestination"; - - public static final String driverDistraction = "driverDistraction"; - public static final String showLockScreen = "showLockScreen"; - public static final String userSelected = "userSelected"; - public static final String notSet = "notSet"; - - public static final String headers = "headers"; - public static final String body = "body"; - - public static final String ContentType = "ContentType"; - public static final String ConnectTimeout = "ConnectTimeout"; - public static final String DoOutput = "DoOutput"; - public static final String DoInput = "DoInput"; - public static final String UseCaches = "UseCaches"; - public static final String RequestMethod = "RequestMethod"; - public static final String ReadTimeout = "ReadTimeout"; - public static final String InstanceFollowRedirects = "InstanceFollowRedirects"; - public static final String charset = "charset"; - public static final String ContentLength = "Content-Length"; -} -- cgit v1.2.1 From e6b4c1050c9d21a6004d6be2de7aa5e0191de194 Mon Sep 17 00:00:00 2001 From: Bilal Alsharifi Date: Wed, 2 Sep 2020 17:54:29 -0400 Subject: Remove deprecated methods from RPCStruct --- base/src/main/java/com/smartdevicelink/proxy/RPCStruct.java | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/base/src/main/java/com/smartdevicelink/proxy/RPCStruct.java b/base/src/main/java/com/smartdevicelink/proxy/RPCStruct.java index 402866291..cebe43a60 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/RPCStruct.java +++ b/base/src/main/java/com/smartdevicelink/proxy/RPCStruct.java @@ -91,19 +91,11 @@ public class RPCStruct { store = JsonRPCMarshaller.deserializeJSONObject(jsonObject); } - - // deserializeJSONObject method moved to JsonRPCMarshaller for consistency - // Keep reference here for backwards compatibility - @Deprecated - public static Hashtable 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) { -- cgit v1.2.1 From f14ec97d16f2bc4ce47630f947e61c63870a46f4 Mon Sep 17 00:00:00 2001 From: Bilal Alsharifi <599206+bilal-alsharifi@users.noreply.github.com> Date: Thu, 3 Sep 2020 10:52:55 -0400 Subject: Remove Deprecated APIs Part 2 (#1479) * Remove deprecated code in streaming package * Fix streaming unit tests * Remove deprecated IProtocolListener class * Remove unsed packetizer testing code * Remove deprecated IPutFileResponseListener --- .../managers/audio/AudioStreamManagerTest.java | 10 - .../test/streaming/AbstractPacketizerTests.java | 21 +- .../test/streaming/MockPacketizer.java | 9 - .../test/streaming/StreamRPCPacketizerTests.java | 54 ---- .../video/VideoStreamingParametersTest.java | 17 +- .../streaming/StreamPacketizer.java | 11 - .../streaming/StreamRPCPacketizer.java | 331 --------------------- .../protocol/IProtocolListener.java | 76 ----- .../proxy/interfaces/IAudioStreamListener.java | 14 - .../proxy/interfaces/IPutFileResponseListener.java | 41 --- .../streaming/AbstractPacketizer.java | 83 ++---- .../streaming/video/VideoStreamingParameters.java | 38 --- 12 files changed, 41 insertions(+), 664 deletions(-) delete mode 100644 android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/StreamRPCPacketizerTests.java delete mode 100644 android/sdl_android/src/main/java/com/smartdevicelink/streaming/StreamRPCPacketizer.java delete mode 100644 base/src/main/java/com/smartdevicelink/protocol/IProtocolListener.java delete mode 100644 base/src/main/java/com/smartdevicelink/proxy/interfaces/IPutFileResponseListener.java diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/audio/AudioStreamManagerTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/audio/AudioStreamManagerTest.java index 4cfa806ad..c5837c2cb 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/audio/AudioStreamManagerTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/audio/AudioStreamManagerTest.java @@ -231,11 +231,6 @@ public class AudioStreamManagerTest extends TestCase { this.sendAudio(buffer, presentationTimeUs, null); } - @Override - public void sendAudio(ByteBuffer data, long presentationTimeUs) { - sendAudio(data, presentationTimeUs, null); - } - @Override public void sendAudio(ByteBuffer data, long presentationTimeUs, CompletionListener listener) { SampleBuffer samples = SampleBuffer.wrap(data, sampleType, presentationTimeUs); @@ -477,11 +472,6 @@ public class AudioStreamManagerTest extends TestCase { this.sendAudio(buffer, presentationTimeUs, null); } - @Override - public void sendAudio(ByteBuffer data, long presentationTimeUs) { - sendAudio(data, presentationTimeUs, null); - } - @Override public void sendAudio(ByteBuffer data, long presentationTimeUs, CompletionListener listener) { try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/AbstractPacketizerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/AbstractPacketizerTests.java index 28b1520d2..0cccc48e8 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/AbstractPacketizerTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/AbstractPacketizerTests.java @@ -32,14 +32,11 @@ public class AbstractPacketizerTests extends TestCase { // Test Values byte testSessionId = (byte) 0x0A; - byte testWiproVersion = (byte) 0x0B; - RPCRequest testRpcRequest = new RPCRequest("test"); SessionType testSessionType = SessionType.RPC; SdlSession testSdlSession = null; InputStream testInputStream = null; MockPacketizer testPacketizer1 = null; MockPacketizer testPacketizer2 = null; - MockPacketizer testPacketizer3 = null; IStreamListener testListener = new MockStreamListener(); try { testInputStream = new BufferedInputStream(new ByteArrayInputStream("sdl streaming test".getBytes())); @@ -48,31 +45,15 @@ public class AbstractPacketizerTests extends TestCase { testSdlSession = new SdlSession(interfaceBroker, transportConfig); testPacketizer1 = new MockPacketizer(testListener, testInputStream, testSessionType, testSessionId, testSdlSession); testPacketizer2 = new MockPacketizer(null, null, null, testSessionId, testSdlSession); - testPacketizer3 = new MockPacketizer(testListener, testInputStream, testRpcRequest, testSessionType, testSessionId, testWiproVersion, testSdlSession); - try { - new MockPacketizer(null, null, null, null, testSessionId, testWiproVersion, null); - fail("Exception should be thrown"); - }catch(Exception e) { - assertTrue(e instanceof IllegalArgumentException); - } - // Valid Tests assertNotNull(TestValues.NOT_NULL, testPacketizer1); assertNotNull(TestValues.NOT_NULL, testPacketizer2); - assertNotNull(TestValues.NOT_NULL, testPacketizer3); - + assertEquals(TestValues.MATCH, testListener, testPacketizer1.getListener()); assertEquals(TestValues.MATCH, testInputStream, testPacketizer1.getInputStream()); assertEquals(TestValues.MATCH, testSessionType, testPacketizer1.getSessionType()); assertEquals(TestValues.MATCH, testSessionId, testPacketizer1.getSessionId()); - assertEquals(TestValues.MATCH, testListener, testPacketizer3.getListener()); - assertEquals(TestValues.MATCH, testInputStream, testPacketizer3.getInputStream()); - assertEquals(TestValues.MATCH, testSessionType, testPacketizer3.getSessionType()); - assertEquals(TestValues.MATCH, testSessionId, testPacketizer3.getSessionId()); - assertEquals(TestValues.MATCH, testWiproVersion, testPacketizer3.getWiproVersion()); - assertEquals(TestValues.MATCH, testRpcRequest.getFunctionName(), testPacketizer3.getRPCRequest().getFunctionName()); - assertEquals(TestValues.MATCH, testSdlSession, testPacketizer3.getSdlSession()); // Invalid/Null Tests assertNull(TestValues.NULL, testPacketizer2.getListener()); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/MockPacketizer.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/MockPacketizer.java index 2c6618f62..ca6a77820 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/MockPacketizer.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/MockPacketizer.java @@ -2,10 +2,8 @@ package com.smartdevicelink.test.streaming; import com.smartdevicelink.SdlConnection.SdlSession; import com.smartdevicelink.protocol.enums.SessionType; -import com.smartdevicelink.proxy.RPCRequest; import com.smartdevicelink.streaming.AbstractPacketizer; import com.smartdevicelink.streaming.IStreamListener; -import com.smartdevicelink.util.Version; import java.io.IOException; import java.io.InputStream; @@ -16,8 +14,6 @@ import java.io.InputStream; */ public class MockPacketizer extends AbstractPacketizer { public MockPacketizer (IStreamListener l, InputStream i, SessionType s, byte sid, SdlSession sdlsession) throws IOException { super (l, i, s, sid, sdlsession); } - public MockPacketizer (IStreamListener l, InputStream i, RPCRequest r, SessionType s, byte sid, Version protocolVersion,SdlSession sdlsession) throws IOException { super (l, i, r, s, sid, protocolVersion, sdlsession); } - public MockPacketizer (IStreamListener l, InputStream i, RPCRequest r, SessionType s, byte sid, byte w, SdlSession sdlsession) throws IOException { super (l, i, r, s, sid, w, sdlsession); } @Override public void start() throws IOException { } @Override public void stop() { } @@ -25,12 +21,7 @@ public class MockPacketizer extends AbstractPacketizer { public IStreamListener getListener () { return _streamListener; } public InputStream getInputStream () { return is; } public SessionType getSessionType () { return _serviceType; } - public SdlSession getSdlSession () { return _session; } public byte getSessionId () { return _rpcSessionID; } - public RPCRequest getRPCRequest () { return _request; } - @Deprecated - public byte getWiproVersion () { if(_wiproVersion != null){return (byte)_wiproVersion.getMajor(); }else{return 5;}} - public Version getProtocolVersion () { return _wiproVersion; } @Override public void pause() { } @Override public void resume() { } diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/StreamRPCPacketizerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/StreamRPCPacketizerTests.java deleted file mode 100644 index 05a579b72..000000000 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/StreamRPCPacketizerTests.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.smartdevicelink.test.streaming; - -import com.smartdevicelink.SdlConnection.SdlSession; -import com.smartdevicelink.protocol.enums.SessionType; -import com.smartdevicelink.proxy.RPCRequest; -import com.smartdevicelink.streaming.IStreamListener; -import com.smartdevicelink.streaming.StreamRPCPacketizer; -import com.smartdevicelink.test.TestValues; -import com.smartdevicelink.transport.MultiplexTransportConfig; - -import junit.framework.TestCase; - -import java.io.BufferedInputStream; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; - -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; - -/** - * This is a unit test class for the SmartDeviceLink library project class : - * {@link com.smartdevicelink.streaming.StreamRPCPacketizer} - */ -public class StreamRPCPacketizerTests extends TestCase { - - /** - * This is a unit test for the following methods : - * {@link com.smartdevicelink.streaming.StreamRPCPacketizer#StreamRPCPacketizer(Object, IStreamListener, InputStream, RPCRequest, SessionType, byte, byte, long, SdlSession)} - */ - public void testConstructor () { - - // Test Values - byte testSessionId = (byte) 0x0A; - byte testWV = (byte) 0x0B; - RPCRequest testRequest = new RPCRequest("test"); - SessionType testSessionType = SessionType.RPC; - InputStream testInputStream = null; - IStreamListener testListener = new MockStreamListener(); - - MockInterfaceBroker interfaceBroker = new MockInterfaceBroker(); - MultiplexTransportConfig transportConfig = new MultiplexTransportConfig(getInstrumentation().getTargetContext(),"19216801"); - SdlSession testSdlSession = new SdlSession(interfaceBroker, transportConfig); - try { - testInputStream = new BufferedInputStream(new ByteArrayInputStream("sdl streaming test".getBytes())); - StreamRPCPacketizer testStreamRpcPacketizer = new StreamRPCPacketizer(null, testListener, testInputStream, testRequest, testSessionType, testSessionId, testWV, testWV, testSdlSession); - assertNotNull(TestValues.NOT_NULL, testStreamRpcPacketizer); - - // NOTE: Cannot test thread handling methods currently. - - } catch (IOException e) { - fail("IOException was thrown."); - } - } -} \ No newline at end of file diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/video/VideoStreamingParametersTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/video/VideoStreamingParametersTest.java index 5867fee7f..a297a9626 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/video/VideoStreamingParametersTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/video/VideoStreamingParametersTest.java @@ -25,6 +25,7 @@ public class VideoStreamingParametersTest { private VideoStreamingParameters params; private VideoStreamingCapability capability; private ImageResolution preferredResolution; + private final String vehicleMake = "SDL"; @Before public void setUp() { @@ -39,7 +40,7 @@ public class VideoStreamingParametersTest { capability.setScale(null); capability.setPreferredResolution(preferredResolution); - params.update(capability); + params.update(capability, vehicleMake); int width = params.getResolution().getResolutionWidth(); int height = params.getResolution().getResolutionHeight(); @@ -55,7 +56,7 @@ public class VideoStreamingParametersTest { capability.setScale(1.0); capability.setPreferredResolution(preferredResolution); - params.update(capability); + params.update(capability, vehicleMake); int width = params.getResolution().getResolutionWidth(); int height = params.getResolution().getResolutionHeight(); @@ -71,7 +72,7 @@ public class VideoStreamingParametersTest { capability.setScale(1.25); capability.setPreferredResolution(preferredResolution); - params.update(capability); + params.update(capability, vehicleMake); int width = params.getResolution().getResolutionWidth(); int height = params.getResolution().getResolutionHeight(); @@ -87,7 +88,7 @@ public class VideoStreamingParametersTest { capability.setScale(1.5); capability.setPreferredResolution(preferredResolution); - params.update(capability); + params.update(capability, vehicleMake); int width = params.getResolution().getResolutionWidth(); int height = params.getResolution().getResolutionHeight(); @@ -175,23 +176,23 @@ public class VideoStreamingParametersTest { assertNull(params.getFormat()); - params.update(capability); + params.update(capability, vehicleMake); assertEquals(params.getFormat(), format); format = new VideoStreamingFormat(VideoStreamingProtocol.RTP, VideoStreamingCodec.H264); capability.setSupportedFormats(Collections.singletonList(format)); - params.update(capability); + params.update(capability, vehicleMake); assertEquals(params.getFormat(), format); format = new VideoStreamingFormat(VideoStreamingProtocol.RTP, VideoStreamingCodec.H265); capability.setSupportedFormats(Collections.singletonList(format)); - params.update(capability); + params.update(capability, vehicleMake); assertFalse(params.getFormat().equals(format)); format = new VideoStreamingFormat(VideoStreamingProtocol.RAW, VideoStreamingCodec.VP8); capability.setSupportedFormats(Collections.singletonList(format)); - params.update(capability); + params.update(capability, vehicleMake); assertFalse(params.getFormat().equals(format)); } diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/streaming/StreamPacketizer.java b/android/sdl_android/src/main/java/com/smartdevicelink/streaming/StreamPacketizer.java index accb59948..1a1ee4156 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/streaming/StreamPacketizer.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/streaming/StreamPacketizer.java @@ -234,17 +234,6 @@ public class StreamPacketizer extends AbstractPacketizer implements IVideoStream sendArrayData(data, offset, length); } - /** - * Called by the app. - * - * @see IAudioStreamListener#sendAudio(ByteBuffer, long) - */ - @Deprecated - @Override - public void sendAudio(ByteBuffer data, long presentationTimeUs) { - sendByteBufferData(data, null); - } - /** * Called by the app. * diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/streaming/StreamRPCPacketizer.java b/android/sdl_android/src/main/java/com/smartdevicelink/streaming/StreamRPCPacketizer.java deleted file mode 100644 index 6d93205c1..000000000 --- a/android/sdl_android/src/main/java/com/smartdevicelink/streaming/StreamRPCPacketizer.java +++ /dev/null @@ -1,331 +0,0 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ -package com.smartdevicelink.streaming; - -import com.smartdevicelink.SdlConnection.SdlSession; -import com.smartdevicelink.marshal.JsonRPCMarshaller; -import com.smartdevicelink.protocol.ProtocolMessage; -import com.smartdevicelink.protocol.enums.FunctionID; -import com.smartdevicelink.protocol.enums.MessageType; -import com.smartdevicelink.protocol.enums.SessionType; -import com.smartdevicelink.proxy.RPCRequest; -import com.smartdevicelink.proxy.RPCResponse; -import com.smartdevicelink.proxy.interfaces.IPutFileResponseListener; -import com.smartdevicelink.proxy.rpc.PutFile; -import com.smartdevicelink.proxy.rpc.PutFileResponse; -import com.smartdevicelink.util.Version; - -import java.io.IOException; -import java.io.InputStream; - -@Deprecated -public class StreamRPCPacketizer extends AbstractPacketizer implements IPutFileResponseListener, Runnable{ - - private Integer iInitialCorrID = 0; - //private Hashtable notificationList = new Hashtable(); - private Thread thread = null; - private long lFileSize = 0; - private String sFileName; - private Object _proxy; - private Object _proxyListener; - - private Object mPauseLock; - private boolean mPaused; - private boolean isRPCProtected = false; - //private OnPutFileUpdateListener callBack; - - private Version rpcSpecVersion; - - public StreamRPCPacketizer(Object proxy, IStreamListener streamListener, InputStream is, RPCRequest request, SessionType sType, byte rpcSessionID, byte wiproVersion, long lLength, SdlSession session) throws IOException { - super(streamListener, is, request, sType, rpcSessionID, wiproVersion, session); - lFileSize = lLength; - iInitialCorrID = request.getCorrelationID(); - mPauseLock = new Object(); - mPaused = false; - isRPCProtected = request.isPayloadProtected(); - if (proxy != null) - { - _proxy = proxy; - //_proxyListener = _proxy.getProxyListener(); - //_proxy.addPutFileResponseListener(this); - } - if(_request.getFunctionName().equalsIgnoreCase(FunctionID.PUT_FILE.toString())){ - //callBack = ((PutFile)_request).getOnPutFileUpdateListener(); - } - } - - public StreamRPCPacketizer(Object proxy, IStreamListener streamListener, InputStream is, RPCRequest request, SessionType sType, byte rpcSessionID, Version wiproVersion, Version rpcSpecVersion, long lLength, SdlSession session) throws IOException { - super(streamListener, is, request, sType, rpcSessionID, wiproVersion, session); - this.rpcSpecVersion = rpcSpecVersion; - lFileSize = lLength; - iInitialCorrID = request.getCorrelationID(); - mPauseLock = new Object(); - mPaused = false; - isRPCProtected = request.isPayloadProtected(); - if (proxy != null) { - _proxy = proxy; - //_proxyListener = _proxy.getProxyListener(); - //_proxy.addPutFileResponseListener(this); - } - if(_request.getFunctionName().equalsIgnoreCase(FunctionID.PUT_FILE.toString())){ - //callBack = ((PutFile)_request).getOnPutFileUpdateListener(); - } - } - - @Override - public void start() throws IOException { - if (thread == null) { - thread = new Thread(this); - thread.start(); - } - } - - @Override - public void stop() { - try { - is.close(); - } catch (IOException ignore) {} - if (thread != null) - { - thread.interrupt(); - thread = null; - } - } - - private void handleStreamSuccess(RPCResponse rpc, Long iSize) - { -// StreamRPCResponse result = new StreamRPCResponse(); -// result.setSuccess(rpc.getSuccess()); -// result.setResultCode(rpc.getResultCode()); -// result.setInfo(rpc.getInfo()); -// result.setFileName(sFileName); -// result.setFileSize(iSize); -// result.setCorrelationID(iInitialCorrID); -// if (_proxyListener != null) -// _proxyListener.onStreamRPCResponse(result); -// stop(); -// _proxy.remPutFileResponseListener(this); -// return; - } - - private void handleStreamException(RPCResponse rpc, Exception e, String error) - { -// StreamRPCResponse result = new StreamRPCResponse(); -// result.setFileName(sFileName); -// result.setCorrelationID(iInitialCorrID); -// if (rpc != null) -// { -// result.setSuccess(rpc.getSuccess()); -// result.setResultCode(rpc.getResultCode()); -// result.setInfo(rpc.getInfo()); -// } -// else -// { -// result.setSuccess(false); -// result.setResultCode(Result.GENERIC_ERROR); -// String sException = ""; -// -// if (e != null) -// sException = sException + " " + e.toString(); -// -// sException = sException + " " + error; -// result.setInfo(sException); -// } -// if (_proxyListener != null) -// _proxyListener.onStreamRPCResponse(result); -// if (e != null) -// e.printStackTrace(); -// stop(); -// _proxy.remPutFileResponseListener(this); -// return; - } - - @Override - public void pause() { - synchronized (mPauseLock) { - mPaused = true; - } - } - - @Override - public void resume() { - synchronized (mPauseLock) { - mPaused = false; - mPauseLock.notifyAll(); - } - } - - public void run() { - int length; - byte[] msgBytes; - ProtocolMessage pm; - //OnStreamRPC notification; - - // Moves the current Thread into the background - android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_BACKGROUND); - - try { - - int iCorrID = 0; - PutFile msg = (PutFile) _request; - sFileName = msg.getSdlFileName(); - long iOffsetCounter = msg.getOffset(); - - int priorityCoefficient = 1; - - if (lFileSize != 0) - { - Long iFileSize = (long) lFileSize; - //TODO: PutFile RPC needs to be updated to accept Long as we might run into overflows since a Long can store a wider range than an Integer - msg.setLength(iFileSize); - } - Long iFileLength = msg.getLength(); - - //notificationList.clear(); - - //start reading from the stream at the given offset - long iSkipBytes = is.skip(iOffsetCounter); - - if (iOffsetCounter != iSkipBytes) - { - handleStreamException(null,null," Error, PutFile offset invalid for file: " + sFileName); - } -// if(callBack!=null){ -// callBack.onStart(_request.getCorrelationID(), lFileSize); -// } - while (!Thread.interrupted()) { - - synchronized (mPauseLock) - { - while (mPaused) - { - try - { - mPauseLock.wait(); - } - catch (InterruptedException e) {} - } - } - - length = is.read(buffer, 0, bufferSize); - - if (length == -1) - stop(); - - if (length >= 0) { - - if (msg.getOffset() != 0) - msg.setLength((Long)null); //only need to send length when offset 0 - - msg.format(rpcSpecVersion,true); - msgBytes = JsonRPCMarshaller.marshall(msg, (byte)_wiproVersion.getMajor()); - pm = new ProtocolMessage(); - pm.setData(msgBytes); - - pm.setSessionID(_rpcSessionID); - pm.setMessageType(MessageType.RPC); - pm.setSessionType(_serviceType); - pm.setFunctionID(FunctionID.getFunctionId(msg.getFunctionName())); - - if (buffer.length != length) - pm.setBulkData(buffer, length); - else - pm.setBulkDataNoCopy(buffer); - - pm.setCorrID(msg.getCorrelationID()); - pm.setPayloadProtected(isRPCProtected); - priorityCoefficient++; - pm.setPriorityCoefficient(priorityCoefficient); - -// notification = new OnStreamRPC(); -// notification.setFileName(msg.getSdlFileName()); -// notification.setFileSize(iFileLength); -// iOffsetCounter = iOffsetCounter + length; -// notification.setBytesComplete(iOffsetCounter); -// notificationList.put(msg.getCorrelationID(),notification); - - msg.setOffset(iOffsetCounter); - iCorrID = msg.getCorrelationID() + 1; - msg.setCorrelationID(iCorrID); - - _streamListener.sendStreamPacket(pm); - } - } - } catch (Exception e) { - handleStreamException(null, e, ""); - } - } - - @Override - public void onPutFileResponse(PutFileResponse response) - { - -// OnStreamRPC streamNote = notificationList.get(response.getCorrelationID()); -// if (streamNote == null) return; -// -// if (response.getSuccess()) -// { -// if(callBack!=null){ -// callBack.onUpdate(response.getCorrelationID(), streamNote.getBytesComplete(), lFileSize); -// } -// if (_proxyListener != null){ -// _proxyListener.onOnStreamRPC(streamNote); -// } -// -// } -// else -// { -// if(callBack!=null){ -// callBack.onError(response.getCorrelationID(), response.getResultCode(), response.getInfo()); -// } -// handleStreamException(response, null, ""); -// -// } -// -// if (response.getSuccess() && streamNote.getBytesComplete().equals(streamNote.getFileSize()) ) -// { -// if(callBack!=null){ -// callBack.onResponse(iInitialCorrID, response, streamNote.getBytesComplete()); -// } -// handleStreamSuccess(response, streamNote.getBytesComplete()); -// -// } - } - - @Override - public void onPutFileStreamError(Exception e, String info) - { - if (thread != null) - handleStreamException(null, e, info); - - } -} diff --git a/base/src/main/java/com/smartdevicelink/protocol/IProtocolListener.java b/base/src/main/java/com/smartdevicelink/protocol/IProtocolListener.java deleted file mode 100644 index 37e7972f4..000000000 --- a/base/src/main/java/com/smartdevicelink/protocol/IProtocolListener.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ -package com.smartdevicelink.protocol; - - -import com.smartdevicelink.protocol.enums.SessionType; - -import java.util.List; - -@Deprecated -public interface IProtocolListener { - // Called to indicate that these bytes are to be sent as part of a message. - // This call includes the part of the message. - void onProtocolMessageBytesToSend(SdlPacket packet); - - // Called to indicate that a complete message (RPC, BULK, etc.) has been - // received. This call includes the message. - void onProtocolMessageReceived(ProtocolMessage msg); - - // Called to indicate that a protocol session has been started (from either side) - void onProtocolSessionStarted(SessionType sessionType, byte sessionID, byte version, String correlationID, int hashID, boolean isEncrypted); - - void onProtocolSessionNACKed(SessionType sessionType, byte sessionID, byte version, - String correlationID, List rejectedParams); - - // Called to indicate that a protocol session has ended (from either side) - void onProtocolSessionEnded(SessionType sessionType, byte sessionID, String correlationID /*, String info, Exception ex*/); - - void onProtocolSessionEndedNACKed(SessionType sessionType, byte sessionID, String correlationID /*, String info, Exception ex*/); - - void onProtocolHeartbeat(SessionType sessionType, byte sessionID); - - /** - * Called when a protocol heartbeat ACK message has been received from SDL. - */ - void onProtocolHeartbeatACK(SessionType sessionType, byte sessionID); - - void onProtocolServiceDataACK(SessionType sessionType, int dataSize, byte sessionID); - - void onResetOutgoingHeartbeat(SessionType sessionType, byte sessionID); - - void onResetIncomingHeartbeat(SessionType sessionType, byte sessionID); - - // Called to indicate that a protocol error was detected in received data. - void onProtocolError(String info, Exception e); - -} // end-interfCe diff --git a/base/src/main/java/com/smartdevicelink/proxy/interfaces/IAudioStreamListener.java b/base/src/main/java/com/smartdevicelink/proxy/interfaces/IAudioStreamListener.java index 616f07f42..c39e6bee2 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/interfaces/IAudioStreamListener.java +++ b/base/src/main/java/com/smartdevicelink/proxy/interfaces/IAudioStreamListener.java @@ -58,20 +58,6 @@ public interface IAudioStreamListener { void sendAudio(byte[] data, int offset, int length, long presentationTimeUs) throws ArrayIndexOutOfBoundsException; - /** - * Sends a chunk of audio data to SDL Core. - *

- * Note: this method must not be called after SdlProxyBase.endAudioStream() is called. - * - * @param data Data chunk to send. Its position will be updated upon return. - * @param presentationTimeUs (Reserved for future use) Presentation timestamp (PTS) of the - * last audio sample data included in this chunk, in microseconds. - * It must be greater than the previous timestamp. - * Specify -1 if unknown. - */ - @Deprecated - void sendAudio(ByteBuffer data, long presentationTimeUs); - /** * Sends a chunk of audio data to SDL Core. *

diff --git a/base/src/main/java/com/smartdevicelink/proxy/interfaces/IPutFileResponseListener.java b/base/src/main/java/com/smartdevicelink/proxy/interfaces/IPutFileResponseListener.java deleted file mode 100644 index b0c557b8e..000000000 --- a/base/src/main/java/com/smartdevicelink/proxy/interfaces/IPutFileResponseListener.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ -package com.smartdevicelink.proxy.interfaces; - -import com.smartdevicelink.proxy.rpc.PutFileResponse; - -@Deprecated -public interface IPutFileResponseListener { - public void onPutFileResponse(PutFileResponse response); - - public void onPutFileStreamError(Exception e, String info); -} diff --git a/base/src/main/java/com/smartdevicelink/streaming/AbstractPacketizer.java b/base/src/main/java/com/smartdevicelink/streaming/AbstractPacketizer.java index 0cfdb4c76..c51652c3b 100644 --- a/base/src/main/java/com/smartdevicelink/streaming/AbstractPacketizer.java +++ b/base/src/main/java/com/smartdevicelink/streaming/AbstractPacketizer.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.streaming; import com.smartdevicelink.SdlConnection.SdlSession; @@ -49,13 +49,9 @@ abstract public class AbstractPacketizer { protected InputStream is = null; protected int bufferSize; protected byte[] buffer; - protected boolean upts = false; protected RPCRequest _request = null; protected Version _wiproVersion = new Version("1.0.0"); - //protected long ts = 0, intervalBetweenReports = 5000, delta = 0; - protected long intervalBetweenReports = 5000, delta = 0; - public AbstractPacketizer(IStreamListener streamListener, InputStream is, SessionType sType, byte rpcSessionID, SdlSession session) throws IOException, IllegalArgumentException { this._streamListener = streamListener; this.is = is; @@ -70,23 +66,6 @@ abstract public class AbstractPacketizer { } } - @Deprecated - public AbstractPacketizer(IStreamListener streamListener, InputStream is, RPCRequest request, SessionType sType, byte rpcSessionID, byte wiproVersion, SdlSession session) throws IOException, IllegalArgumentException { - this._streamListener = streamListener; - this.is = is; - _rpcSessionID = rpcSessionID; - _serviceType = sType; - _request = request; - _wiproVersion = new Version(wiproVersion+".0.0"); - this._session = session; - if (this._session != null) { - bufferSize = this._session.getMtu(); - buffer = new byte[bufferSize]; - }else{ - throw new IllegalArgumentException("Session variable is null"); - } - } - public AbstractPacketizer(IStreamListener streamListener, InputStream is, RPCRequest request, SessionType sType, byte rpcSessionID, Version protocolVersion, SdlSession session) throws IOException, IllegalArgumentException { this._streamListener = streamListener; this.is = is; diff --git a/base/src/main/java/com/smartdevicelink/streaming/video/VideoStreamingParameters.java b/base/src/main/java/com/smartdevicelink/streaming/video/VideoStreamingParameters.java index d66b75ed4..372e2548c 100644 --- a/base/src/main/java/com/smartdevicelink/streaming/video/VideoStreamingParameters.java +++ b/base/src/main/java/com/smartdevicelink/streaming/video/VideoStreamingParameters.java @@ -172,44 +172,6 @@ public class VideoStreamingParameters { } - /** - * Update the values contained in the capability that should have been returned through the SystemCapabilityManager. - * This update will use the most preferred streaming format from the module. - * @param capability the video streaming capability returned from the SystemCapabilityManager - * @see com.smartdevicelink.proxy.SystemCapabilityManager - * @see VideoStreamingCapability - */ - @Deprecated - public void update(VideoStreamingCapability capability){ - if(capability.getMaxBitrate()!=null){ this.bitrate = capability.getMaxBitrate() * 1000; } // NOTE: the unit of maxBitrate in getSystemCapability is kbps. - double scale = DEFAULT_SCALE; - if(capability.getScale() != null) { scale = capability.getScale(); } - ImageResolution resolution = capability.getPreferredResolution(); - if(resolution!=null){ - - if(resolution.getResolutionHeight()!=null && resolution.getResolutionHeight() > 0){ this.resolution.setResolutionHeight((int)(resolution.getResolutionHeight() / scale)); } - if(resolution.getResolutionWidth()!=null && resolution.getResolutionWidth() > 0){ this.resolution.setResolutionWidth((int)(resolution.getResolutionWidth() / scale)); } - } - - // This should be the last call as it will return out once a suitable format is found - final List formats = capability.getSupportedFormats(); - if(formats != null && formats.size()>0){ - for(VideoStreamingFormat format : formats){ - for(int i = 0; i < CURRENTLY_SUPPORTED_FORMATS.length; i ++){ - if(CURRENTLY_SUPPORTED_FORMATS[i].equals(format) ){ - this.format = format; - return; - } - } - } - DebugTool.logWarning(TAG, "The VideoStreamingFormat has not been updated because none of the provided formats are supported."); - - //TODO In the future we should set format to null, but might be a breaking change - // For now, format will remain whatever was set prior to this update - } - - } - @SuppressWarnings("unused") public void setDisplayDensity(int displayDensity) { this.displayDensity = displayDensity; -- cgit v1.2.1 From 5f53391cfc8b0f827885cdd86610e97fc47ab4d5 Mon Sep 17 00:00:00 2001 From: Robert Henigan Date: Thu, 3 Sep 2020 10:55:20 -0400 Subject: Feature/remove old manager methods (#1476) * Remove Deprecated Methods from managers * Update HelloSdl * Remove Deprecated JavaSE method * Remove deprecated methods from managers * Remove Deprecated manager methods * Remove deprecated methods from javaSE managers * Hello Sdl Java Cleanup * Remove use of deprecated methods --- .../java/com/sdl/hellosdlandroid/SdlService.java | 5 -- .../smartdevicelink/managers/SdlManagerTests.java | 25 ++++------ .../lifecycle/SystemCapabilityManagerTests.java | 56 +++++++++++----------- .../managers/lockscreen/LockScreenConfigTests.java | 2 - .../lockscreen/LockScreenManagerTests.java | 1 - .../java/com/smartdevicelink/test/TestValues.java | 2 +- .../com/smartdevicelink/managers/SdlManager.java | 12 ++--- .../managers/SdlManagerListener.java | 15 ------ .../smartdevicelink/managers/file/FileManager.java | 8 ---- .../managers/lockscreen/LockScreenConfig.java | 24 ---------- .../managers/lockscreen/LockScreenManager.java | 2 +- .../smartdevicelink/managers/BaseSdlManager.java | 24 ++-------- .../managers/file/BaseFileManager.java | 8 ---- .../managers/lifecycle/BaseLifecycleManager.java | 9 +--- .../lifecycle/BaseSystemCapabilityManager.java | 28 ++--------- .../KeyboardAutocompleteCompletionListener.java | 8 ---- .../choiceset/PresentChoiceSetOperation.java | 7 --- .../screen/choiceset/PresentKeyboardOperation.java | 6 --- .../managers/screen/menu/MenuCell.java | 18 ------- .../java/com/smartdevicelink/java/SdlService.java | 5 -- .../managers/SdlManagerListener.java | 15 ------ .../smartdevicelink/managers/file/FileManager.java | 7 --- 22 files changed, 55 insertions(+), 232 deletions(-) diff --git a/android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlService.java b/android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlService.java index 893525b97..fbfcfdabc 100755 --- a/android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlService.java +++ b/android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlService.java @@ -202,11 +202,6 @@ public class SdlService extends Service { public void onError(String info, Exception e) { } - @Override - public LifecycleConfigurationUpdate managerShouldUpdateLifecycle(Language language) { - return null; - } - @Override public LifecycleConfigurationUpdate managerShouldUpdateLifecycle(Language language, Language hmiLanguage) { boolean isNeedUpdate = false; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/SdlManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/SdlManagerTests.java index 7c4fb11ff..97361adc9 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/SdlManagerTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/SdlManagerTests.java @@ -111,11 +111,6 @@ public class SdlManagerTests { } - @Override - public LifecycleConfigurationUpdate managerShouldUpdateLifecycle(Language language) { - return null; - } - @Override public LifecycleConfigurationUpdate managerShouldUpdateLifecycle(Language language, Language hmiLanguage) { return null; @@ -222,7 +217,7 @@ public class SdlManagerTests { sdlManager.getPermissionManager().transitionToState(BaseSubManager.READY); sdlManager.getFileManager().transitionToState(BaseSubManager.READY); sdlManager.getScreenManager().transitionToState(BaseSubManager.READY); - sdlManager.getLockScreenConfig().setEnabled(true); + sdlManager.getLockScreenConfig().setDisplayMode(LockScreenConfig.DISPLAY_MODE_ALWAYS); sdlManager.getLockScreenManager().transitionToState(BaseSubManager.READY); sdlManager.checkState(); assertEquals(BaseSubManager.READY, sdlManager.getState()); @@ -232,7 +227,7 @@ public class SdlManagerTests { sdlManager.getPermissionManager().transitionToState(BaseSubManager.READY); sdlManager.getFileManager().transitionToState(BaseSubManager.READY); sdlManager.getScreenManager().transitionToState(BaseSubManager.READY); - sdlManager.getLockScreenConfig().setEnabled(false); + sdlManager.getLockScreenConfig().setDisplayMode(LockScreenConfig.DISPLAY_MODE_NEVER); sdlManager.getLockScreenManager().transitionToState(BaseSubManager.SETTING_UP); sdlManager.checkState(); assertEquals(BaseSubManager.READY, sdlManager.getState()); @@ -242,7 +237,7 @@ public class SdlManagerTests { sdlManager.getPermissionManager().transitionToState(BaseSubManager.ERROR); sdlManager.getFileManager().transitionToState(BaseSubManager.ERROR); sdlManager.getScreenManager().transitionToState(BaseSubManager.ERROR); - sdlManager.getLockScreenConfig().setEnabled(true); + sdlManager.getLockScreenConfig().setDisplayMode(LockScreenConfig.DISPLAY_MODE_ALWAYS); sdlManager.getLockScreenManager().transitionToState(BaseSubManager.ERROR); sdlManager.checkState(); assertEquals(BaseSubManager.ERROR, sdlManager.getState()); @@ -252,7 +247,7 @@ public class SdlManagerTests { sdlManager.getPermissionManager().transitionToState(BaseSubManager.ERROR); sdlManager.getFileManager().transitionToState(BaseSubManager.ERROR); sdlManager.getScreenManager().transitionToState(BaseSubManager.ERROR); - sdlManager.getLockScreenConfig().setEnabled(false); + sdlManager.getLockScreenConfig().setDisplayMode(LockScreenConfig.DISPLAY_MODE_NEVER); sdlManager.getLockScreenManager().transitionToState(BaseSubManager.SETTING_UP); sdlManager.checkState(); assertEquals(BaseSubManager.ERROR, sdlManager.getState()); @@ -262,7 +257,7 @@ public class SdlManagerTests { sdlManager.getPermissionManager().transitionToState(BaseSubManager.ERROR); sdlManager.getFileManager().transitionToState(BaseSubManager.READY); sdlManager.getScreenManager().transitionToState(BaseSubManager.SETTING_UP); - sdlManager.getLockScreenConfig().setEnabled(true); + sdlManager.getLockScreenConfig().setDisplayMode(LockScreenConfig.DISPLAY_MODE_ALWAYS); sdlManager.getLockScreenManager().transitionToState(BaseSubManager.LIMITED); sdlManager.checkState(); assertEquals(BaseSubManager.SETTING_UP, sdlManager.getState()); @@ -272,7 +267,7 @@ public class SdlManagerTests { sdlManager.getPermissionManager().transitionToState(BaseSubManager.ERROR); sdlManager.getFileManager().transitionToState(BaseSubManager.READY); sdlManager.getScreenManager().transitionToState(BaseSubManager.SETTING_UP); - sdlManager.getLockScreenConfig().setEnabled(false); + sdlManager.getLockScreenConfig().setDisplayMode(LockScreenConfig.DISPLAY_MODE_NEVER); sdlManager.getLockScreenManager().transitionToState(BaseSubManager.SETTING_UP); sdlManager.checkState(); assertEquals(BaseSubManager.SETTING_UP, sdlManager.getState()); @@ -282,7 +277,7 @@ public class SdlManagerTests { sdlManager.getPermissionManager().transitionToState(BaseSubManager.READY); sdlManager.getFileManager().transitionToState(BaseSubManager.ERROR); sdlManager.getScreenManager().transitionToState(BaseSubManager.READY); - sdlManager.getLockScreenConfig().setEnabled(true); + sdlManager.getLockScreenConfig().setDisplayMode(LockScreenConfig.DISPLAY_MODE_ALWAYS); sdlManager.getLockScreenManager().transitionToState(BaseSubManager.READY); sdlManager.checkState(); assertEquals(BaseSubManager.LIMITED, sdlManager.getState()); @@ -292,7 +287,7 @@ public class SdlManagerTests { sdlManager.getPermissionManager().transitionToState(BaseSubManager.READY); sdlManager.getFileManager().transitionToState(BaseSubManager.ERROR); sdlManager.getScreenManager().transitionToState(BaseSubManager.READY); - sdlManager.getLockScreenConfig().setEnabled(false); + sdlManager.getLockScreenConfig().setDisplayMode(LockScreenConfig.DISPLAY_MODE_NEVER); sdlManager.getLockScreenManager().transitionToState(BaseSubManager.SETTING_UP); sdlManager.checkState(); assertEquals(BaseSubManager.LIMITED, sdlManager.getState()); @@ -302,7 +297,7 @@ public class SdlManagerTests { sdlManager.getPermissionManager().transitionToState(BaseSubManager.READY); sdlManager.getFileManager().transitionToState(BaseSubManager.LIMITED); sdlManager.getScreenManager().transitionToState(BaseSubManager.ERROR); - sdlManager.getLockScreenConfig().setEnabled(true); + sdlManager.getLockScreenConfig().setDisplayMode(LockScreenConfig.DISPLAY_MODE_ALWAYS); sdlManager.getLockScreenManager().transitionToState(BaseSubManager.READY); sdlManager.checkState(); assertEquals(BaseSubManager.LIMITED, sdlManager.getState()); @@ -312,7 +307,7 @@ public class SdlManagerTests { sdlManager.getPermissionManager().transitionToState(BaseSubManager.READY); sdlManager.getFileManager().transitionToState(BaseSubManager.LIMITED); sdlManager.getScreenManager().transitionToState(BaseSubManager.ERROR); - sdlManager.getLockScreenConfig().setEnabled(false); + sdlManager.getLockScreenConfig().setDisplayMode(LockScreenConfig.DISPLAY_MODE_NEVER); sdlManager.getLockScreenManager().transitionToState(BaseSubManager.SETTING_UP); sdlManager.checkState(); assertEquals(BaseSubManager.LIMITED, sdlManager.getState()); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lifecycle/SystemCapabilityManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lifecycle/SystemCapabilityManagerTests.java index d99e3e228..109bf6316 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lifecycle/SystemCapabilityManagerTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lifecycle/SystemCapabilityManagerTests.java @@ -183,25 +183,25 @@ public class SystemCapabilityManagerTests { List displayCapabilityList = createDisplayCapabilityList(TestValues.GENERAL_DISPLAYCAPABILITIES, TestValues.GENERAL_BUTTONCAPABILITIES_LIST, TestValues.GENERAL_SOFTBUTTONCAPABILITIES_LIST); assertTrue(TestValues.TRUE, - Validator.validateDisplayCapabilityList(displayCapabilityList, (List) systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAYS))); + Validator.validateDisplayCapabilityList(displayCapabilityList, (List) systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAYS, null, false))); assertTrue(TestValues.TRUE, - Validator.validateHMICapabilities(TestValues.GENERAL_HMICAPABILITIES, (HMICapabilities) systemCapabilityManager.getCapability(SystemCapabilityType.HMI))); + Validator.validateHMICapabilities(TestValues.GENERAL_HMICAPABILITIES, (HMICapabilities) systemCapabilityManager.getCapability(SystemCapabilityType.HMI, null, false))); assertTrue(TestValues.TRUE, - Validator.validateDisplayCapabilities(TestValues.GENERAL_DISPLAYCAPABILITIES, (DisplayCapabilities) systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAY))); + Validator.validateDisplayCapabilities(TestValues.GENERAL_DISPLAYCAPABILITIES, (DisplayCapabilities) systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAY, null, false))); assertTrue(TestValues.TRUE, - Validator.validateAudioPassThruCapabilities(TestValues.GENERAL_AUDIOPASSTHRUCAPABILITIES_LIST, (List) systemCapabilityManager.getCapability(SystemCapabilityType.AUDIO_PASSTHROUGH))); + Validator.validateAudioPassThruCapabilities(TestValues.GENERAL_AUDIOPASSTHRUCAPABILITIES_LIST, (List) systemCapabilityManager.getCapability(SystemCapabilityType.AUDIO_PASSTHROUGH, null, false))); assertTrue(TestValues.TRUE, - Validator.validateButtonCapabilities(TestValues.GENERAL_BUTTONCAPABILITIES_LIST, (List )systemCapabilityManager.getCapability(SystemCapabilityType.BUTTON))); + Validator.validateButtonCapabilities(TestValues.GENERAL_BUTTONCAPABILITIES_LIST, (List )systemCapabilityManager.getCapability(SystemCapabilityType.BUTTON, null, false))); assertTrue(TestValues.TRUE, - Validator.validateHMIZoneCapabilities(TestValues.GENERAL_HMIZONECAPABILITIES_LIST, (List) systemCapabilityManager.getCapability(SystemCapabilityType.HMI_ZONE))); + Validator.validateHMIZoneCapabilities(TestValues.GENERAL_HMIZONECAPABILITIES_LIST, (List) systemCapabilityManager.getCapability(SystemCapabilityType.HMI_ZONE, null, false))); assertTrue(TestValues.TRUE, - Validator.validatePresetBankCapabilities(TestValues.GENERAL_PRESETBANKCAPABILITIES, (PresetBankCapabilities) systemCapabilityManager.getCapability(SystemCapabilityType.PRESET_BANK))); + Validator.validatePresetBankCapabilities(TestValues.GENERAL_PRESETBANKCAPABILITIES, (PresetBankCapabilities) systemCapabilityManager.getCapability(SystemCapabilityType.PRESET_BANK, null, false))); assertTrue(TestValues.TRUE, - Validator.validateSoftButtonCapabilities(TestValues.GENERAL_SOFTBUTTONCAPABILITIES_LIST, (List) systemCapabilityManager.getCapability(SystemCapabilityType.SOFTBUTTON))); + Validator.validateSoftButtonCapabilities(TestValues.GENERAL_SOFTBUTTONCAPABILITIES_LIST, (List) systemCapabilityManager.getCapability(SystemCapabilityType.SOFTBUTTON, null, false))); assertTrue(TestValues.TRUE, - Validator.validateSpeechCapabilities(TestValues.GENERAL_SPEECHCAPABILITIES_LIST, (List) systemCapabilityManager.getCapability(SystemCapabilityType.SPEECH))); + Validator.validateSpeechCapabilities(TestValues.GENERAL_SPEECHCAPABILITIES_LIST, (List) systemCapabilityManager.getCapability(SystemCapabilityType.SPEECH, null, false))); assertTrue(TestValues.TRUE, - Validator.validatePreRecordedSpeechCapabilities(TestValues.GENERAL_PRERECORDEDSPEECH_LIST, (List) systemCapabilityManager.getCapability(SystemCapabilityType.PRERECORDED_SPEECH))); + Validator.validatePreRecordedSpeechCapabilities(TestValues.GENERAL_PRERECORDEDSPEECH_LIST, (List) systemCapabilityManager.getCapability(SystemCapabilityType.PRERECORDED_SPEECH, null, false))); } @@ -256,7 +256,7 @@ public class SystemCapabilityManagerTests { public void onError(String info) { assertTrue(false); } - }); + }, false); } private Answer createOnHMIStatusAnswer(final HMILevel hmiLevel){ @@ -687,7 +687,7 @@ public class SystemCapabilityManagerTests { @Test public void testListConversion(){ SystemCapabilityManager systemCapabilityManager = createSampleManager(); - Object capability = systemCapabilityManager.getCapability(SystemCapabilityType.SOFTBUTTON); + Object capability = systemCapabilityManager.getCapability(SystemCapabilityType.SOFTBUTTON, null, false); assertNotNull(capability); List list = SystemCapabilityManager.convertToList(capability, SoftButtonCapabilities.class); assertNotNull(list); @@ -707,7 +707,7 @@ public class SystemCapabilityManagerTests { OnRPCListener scmRpcListener = iSDL.rpcListeners.get(FunctionID.ON_SYSTEM_CAPABILITY_UPDATED.getId()).get(0); assertNotNull(scmRpcListener); - assertNull(systemCapabilityManager.getCapability(SystemCapabilityType.APP_SERVICES)); + assertNull(systemCapabilityManager.getCapability(SystemCapabilityType.APP_SERVICES, null, false)); /* PERFORM A NOTIFICATION SEND THROUGH THE SCM */ AppServiceCapability addServiceID = AppServiceFactory.createAppServiceCapability(AppServiceType.NAVIGATION, "test", "3453", true, null); @@ -723,7 +723,7 @@ public class SystemCapabilityManagerTests { scmRpcListener.onReceived(onSystemCapabilityUpdated); - assertNotNull(systemCapabilityManager.getCapability(SystemCapabilityType.APP_SERVICES)); + assertNotNull(systemCapabilityManager.getCapability(SystemCapabilityType.APP_SERVICES, null, false)); } @Test @@ -733,8 +733,8 @@ public class SystemCapabilityManagerTests { OnRPCListener scmRpcListener = iSDL.rpcListeners.get(FunctionID.ON_SYSTEM_CAPABILITY_UPDATED.getId()).get(0); assertNotNull(scmRpcListener); - assertNotNull(systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAYS)); - assertNotNull(systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAY)); + assertNotNull(systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAYS, null, false)); + assertNotNull(systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAY, null, false)); List newCaps = createDisplayCapabilityList(TestValues.GENERAL_DISPLAYCAPABILITIES, TestValues.GENERAL_BUTTONCAPABILITIES_LIST, TestValues.GENERAL_SOFTBUTTONCAPABILITIES_LIST);; @@ -747,11 +747,11 @@ public class SystemCapabilityManagerTests { scmRpcListener.onReceived(onSystemCapabilityUpdated); - List appliedCaps = (List)systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAYS); + List appliedCaps = (List)systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAYS, null, false); assertNotNull(appliedCaps); assertTrue(Validator.validateDisplayCapabilityList(newCaps, appliedCaps)); - DisplayCapabilities appliedConvertedCaps = (DisplayCapabilities)systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAY); + DisplayCapabilities appliedConvertedCaps = (DisplayCapabilities)systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAY, null, false); assertNotNull(appliedConvertedCaps); DisplayCapabilities testConvertedCaps = createDisplayCapabilities(newCaps.get(0).getDisplayName(), newCaps.get(0).getWindowCapabilities().get(0)); assertTrue(Validator.validateDisplayCapabilities(appliedConvertedCaps, testConvertedCaps)); @@ -772,13 +772,13 @@ public class SystemCapabilityManagerTests { assertNotNull(scmRpcListener); /* CONFIRM THE CAP DOESN'T EXIST IN SCM */ - AppServicesCapabilities cachedCap = (AppServicesCapabilities)systemCapabilityManager.getCapability(SystemCapabilityType.APP_SERVICES); + AppServicesCapabilities cachedCap = (AppServicesCapabilities)systemCapabilityManager.getCapability(SystemCapabilityType.APP_SERVICES, null, false); assertNull(cachedCap); /* ADD THE CAP IN SCM */ systemCapabilityManager.setCapability(SystemCapabilityType.APP_SERVICES, appServicesCapabilities); /* CONFIRM THE CAP DOES EXIST IN SCM */ - cachedCap = (AppServicesCapabilities)systemCapabilityManager.getCapability(SystemCapabilityType.APP_SERVICES); + cachedCap = (AppServicesCapabilities)systemCapabilityManager.getCapability(SystemCapabilityType.APP_SERVICES, null, false); assertNotNull(cachedCap); /* CONFIRM THE CAP IN SCM EQUALS ORIGINAL*/ assertEquals(cachedCap, appServicesCapabilities); @@ -798,7 +798,7 @@ public class SystemCapabilityManagerTests { scmRpcListener.onReceived(onSystemCapabilityUpdated); - cachedCap = (AppServicesCapabilities)systemCapabilityManager.getCapability(SystemCapabilityType.APP_SERVICES); + cachedCap = (AppServicesCapabilities)systemCapabilityManager.getCapability(SystemCapabilityType.APP_SERVICES, null, false); assertNotNull(cachedCap); assertTrue(cachedCap.getAppServices().get(0).getUpdatedAppServiceRecord().getServiceID().equals(baseID)); @@ -823,7 +823,7 @@ public class SystemCapabilityManagerTests { scmRpcListener.onReceived(onSystemCapabilityUpdated); - cachedCap = (AppServicesCapabilities)systemCapabilityManager.getCapability(SystemCapabilityType.APP_SERVICES); + cachedCap = (AppServicesCapabilities)systemCapabilityManager.getCapability(SystemCapabilityType.APP_SERVICES, null, false); assertNotNull(cachedCap); assertEquals(cachedCap.getAppServices().size(), 1); @@ -842,7 +842,7 @@ public class SystemCapabilityManagerTests { scmRpcListener.onReceived(onSystemCapabilityUpdated); - cachedCap = (AppServicesCapabilities)systemCapabilityManager.getCapability(SystemCapabilityType.APP_SERVICES); + cachedCap = (AppServicesCapabilities)systemCapabilityManager.getCapability(SystemCapabilityType.APP_SERVICES, null, false); assertNotNull(cachedCap); assertEquals(cachedCap.getAppServices().size(), 2); @@ -861,7 +861,7 @@ public class SystemCapabilityManagerTests { scmRpcListener.onReceived(onSystemCapabilityUpdated); - cachedCap = (AppServicesCapabilities)systemCapabilityManager.getCapability(SystemCapabilityType.APP_SERVICES); + cachedCap = (AppServicesCapabilities)systemCapabilityManager.getCapability(SystemCapabilityType.APP_SERVICES, null, false); assertNotNull(cachedCap); assertEquals(cachedCap.getAppServices().size(), 1); @@ -876,7 +876,7 @@ public class SystemCapabilityManagerTests { assertNotNull(scmRpcListener); systemCapabilityManager.setCapability(SystemCapabilityType.PHONE_CALL, TestValues.GENERAL_PHONECAPABILITY); - PhoneCapability phoneCapability = (PhoneCapability)systemCapabilityManager.getCapability(SystemCapabilityType.PHONE_CALL); + PhoneCapability phoneCapability = (PhoneCapability)systemCapabilityManager.getCapability(SystemCapabilityType.PHONE_CALL, null, false); assertNotNull(phoneCapability); assertEquals(phoneCapability, TestValues.GENERAL_PHONECAPABILITY); @@ -889,7 +889,7 @@ public class SystemCapabilityManagerTests { scmRpcListener.onReceived(onSystemCapabilityUpdated); - PhoneCapability phoneCapabilityUpdated = (PhoneCapability)systemCapabilityManager.getCapability(SystemCapabilityType.PHONE_CALL); + PhoneCapability phoneCapabilityUpdated = (PhoneCapability)systemCapabilityManager.getCapability(SystemCapabilityType.PHONE_CALL, null, false); assertNotNull(phoneCapabilityUpdated); assertFalse(phoneCapabilityUpdated.getDialNumberEnabled()); assertEquals(phoneCapability, phoneCapabilityUpdated); @@ -913,11 +913,11 @@ public class SystemCapabilityManagerTests { dlRpcListener.onReceived(newLayout); - DisplayCapabilities appliedCaps = (DisplayCapabilities)systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAY); + DisplayCapabilities appliedCaps = (DisplayCapabilities)systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAY, null, false); assertNotNull(appliedCaps); assertTrue(Validator.validateDisplayCapabilities(newLayout.getDisplayCapabilities(), appliedCaps)); - List convertedCaps = (List)systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAYS); + List convertedCaps = (List)systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAYS, null, false); assertNotNull(convertedCaps); List testCaps = createDisplayCapabilityList(newLayout.getDisplayCapabilities(), newLayout.getButtonCapabilities(), newLayout.getSoftButtonCapabilities()); assertTrue(Validator.validateDisplayCapabilityList(convertedCaps, testCaps)); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lockscreen/LockScreenConfigTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lockscreen/LockScreenConfigTests.java index 84a4e52ef..500680e02 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lockscreen/LockScreenConfigTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lockscreen/LockScreenConfigTests.java @@ -30,7 +30,6 @@ public class LockScreenConfigTests { lockScreenConfig.setAppIcon(TestValues.GENERAL_INT); lockScreenConfig.setBackgroundColor(TestValues.GENERAL_INT); lockScreenConfig.showDeviceLogo(true); - lockScreenConfig.setEnabled(true); lockScreenConfig.setDisplayMode(LockScreenConfig.DISPLAY_MODE_OPTIONAL_OR_REQUIRED); } @@ -41,7 +40,6 @@ public class LockScreenConfigTests { assertEquals(TestValues.GENERAL_INT, lockScreenConfig.getCustomView()); assertEquals(TestValues.GENERAL_INT, lockScreenConfig.getAppIcon()); assertEquals(TestValues.GENERAL_INT, lockScreenConfig.getBackgroundColor()); - assertTrue(lockScreenConfig.isEnabled()); assertTrue(lockScreenConfig.isDeviceLogoEnabled()); assertEquals(LockScreenConfig.DISPLAY_MODE_OPTIONAL_OR_REQUIRED, lockScreenConfig.getDisplayMode()); } diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lockscreen/LockScreenManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lockscreen/LockScreenManagerTests.java index 2509a2298..6baf9f7ee 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lockscreen/LockScreenManagerTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lockscreen/LockScreenManagerTests.java @@ -60,7 +60,6 @@ public class LockScreenManagerTests { lockScreenConfig.setAppIcon(TestValues.GENERAL_INT); lockScreenConfig.setBackgroundColor(TestValues.GENERAL_INT); lockScreenConfig.showDeviceLogo(true); - lockScreenConfig.setEnabled(true); lockScreenConfig.setDisplayMode(LockScreenConfig.DISPLAY_MODE_OPTIONAL_OR_REQUIRED); lockScreenManager = new LockScreenManager(lockScreenConfig, context, internalInterface); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/TestValues.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/TestValues.java index bd82d2d5d..2b721db7c 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/TestValues.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/TestValues.java @@ -1031,7 +1031,7 @@ public class TestValues { GENERAL_LOCKSCREENCONFIG.setAppIcon(R.drawable.sdl_lockscreen_icon); GENERAL_LOCKSCREENCONFIG.setBackgroundColor(Color.BLUE); - GENERAL_LOCKSCREENCONFIG.setEnabled(true); + GENERAL_LOCKSCREENCONFIG.setDisplayMode(LockScreenConfig.DISPLAY_MODE_ALWAYS); GENERAL_LOCKSCREENCONFIG.setCustomView(R.layout.activity_sdllock_screen); GENERAL_CLOUDAPPPROPERTIES.setNicknames(GENERAL_STRING_LIST); GENERAL_CLOUDAPPPROPERTIES.setAppID(GENERAL_STRING); diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/managers/SdlManager.java b/android/sdl_android/src/main/java/com/smartdevicelink/managers/SdlManager.java index 42dc6a165..f109cbe85 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/managers/SdlManager.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/managers/SdlManager.java @@ -124,7 +124,7 @@ public class SdlManager extends BaseSdlManager { // Instantiate sub managers this.permissionManager = new PermissionManager(_internalInterface); this.fileManager = new FileManager(_internalInterface, context, fileManagerConfig); - if (lockScreenConfig.isEnabled()) { + if (lockScreenConfig.getDisplayMode() != LockScreenConfig.DISPLAY_MODE_NEVER) { this.lockScreenManager = new LockScreenManager(lockScreenConfig, context, _internalInterface); } this.screenManager = new ScreenManager(_internalInterface, this.fileManager); @@ -142,7 +142,7 @@ public class SdlManager extends BaseSdlManager { // Start sub managers this.permissionManager.start(subManagerListener); this.fileManager.start(subManagerListener); - if (lockScreenConfig.isEnabled()) { + if (lockScreenConfig.getDisplayMode() != LockScreenConfig.DISPLAY_MODE_NEVER) { this.lockScreenManager.start(subManagerListener); } this.screenManager.start(subManagerListener); @@ -150,19 +150,19 @@ public class SdlManager extends BaseSdlManager { @Override void checkState() { - if (permissionManager != null && fileManager != null && screenManager != null && (!lockScreenConfig.isEnabled() || lockScreenManager != null)) { - if (permissionManager.getState() == BaseSubManager.READY && fileManager.getState() == BaseSubManager.READY && screenManager.getState() == BaseSubManager.READY && (!lockScreenConfig.isEnabled() || lockScreenManager.getState() == BaseSubManager.READY)) { + if (permissionManager != null && fileManager != null && screenManager != null && (lockScreenConfig.getDisplayMode() == LockScreenConfig.DISPLAY_MODE_NEVER || lockScreenManager != null)) { + if (permissionManager.getState() == BaseSubManager.READY && fileManager.getState() == BaseSubManager.READY && screenManager.getState() == BaseSubManager.READY && (lockScreenConfig.getDisplayMode() == LockScreenConfig.DISPLAY_MODE_NEVER || lockScreenManager.getState() == BaseSubManager.READY)) { DebugTool.logInfo(TAG, "Starting sdl manager, all sub managers are in ready state"); transitionToState(BaseSubManager.READY); handleQueuedNotifications(); notifyDevListener(null); onReady(); - } else if (permissionManager.getState() == BaseSubManager.ERROR && fileManager.getState() == BaseSubManager.ERROR && screenManager.getState() == BaseSubManager.ERROR && (!lockScreenConfig.isEnabled() || lockScreenManager.getState() == BaseSubManager.ERROR)) { + } else if (permissionManager.getState() == BaseSubManager.ERROR && fileManager.getState() == BaseSubManager.ERROR && screenManager.getState() == BaseSubManager.ERROR && (lockScreenConfig.getDisplayMode() == LockScreenConfig.DISPLAY_MODE_NEVER || lockScreenManager.getState() == BaseSubManager.ERROR)) { String info = "ERROR starting sdl manager, all sub managers are in error state"; DebugTool.logError(TAG, info); transitionToState(BaseSubManager.ERROR); notifyDevListener(info); - } else if (permissionManager.getState() == BaseSubManager.SETTING_UP || fileManager.getState() == BaseSubManager.SETTING_UP || screenManager.getState() == BaseSubManager.SETTING_UP || (lockScreenConfig.isEnabled() && lockScreenManager != null && lockScreenManager.getState() == BaseSubManager.SETTING_UP)) { + } else if (permissionManager.getState() == BaseSubManager.SETTING_UP || fileManager.getState() == BaseSubManager.SETTING_UP || screenManager.getState() == BaseSubManager.SETTING_UP || (lockScreenConfig.getDisplayMode() != LockScreenConfig.DISPLAY_MODE_NEVER && lockScreenManager != null && lockScreenManager.getState() == BaseSubManager.SETTING_UP)) { DebugTool.logInfo(TAG, "SETTING UP sdl manager, some sub managers are still setting up"); transitionToState(BaseSubManager.SETTING_UP); // No need to notify developer here! diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/managers/SdlManagerListener.java b/android/sdl_android/src/main/java/com/smartdevicelink/managers/SdlManagerListener.java index aa0e4f84a..8bd1f6259 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/managers/SdlManagerListener.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/managers/SdlManagerListener.java @@ -54,21 +54,6 @@ public interface SdlManagerListener extends BaseSdlManagerListener{ */ void onError(String info, Exception e); - /** - * Called when the SDL manager detected a language mismatch. In case of a language mismatch the - * manager should change the apps registration by updating the lifecycle configuration to the - * specified language. If the app can support the specified language it should return an Object - * of LifecycleConfigurationUpdate, otherwise it should return null to indicate that the language - * is not supported. - * - * @param language The language of the connected head unit the manager is trying to update the configuration. - * @return An object of LifecycleConfigurationUpdate if the head unit language is supported, - * otherwise null to indicate that the language is not supported. - * @deprecated use {@link #managerShouldUpdateLifecycle(Language language, Language hmiLanguage)} instead - */ - @Deprecated - LifecycleConfigurationUpdate managerShouldUpdateLifecycle(Language language); - /** * Called when the SDL manager detected a language mismatch. In case of a language mismatch the * manager should change the apps registration by updating the lifecycle configuration to the diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/managers/file/FileManager.java b/android/sdl_android/src/main/java/com/smartdevicelink/managers/file/FileManager.java index bdd21ba45..f03c24084 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/managers/file/FileManager.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/managers/file/FileManager.java @@ -65,14 +65,6 @@ public class FileManager extends BaseFileManager { private final WeakReference context; - @Deprecated - public FileManager(ISdl internalInterface, Context context) { - - // setup - super(internalInterface); - this.context = new WeakReference<>(context); - } - /** * Constructor for FileManager * @param internalInterface an instance of the ISdl interface that can be used for common SDL operations (sendRpc, addRpcListener, etc) diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/managers/lockscreen/LockScreenConfig.java b/android/sdl_android/src/main/java/com/smartdevicelink/managers/lockscreen/LockScreenConfig.java index 8fe3286ba..8d1e9a6c8 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/managers/lockscreen/LockScreenConfig.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/managers/lockscreen/LockScreenConfig.java @@ -87,30 +87,6 @@ public class LockScreenConfig { this.enableDismissGesture = true; } - /** - * If set to true, SDL will manage the showing and dismissing of the lock screen for you.
- * - * If false, you must manage the lock screen - * @param enable boolean - * - * @deprecated to disable the lockscreen, use setDisplayMode with DISPLAY_MODE_NEVER instead - */ - @Deprecated - public void setEnabled(boolean enable){ - this.enable = enable; - } - - /** - * Gets whether the lock screen is being managed for you - * @return boolean - * - * @deprecated to disable the lockscreen, use setDisplayMode with DISPLAY_MODE_NEVER instead - */ - @Deprecated - public boolean isEnabled() { - return enable; - } - /** * Set the resource int of the background color. Colors should define colors in your Colors.xml file * @param resourceColor resource int of the color diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/managers/lockscreen/LockScreenManager.java b/android/sdl_android/src/main/java/com/smartdevicelink/managers/lockscreen/LockScreenManager.java index c5d567e56..48ab19960 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/managers/lockscreen/LockScreenManager.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/managers/lockscreen/LockScreenManager.java @@ -96,7 +96,7 @@ public class LockScreenManager extends BaseSubManager { lockScreenIcon = lockScreenConfig.getAppIcon(); lockScreenColor = lockScreenConfig.getBackgroundColor(); customView = lockScreenConfig.getCustomView(); - lockScreenEnabled = lockScreenConfig.isEnabled(); + lockScreenEnabled = lockScreenConfig.getDisplayMode() != LockScreenConfig.DISPLAY_MODE_NEVER; deviceLogoEnabled = lockScreenConfig.isDeviceLogoEnabled(); displayMode = lockScreenConfig.getDisplayMode(); enableDismissGesture = lockScreenConfig.enableDismissGesture(); diff --git a/base/src/main/java/com/smartdevicelink/managers/BaseSdlManager.java b/base/src/main/java/com/smartdevicelink/managers/BaseSdlManager.java index 8332f9d0e..8e2b5b84d 100644 --- a/base/src/main/java/com/smartdevicelink/managers/BaseSdlManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/BaseSdlManager.java @@ -178,17 +178,10 @@ abstract class BaseSdlManager { if ((actualLanguage != null && !actualLanguage.equals(language)) || (actualHMILanguage != null && !actualHMILanguage.equals(hmiLanguage))) { - LifecycleConfigurationUpdate lcuNew = managerListener.managerShouldUpdateLifecycle(actualLanguage, actualHMILanguage); - LifecycleConfigurationUpdate lcuOld = managerListener.managerShouldUpdateLifecycle(actualLanguage); - final LifecycleConfigurationUpdate lcu; + final LifecycleConfigurationUpdate lcu = managerListener.managerShouldUpdateLifecycle(actualLanguage, actualHMILanguage); + ChangeRegistration changeRegistration; - if (lcuNew == null) { - lcu = lcuOld; - changeRegistration = new ChangeRegistration(actualLanguage, actualLanguage); - } else { - lcu = lcuNew; - changeRegistration = new ChangeRegistration(actualLanguage, actualHMILanguage); - } + changeRegistration = new ChangeRegistration(actualLanguage, actualHMILanguage); if (lcu != null) { changeRegistration.setAppName(lcu.getAppName()); @@ -786,17 +779,6 @@ abstract class BaseSdlManager { return this; } - /** - * Sets the Security libraries - * - * @param secList The list of security class(es) - */ - @Deprecated - public Builder setSdlSecurity(List> secList) { - sdlManager.sdlSecList = secList; - return this; - } - /** * Sets the security libraries and a callback to notify caller when there is update to encryption service * diff --git a/base/src/main/java/com/smartdevicelink/managers/file/BaseFileManager.java b/base/src/main/java/com/smartdevicelink/managers/file/BaseFileManager.java index 6056cdbf6..87cb05eb4 100644 --- a/base/src/main/java/com/smartdevicelink/managers/file/BaseFileManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/file/BaseFileManager.java @@ -86,14 +86,6 @@ abstract class BaseFileManager extends BaseSubManager { private FileManagerConfig fileManagerConfig; private HashMap failedFileUploadsIndex; - @Deprecated - BaseFileManager(ISdl internalInterface) { - - // setup - super(internalInterface); - uploadedEphemeralFileNames = new ArrayList<>(); - } - /** * Constructor for BaseFileManager * @param internalInterface ISDL diff --git a/base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseLifecycleManager.java b/base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseLifecycleManager.java index a366d5984..d780ef244 100644 --- a/base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseLifecycleManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseLifecycleManager.java @@ -1028,7 +1028,7 @@ abstract class BaseLifecycleManager { @Override public Object getCapability(SystemCapabilityType systemCapabilityType) { if (BaseLifecycleManager.this.systemCapabilityManager != null) { - return BaseLifecycleManager.this.systemCapabilityManager.getCapability(systemCapabilityType); + return BaseLifecycleManager.this.systemCapabilityManager.getCapability(systemCapabilityType, null, false); } else { return null; } @@ -1037,7 +1037,7 @@ abstract class BaseLifecycleManager { @Override public void getCapability(SystemCapabilityType systemCapabilityType, OnSystemCapabilityListener scListener) { if (BaseLifecycleManager.this.systemCapabilityManager != null) { - BaseLifecycleManager.this.systemCapabilityManager.getCapability(systemCapabilityType, scListener); + BaseLifecycleManager.this.systemCapabilityManager.getCapability(systemCapabilityType, scListener, false); } } @@ -1188,11 +1188,6 @@ abstract class BaseLifecycleManager { } } - @Deprecated - public void setSdlSecurityClassList(List> list) { - _secList = list; - } - /** * Sets the security libraries and a callback to notify caller when there is update to encryption service * diff --git a/base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseSystemCapabilityManager.java b/base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseSystemCapabilityManager.java index ede4d7fbe..d53dfe9bd 100644 --- a/base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseSystemCapabilityManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseSystemCapabilityManager.java @@ -167,7 +167,7 @@ abstract class BaseSystemCapabilityManager { private void updateDeprecatedDisplayCapabilities() { WindowCapability defaultMainWindowCapabilities = getDefaultMainWindowCapability(); - List displayCapabilityList = convertToList(getCapability(SystemCapabilityType.DISPLAYS), DisplayCapability.class); + List displayCapabilityList = convertToList(getCapability(SystemCapabilityType.DISPLAYS, null, false), DisplayCapability.class); if (defaultMainWindowCapabilities == null || displayCapabilityList == null || displayCapabilityList.size() == 0) { return; @@ -185,7 +185,7 @@ abstract class BaseSystemCapabilityManager { return; } - List oldCapabilities = convertToList(getCapability(SystemCapabilityType.DISPLAYS), DisplayCapability.class); + List oldCapabilities = convertToList(getCapability(SystemCapabilityType.DISPLAYS, null, false), DisplayCapability.class); if (oldCapabilities == null || oldCapabilities.size() == 0) { setCapability(SystemCapabilityType.DISPLAYS, newCapabilities); @@ -228,7 +228,7 @@ abstract class BaseSystemCapabilityManager { public WindowCapability getWindowCapability(int windowID) { - List capabilities = convertToList(getCapability(SystemCapabilityType.DISPLAYS), DisplayCapability.class); + List capabilities = convertToList(getCapability(SystemCapabilityType.DISPLAYS, null, false), DisplayCapability.class); if (capabilities == null || capabilities.size() == 0) { return null; } @@ -405,7 +405,7 @@ abstract class BaseSystemCapabilityManager { if (rpcVersion.isBetween(new Version(3, 0, 0), new Version(4, 4, 0)) >= 0) { //This was before the system capability feature was added so check if // graphics are supported instead - DisplayCapabilities displayCapabilities = (DisplayCapabilities) getCapability(SystemCapabilityType.DISPLAY); + DisplayCapabilities displayCapabilities = (DisplayCapabilities) getCapability(SystemCapabilityType.DISPLAY, null, false); if (displayCapabilities != null) { return displayCapabilities.getGraphicSupported() != null && displayCapabilities.getGraphicSupported(); } @@ -498,26 +498,6 @@ abstract class BaseSystemCapabilityManager { return getCapabilityPrivate(systemCapabilityType, scListener, null, forceUpdate); } - /** Gets the capability object that corresponds to the supplied capability type by calling the listener immediately with the cached value, if available. If not available, the listener will retrieve a new value and return that when the head unit responds. - * @param systemCapabilityType Type of capability desired - * @param scListener callback to execute upon retrieving capability - * @deprecated use {@link #getCapability(SystemCapabilityType, OnSystemCapabilityListener, boolean)} instead. - */ - @Deprecated - public void getCapability(final SystemCapabilityType systemCapabilityType, final OnSystemCapabilityListener scListener) { - getCapabilityPrivate(systemCapabilityType, scListener, null, false); - } - - /** Gets the capability object that corresponds to the supplied capability type by returning the currently cached value immediately if available. Otherwise returns a null object and works in the background to retrieve the capability for the next call - * @param systemCapabilityType Type of capability desired - * @return Desired capability if it is cached in the manager, otherwise returns null - * @deprecated use {@link #getCapability(SystemCapabilityType, OnSystemCapabilityListener, boolean)} instead. - */ - @Deprecated - public Object getCapability(final SystemCapabilityType systemCapabilityType) { - return getCapabilityPrivate(systemCapabilityType, null, null, false); - } - /** * Adds a listener to be called whenever a new capability is retrieved. This method automatically subscribes to the supplied capability type and may call the listener multiple times if there are future updates, unlike getCapability() methods, which only call the listener one time. * @param systemCapabilityType Type of capability desired diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/KeyboardAutocompleteCompletionListener.java b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/KeyboardAutocompleteCompletionListener.java index 13b19238d..9178e6c74 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/KeyboardAutocompleteCompletionListener.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/KeyboardAutocompleteCompletionListener.java @@ -36,14 +36,6 @@ import java.util.List; public interface KeyboardAutocompleteCompletionListener { - /** - * This listener is called when you wish to update your autocomplete text in response to the user's input - * @param updatedAutoCompleteText - The new autocomplete text to use - * @deprecated use {@link #onUpdatedAutoCompleteList(List)} instead - */ - @Deprecated - void onUpdatedAutoCompleteText(String updatedAutoCompleteText); - /** * This listener is called when you wish to update your autocomplete suggestions list in response to the user's input * @param updatedAutoCompleteList - The new autocomplete suggestions list to use diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PresentChoiceSetOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PresentChoiceSetOperation.java index 121b1f6c0..c0e206eed 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PresentChoiceSetOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PresentChoiceSetOperation.java @@ -340,16 +340,9 @@ class PresentChoiceSetOperation extends Task { } else if (onKeyboard.getEvent().equals(KeyboardEvent.KEYPRESS)){ // Notify of Keypress keyboardListener.updateAutocompleteWithInput(onKeyboard.getData(), new KeyboardAutocompleteCompletionListener() { - @Override - public void onUpdatedAutoCompleteText(String updatedAutoCompleteText) { - keyboardProperties.setAutoCompleteText(updatedAutoCompleteText); - updateKeyboardProperties(null); - } - @Override public void onUpdatedAutoCompleteList(List updatedAutoCompleteList) { keyboardProperties.setAutoCompleteList(updatedAutoCompleteList != null ? updatedAutoCompleteList : new ArrayList()); - keyboardProperties.setAutoCompleteText(updatedAutoCompleteList != null && !updatedAutoCompleteList.isEmpty() ? updatedAutoCompleteList.get(0) : null); updateKeyboardProperties(null); } }); diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PresentKeyboardOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PresentKeyboardOperation.java index 33db35607..b48bbffd2 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PresentKeyboardOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PresentKeyboardOperation.java @@ -285,12 +285,6 @@ class PresentKeyboardOperation extends Task { } else if (onKeyboard.getEvent().equals(KeyboardEvent.KEYPRESS)){ // Notify of Keypress keyboardListener.updateAutocompleteWithInput(onKeyboard.getData(), new KeyboardAutocompleteCompletionListener() { - @Override - public void onUpdatedAutoCompleteText(String updatedAutoCompleteText) { - keyboardProperties.setAutoCompleteText(updatedAutoCompleteText); - updateKeyboardProperties(null); - } - @Override public void onUpdatedAutoCompleteList(List updatedAutoCompleteList) { keyboardProperties.setAutoCompleteList(updatedAutoCompleteList != null ? updatedAutoCompleteList : new ArrayList()); diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/menu/MenuCell.java b/base/src/main/java/com/smartdevicelink/managers/screen/menu/MenuCell.java index 20cc44d38..4eef7777f 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/menu/MenuCell.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/menu/MenuCell.java @@ -112,24 +112,6 @@ public class MenuCell implements Cloneable{ // CONSTRUCTOR FOR CELL THAT WILL LINK TO SUB MENU - /** - * Creates a new MenuCell Object with multiple parameters set - * NOTE: because this has sub-cells, there does not need to be a listener - * @param title The cell's primary text - * @param icon The cell's image - * @param subCells The sub-cells for the sub menu that will appear when the cell is selected - * - * @deprecated use {@link #MenuCell(String, MenuLayout, SdlArtwork, List)} - */ - @Deprecated - public MenuCell(@NonNull String title, @Nullable SdlArtwork icon, @Nullable List subCells) { - setTitle(title); // title is the only required param - setIcon(icon); - setSubCells(subCells); - setCellId(MAX_ID); - setParentCellId(MAX_ID); - } - /** * Creates a new MenuCell Object with multiple parameters set * NOTE: because this has sub-cells, there does not need to be a listener diff --git a/hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java b/hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java index 0c1b87c6a..c619b46fb 100644 --- a/hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java +++ b/hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java @@ -135,11 +135,6 @@ public class SdlService { public void onError(SdlManager sdlManager, String info, Exception e) { } - @Override - public LifecycleConfigurationUpdate managerShouldUpdateLifecycle(Language language) { - return null; - } - @Override public LifecycleConfigurationUpdate managerShouldUpdateLifecycle(Language language, Language hmiLanguage) { boolean isNeedUpdate = false; diff --git a/javaSE/src/main/java/com/smartdevicelink/managers/SdlManagerListener.java b/javaSE/src/main/java/com/smartdevicelink/managers/SdlManagerListener.java index 8118a9c93..43aad3161 100644 --- a/javaSE/src/main/java/com/smartdevicelink/managers/SdlManagerListener.java +++ b/javaSE/src/main/java/com/smartdevicelink/managers/SdlManagerListener.java @@ -53,21 +53,6 @@ public interface SdlManagerListener extends BaseSdlManagerListener { */ void onError(SdlManager manager, String info, Exception e); - /** - * Called when the SDL manager detected a language mismatch. In case of a language mismatch the - * manager should change the apps registration by updating the lifecycle configuration to the - * specified language. If the app can support the specified language it should return an Object - * of LifecycleConfigurationUpdate, otherwise it should return null to indicate that the language - * is not supported. - * - * @param language The language of the connected head unit the manager is trying to update the configuration. - * @return An object of LifecycleConfigurationUpdate if the head unit language is supported, - * otherwise null to indicate that the language is not supported. - * @deprecated use {@link #managerShouldUpdateLifecycle(Language language, Language hmiLanguage)} instead - */ - @Deprecated - LifecycleConfigurationUpdate managerShouldUpdateLifecycle(Language language); - /** * Called when the SDL manager detected a language mismatch. In case of a language mismatch the * manager should change the apps registration by updating the lifecycle configuration to the diff --git a/javaSE/src/main/java/com/smartdevicelink/managers/file/FileManager.java b/javaSE/src/main/java/com/smartdevicelink/managers/file/FileManager.java index 54896f273..b4a92ddb6 100644 --- a/javaSE/src/main/java/com/smartdevicelink/managers/file/FileManager.java +++ b/javaSE/src/main/java/com/smartdevicelink/managers/file/FileManager.java @@ -60,13 +60,6 @@ import java.net.URI; */ public class FileManager extends BaseFileManager { - @Deprecated - public FileManager(ISdl internalInterface) { - - // setup - super(internalInterface); - } - /** * Constructor for FileManager * @param internalInterface an instance of the ISdl interface that can be used for common SDL operations (sendRpc, addRpcListener, etc) -- cgit v1.2.1 From bbfd7762c7a2dc92b95725da2d8a1948e6cfd632 Mon Sep 17 00:00:00 2001 From: Joey Grover Date: Thu, 3 Sep 2020 11:14:37 -0400 Subject: Refactor javaSE lib and sample to one directory --- hello_sdl_java/assets/images/sdl.png | Bin 3274 -> 0 bytes hello_sdl_java/assets/images/sdl_s_green.png | Bin 25896 -> 0 bytes hello_sdl_java/build.gradle | 33 - hello_sdl_java/gradle/wrapper/gradle-wrapper.jar | Bin 56172 -> 0 bytes .../gradle/wrapper/gradle-wrapper.properties | 6 - hello_sdl_java/gradlew | 172 ----- hello_sdl_java/gradlew.bat | 84 --- hello_sdl_java/settings.gradle | 4 - .../main/java/com/smartdevicelink/java/Main.java | 101 --- .../java/com/smartdevicelink/java/SdlService.java | 408 ---------- javaSE/README.md | 25 - javaSE/bintray.gradle | 96 --- javaSE/bintray.properties | 8 - javaSE/build.gradle | 80 -- javaSE/gradle/wrapper/gradle-wrapper.jar | Bin 55190 -> 0 bytes javaSE/gradle/wrapper/gradle-wrapper.properties | 6 - javaSE/gradlew | 172 ----- javaSE/gradlew.bat | 84 --- javaSE/hello_sdl_java/assets/images/sdl.png | Bin 0 -> 3274 bytes .../hello_sdl_java/assets/images/sdl_s_green.png | Bin 0 -> 25896 bytes javaSE/hello_sdl_java/build.gradle | 33 + javaSE/hello_sdl_java/settings.gradle | 4 + .../main/java/com/smartdevicelink/java/Main.java | 101 +++ .../java/com/smartdevicelink/java/SdlService.java | 408 ++++++++++ javaSE/javaSE/README.md | 25 + javaSE/javaSE/bintray.gradle | 96 +++ javaSE/javaSE/bintray.properties | 8 + javaSE/javaSE/build.gradle | 80 ++ javaSE/javaSE/settings.gradle | 2 + .../src/main/java/com/livio/BSON/BsonEncoder.java | 118 +++ .../main/java/com/smartdevicelink/BuildConfig.java | 36 + .../smartdevicelink/SdlConnection/SdlSession.java | 109 +++ .../com/smartdevicelink/managers/SdlManager.java | 183 +++++ .../managers/SdlManagerListener.java | 84 +++ .../smartdevicelink/managers/file/FileManager.java | 150 ++++ .../managers/file/filetypes/SdlArtwork.java | 165 ++++ .../managers/file/filetypes/SdlFile.java | 342 +++++++++ .../lifecycle/EncryptionLifecycleManager.java | 45 ++ .../managers/lifecycle/LifecycleManager.java | 77 ++ .../lifecycle/SystemCapabilityManager.java | 45 ++ .../managers/permission/PermissionManager.java | 55 ++ .../managers/screen/ScreenManager.java | 48 ++ .../managers/screen/SoftButtonManager.java | 54 ++ .../managers/screen/SubscribeButtonManager.java | 11 + .../managers/screen/TextAndGraphicManager.java | 62 ++ .../screen/choiceset/ChoiceSetManager.java | 54 ++ .../managers/screen/menu/MenuManager.java | 52 ++ .../managers/screen/menu/VoiceCommandManager.java | 51 ++ .../com/smartdevicelink/protocol/SdlPacket.java | 56 ++ .../com/smartdevicelink/protocol/SdlProtocol.java | 51 ++ .../smartdevicelink/security/SdlSecurityBase.java | 36 + .../java/com/smartdevicelink/trace/SdlTrace.java | 48 ++ .../smartdevicelink/transport/CustomTransport.java | 171 +++++ .../transport/CustomTransportConfig.java | 53 ++ .../transport/TransportCallback.java | 44 ++ .../transport/TransportInterface.java | 47 ++ .../transport/TransportManager.java | 214 ++++++ .../smartdevicelink/transport/WebSocketServer.java | 198 +++++ .../transport/WebSocketServerConfig.java | 65 ++ .../smartdevicelink/transport/utl/SSLConfig.java | 111 +++ .../utl/SSLWebSocketFactoryGenerator.java | 163 ++++ .../transport/utl/TransportRecord.java | 41 + .../main/java/com/smartdevicelink/util/Log.java | 19 + javaSE/javaSE/src/main/java/org/json/JSON.java | 116 +++ .../javaSE/src/main/java/org/json/JSONArray.java | 626 ++++++++++++++++ .../src/main/java/org/json/JSONException.java | 58 ++ .../javaSE/src/main/java/org/json/JSONObject.java | 829 +++++++++++++++++++++ .../src/main/java/org/json/JSONStringer.java | 432 +++++++++++ .../javaSE/src/main/java/org/json/JSONTokener.java | 611 +++++++++++++++ javaSE/settings.gradle | 2 - .../src/main/java/com/livio/BSON/BsonEncoder.java | 118 --- .../main/java/com/smartdevicelink/BuildConfig.java | 36 - .../smartdevicelink/SdlConnection/SdlSession.java | 109 --- .../com/smartdevicelink/managers/SdlManager.java | 183 ----- .../managers/SdlManagerListener.java | 84 --- .../smartdevicelink/managers/file/FileManager.java | 150 ---- .../managers/file/filetypes/SdlArtwork.java | 165 ---- .../managers/file/filetypes/SdlFile.java | 342 --------- .../lifecycle/EncryptionLifecycleManager.java | 45 -- .../managers/lifecycle/LifecycleManager.java | 77 -- .../lifecycle/SystemCapabilityManager.java | 45 -- .../managers/permission/PermissionManager.java | 55 -- .../managers/screen/ScreenManager.java | 48 -- .../managers/screen/SoftButtonManager.java | 54 -- .../managers/screen/SubscribeButtonManager.java | 11 - .../managers/screen/TextAndGraphicManager.java | 62 -- .../screen/choiceset/ChoiceSetManager.java | 54 -- .../managers/screen/menu/MenuManager.java | 52 -- .../managers/screen/menu/VoiceCommandManager.java | 51 -- .../com/smartdevicelink/protocol/SdlPacket.java | 56 -- .../com/smartdevicelink/protocol/SdlProtocol.java | 51 -- .../smartdevicelink/security/SdlSecurityBase.java | 36 - .../java/com/smartdevicelink/trace/SdlTrace.java | 48 -- .../smartdevicelink/transport/CustomTransport.java | 171 ----- .../transport/CustomTransportConfig.java | 53 -- .../transport/TransportCallback.java | 44 -- .../transport/TransportInterface.java | 47 -- .../transport/TransportManager.java | 214 ------ .../smartdevicelink/transport/WebSocketServer.java | 198 ----- .../transport/WebSocketServerConfig.java | 65 -- .../smartdevicelink/transport/utl/SSLConfig.java | 111 --- .../utl/SSLWebSocketFactoryGenerator.java | 163 ---- .../transport/utl/TransportRecord.java | 41 - .../main/java/com/smartdevicelink/util/Log.java | 19 - javaSE/src/main/java/org/json/JSON.java | 116 --- javaSE/src/main/java/org/json/JSONArray.java | 626 ---------------- javaSE/src/main/java/org/json/JSONException.java | 58 -- javaSE/src/main/java/org/json/JSONObject.java | 829 --------------------- javaSE/src/main/java/org/json/JSONStringer.java | 432 ----------- javaSE/src/main/java/org/json/JSONTokener.java | 611 --------------- 110 files changed, 6487 insertions(+), 7011 deletions(-) delete mode 100755 hello_sdl_java/assets/images/sdl.png delete mode 100755 hello_sdl_java/assets/images/sdl_s_green.png delete mode 100644 hello_sdl_java/build.gradle delete mode 100644 hello_sdl_java/gradle/wrapper/gradle-wrapper.jar delete mode 100644 hello_sdl_java/gradle/wrapper/gradle-wrapper.properties delete mode 100755 hello_sdl_java/gradlew delete mode 100644 hello_sdl_java/gradlew.bat delete mode 100644 hello_sdl_java/settings.gradle delete mode 100644 hello_sdl_java/src/main/java/com/smartdevicelink/java/Main.java delete mode 100644 hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java delete mode 100644 javaSE/README.md delete mode 100644 javaSE/bintray.gradle delete mode 100644 javaSE/bintray.properties delete mode 100644 javaSE/build.gradle delete mode 100644 javaSE/gradle/wrapper/gradle-wrapper.jar delete mode 100644 javaSE/gradle/wrapper/gradle-wrapper.properties delete mode 100755 javaSE/gradlew delete mode 100644 javaSE/gradlew.bat create mode 100755 javaSE/hello_sdl_java/assets/images/sdl.png create mode 100755 javaSE/hello_sdl_java/assets/images/sdl_s_green.png create mode 100644 javaSE/hello_sdl_java/build.gradle create mode 100644 javaSE/hello_sdl_java/settings.gradle create mode 100644 javaSE/hello_sdl_java/src/main/java/com/smartdevicelink/java/Main.java create mode 100644 javaSE/hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java create mode 100644 javaSE/javaSE/README.md create mode 100644 javaSE/javaSE/bintray.gradle create mode 100644 javaSE/javaSE/bintray.properties create mode 100644 javaSE/javaSE/build.gradle create mode 100644 javaSE/javaSE/settings.gradle create mode 100644 javaSE/javaSE/src/main/java/com/livio/BSON/BsonEncoder.java create mode 100644 javaSE/javaSE/src/main/java/com/smartdevicelink/BuildConfig.java create mode 100644 javaSE/javaSE/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java create mode 100644 javaSE/javaSE/src/main/java/com/smartdevicelink/managers/SdlManager.java create mode 100644 javaSE/javaSE/src/main/java/com/smartdevicelink/managers/SdlManagerListener.java create mode 100644 javaSE/javaSE/src/main/java/com/smartdevicelink/managers/file/FileManager.java create mode 100644 javaSE/javaSE/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlArtwork.java create mode 100644 javaSE/javaSE/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlFile.java create mode 100644 javaSE/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/EncryptionLifecycleManager.java create mode 100644 javaSE/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java create mode 100644 javaSE/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/SystemCapabilityManager.java create mode 100644 javaSE/javaSE/src/main/java/com/smartdevicelink/managers/permission/PermissionManager.java create mode 100644 javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/ScreenManager.java create mode 100644 javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/SoftButtonManager.java create mode 100644 javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/SubscribeButtonManager.java create mode 100644 javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicManager.java create mode 100644 javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSetManager.java create mode 100644 javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/menu/MenuManager.java create mode 100644 javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/menu/VoiceCommandManager.java create mode 100644 javaSE/javaSE/src/main/java/com/smartdevicelink/protocol/SdlPacket.java create mode 100644 javaSE/javaSE/src/main/java/com/smartdevicelink/protocol/SdlProtocol.java create mode 100644 javaSE/javaSE/src/main/java/com/smartdevicelink/security/SdlSecurityBase.java create mode 100644 javaSE/javaSE/src/main/java/com/smartdevicelink/trace/SdlTrace.java create mode 100644 javaSE/javaSE/src/main/java/com/smartdevicelink/transport/CustomTransport.java create mode 100644 javaSE/javaSE/src/main/java/com/smartdevicelink/transport/CustomTransportConfig.java create mode 100644 javaSE/javaSE/src/main/java/com/smartdevicelink/transport/TransportCallback.java create mode 100644 javaSE/javaSE/src/main/java/com/smartdevicelink/transport/TransportInterface.java create mode 100644 javaSE/javaSE/src/main/java/com/smartdevicelink/transport/TransportManager.java create mode 100644 javaSE/javaSE/src/main/java/com/smartdevicelink/transport/WebSocketServer.java create mode 100644 javaSE/javaSE/src/main/java/com/smartdevicelink/transport/WebSocketServerConfig.java create mode 100644 javaSE/javaSE/src/main/java/com/smartdevicelink/transport/utl/SSLConfig.java create mode 100644 javaSE/javaSE/src/main/java/com/smartdevicelink/transport/utl/SSLWebSocketFactoryGenerator.java create mode 100644 javaSE/javaSE/src/main/java/com/smartdevicelink/transport/utl/TransportRecord.java create mode 100644 javaSE/javaSE/src/main/java/com/smartdevicelink/util/Log.java create mode 100644 javaSE/javaSE/src/main/java/org/json/JSON.java create mode 100644 javaSE/javaSE/src/main/java/org/json/JSONArray.java create mode 100644 javaSE/javaSE/src/main/java/org/json/JSONException.java create mode 100644 javaSE/javaSE/src/main/java/org/json/JSONObject.java create mode 100644 javaSE/javaSE/src/main/java/org/json/JSONStringer.java create mode 100644 javaSE/javaSE/src/main/java/org/json/JSONTokener.java delete mode 100644 javaSE/settings.gradle delete mode 100644 javaSE/src/main/java/com/livio/BSON/BsonEncoder.java delete mode 100644 javaSE/src/main/java/com/smartdevicelink/BuildConfig.java delete mode 100644 javaSE/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java delete mode 100644 javaSE/src/main/java/com/smartdevicelink/managers/SdlManager.java delete mode 100644 javaSE/src/main/java/com/smartdevicelink/managers/SdlManagerListener.java delete mode 100644 javaSE/src/main/java/com/smartdevicelink/managers/file/FileManager.java delete mode 100644 javaSE/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlArtwork.java delete mode 100644 javaSE/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlFile.java delete mode 100644 javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/EncryptionLifecycleManager.java delete mode 100644 javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java delete mode 100644 javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/SystemCapabilityManager.java delete mode 100644 javaSE/src/main/java/com/smartdevicelink/managers/permission/PermissionManager.java delete mode 100644 javaSE/src/main/java/com/smartdevicelink/managers/screen/ScreenManager.java delete mode 100644 javaSE/src/main/java/com/smartdevicelink/managers/screen/SoftButtonManager.java delete mode 100644 javaSE/src/main/java/com/smartdevicelink/managers/screen/SubscribeButtonManager.java delete mode 100644 javaSE/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicManager.java delete mode 100644 javaSE/src/main/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSetManager.java delete mode 100644 javaSE/src/main/java/com/smartdevicelink/managers/screen/menu/MenuManager.java delete mode 100644 javaSE/src/main/java/com/smartdevicelink/managers/screen/menu/VoiceCommandManager.java delete mode 100644 javaSE/src/main/java/com/smartdevicelink/protocol/SdlPacket.java delete mode 100644 javaSE/src/main/java/com/smartdevicelink/protocol/SdlProtocol.java delete mode 100644 javaSE/src/main/java/com/smartdevicelink/security/SdlSecurityBase.java delete mode 100644 javaSE/src/main/java/com/smartdevicelink/trace/SdlTrace.java delete mode 100644 javaSE/src/main/java/com/smartdevicelink/transport/CustomTransport.java delete mode 100644 javaSE/src/main/java/com/smartdevicelink/transport/CustomTransportConfig.java delete mode 100644 javaSE/src/main/java/com/smartdevicelink/transport/TransportCallback.java delete mode 100644 javaSE/src/main/java/com/smartdevicelink/transport/TransportInterface.java delete mode 100644 javaSE/src/main/java/com/smartdevicelink/transport/TransportManager.java delete mode 100644 javaSE/src/main/java/com/smartdevicelink/transport/WebSocketServer.java delete mode 100644 javaSE/src/main/java/com/smartdevicelink/transport/WebSocketServerConfig.java delete mode 100644 javaSE/src/main/java/com/smartdevicelink/transport/utl/SSLConfig.java delete mode 100644 javaSE/src/main/java/com/smartdevicelink/transport/utl/SSLWebSocketFactoryGenerator.java delete mode 100644 javaSE/src/main/java/com/smartdevicelink/transport/utl/TransportRecord.java delete mode 100644 javaSE/src/main/java/com/smartdevicelink/util/Log.java delete mode 100644 javaSE/src/main/java/org/json/JSON.java delete mode 100644 javaSE/src/main/java/org/json/JSONArray.java delete mode 100644 javaSE/src/main/java/org/json/JSONException.java delete mode 100644 javaSE/src/main/java/org/json/JSONObject.java delete mode 100644 javaSE/src/main/java/org/json/JSONStringer.java delete mode 100644 javaSE/src/main/java/org/json/JSONTokener.java diff --git a/hello_sdl_java/assets/images/sdl.png b/hello_sdl_java/assets/images/sdl.png deleted file mode 100755 index 5cfc0f84a..000000000 Binary files a/hello_sdl_java/assets/images/sdl.png and /dev/null differ diff --git a/hello_sdl_java/assets/images/sdl_s_green.png b/hello_sdl_java/assets/images/sdl_s_green.png deleted file mode 100755 index c43021775..000000000 Binary files a/hello_sdl_java/assets/images/sdl_s_green.png and /dev/null differ diff --git a/hello_sdl_java/build.gradle b/hello_sdl_java/build.gradle deleted file mode 100644 index ce0689640..000000000 --- a/hello_sdl_java/build.gradle +++ /dev/null @@ -1,33 +0,0 @@ -plugins { - id 'java' -} - -version '1.0' - -sourceCompatibility = 1.7 - -repositories { - mavenCentral() - mavenLocal() - google() - jcenter() -} -// This extraLibs solution is explained here: https://discuss.gradle.org/t/how-to-include-dependencies-in-jar/19571/5 -configurations { - // configuration that holds jars to include in the jar - extraLibs -} -dependencies { - extraLibs fileTree(dir: 'libs', include: ['*.jar']) - extraLibs project(path: ':sdl_java_se') - configurations.implementation.extendsFrom(configurations.extraLibs) -} -jar { - from { - configurations.extraLibs.collect { it.isDirectory() ? it : zipTree(it) } - } - manifest { - attributes 'Class-Path': configurations.compile.collect { it.getName() }.join(' ') - attributes 'Main-Class': 'com.smartdevicelink.java.Main' - } -} \ No newline at end of file diff --git a/hello_sdl_java/gradle/wrapper/gradle-wrapper.jar b/hello_sdl_java/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 28861d273..000000000 Binary files a/hello_sdl_java/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/hello_sdl_java/gradle/wrapper/gradle-wrapper.properties b/hello_sdl_java/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index fd6d42bd6..000000000 --- a/hello_sdl_java/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Mon Mar 18 12:47:09 EDT 2019 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-all.zip diff --git a/hello_sdl_java/gradlew b/hello_sdl_java/gradlew deleted file mode 100755 index cccdd3d51..000000000 --- a/hello_sdl_java/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/hello_sdl_java/gradlew.bat b/hello_sdl_java/gradlew.bat deleted file mode 100644 index f9553162f..000000000 --- a/hello_sdl_java/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/hello_sdl_java/settings.gradle b/hello_sdl_java/settings.gradle deleted file mode 100644 index fd254fa69..000000000 --- a/hello_sdl_java/settings.gradle +++ /dev/null @@ -1,4 +0,0 @@ -rootProject.name = 'hello_sdl_java' -include ":sdl_java_se" -project (":sdl_java_se").projectDir = new File("../javaSE/") - diff --git a/hello_sdl_java/src/main/java/com/smartdevicelink/java/Main.java b/hello_sdl_java/src/main/java/com/smartdevicelink/java/Main.java deleted file mode 100644 index dc1ce2457..000000000 --- a/hello_sdl_java/src/main/java/com/smartdevicelink/java/Main.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2019. 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. - */ - -package com.smartdevicelink.java; - -import com.smartdevicelink.transport.WebSocketServerConfig; -import com.smartdevicelink.util.DebugTool; - -public class Main { - private static final String TAG = "Main"; - static Thread thread = null, mainThread; - static Object LOCK; - - static SdlService sdlService; - - public static void main(String[] args) { - //Enable DebugTool - DebugTool.enableDebugTool(); - - mainThread = Thread.currentThread(); - LOCK = new Object(); - startSdlService(); - - while(!mainThread.isInterrupted()) { - try { - synchronized (LOCK) { - LOCK.wait(); - } - System.gc(); - Thread.sleep(500); - DebugTool.logInfo(TAG, "Attempting to start SDL Service again"); - startSdlService(); - DebugTool.logInfo(TAG, "SdlService started"); - - } catch (InterruptedException e) { - e.printStackTrace(); - break; - } - } - } - - static SdlService.SdlServiceCallback serviceCallback = new SdlService.SdlServiceCallback() { - @Override - public void onEnd() { - if (thread != null) { - thread.interrupt(); - thread = null; - } - synchronized (LOCK) { - LOCK.notify(); - } - - } - }; - - private static void startSdlService() { - - thread = new Thread(new Runnable() { - - @Override - public void run() { - DebugTool.logInfo(TAG, "Starting SDL Service"); - sdlService = new SdlService(new WebSocketServerConfig(5432, -1), serviceCallback); - sdlService.start(); - - System.gc(); - - } - }); - thread.start(); - } -} diff --git a/hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java b/hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java deleted file mode 100644 index 0c1b87c6a..000000000 --- a/hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java +++ /dev/null @@ -1,408 +0,0 @@ -/* - * Copyright (c) 2019. 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. - */ - -package com.smartdevicelink.java; - -import com.smartdevicelink.managers.CompletionListener; -import com.smartdevicelink.managers.screen.OnButtonListener; -import com.smartdevicelink.managers.SdlManager; -import com.smartdevicelink.managers.SdlManagerListener; -import com.smartdevicelink.managers.file.filetypes.SdlArtwork; -import com.smartdevicelink.managers.lifecycle.LifecycleConfigurationUpdate; -import com.smartdevicelink.managers.screen.choiceset.ChoiceCell; -import com.smartdevicelink.managers.screen.choiceset.ChoiceSet; -import com.smartdevicelink.managers.screen.choiceset.ChoiceSetSelectionListener; -import com.smartdevicelink.managers.screen.menu.MenuCell; -import com.smartdevicelink.managers.screen.menu.MenuSelectionListener; -import com.smartdevicelink.managers.screen.menu.VoiceCommand; -import com.smartdevicelink.managers.screen.menu.VoiceCommandSelectionListener; -import com.smartdevicelink.protocol.enums.FunctionID; -import com.smartdevicelink.proxy.RPCNotification; -import com.smartdevicelink.proxy.TTSChunkFactory; -import com.smartdevicelink.proxy.rpc.*; -import com.smartdevicelink.proxy.rpc.enums.*; -import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener; -import com.smartdevicelink.transport.BaseTransportConfig; -import com.smartdevicelink.util.DebugTool; - -import java.util.*; - -public class SdlService { - - - private static final String TAG = "SDL Service"; - - private static final String APP_NAME = "Hello Sdl"; - private static final String APP_NAME_ES = "Hola Sdl"; - private static final String APP_NAME_FR = "Bonjour Sdl"; - private static final String APP_ID = "8678309"; - - private static final String ICON_FILENAME = "hello_sdl_icon.png"; - private static final String SDL_IMAGE_FILENAME = "sdl_full_image.png"; - - private static final String WELCOME_SHOW = "Welcome to HelloSDL"; - private static final String WELCOME_SPEAK = "Welcome to Hello S D L"; - - private static final String TEST_COMMAND_NAME = "Test Command"; - - private static final String IMAGE_DIR = "assets/images/"; - - // variable to create and call functions of the SyncProxy - private SdlManager sdlManager = null; - private List choiceCellList; - - private SdlServiceCallback callback; - - public SdlService(BaseTransportConfig config, SdlServiceCallback callback){ - this.callback = callback; - buildSdlManager(config); - } - - public void start() { - DebugTool.logInfo(TAG, "SdlService start() "); - if(sdlManager != null){ - sdlManager.start(); - } - } - - public void stop() { - if (sdlManager != null) { - sdlManager.dispose(); - sdlManager = null; - } - } - - private void buildSdlManager(BaseTransportConfig transport) { - // This logic is to select the correct transport and security levels defined in the selected build flavor - // Build flavors are selected by the "build variants" tab typically located in the bottom left of Android Studio - // Typically in your app, you will only set one of these. - if (sdlManager == null) { - DebugTool.logInfo(TAG, "Creating SDL Manager"); - - //FIXME add the transport type - // The app type to be used - Vector appType = new Vector<>(); - appType.add(AppHMIType.MEDIA); - - // The manager listener helps you know when certain events that pertain to the SDL Manager happen - // Here we will listen for ON_HMI_STATUS and ON_COMMAND notifications - SdlManagerListener listener = new SdlManagerListener() { - @Override - public void onStart(SdlManager sdlManager) { - DebugTool.logInfo(TAG, "SdlManager onStart"); - } - - @Override - public void onDestroy(SdlManager sdlManager) { - DebugTool.logInfo(TAG, "SdlManager onDestroy "); - SdlService.this.sdlManager = null; - if(SdlService.this.callback != null){ - SdlService.this.callback.onEnd(); - stop(); - } - } - - @Override - public void onError(SdlManager sdlManager, String info, Exception e) { - } - - @Override - public LifecycleConfigurationUpdate managerShouldUpdateLifecycle(Language language) { - return null; - } - - @Override - public LifecycleConfigurationUpdate managerShouldUpdateLifecycle(Language language, Language hmiLanguage) { - boolean isNeedUpdate = false; - String appName = APP_NAME; - String ttsName = APP_NAME; - switch (language) { - case ES_MX: - isNeedUpdate = true; - ttsName = APP_NAME_ES; - break; - case FR_CA: - isNeedUpdate = true; - ttsName = APP_NAME_FR; - break; - default: - break; - } - switch (hmiLanguage) { - case ES_MX: - isNeedUpdate = true; - appName = APP_NAME_ES; - break; - case FR_CA: - isNeedUpdate = true; - appName = APP_NAME_FR; - break; - default: - break; - } - if (isNeedUpdate) { - return new LifecycleConfigurationUpdate(appName, null, TTSChunkFactory.createSimpleTTSChunks(ttsName), null); - } else { - return null; - } - } - }; - - - HashMap notificationListenerHashMap = new HashMap(); - notificationListenerHashMap.put(FunctionID.ON_HMI_STATUS, new OnRPCNotificationListener() { - @Override - public void onNotified(RPCNotification notification) { - OnHMIStatus status = (OnHMIStatus) notification; - if (status.getHmiLevel() == HMILevel.HMI_FULL && ((OnHMIStatus) notification).getFirstRun()) { - setVoiceCommands(); - sendMenus(); - performWelcomeSpeak(); - performWelcomeShow(); - preloadChoices(); - subscribeToButtons(); - } - } - }); - - // Create App Icon, this is set in the SdlManager builder - SdlArtwork appIcon = new SdlArtwork(ICON_FILENAME, FileType.GRAPHIC_PNG, IMAGE_DIR+"sdl_s_green.png", true); - - // The manager builder sets options for your session - SdlManager.Builder builder = new SdlManager.Builder(APP_ID, APP_NAME, listener); - builder.setAppTypes(appType); - builder.setTransportType(transport); - builder.setAppIcon(appIcon); - builder.setRPCNotificationListeners(notificationListenerHashMap); - sdlManager = builder.build(); - } - } - - /** - * Send some voice commands - */ - private void setVoiceCommands(){ - - List list1 = Collections.singletonList("Command One"); - List list2 = Collections.singletonList("Command two"); - - VoiceCommand voiceCommand1 = new VoiceCommand(list1, new VoiceCommandSelectionListener() { - @Override - public void onVoiceCommandSelected() { - DebugTool.logInfo(TAG, "Voice Command 1 triggered"); - } - }); - - VoiceCommand voiceCommand2 = new VoiceCommand(list2, new VoiceCommandSelectionListener() { - @Override - public void onVoiceCommandSelected() { - DebugTool.logInfo(TAG, "Voice Command 2 triggered"); - } - }); - - sdlManager.getScreenManager().setVoiceCommands(Arrays.asList(voiceCommand1,voiceCommand2)); - } - - /** - * Add menus for the app on SDL. - */ - private void sendMenus(){ - - // some arts - SdlArtwork livio = new SdlArtwork(ICON_FILENAME, FileType.GRAPHIC_PNG, IMAGE_DIR+"sdl_s_green.png", true); - - // some voice commands - List voice2 = Collections.singletonList("Cell two"); - - MenuCell mainCell1 = new MenuCell("Test Cell 1 (speak)", livio, null, new MenuSelectionListener() { - @Override - public void onTriggered(TriggerSource trigger) { - DebugTool.logInfo(TAG, "Test cell 1 triggered. Source: "+ trigger.toString()); - showTest(); - } - }); - - MenuCell mainCell2 = new MenuCell("Test Cell 2", null, voice2, new MenuSelectionListener() { - @Override - public void onTriggered(TriggerSource trigger) { - DebugTool.logInfo(TAG, "Test cell 2 triggered. Source: "+ trigger.toString()); - } - }); - - // SUB MENU - - MenuCell subCell1 = new MenuCell("SubCell 1",null, null, new MenuSelectionListener() { - @Override - public void onTriggered(TriggerSource trigger) { - DebugTool.logInfo(TAG, "Sub cell 1 triggered. Source: "+ trigger.toString()); - } - }); - - MenuCell subCell2 = new MenuCell("SubCell 2",null, null, new MenuSelectionListener() { - @Override - public void onTriggered(TriggerSource trigger) { - DebugTool.logInfo(TAG, "Sub cell 2 triggered. Source: "+ trigger.toString()); - } - }); - - // sub menu parent cell - MenuCell mainCell3 = new MenuCell("Test Cell 3 (sub menu)", MenuLayout.LIST, null, Arrays.asList(subCell1,subCell2)); - - MenuCell mainCell4 = new MenuCell("Show Perform Interaction", null, null, new MenuSelectionListener() { - @Override - public void onTriggered(TriggerSource trigger) { - showPerformInteraction(); - } - }); - - MenuCell mainCell5 = new MenuCell("Clear the menu",null, null, new MenuSelectionListener() { - @Override - public void onTriggered(TriggerSource trigger) { - DebugTool.logInfo(TAG, "Clearing Menu. Source: "+ trigger.toString()); - // Clear this thing - sdlManager.getScreenManager().setMenu(Collections.emptyList()); - showAlert("Menu Cleared"); - } - }); - - // Send the entire menu off to be created - sdlManager.getScreenManager().setMenu(Arrays.asList(mainCell1, mainCell2, mainCell3, mainCell4, mainCell5)); - } - - /** - * Will speak a sample welcome message - */ - private void performWelcomeSpeak(){ - sdlManager.sendRPC(new Speak(TTSChunkFactory.createSimpleTTSChunks(WELCOME_SPEAK))); - } - - /** - * Use the Screen Manager to set the initial screen text and set the image. - * Because we are setting multiple items, we will call beginTransaction() first, - * and finish with commit() when we are done. - */ - private void performWelcomeShow() { - sdlManager.getScreenManager().beginTransaction(); - sdlManager.getScreenManager().setTextField1(APP_NAME); - sdlManager.getScreenManager().setTextField2(WELCOME_SHOW); - sdlManager.getScreenManager().setPrimaryGraphic(new SdlArtwork(SDL_IMAGE_FILENAME, FileType.GRAPHIC_PNG, IMAGE_DIR+"sdl.png", true)); - sdlManager.getScreenManager().commit(new CompletionListener() { - @Override - public void onComplete(boolean success) { - if (success){ - DebugTool.logInfo(TAG, "welcome show successful"); - } - } - }); - } - - /** - * Attempts to Subscribe to all preset buttons - */ - private void subscribeToButtons() { - ButtonName[] buttonNames = {ButtonName.PLAY_PAUSE, ButtonName.SEEKLEFT, ButtonName.SEEKRIGHT, ButtonName.AC_MAX, ButtonName.AC, ButtonName.RECIRCULATE, - ButtonName.FAN_UP, ButtonName.FAN_DOWN, ButtonName.TEMP_UP, ButtonName.TEMP_DOWN, ButtonName.FAN_DOWN, ButtonName.DEFROST_MAX, ButtonName.DEFROST_REAR, ButtonName.DEFROST, - ButtonName.UPPER_VENT, ButtonName.LOWER_VENT, ButtonName.VOLUME_UP, ButtonName.VOLUME_DOWN, ButtonName.EJECT, ButtonName.SOURCE, ButtonName.SHUFFLE, ButtonName.REPEAT}; - - OnButtonListener onButtonListener = new OnButtonListener() { - @Override - public void onPress(ButtonName buttonName, OnButtonPress buttonPress) { - sdlManager.getScreenManager().setTextField1(buttonName + " pressed"); - DebugTool.logInfo(TAG, "onPress: " + buttonName); - } - - @Override - public void onEvent(ButtonName buttonName, OnButtonEvent buttonEvent) { - sdlManager.getScreenManager().setTextField2(buttonName + " " + buttonEvent.getButtonEventMode()); - } - - @Override - public void onError(String info) { - DebugTool.logInfo(TAG, "onError: " + info); - } - }; - - for (ButtonName buttonName : buttonNames) { - sdlManager.getScreenManager().addButtonListener(buttonName, onButtonListener); - } - } - - /** - * Will show a sample test message on screen as well as speak a sample test message - */ - private void showTest(){ - sdlManager.getScreenManager().beginTransaction(); - sdlManager.getScreenManager().setTextField1("Test Cell 1 has been selected"); - sdlManager.getScreenManager().setTextField2(""); - sdlManager.getScreenManager().commit(null); - - sdlManager.sendRPC(new Speak(TTSChunkFactory.createSimpleTTSChunks(TEST_COMMAND_NAME))); - } - - private void showAlert(String text){ - Alert alert = new Alert(); - alert.setAlertText1(text); - alert.setDuration(5000); - sdlManager.sendRPC(alert); - } - - public interface SdlServiceCallback{ - void onEnd(); - } - - // Choice Set - - private void preloadChoices(){ - ChoiceCell cell1 = new ChoiceCell("Item 1"); - ChoiceCell cell2 = new ChoiceCell("Item 2"); - ChoiceCell cell3 = new ChoiceCell("Item 3"); - choiceCellList = new ArrayList<>(Arrays.asList(cell1,cell2,cell3)); - sdlManager.getScreenManager().preloadChoices(choiceCellList, null); - } - - private void showPerformInteraction(){ - if (choiceCellList != null) { - ChoiceSet choiceSet = new ChoiceSet("Choose an Item from the list", choiceCellList, new ChoiceSetSelectionListener() { - @Override - public void onChoiceSelected(ChoiceCell choiceCell, TriggerSource triggerSource, int rowIndex) { - showAlert(choiceCell.getText() + " was selected"); - } - - @Override - public void onError(String error) { - DebugTool.logError(TAG, "There was an error showing the perform interaction: "+ error); - } - }); - sdlManager.getScreenManager().presentChoiceSet(choiceSet, InteractionMode.MANUAL_ONLY); - } - } -} diff --git a/javaSE/README.md b/javaSE/README.md deleted file mode 100644 index e40e9ca4a..000000000 --- a/javaSE/README.md +++ /dev/null @@ -1,25 +0,0 @@ -## SmartDeviceLink JavaSE - -The JavaSE project is meant to allow SDL compatibility for embedded applications. - -#### Dependency Managers - -To compile with the latest release of SDL JavaSE, include the following in your app's `build.gradle` file, - -```sh -repositories { - jcenter() -} -dependencies { - implementation 'com.smartdevicelink:sdl_java_se:4.+' -} -``` - -#### Manually building a JAR - -If you prefer making a JAR, simply call: - -```sh -gradle build -``` -from within the project and a JAR should be generated in the `build/libs` folder \ No newline at end of file diff --git a/javaSE/bintray.gradle b/javaSE/bintray.gradle deleted file mode 100644 index 49ab4761a..000000000 --- a/javaSE/bintray.gradle +++ /dev/null @@ -1,96 +0,0 @@ -apply plugin: "com.jfrog.bintray" -apply plugin: 'maven-publish' -apply plugin: 'maven' - -def siteUrl = 'https://github.com/smartdevicelink/sdl_java_suite' // Homepage URL of the library -def gitUrl = 'https://github.com/smartdevicelink/sdl_java_suite.git' // Git repository URL -def libDescription = 'SmartDeviceLink mobile library' -def libVersion = new File(projectDir.path, ('/../VERSION')).text.trim() - -task sourcesJar(type: Jar, dependsOn: classes) { - classifier = 'sources' - from sourceSets.main.allSource -} - -javadoc.failOnError = false -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -artifacts { - archives sourcesJar - archives javadocJar -} - -bintray { - Properties props = new Properties() - props.load(new FileInputStream("$projectDir/bintray.properties")) - - // Authorization - user = props.getProperty("bintray.user") - key = props.getProperty("bintray.key") - version = libVersion - publications = ['mavenPublication'] - - - pkg { - repo = props.getProperty("bintray.repo") - name = props.getProperty("bintray.package") - websiteUrl = siteUrl - vcsUrl = gitUrl - userOrg = props.getProperty("bintray.userorg") - licenses = ["BSD 3-Clause"] - publish = props.getProperty("bintray.publish") // Will upload to jCenter - version { - name = libVersion // Change to release version - desc = libDescription - released = new Date() // Will be the current date & time - vcsTag = libVersion // Should match git tag - } - } -} - -def pomConfig = { - Properties props = new Properties() - props.load(new FileInputStream("$projectDir/bintray.properties")) - - licenses { - license { - name 'BSD 3-Clause' - url 'https://opensource.org/licenses/BSD-3-Clause' - distribution "repo" - } - } - - scm { - url siteUrl - } -} - -publishing { - publications { - mavenPublication(MavenPublication) { - Properties props = new Properties() - props.load(new FileInputStream("$projectDir/bintray.properties")) - - from components.java - artifact sourcesJar { - classifier "sources" - } - artifact javadocJar { - classifier "javadoc" - } - groupId props.getProperty("bintray.group") - artifactId props.getProperty("bintray.artifact") - version libVersion - pom.withXml { - def root = asNode() - root.appendNode('description', libDescription) - root.appendNode('name', props.getProperty("bintray.artifact")) - root.appendNode('url', siteUrl) - root.children().last() + pomConfig - } - } - } -} \ No newline at end of file diff --git a/javaSE/bintray.properties b/javaSE/bintray.properties deleted file mode 100644 index b491c7774..000000000 --- a/javaSE/bintray.properties +++ /dev/null @@ -1,8 +0,0 @@ -bintray.user=username -bintray.key=apikey -bintray.userorg=smartdevicelink -bintray.repo=sdl_java_se -bintray.package=sdl_javase -bintray.group=com.smartdevicelink -bintray.artifact=sdl_java_se -bintray.publish=true \ No newline at end of file diff --git a/javaSE/build.gradle b/javaSE/build.gradle deleted file mode 100644 index b056fe7a0..000000000 --- a/javaSE/build.gradle +++ /dev/null @@ -1,80 +0,0 @@ -apply plugin: 'java-library' - -group 'com.smartdevicelink' -version new File(projectDir.path, ('/../VERSION')).text.trim() - -sourceCompatibility = 1.7 - - -buildscript { - repositories { - jcenter() - } - dependencies { - classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4' - } -} - -repositories { - google() - jcenter() -} - -// This extraLibs solution is explained here: https://discuss.gradle.org/t/how-to-include-dependencies-in-jar/19571/5 -configurations { - // configuration that holds jars to include in the jar - extraLibs -} - -dependencies { - extraLibs fileTree(dir: 'libs', include: ['*.jar']) - extraLibs 'org.mongodb:bson:4.0.5' - extraLibs 'androidx.annotation:annotation:1.1.0' - extraLibs 'org.java-websocket:Java-WebSocket:1.3.9' - extraLibs 'com.livio.taskmaster:taskmaster:0.3.0' - configurations.api.extendsFrom(configurations.extraLibs) -} - -sourceSets { - main.java.srcDirs += '../base/src/main/java' -} - -jar { - dependsOn 'generateSources' - from { - configurations.extraLibs.collect { it.isDirectory() ? it : zipTree(it) } - } -} - -task generateSources { - outputs.upToDateWhen { false } - File outputDir = file("$buildDir/../src/main/java/com/smartdevicelink/") - outputs.dir outputDir - doFirst { - println "Generating BuildConfig.java ..." - def srcFile = new File(outputDir, "BuildConfig.java") - srcFile.parentFile.mkdirs() - File license = new File("$buildDir/../../LICENSE") - if (license.exists()) { - srcFile.write("/*\n") - def lines = license.readLines() - for (line in lines) { - srcFile.append("* ") - srcFile.append(line) - srcFile.append("\n") - } - srcFile.append("*/\n") - }else{ - srcFile.write("\n") - } - srcFile.append( -"""package com.smartdevicelink; - -// THIS FILE IS AUTO GENERATED, DO NOT MODIFY!! -public final class BuildConfig { - public static final String VERSION_NAME = "$project.version"; -}""") - } -} - -apply from: 'bintray.gradle' diff --git a/javaSE/gradle/wrapper/gradle-wrapper.jar b/javaSE/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 87b738cbd..000000000 Binary files a/javaSE/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/javaSE/gradle/wrapper/gradle-wrapper.properties b/javaSE/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index ca21d83d3..000000000 --- a/javaSE/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Fri Jan 25 17:44:56 EST 2019 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip diff --git a/javaSE/gradlew b/javaSE/gradlew deleted file mode 100755 index af6708ff2..000000000 --- a/javaSE/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/javaSE/gradlew.bat b/javaSE/gradlew.bat deleted file mode 100644 index 0f8d5937c..000000000 --- a/javaSE/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/javaSE/hello_sdl_java/assets/images/sdl.png b/javaSE/hello_sdl_java/assets/images/sdl.png new file mode 100755 index 000000000..5cfc0f84a Binary files /dev/null and b/javaSE/hello_sdl_java/assets/images/sdl.png differ diff --git a/javaSE/hello_sdl_java/assets/images/sdl_s_green.png b/javaSE/hello_sdl_java/assets/images/sdl_s_green.png new file mode 100755 index 000000000..c43021775 Binary files /dev/null and b/javaSE/hello_sdl_java/assets/images/sdl_s_green.png differ diff --git a/javaSE/hello_sdl_java/build.gradle b/javaSE/hello_sdl_java/build.gradle new file mode 100644 index 000000000..ce0689640 --- /dev/null +++ b/javaSE/hello_sdl_java/build.gradle @@ -0,0 +1,33 @@ +plugins { + id 'java' +} + +version '1.0' + +sourceCompatibility = 1.7 + +repositories { + mavenCentral() + mavenLocal() + google() + jcenter() +} +// This extraLibs solution is explained here: https://discuss.gradle.org/t/how-to-include-dependencies-in-jar/19571/5 +configurations { + // configuration that holds jars to include in the jar + extraLibs +} +dependencies { + extraLibs fileTree(dir: 'libs', include: ['*.jar']) + extraLibs project(path: ':sdl_java_se') + configurations.implementation.extendsFrom(configurations.extraLibs) +} +jar { + from { + configurations.extraLibs.collect { it.isDirectory() ? it : zipTree(it) } + } + manifest { + attributes 'Class-Path': configurations.compile.collect { it.getName() }.join(' ') + attributes 'Main-Class': 'com.smartdevicelink.java.Main' + } +} \ No newline at end of file diff --git a/javaSE/hello_sdl_java/settings.gradle b/javaSE/hello_sdl_java/settings.gradle new file mode 100644 index 000000000..fd254fa69 --- /dev/null +++ b/javaSE/hello_sdl_java/settings.gradle @@ -0,0 +1,4 @@ +rootProject.name = 'hello_sdl_java' +include ":sdl_java_se" +project (":sdl_java_se").projectDir = new File("../javaSE/") + diff --git a/javaSE/hello_sdl_java/src/main/java/com/smartdevicelink/java/Main.java b/javaSE/hello_sdl_java/src/main/java/com/smartdevicelink/java/Main.java new file mode 100644 index 000000000..dc1ce2457 --- /dev/null +++ b/javaSE/hello_sdl_java/src/main/java/com/smartdevicelink/java/Main.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2019. 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. + */ + +package com.smartdevicelink.java; + +import com.smartdevicelink.transport.WebSocketServerConfig; +import com.smartdevicelink.util.DebugTool; + +public class Main { + private static final String TAG = "Main"; + static Thread thread = null, mainThread; + static Object LOCK; + + static SdlService sdlService; + + public static void main(String[] args) { + //Enable DebugTool + DebugTool.enableDebugTool(); + + mainThread = Thread.currentThread(); + LOCK = new Object(); + startSdlService(); + + while(!mainThread.isInterrupted()) { + try { + synchronized (LOCK) { + LOCK.wait(); + } + System.gc(); + Thread.sleep(500); + DebugTool.logInfo(TAG, "Attempting to start SDL Service again"); + startSdlService(); + DebugTool.logInfo(TAG, "SdlService started"); + + } catch (InterruptedException e) { + e.printStackTrace(); + break; + } + } + } + + static SdlService.SdlServiceCallback serviceCallback = new SdlService.SdlServiceCallback() { + @Override + public void onEnd() { + if (thread != null) { + thread.interrupt(); + thread = null; + } + synchronized (LOCK) { + LOCK.notify(); + } + + } + }; + + private static void startSdlService() { + + thread = new Thread(new Runnable() { + + @Override + public void run() { + DebugTool.logInfo(TAG, "Starting SDL Service"); + sdlService = new SdlService(new WebSocketServerConfig(5432, -1), serviceCallback); + sdlService.start(); + + System.gc(); + + } + }); + thread.start(); + } +} diff --git a/javaSE/hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java b/javaSE/hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java new file mode 100644 index 000000000..0c1b87c6a --- /dev/null +++ b/javaSE/hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java @@ -0,0 +1,408 @@ +/* + * Copyright (c) 2019. 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. + */ + +package com.smartdevicelink.java; + +import com.smartdevicelink.managers.CompletionListener; +import com.smartdevicelink.managers.screen.OnButtonListener; +import com.smartdevicelink.managers.SdlManager; +import com.smartdevicelink.managers.SdlManagerListener; +import com.smartdevicelink.managers.file.filetypes.SdlArtwork; +import com.smartdevicelink.managers.lifecycle.LifecycleConfigurationUpdate; +import com.smartdevicelink.managers.screen.choiceset.ChoiceCell; +import com.smartdevicelink.managers.screen.choiceset.ChoiceSet; +import com.smartdevicelink.managers.screen.choiceset.ChoiceSetSelectionListener; +import com.smartdevicelink.managers.screen.menu.MenuCell; +import com.smartdevicelink.managers.screen.menu.MenuSelectionListener; +import com.smartdevicelink.managers.screen.menu.VoiceCommand; +import com.smartdevicelink.managers.screen.menu.VoiceCommandSelectionListener; +import com.smartdevicelink.protocol.enums.FunctionID; +import com.smartdevicelink.proxy.RPCNotification; +import com.smartdevicelink.proxy.TTSChunkFactory; +import com.smartdevicelink.proxy.rpc.*; +import com.smartdevicelink.proxy.rpc.enums.*; +import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener; +import com.smartdevicelink.transport.BaseTransportConfig; +import com.smartdevicelink.util.DebugTool; + +import java.util.*; + +public class SdlService { + + + private static final String TAG = "SDL Service"; + + private static final String APP_NAME = "Hello Sdl"; + private static final String APP_NAME_ES = "Hola Sdl"; + private static final String APP_NAME_FR = "Bonjour Sdl"; + private static final String APP_ID = "8678309"; + + private static final String ICON_FILENAME = "hello_sdl_icon.png"; + private static final String SDL_IMAGE_FILENAME = "sdl_full_image.png"; + + private static final String WELCOME_SHOW = "Welcome to HelloSDL"; + private static final String WELCOME_SPEAK = "Welcome to Hello S D L"; + + private static final String TEST_COMMAND_NAME = "Test Command"; + + private static final String IMAGE_DIR = "assets/images/"; + + // variable to create and call functions of the SyncProxy + private SdlManager sdlManager = null; + private List choiceCellList; + + private SdlServiceCallback callback; + + public SdlService(BaseTransportConfig config, SdlServiceCallback callback){ + this.callback = callback; + buildSdlManager(config); + } + + public void start() { + DebugTool.logInfo(TAG, "SdlService start() "); + if(sdlManager != null){ + sdlManager.start(); + } + } + + public void stop() { + if (sdlManager != null) { + sdlManager.dispose(); + sdlManager = null; + } + } + + private void buildSdlManager(BaseTransportConfig transport) { + // This logic is to select the correct transport and security levels defined in the selected build flavor + // Build flavors are selected by the "build variants" tab typically located in the bottom left of Android Studio + // Typically in your app, you will only set one of these. + if (sdlManager == null) { + DebugTool.logInfo(TAG, "Creating SDL Manager"); + + //FIXME add the transport type + // The app type to be used + Vector appType = new Vector<>(); + appType.add(AppHMIType.MEDIA); + + // The manager listener helps you know when certain events that pertain to the SDL Manager happen + // Here we will listen for ON_HMI_STATUS and ON_COMMAND notifications + SdlManagerListener listener = new SdlManagerListener() { + @Override + public void onStart(SdlManager sdlManager) { + DebugTool.logInfo(TAG, "SdlManager onStart"); + } + + @Override + public void onDestroy(SdlManager sdlManager) { + DebugTool.logInfo(TAG, "SdlManager onDestroy "); + SdlService.this.sdlManager = null; + if(SdlService.this.callback != null){ + SdlService.this.callback.onEnd(); + stop(); + } + } + + @Override + public void onError(SdlManager sdlManager, String info, Exception e) { + } + + @Override + public LifecycleConfigurationUpdate managerShouldUpdateLifecycle(Language language) { + return null; + } + + @Override + public LifecycleConfigurationUpdate managerShouldUpdateLifecycle(Language language, Language hmiLanguage) { + boolean isNeedUpdate = false; + String appName = APP_NAME; + String ttsName = APP_NAME; + switch (language) { + case ES_MX: + isNeedUpdate = true; + ttsName = APP_NAME_ES; + break; + case FR_CA: + isNeedUpdate = true; + ttsName = APP_NAME_FR; + break; + default: + break; + } + switch (hmiLanguage) { + case ES_MX: + isNeedUpdate = true; + appName = APP_NAME_ES; + break; + case FR_CA: + isNeedUpdate = true; + appName = APP_NAME_FR; + break; + default: + break; + } + if (isNeedUpdate) { + return new LifecycleConfigurationUpdate(appName, null, TTSChunkFactory.createSimpleTTSChunks(ttsName), null); + } else { + return null; + } + } + }; + + + HashMap notificationListenerHashMap = new HashMap(); + notificationListenerHashMap.put(FunctionID.ON_HMI_STATUS, new OnRPCNotificationListener() { + @Override + public void onNotified(RPCNotification notification) { + OnHMIStatus status = (OnHMIStatus) notification; + if (status.getHmiLevel() == HMILevel.HMI_FULL && ((OnHMIStatus) notification).getFirstRun()) { + setVoiceCommands(); + sendMenus(); + performWelcomeSpeak(); + performWelcomeShow(); + preloadChoices(); + subscribeToButtons(); + } + } + }); + + // Create App Icon, this is set in the SdlManager builder + SdlArtwork appIcon = new SdlArtwork(ICON_FILENAME, FileType.GRAPHIC_PNG, IMAGE_DIR+"sdl_s_green.png", true); + + // The manager builder sets options for your session + SdlManager.Builder builder = new SdlManager.Builder(APP_ID, APP_NAME, listener); + builder.setAppTypes(appType); + builder.setTransportType(transport); + builder.setAppIcon(appIcon); + builder.setRPCNotificationListeners(notificationListenerHashMap); + sdlManager = builder.build(); + } + } + + /** + * Send some voice commands + */ + private void setVoiceCommands(){ + + List list1 = Collections.singletonList("Command One"); + List list2 = Collections.singletonList("Command two"); + + VoiceCommand voiceCommand1 = new VoiceCommand(list1, new VoiceCommandSelectionListener() { + @Override + public void onVoiceCommandSelected() { + DebugTool.logInfo(TAG, "Voice Command 1 triggered"); + } + }); + + VoiceCommand voiceCommand2 = new VoiceCommand(list2, new VoiceCommandSelectionListener() { + @Override + public void onVoiceCommandSelected() { + DebugTool.logInfo(TAG, "Voice Command 2 triggered"); + } + }); + + sdlManager.getScreenManager().setVoiceCommands(Arrays.asList(voiceCommand1,voiceCommand2)); + } + + /** + * Add menus for the app on SDL. + */ + private void sendMenus(){ + + // some arts + SdlArtwork livio = new SdlArtwork(ICON_FILENAME, FileType.GRAPHIC_PNG, IMAGE_DIR+"sdl_s_green.png", true); + + // some voice commands + List voice2 = Collections.singletonList("Cell two"); + + MenuCell mainCell1 = new MenuCell("Test Cell 1 (speak)", livio, null, new MenuSelectionListener() { + @Override + public void onTriggered(TriggerSource trigger) { + DebugTool.logInfo(TAG, "Test cell 1 triggered. Source: "+ trigger.toString()); + showTest(); + } + }); + + MenuCell mainCell2 = new MenuCell("Test Cell 2", null, voice2, new MenuSelectionListener() { + @Override + public void onTriggered(TriggerSource trigger) { + DebugTool.logInfo(TAG, "Test cell 2 triggered. Source: "+ trigger.toString()); + } + }); + + // SUB MENU + + MenuCell subCell1 = new MenuCell("SubCell 1",null, null, new MenuSelectionListener() { + @Override + public void onTriggered(TriggerSource trigger) { + DebugTool.logInfo(TAG, "Sub cell 1 triggered. Source: "+ trigger.toString()); + } + }); + + MenuCell subCell2 = new MenuCell("SubCell 2",null, null, new MenuSelectionListener() { + @Override + public void onTriggered(TriggerSource trigger) { + DebugTool.logInfo(TAG, "Sub cell 2 triggered. Source: "+ trigger.toString()); + } + }); + + // sub menu parent cell + MenuCell mainCell3 = new MenuCell("Test Cell 3 (sub menu)", MenuLayout.LIST, null, Arrays.asList(subCell1,subCell2)); + + MenuCell mainCell4 = new MenuCell("Show Perform Interaction", null, null, new MenuSelectionListener() { + @Override + public void onTriggered(TriggerSource trigger) { + showPerformInteraction(); + } + }); + + MenuCell mainCell5 = new MenuCell("Clear the menu",null, null, new MenuSelectionListener() { + @Override + public void onTriggered(TriggerSource trigger) { + DebugTool.logInfo(TAG, "Clearing Menu. Source: "+ trigger.toString()); + // Clear this thing + sdlManager.getScreenManager().setMenu(Collections.emptyList()); + showAlert("Menu Cleared"); + } + }); + + // Send the entire menu off to be created + sdlManager.getScreenManager().setMenu(Arrays.asList(mainCell1, mainCell2, mainCell3, mainCell4, mainCell5)); + } + + /** + * Will speak a sample welcome message + */ + private void performWelcomeSpeak(){ + sdlManager.sendRPC(new Speak(TTSChunkFactory.createSimpleTTSChunks(WELCOME_SPEAK))); + } + + /** + * Use the Screen Manager to set the initial screen text and set the image. + * Because we are setting multiple items, we will call beginTransaction() first, + * and finish with commit() when we are done. + */ + private void performWelcomeShow() { + sdlManager.getScreenManager().beginTransaction(); + sdlManager.getScreenManager().setTextField1(APP_NAME); + sdlManager.getScreenManager().setTextField2(WELCOME_SHOW); + sdlManager.getScreenManager().setPrimaryGraphic(new SdlArtwork(SDL_IMAGE_FILENAME, FileType.GRAPHIC_PNG, IMAGE_DIR+"sdl.png", true)); + sdlManager.getScreenManager().commit(new CompletionListener() { + @Override + public void onComplete(boolean success) { + if (success){ + DebugTool.logInfo(TAG, "welcome show successful"); + } + } + }); + } + + /** + * Attempts to Subscribe to all preset buttons + */ + private void subscribeToButtons() { + ButtonName[] buttonNames = {ButtonName.PLAY_PAUSE, ButtonName.SEEKLEFT, ButtonName.SEEKRIGHT, ButtonName.AC_MAX, ButtonName.AC, ButtonName.RECIRCULATE, + ButtonName.FAN_UP, ButtonName.FAN_DOWN, ButtonName.TEMP_UP, ButtonName.TEMP_DOWN, ButtonName.FAN_DOWN, ButtonName.DEFROST_MAX, ButtonName.DEFROST_REAR, ButtonName.DEFROST, + ButtonName.UPPER_VENT, ButtonName.LOWER_VENT, ButtonName.VOLUME_UP, ButtonName.VOLUME_DOWN, ButtonName.EJECT, ButtonName.SOURCE, ButtonName.SHUFFLE, ButtonName.REPEAT}; + + OnButtonListener onButtonListener = new OnButtonListener() { + @Override + public void onPress(ButtonName buttonName, OnButtonPress buttonPress) { + sdlManager.getScreenManager().setTextField1(buttonName + " pressed"); + DebugTool.logInfo(TAG, "onPress: " + buttonName); + } + + @Override + public void onEvent(ButtonName buttonName, OnButtonEvent buttonEvent) { + sdlManager.getScreenManager().setTextField2(buttonName + " " + buttonEvent.getButtonEventMode()); + } + + @Override + public void onError(String info) { + DebugTool.logInfo(TAG, "onError: " + info); + } + }; + + for (ButtonName buttonName : buttonNames) { + sdlManager.getScreenManager().addButtonListener(buttonName, onButtonListener); + } + } + + /** + * Will show a sample test message on screen as well as speak a sample test message + */ + private void showTest(){ + sdlManager.getScreenManager().beginTransaction(); + sdlManager.getScreenManager().setTextField1("Test Cell 1 has been selected"); + sdlManager.getScreenManager().setTextField2(""); + sdlManager.getScreenManager().commit(null); + + sdlManager.sendRPC(new Speak(TTSChunkFactory.createSimpleTTSChunks(TEST_COMMAND_NAME))); + } + + private void showAlert(String text){ + Alert alert = new Alert(); + alert.setAlertText1(text); + alert.setDuration(5000); + sdlManager.sendRPC(alert); + } + + public interface SdlServiceCallback{ + void onEnd(); + } + + // Choice Set + + private void preloadChoices(){ + ChoiceCell cell1 = new ChoiceCell("Item 1"); + ChoiceCell cell2 = new ChoiceCell("Item 2"); + ChoiceCell cell3 = new ChoiceCell("Item 3"); + choiceCellList = new ArrayList<>(Arrays.asList(cell1,cell2,cell3)); + sdlManager.getScreenManager().preloadChoices(choiceCellList, null); + } + + private void showPerformInteraction(){ + if (choiceCellList != null) { + ChoiceSet choiceSet = new ChoiceSet("Choose an Item from the list", choiceCellList, new ChoiceSetSelectionListener() { + @Override + public void onChoiceSelected(ChoiceCell choiceCell, TriggerSource triggerSource, int rowIndex) { + showAlert(choiceCell.getText() + " was selected"); + } + + @Override + public void onError(String error) { + DebugTool.logError(TAG, "There was an error showing the perform interaction: "+ error); + } + }); + sdlManager.getScreenManager().presentChoiceSet(choiceSet, InteractionMode.MANUAL_ONLY); + } + } +} diff --git a/javaSE/javaSE/README.md b/javaSE/javaSE/README.md new file mode 100644 index 000000000..e40e9ca4a --- /dev/null +++ b/javaSE/javaSE/README.md @@ -0,0 +1,25 @@ +## SmartDeviceLink JavaSE + +The JavaSE project is meant to allow SDL compatibility for embedded applications. + +#### Dependency Managers + +To compile with the latest release of SDL JavaSE, include the following in your app's `build.gradle` file, + +```sh +repositories { + jcenter() +} +dependencies { + implementation 'com.smartdevicelink:sdl_java_se:4.+' +} +``` + +#### Manually building a JAR + +If you prefer making a JAR, simply call: + +```sh +gradle build +``` +from within the project and a JAR should be generated in the `build/libs` folder \ No newline at end of file diff --git a/javaSE/javaSE/bintray.gradle b/javaSE/javaSE/bintray.gradle new file mode 100644 index 000000000..d40cb0e28 --- /dev/null +++ b/javaSE/javaSE/bintray.gradle @@ -0,0 +1,96 @@ +apply plugin: "com.jfrog.bintray" +apply plugin: 'maven-publish' +apply plugin: 'maven' + +def siteUrl = 'https://github.com/smartdevicelink/sdl_java_suite' // Homepage URL of the library +def gitUrl = 'https://github.com/smartdevicelink/sdl_java_suite.git' // Git repository URL +def libDescription = 'SmartDeviceLink mobile library' +def libVersion = new File(projectDir.path, ('/../../VERSION')).text.trim() + +task sourcesJar(type: Jar, dependsOn: classes) { + classifier = 'sources' + from sourceSets.main.allSource +} + +javadoc.failOnError = false +task javadocJar(type: Jar, dependsOn: javadoc) { + classifier = 'javadoc' + from javadoc.destinationDir +} + +artifacts { + archives sourcesJar + archives javadocJar +} + +bintray { + Properties props = new Properties() + props.load(new FileInputStream("$projectDir/bintray.properties")) + + // Authorization + user = props.getProperty("bintray.user") + key = props.getProperty("bintray.key") + version = libVersion + publications = ['mavenPublication'] + + + pkg { + repo = props.getProperty("bintray.repo") + name = props.getProperty("bintray.package") + websiteUrl = siteUrl + vcsUrl = gitUrl + userOrg = props.getProperty("bintray.userorg") + licenses = ["BSD 3-Clause"] + publish = props.getProperty("bintray.publish") // Will upload to jCenter + version { + name = libVersion // Change to release version + desc = libDescription + released = new Date() // Will be the current date & time + vcsTag = libVersion // Should match git tag + } + } +} + +def pomConfig = { + Properties props = new Properties() + props.load(new FileInputStream("$projectDir/bintray.properties")) + + licenses { + license { + name 'BSD 3-Clause' + url 'https://opensource.org/licenses/BSD-3-Clause' + distribution "repo" + } + } + + scm { + url siteUrl + } +} + +publishing { + publications { + mavenPublication(MavenPublication) { + Properties props = new Properties() + props.load(new FileInputStream("$projectDir/bintray.properties")) + + from components.java + artifact sourcesJar { + classifier "sources" + } + artifact javadocJar { + classifier "javadoc" + } + groupId props.getProperty("bintray.group") + artifactId props.getProperty("bintray.artifact") + version libVersion + pom.withXml { + def root = asNode() + root.appendNode('description', libDescription) + root.appendNode('name', props.getProperty("bintray.artifact")) + root.appendNode('url', siteUrl) + root.children().last() + pomConfig + } + } + } +} \ No newline at end of file diff --git a/javaSE/javaSE/bintray.properties b/javaSE/javaSE/bintray.properties new file mode 100644 index 000000000..b491c7774 --- /dev/null +++ b/javaSE/javaSE/bintray.properties @@ -0,0 +1,8 @@ +bintray.user=username +bintray.key=apikey +bintray.userorg=smartdevicelink +bintray.repo=sdl_java_se +bintray.package=sdl_javase +bintray.group=com.smartdevicelink +bintray.artifact=sdl_java_se +bintray.publish=true \ No newline at end of file diff --git a/javaSE/javaSE/build.gradle b/javaSE/javaSE/build.gradle new file mode 100644 index 000000000..6c8fb5802 --- /dev/null +++ b/javaSE/javaSE/build.gradle @@ -0,0 +1,80 @@ +apply plugin: 'java-library' + +group 'com.smartdevicelink' +version new File(projectDir.path, ('/../../VERSION')).text.trim() + +sourceCompatibility = 1.7 + + +buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4' + } +} + +repositories { + google() + jcenter() +} + +// This extraLibs solution is explained here: https://discuss.gradle.org/t/how-to-include-dependencies-in-jar/19571/5 +configurations { + // configuration that holds jars to include in the jar + extraLibs +} + +dependencies { + extraLibs fileTree(dir: 'libs', include: ['*.jar']) + extraLibs 'org.mongodb:bson:4.0.5' + extraLibs 'androidx.annotation:annotation:1.1.0' + extraLibs 'org.java-websocket:Java-WebSocket:1.3.9' + extraLibs 'com.livio.taskmaster:taskmaster:0.3.0' + configurations.api.extendsFrom(configurations.extraLibs) +} + +sourceSets { + main.java.srcDirs += '../../base/src/main/java' +} + +jar { + dependsOn 'generateSources' + from { + configurations.extraLibs.collect { it.isDirectory() ? it : zipTree(it) } + } +} + +task generateSources { + outputs.upToDateWhen { false } + File outputDir = file("$buildDir/../src/main/java/com/smartdevicelink/") + outputs.dir outputDir + doFirst { + println "Generating BuildConfig.java ..." + def srcFile = new File(outputDir, "BuildConfig.java") + srcFile.parentFile.mkdirs() + File license = new File("$buildDir/../../LICENSE") + if (license.exists()) { + srcFile.write("/*\n") + def lines = license.readLines() + for (line in lines) { + srcFile.append("* ") + srcFile.append(line) + srcFile.append("\n") + } + srcFile.append("*/\n") + }else{ + srcFile.write("\n") + } + srcFile.append( +"""package com.smartdevicelink; + +// THIS FILE IS AUTO GENERATED, DO NOT MODIFY!! +public final class BuildConfig { + public static final String VERSION_NAME = "$project.version"; +}""") + } +} + +apply from: 'bintray.gradle' diff --git a/javaSE/javaSE/settings.gradle b/javaSE/javaSE/settings.gradle new file mode 100644 index 000000000..f7ac48020 --- /dev/null +++ b/javaSE/javaSE/settings.gradle @@ -0,0 +1,2 @@ +rootProject.name = 'javaSE' + diff --git a/javaSE/javaSE/src/main/java/com/livio/BSON/BsonEncoder.java b/javaSE/javaSE/src/main/java/com/livio/BSON/BsonEncoder.java new file mode 100644 index 000000000..22c47f6cb --- /dev/null +++ b/javaSE/javaSE/src/main/java/com/livio/BSON/BsonEncoder.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2019, 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. + */ +package com.livio.BSON; + +import com.smartdevicelink.util.DebugTool; +import org.bson.*; + +import java.util.*; + +public class BsonEncoder { + private static final String TAG = "BsonEncoder"; + + public static byte[] encodeToBytes(HashMap map) throws ClassCastException { + if(map != null) { + BasicBSONObject bson = new BasicBSONObject(); + bson.putAll(sanitizeMap(map)); + BasicBSONEncoder encoder = new BasicBSONEncoder(); + + return encoder.encode(bson); + } + DebugTool.logError(TAG, "Something went wrong encoding the map into BSON bytes"); + + return null; + } + + public static HashMap decodeFromBytes(byte[] bytes) { + if(bytes != null) { + BasicBSONDecoder decoder = new BasicBSONDecoder(); + BSONObject object = decoder.readObject(bytes); + if (object != null) { + Map map = object.toMap(); + if (map != null) { + return sanitizeMap(new HashMap<>(map)); + } + } + } + DebugTool.logError(TAG, "Something went wrong decoding bytes into BSON"); + return null; + } + + /** + * Goes thorugh the map and ensures that all the values included are supported by SDL. If they are not of a supported + * value it is removed from the map + * @param map the map to be sanitized + * @return a sanitized HashMap with non-supported object type removes + */ + private static HashMap sanitizeMap(HashMap map){ + Set keys = map.keySet(); + Object value; + for(String key : keys){ + value = map.get(key); + + //First check to see if it value is a valid type used in SDL + if(isSupportedType(value)){ + continue; + }else if(value instanceof List){ //Next, check to see if it is a list of values + List list = (List)value; + + //If the list is empty, there shouldn't be a problem leaving it in the map + if(list.isEmpty()){ + continue; + } + + //Since the list isn't empty, check the first item + if(isSupportedType(list.get(0))){ + continue; + } + } + //If the item isn't valid, remove it from the map + map.remove(key); + + } + return map; + } + + /** + * Checks the value to ensure it is of a supported type + * @param value the generic object value + * @return if the object is an instanceOf one of the supported SDL BSON objects + */ + private static boolean isSupportedType(Object value){ + return value instanceof Integer + || value instanceof Long + || value instanceof Double + || value instanceof String + || value instanceof Boolean; + } + +} diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/BuildConfig.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/BuildConfig.java new file mode 100644 index 000000000..ecd7b1f9b --- /dev/null +++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/BuildConfig.java @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2017 - 2020, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. +* +*/ +package com.smartdevicelink; + +// THIS FILE IS AUTO GENERATED, DO NOT MODIFY!! +public final class BuildConfig { + public static final String VERSION_NAME = "4.12.0"; +} \ No newline at end of file diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java new file mode 100644 index 000000000..542ff6b35 --- /dev/null +++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2019 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. + */ + +package com.smartdevicelink.SdlConnection; + + +import com.smartdevicelink.protocol.SdlPacket; +import com.smartdevicelink.protocol.SdlProtocol; +import com.smartdevicelink.protocol.SdlProtocolBase; +import com.smartdevicelink.protocol.enums.SessionType; +import com.smartdevicelink.proxy.interfaces.ISdlServiceListener; +import com.smartdevicelink.transport.BaseTransportConfig; +import com.smartdevicelink.util.DebugTool; +import com.smartdevicelink.util.Version; + +import java.util.concurrent.CopyOnWriteArrayList; + +public class SdlSession extends BaseSdlSession { + + private static final String TAG = "SdlSession"; + + + public SdlSession(ISdlSessionListener listener, BaseTransportConfig config) { + super(listener, config); + } + + @Override + protected SdlProtocolBase getSdlProtocolImplementation() { + return new SdlProtocol(this, transportConfig); + } + + @Override + public void onServiceStarted(SdlPacket packet, SessionType serviceType, int sessionID, Version version, boolean isEncrypted) { + DebugTool.logInfo(TAG, serviceType.getName() + " service started"); + + if (serviceType != null && serviceType.eq(SessionType.RPC) && this.sessionId == -1) { + this.sessionId = sessionID; + this.sessionListener.onSessionStarted(sessionID, version); + } + + if (isEncrypted) { + encryptedServices.addIfAbsent(serviceType); + } + + if (serviceListeners != null && serviceListeners.containsKey(serviceType)) { + CopyOnWriteArrayList listeners = serviceListeners.get(serviceType); + for (ISdlServiceListener listener : listeners) { + listener.onServiceStarted(this, serviceType, isEncrypted); + } + } + } + + @Override + public void onServiceEnded(SdlPacket packet, SessionType serviceType, int sessionID) { + + if (SessionType.RPC.equals(serviceType)) { + this.sessionListener.onSessionEnded(sessionID); + } + + if (serviceListeners != null && serviceListeners.containsKey(serviceType)) { + CopyOnWriteArrayList listeners = serviceListeners.get(serviceType); + for (ISdlServiceListener listener : listeners) { + listener.onServiceEnded(this, serviceType); + } + } + + encryptedServices.remove(serviceType); + } + + @Override + public void onServiceError(SdlPacket packet, SessionType sessionType, int sessionID, String error) { + if (serviceListeners != null && serviceListeners.containsKey(sessionType)) { + CopyOnWriteArrayList listeners = serviceListeners.get(sessionType); + for (ISdlServiceListener listener : listeners) { + listener.onServiceError(this, sessionType, "End " + sessionType.toString() + " Service NACK'ed"); + } + } + } + +} \ No newline at end of file diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/SdlManager.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/SdlManager.java new file mode 100644 index 000000000..4dae813f6 --- /dev/null +++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/SdlManager.java @@ -0,0 +1,183 @@ +/* + * Copyright (c) 2019 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. + */ + +package com.smartdevicelink.managers; + +import androidx.annotation.NonNull; +import com.smartdevicelink.util.Log; + +import com.smartdevicelink.managers.file.FileManager; +import com.smartdevicelink.managers.permission.PermissionManager; +import com.smartdevicelink.managers.screen.ScreenManager; +import com.smartdevicelink.proxy.rpc.enums.SdlDisconnectedReason; +import com.smartdevicelink.transport.enums.TransportType; +import com.smartdevicelink.util.DebugTool; + +/** + * SDLManager
+ *

+ * This is the main point of contact between an application and SDL
+ *

+ * It is broken down to these areas:
+ *

+ * 1. SDLManagerBuilder
+ * 2. ISdl Interface along with its overridden methods - This can be passed into attached managers
+ * 3. Sending Requests
+ * 4. Helper methods + */ +public class SdlManager extends BaseSdlManager { + + /** + * Starts up a SdlManager, and calls provided callback called once all BaseSubManagers are done setting up + */ + @Override + public void start() { + Runtime.getRuntime().addShutdownHook(new Thread() { + @Override + public void run() { + dispose(); + } + }); + + DebugTool.logInfo(TAG, "start"); + if (lifecycleManager == null) { + if (transport != null && (transport.getTransportType().equals(TransportType.WEB_SOCKET_SERVER) || transport.getTransportType().equals(TransportType.CUSTOM))) { + super.start(); + lifecycleManager.start(); + } else { + throw new RuntimeException("No transport provided"); + } + } + } + + @Override + protected void initialize() { + // Instantiate sub managers + this.permissionManager = new PermissionManager(_internalInterface); + this.fileManager = new FileManager(_internalInterface, fileManagerConfig); + this.screenManager = new ScreenManager(_internalInterface, this.fileManager); + + // Start sub managers + this.permissionManager.start(subManagerListener); + this.fileManager.start(subManagerListener); + this.screenManager.start(subManagerListener); + } + + @Override + void checkState() { + if (permissionManager != null && fileManager != null && screenManager != null) { + if (permissionManager.getState() == BaseSubManager.READY && fileManager.getState() == BaseSubManager.READY && screenManager.getState() == BaseSubManager.READY) { + DebugTool.logInfo(TAG, "Starting sdl manager, all sub managers are in ready state"); + transitionToState(BaseSubManager.READY); + handleQueuedNotifications(); + notifyDevListener(null); + onReady(); + } else if (permissionManager.getState() == BaseSubManager.ERROR && fileManager.getState() == BaseSubManager.ERROR && screenManager.getState() == BaseSubManager.ERROR) { + String info = "ERROR starting sdl manager, all sub managers are in error state"; + DebugTool.logError(TAG, info); + transitionToState(BaseSubManager.ERROR); + notifyDevListener(info); + } else if (permissionManager.getState() == BaseSubManager.SETTING_UP || fileManager.getState() == BaseSubManager.SETTING_UP || screenManager.getState() == BaseSubManager.SETTING_UP) { + DebugTool.logInfo(TAG, "SETTING UP sdl manager, some sub managers are still setting up"); + transitionToState(BaseSubManager.SETTING_UP); + // No need to notify developer here! + } else { + DebugTool.logWarning(TAG, "LIMITED starting sdl manager, some sub managers are in error or limited state and the others finished setting up"); + transitionToState(BaseSubManager.LIMITED); + handleQueuedNotifications(); + notifyDevListener(null); + onReady(); + } + } else { + // We should never be here, but somehow one of the sub-sub managers is null + String info = "ERROR one of the sdl sub managers is null"; + DebugTool.logError(TAG, info); + transitionToState(BaseSubManager.ERROR); + notifyDevListener(info); + } + } + + private void notifyDevListener(String info) { + if (managerListener != null) { + if (getState() == BaseSubManager.ERROR) { + managerListener.onError((SdlManager) this, info, null); + } else { + managerListener.onStart((SdlManager) this); + } + } + } + + @Override + void retryChangeRegistration() { + // Do nothing + } + + @Override + public void dispose() { + if (this.permissionManager != null) { + this.permissionManager.dispose(); + } + + if (this.fileManager != null) { + this.fileManager.dispose(); + } + + if (this.screenManager != null) { + this.screenManager.dispose(); + } + + if (this.lifecycleManager != null) { + this.lifecycleManager.stop(); + } + + if (managerListener != null) { + managerListener.onDestroy((SdlManager) this); + managerListener = null; + } + + transitionToState(BaseSubManager.SHUTDOWN); + } + + // BUILDER + public static class Builder extends BaseSdlManager.Builder { + /** + * Builder for the SdlManager. Parameters in the constructor are required. + * + * @param appId the app's ID + * @param appName the app's name + * @param listener a SdlManagerListener object + */ + public Builder(@NonNull final String appId, @NonNull final String appName, @NonNull final SdlManagerListener listener) { + super(appId, appName, listener); + } + } +} diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/SdlManagerListener.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/SdlManagerListener.java new file mode 100644 index 000000000..8118a9c93 --- /dev/null +++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/SdlManagerListener.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2019 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. + */ +package com.smartdevicelink.managers; + +import com.smartdevicelink.managers.lifecycle.LifecycleConfigurationUpdate; +import com.smartdevicelink.proxy.rpc.enums.Language; + +public interface SdlManagerListener extends BaseSdlManagerListener { + + /** + * Called when a manager is ready for use + */ + void onStart(SdlManager manager); + + /** + * Called when the manager is destroyed + */ + void onDestroy(SdlManager manager); + + /** + * Called when the manager encounters an error + * @param info info regarding the error + * @param e the exception + */ + void onError(SdlManager manager, String info, Exception e); + + /** + * Called when the SDL manager detected a language mismatch. In case of a language mismatch the + * manager should change the apps registration by updating the lifecycle configuration to the + * specified language. If the app can support the specified language it should return an Object + * of LifecycleConfigurationUpdate, otherwise it should return null to indicate that the language + * is not supported. + * + * @param language The language of the connected head unit the manager is trying to update the configuration. + * @return An object of LifecycleConfigurationUpdate if the head unit language is supported, + * otherwise null to indicate that the language is not supported. + * @deprecated use {@link #managerShouldUpdateLifecycle(Language language, Language hmiLanguage)} instead + */ + @Deprecated + LifecycleConfigurationUpdate managerShouldUpdateLifecycle(Language language); + + /** + * Called when the SDL manager detected a language mismatch. In case of a language mismatch the + * manager should change the apps registration by updating the lifecycle configuration to the + * specified language. If the app can support the specified language it should return an Object + * of LifecycleConfigurationUpdate, otherwise it should return null to indicate that the language + * is not supported. + * + * @param language The VR+TTS language of the connected head unit the manager is trying to update the configuration. + * @param hmiLanguage The HMI display language of the connected head unit the manager is trying to update the configuration. + * @return An object of LifecycleConfigurationUpdate if the head unit language is supported, + * otherwise null to indicate that the language is not supported. + */ + LifecycleConfigurationUpdate managerShouldUpdateLifecycle(Language language, Language hmiLanguage); +} diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/file/FileManager.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/file/FileManager.java new file mode 100644 index 000000000..54896f273 --- /dev/null +++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/file/FileManager.java @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2019 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. + */ +package com.smartdevicelink.managers.file; + + +import androidx.annotation.NonNull; +import com.smartdevicelink.managers.file.filetypes.SdlFile; +import com.smartdevicelink.proxy.interfaces.ISdl; +import com.smartdevicelink.proxy.rpc.PutFile; +import com.smartdevicelink.util.DebugTool; +import com.smartdevicelink.util.FileUtls; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URI; + +/** + * FileManager
+ * + * Note: This class must be accessed through the SdlManager. Do not instantiate it by itself.
+ * + * The SDLFileManager uploads files and keeps track of all the uploaded files names during a session.
+ * + * We need to add the following struct: SDLFile
+ * + * It is broken down to these areas:
+ * + * 1. Getters
+ * 2. Deletion methods
+ * 3. Uploading Files / Artwork + */ +public class FileManager extends BaseFileManager { + + @Deprecated + public FileManager(ISdl internalInterface) { + + // setup + super(internalInterface); + } + + /** + * Constructor for FileManager + * @param internalInterface an instance of the ISdl interface that can be used for common SDL operations (sendRpc, addRpcListener, etc) + * @param fileManagerConfig an instance of the FileManagerConfig gives access to artworkRetryCount and fileRetryCount to let us if those file types can be re-upload if they fail + */ + public FileManager(ISdl internalInterface, FileManagerConfig fileManagerConfig) { + // setup + super(internalInterface, fileManagerConfig); + } + + /** + * Creates and returns a PutFile request that would upload a given SdlFile + * @param file SdlFile with fileName and one of A) fileData, B) Uri, or C) resourceID set + * @return a valid PutFile request if SdlFile contained a fileName and sufficient data + */ + @Override + PutFile createPutFile(@NonNull final SdlFile file){ + PutFile putFile = new PutFile(); + if(file.getName() == null){ + throw new IllegalArgumentException("You must specify an file name in the SdlFile"); + }else{ + putFile.setSdlFileName(file.getName()); + } + + if(file.getFilePath() != null){ + //Attempt to access the file via a path + byte[] data = FileUtls.getFileData(file.getFilePath()); + if(data != null ){ + putFile.setFileData(data); + }else{ + throw new IllegalArgumentException("File at path was empty"); + } + }else if(file.getURI() != null){ + // Use URI to upload file + byte[] data = contentsOfUri(file.getURI()); + if(data != null){ + putFile.setFileData(data); + }else{ + throw new IllegalArgumentException("Uri was empty"); + } + }else if(file.getFileData() != null){ + // Use file data (raw bytes) to upload file + putFile.setFileData(file.getFileData()); + }else{ + throw new IllegalArgumentException("The SdlFile to upload does " + + "not specify its resourceId, Uri, or file data"); + } + + if(file.getType() != null){ + putFile.setFileType(file.getType()); + } + putFile.setPersistentFile(file.isPersistent()); + + return putFile; + } + + + /** + * Helper method to take Uri and turn it into byte array + * @param uri Uri for desired file + * @return Resulting byte array + */ + private byte[] contentsOfUri(URI uri){ + InputStream is = null; + try{ + is = uri.toURL().openStream(); + return contentsOfInputStream(is); + } catch (IOException e){ + DebugTool.logError(TAG, "Can't read from URI", e); + return null; + } finally { + if (is != null) { + try { + is.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } +} diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlArtwork.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlArtwork.java new file mode 100644 index 000000000..a63c3e27b --- /dev/null +++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlArtwork.java @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2019 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. + */ +package com.smartdevicelink.managers.file.filetypes; + +import androidx.annotation.NonNull; +import com.smartdevicelink.proxy.rpc.Image; +import com.smartdevicelink.proxy.rpc.enums.FileType; +import com.smartdevicelink.proxy.rpc.enums.ImageType; +import com.smartdevicelink.proxy.rpc.enums.StaticIconName; +import com.smartdevicelink.util.DebugTool; + +import java.net.URI; + +/** + * A class that extends SdlFile, representing artwork (JPEG, PNG, or BMP) to be uploaded to core + */ +public class SdlArtwork extends SdlFile implements Cloneable{ + private boolean isTemplate; + private Image imageRPC; + + /** + * Creates a new instance of SdlArtwork + */ + public SdlArtwork(){} + + /** + * Creates a new instance of SdlArtwork + * @param fileName a String value representing the name that will be used to store the file in the head unit. You can pass null if you want the library to auto generate the name + * @param fileType a FileType enum value representing the type of the file + * @param filePath a String value representing the the location of the file + * @param persistentFile a boolean value that indicates if the file is meant to persist between sessions / ignition cycles + */ + public SdlArtwork(String fileName, @NonNull FileType fileType, String filePath, boolean persistentFile) { + super(fileName, fileType, filePath, persistentFile); + } + + /** + * Creates a new instance of SdlArtwork + * @param fileName a String value representing the name that will be used to store the file in the head unit. You can pass null if you want the library to auto generate the name + * @param fileType a FileType enum value representing the type of the file + * @param uri a URI value representing a file's location. Currently, it only supports local files + * @param persistentFile a boolean value that indicates if the file is meant to persist between sessions / ignition cycles + */ + public SdlArtwork(String fileName, @NonNull FileType fileType, URI uri, boolean persistentFile) { + super(fileName, fileType, uri, persistentFile); + } + + /** + * Creates a new instance of SdlArtwork + * @param fileName a String value representing the name that will be used to store the file in the head unit. You can pass null if you want the library to auto generate the name + * @param fileType a FileType enum value representing the type of the file + * @param data a byte array representing the data of the file + * @param persistentFile a boolean value that indicates if the file is meant to persist between sessions / ignition cycles + */ + public SdlArtwork(String fileName, @NonNull FileType fileType, byte[] data, boolean persistentFile) { + super(fileName, fileType, data, persistentFile); + } + + /** + * Creates a new instance of SdlArtwork + * @param staticIconName a StaticIconName enum value representing the name of a static file that comes pre-shipped with the head unit + */ + public SdlArtwork(@NonNull StaticIconName staticIconName) { + super(staticIconName); + } + + /** + * Sets whether this SdlArtwork is a template image whose coloring should be decided by the HMI + * @param isTemplate boolean that tells whether this SdlArtwork is a template image + */ + public void setTemplateImage(boolean isTemplate){ + this.isTemplate = isTemplate; + } + + /** + * Gets whether this SdlArtwork is a template image whose coloring should be decided by the HMI + * @return boolean that tells whether this SdlArtwork is a template image + */ + public boolean isTemplateImage(){ + return isTemplate; + } + + + @Override + public void setType(FileType fileType) { + if(fileType == null || fileType.equals(FileType.GRAPHIC_JPEG) || fileType.equals(FileType.GRAPHIC_PNG) + || fileType.equals(FileType.GRAPHIC_BMP)){ + super.setType(fileType); + }else{ + throw new IllegalArgumentException("Only JPEG, PNG, and BMP image types are supported."); + } + } + + /** + * Gets the Image RPC representing this artwork. Generally for use internally, you should instead pass an artwork to a Screen Manager method + * @return The Image RPC representing this artwork. + */ + public Image getImageRPC() { + if (imageRPC == null) { + imageRPC = createImageRPC(); + } + return imageRPC; + } + + private Image createImageRPC(){ + Image image; + if (isStaticIcon()) { + image = new Image(getName(), ImageType.STATIC); + image.setIsTemplate(true); + } else { + image = new Image(getName(), ImageType.DYNAMIC); + image.setIsTemplate(isTemplate); + } + return image; + } + + /** + * Creates a deep copy of the object + * @return deep copy of the object + */ + @Override + public SdlArtwork clone() { + try{ + SdlArtwork artwork = (SdlArtwork) super.clone(); + if(artwork != null){ + artwork.imageRPC = artwork.createImageRPC(); + } + return artwork; + } catch (CloneNotSupportedException e) { + if(DebugTool.isDebugEnabled()){ + throw new RuntimeException("Clone not supported by super class"); + } + } + return null; + } +} \ No newline at end of file diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlFile.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlFile.java new file mode 100644 index 000000000..bb1c170d4 --- /dev/null +++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlFile.java @@ -0,0 +1,342 @@ +/* + * Copyright (c) 2019 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. + */ +package com.smartdevicelink.managers.file.filetypes; + +import androidx.annotation.NonNull; + +import com.smartdevicelink.proxy.rpc.enums.FileType; +import com.smartdevicelink.proxy.rpc.enums.StaticIconName; + +import java.net.URI; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +/** + * A class representing data to be uploaded to core + */ +public class SdlFile{ + private String fileName; + private String filePath; + private URI uri; + private byte[] fileData; + private FileType fileType; + private boolean persistentFile; + private boolean isStaticIcon; + private boolean shouldAutoGenerateName; + // Overwrite property by default is set to true in SdlFile constructors indicating that a file can be overwritten + private boolean overwrite = true; + + /** + * Creates a new instance of SdlFile + */ + public SdlFile(){} + + /** + * Creates a new instance of SdlFile + * @param fileName a String value representing the name that will be used to store the file in the head unit. You can pass null if you want the library to auto generate the name + * @param fileType a FileType enum value representing the type of the file + * @param filePath a String value representing the the location of the file + * @param persistentFile a boolean value that indicates if the file is meant to persist between sessions / ignition cycles + */ + public SdlFile(String fileName, @NonNull FileType fileType, String filePath, boolean persistentFile){ + setName(fileName); + setType(fileType); + setFilePath(filePath); + setPersistent(persistentFile); + } + + /** + * Creates a new instance of SdlFile + * @param fileName a String value representing the name that will be used to store the file in the head unit. You can pass null if you want the library to auto generate the name + * @param fileType a FileType enum value representing the type of the file + * @param uri a URI value representing a file's location. Currently, it only supports local files + * @param persistentFile a boolean value that indicates if the file is meant to persist between sessions / ignition cycles + */ + public SdlFile(String fileName, @NonNull FileType fileType, URI uri, boolean persistentFile){ + setName(fileName); + setType(fileType); + setURI(uri); + setPersistent(persistentFile); + } + + /** + * Creates a new instance of SdlFile + * @param fileName a String value representing the name that will be used to store the file in the head unit. You can pass null if you want the library to auto generate the name + * @param fileType a FileType enum value representing the type of the file + * @param data a byte array representing the data of the file + * @param persistentFile a boolean value that indicates if the file is meant to persist between sessions / ignition cycles + */ + public SdlFile(String fileName, @NonNull FileType fileType, byte[] data, boolean persistentFile){ + setName(fileName); + setType(fileType); + setFileData(data); + setPersistent(persistentFile); + } + + /** + * Creates a new instance of SdlFile + * @param staticIconName a StaticIconName enum value representing the name of a static file that comes pre-shipped with the head unit + */ + public SdlFile(@NonNull StaticIconName staticIconName){ + setName(staticIconName.toString()); + setFileData(staticIconName.toString().getBytes()); + setPersistent(false); + setStaticIcon(true); + } + + /** + * Sets the name of the file + * @param fileName a String value representing the name that will be used to store the file in the head unit. You can pass null if you want the library to auto generate the name + */ + public void setName(String fileName) { + if (fileName != null) { + this.shouldAutoGenerateName = false; + this.fileName = fileName; + } else { + this.shouldAutoGenerateName = true; + if (this.getFileData() != null) { + this.fileName = generateFileNameFromData(this.getFileData()); + } else if (this.getURI() != null) { + this.fileName = generateFileNameFromUri(this.getURI()); + } else if (this.getFilePath() != null) { + this.fileName = generateFileNameFromFilePath(this.getFilePath()); + } + } + } + + /** + * Gets the name of the file + * @return a String value representing the name that will be used to store the file in the head unit + */ + public String getName(){ + return fileName; + } + + /** + * Sets the location of the file + * @param filePath a String value representing the the location of the file + */ + public void setFilePath(String filePath){ + this.filePath = filePath; + if (shouldAutoGenerateName && filePath != null) { + this.fileName = generateFileNameFromFilePath(filePath); + } + } + + /** + * Gets the location of the file + * @return + */ + public String getFilePath(){ + return this.filePath; + } + + /** + * Sets the uri of the file + * @param uri a URI value representing a file's location. Currently, it only supports local files + */ + public void setURI(URI uri){ + this.uri = uri; + if (shouldAutoGenerateName && uri != null) { + this.fileName = generateFileNameFromUri(uri); + } + } + + /** + * Gets the uri of the file + * @return a URI value representing a file's location. Currently, it only supports local files + */ + public URI getURI(){ + return uri; + } + + /** + * Sets the byte array that represents the content of the file + * @param data a byte array representing the data of the file + */ + public void setFileData(byte[] data){ + this.fileData = data; + if (shouldAutoGenerateName && data != null) { + this.fileName = generateFileNameFromData(data); + } + } + + /** + * Gets the byte array that represents the content of the file + * @return a byte array representing the data of the file + */ + public byte[] getFileData(){ + return fileData; + } + + /** + * Sets the type of the file + * @param fileType a FileType enum value representing the type of the file + */ + public void setType(@NonNull FileType fileType){ + this.fileType = fileType; + } + + /** + * Gets the type of the file + * @return a FileType enum value representing the type of the file + */ + public FileType getType(){ + return fileType; + } + + /** + * Sets whether the file should persist between sessions / ignition cycles + * @param persistentFile a boolean value that indicates if the file is meant to persist between sessions / ignition cycles + */ + public void setPersistent(boolean persistentFile){ + this.persistentFile = persistentFile; + } + + /** + * Gets whether the file should persist between sessions / ignition cycles + * @return a boolean value that indicates if the file is meant to persist between sessions / ignition cycles + */ + public boolean isPersistent(){ + return this.persistentFile; + } + + /** + * Sets the the name of the static file. Static files comes pre-shipped with the head unit + * @param staticIcon a StaticIconName enum value representing the name of a static file that comes pre-shipped with the head unit + */ + public void setStaticIcon(boolean staticIcon) { + isStaticIcon = staticIcon; + } + + /** + * Gets the the name of the static file. Static files comes pre-shipped with the head unit + * @return a StaticIconName enum value representing the name of a static file that comes pre-shipped with the head unit + */ + public boolean isStaticIcon() { + return isStaticIcon; + } + + /** + * Gets the overwrite property for an SdlFile by default its set to true + * @return a boolean value that indicates if a file can be overwritten. + */ + public boolean getOverwrite() { + return overwrite; + } + + /** + * Sets the overwrite property for an SdlFile by default its set to true + * @param overwrite a boolean value that indicates if a file can be overwritten + */ + public void setOverwrite(boolean overwrite) { + this.overwrite = overwrite; + } + + /** + * Generates a file name from data by hashing the data and returning the last 16 chars + * @param data a byte array representing the data of the file + * @return a String value representing the name that will be used to store the file in the head unit + */ + private String generateFileNameFromData(@NonNull byte[] data) { + String result; + MessageDigest messageDigest; + try { + messageDigest = MessageDigest.getInstance("md5"); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + return null; + } + byte[] hash = new byte[0]; + if (messageDigest != null) { + hash = messageDigest.digest(data); + } + StringBuilder stringBuilder = new StringBuilder(2 * hash.length); + for (byte b : hash) { + stringBuilder.append(String.format("%02x", b & 0xff)); + } + String hashString = stringBuilder.toString(); + result = hashString.substring(hashString.length() - 16); + return result; + } + + /** + * Generates a file name from filePath by hashing the filePath and returning the last 16 chars + * @param filePath a String value representing the the location of the file + * @return a String value representing the name that will be used to store the file in the head unit + */ + private String generateFileNameFromFilePath(String filePath) { + return generateFileNameFromData(filePath.getBytes()); + } + + /** + * Generates a file name from uri by hashing the uri string and returning the last 16 chars + * @param uri a URI value representing a file's location + * @return a String value representing the name that will be used to store the file in the head unit + */ + private String generateFileNameFromUri(@NonNull URI uri) { + return generateFileNameFromData(uri.toString().getBytes()); + } + + /** + * Used to compile hashcode for SdlFile for use to compare in equals method + * @return Custom hashcode of SdlFile variables + */ + @Override + public int hashCode() { + int result = 1; + result += ((getName() == null) ? 0 : Integer.rotateLeft(getName().hashCode(), 1)); + result += ((getURI() == null) ? 0 : Integer.rotateLeft(getURI().hashCode(), 2)); + result += ((getFilePath() == null) ? 0 : Integer.rotateLeft(getFilePath().hashCode(), 3)); + result += ((getFileData() == null) ? 0 : Integer.rotateLeft(getFileData().hashCode(), 4)); + result += ((getType() == null) ? 0 : Integer.rotateLeft(getType().hashCode(), 5)); + result += Integer.rotateLeft(Boolean.valueOf(isStaticIcon()).hashCode(), 6); + result += Integer.rotateLeft(Boolean.valueOf(isPersistent()).hashCode(), 7); + return result; + } + + /** + * Uses our custom hashCode for SdlFile objects + * @param o - The object to compare + * @return boolean of whether the objects are the same or not + */ + @Override + public boolean equals(Object o) { + if (o == null) return false; + // if this is the same memory address, it's the same + if (this == o) return true; + // if this is not an instance of SdlFile, not the same + if (!(o instanceof SdlFile)) return false; + // return comparison + return hashCode() == o.hashCode(); + } +} diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/EncryptionLifecycleManager.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/EncryptionLifecycleManager.java new file mode 100644 index 000000000..eda411dc5 --- /dev/null +++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/EncryptionLifecycleManager.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2019 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. + */ + +package com.smartdevicelink.managers.lifecycle; + +import androidx.annotation.NonNull; + +import com.smartdevicelink.managers.ServiceEncryptionListener; +import com.smartdevicelink.proxy.interfaces.ISdl; + +class EncryptionLifecycleManager extends BaseEncryptionLifecycleManager { + + EncryptionLifecycleManager(@NonNull ISdl internalInterface, ServiceEncryptionListener listener) { + super(internalInterface, listener); + } +} diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java new file mode 100644 index 000000000..b7167b81c --- /dev/null +++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2019 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. + */ + +package com.smartdevicelink.managers.lifecycle; + +import androidx.annotation.RestrictTo; + +import com.smartdevicelink.SdlConnection.SdlSession; +import com.smartdevicelink.exception.SdlException; +import com.smartdevicelink.proxy.rpc.enums.SdlDisconnectedReason; +import com.smartdevicelink.transport.BaseTransportConfig; + +/** + * The lifecycle manager creates a central point for all SDL session logic to converge. It should only be used by + * the library itself. Usage outside the library is not permitted and will not be protected for in the future. + */ +@RestrictTo(RestrictTo.Scope.LIBRARY) +public class LifecycleManager extends BaseLifecycleManager { + public LifecycleManager(AppConfig appConfig, BaseTransportConfig config, LifecycleListener listener) { + super(appConfig, config, listener); + } + + @Override + void initialize() { + super.initialize(); + this.session = new SdlSession(this.sdlSessionListener, _transportConfig); + } + + @Override + void cycle(SdlDisconnectedReason disconnectedReason) { + clean(); + if (session != null) { + try { + session.startSession(); + } catch (SdlException e) { + e.printStackTrace(); + } + } + } + + @Override + void onTransportDisconnected(String info, boolean availablePrimary, BaseTransportConfig transportConfig) { + super.onTransportDisconnected(info, availablePrimary, transportConfig); + if (!availablePrimary) { + onClose(info, null, null); + } + } +} diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/SystemCapabilityManager.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/SystemCapabilityManager.java new file mode 100644 index 000000000..e4e635883 --- /dev/null +++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/SystemCapabilityManager.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2020 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. + */ +package com.smartdevicelink.managers.lifecycle; + +import com.smartdevicelink.proxy.interfaces.ISdl; + +/** + * SystemCapabilityManager
+ * + * Note: This class must be accessed through the SdlManager. Do not instantiate it by itself.
+ */ +public class SystemCapabilityManager extends BaseSystemCapabilityManager { + SystemCapabilityManager(ISdl callback) { + super(callback); + } +} diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/permission/PermissionManager.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/permission/PermissionManager.java new file mode 100644 index 000000000..2918e0161 --- /dev/null +++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/permission/PermissionManager.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2019 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. + */ +package com.smartdevicelink.managers.permission; + +import androidx.annotation.NonNull; +import com.smartdevicelink.proxy.interfaces.ISdl; + +/** + PermissionManager gives the developer information about what permissions are permitted in specific HMI level + and helps developers setup listeners to be called when specific permissions become allowed.
+ + This should be used through the {@link com.smartdevicelink.managers.SdlManager} and not be instantiated by itself +**/ + + public class PermissionManager extends BasePermissionManager{ + + + /** + * Creates a new instance of the PermissionManager + * + * @param internalInterface an instance of the FileManager so that button graphics can be sent + */ + public PermissionManager(@NonNull ISdl internalInterface) { + super(internalInterface); + } +} diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/ScreenManager.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/ScreenManager.java new file mode 100644 index 000000000..38e17d0dc --- /dev/null +++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/ScreenManager.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2019 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. + */ +package com.smartdevicelink.managers.screen; + +import androidx.annotation.NonNull; +import com.smartdevicelink.managers.file.FileManager; +import com.smartdevicelink.proxy.interfaces.ISdl; + +/** + * ScreenManager
+ * + * Note: This class must be accessed through the SdlManager. Do not instantiate it by itself.
+*/ +public class ScreenManager extends BaseScreenManager { + + public ScreenManager(@NonNull ISdl internalInterface, @NonNull FileManager fileManager) { + super(internalInterface, fileManager); + } +} diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/SoftButtonManager.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/SoftButtonManager.java new file mode 100644 index 000000000..0b95d1aa5 --- /dev/null +++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/SoftButtonManager.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2019 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. + */ +package com.smartdevicelink.managers.screen; + +import androidx.annotation.NonNull; +import com.smartdevicelink.managers.file.FileManager; +import com.smartdevicelink.proxy.interfaces.ISdl; + +/** + * SoftButtonManager
+ * SoftButtonManager gives the developer the ability to control how soft buttons are displayed on the head unit.
+ * Note: This class must be accessed through the SdlManager->ScreenManager. Do not instantiate it by itself.
+ */ +class SoftButtonManager extends BaseSoftButtonManager { + + /** + * Creates a new instance of the SoftButtonManager + * + * @param internalInterface an instance of the ISdl interface that can be used for common SDL operations (sendRpc, addRpcListener, etc) + * @param fileManager an instance of the FileManager so that button graphics can be sent + */ + SoftButtonManager(@NonNull ISdl internalInterface, @NonNull FileManager fileManager) { + super(internalInterface, fileManager); + } +} diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/SubscribeButtonManager.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/SubscribeButtonManager.java new file mode 100644 index 000000000..49d41d495 --- /dev/null +++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/SubscribeButtonManager.java @@ -0,0 +1,11 @@ +package com.smartdevicelink.managers.screen; + +import androidx.annotation.NonNull; +import com.smartdevicelink.proxy.interfaces.ISdl; + +public class SubscribeButtonManager extends BaseSubscribeButtonManager { + + public SubscribeButtonManager(@NonNull ISdl internalInterface) { + super(internalInterface); + } +} diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicManager.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicManager.java new file mode 100644 index 000000000..b84734a52 --- /dev/null +++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicManager.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2019 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. + */ +package com.smartdevicelink.managers.screen; + +import androidx.annotation.NonNull; +import com.smartdevicelink.managers.file.FileManager; +import com.smartdevicelink.managers.file.filetypes.SdlArtwork; +import com.smartdevicelink.proxy.interfaces.ISdl; +import com.smartdevicelink.proxy.rpc.enums.FileType; + +/** + * TextAndGraphicManager
+ * + * Note: This class must be accessed through the SdlManager. Do not instantiate it by itself.
+ * + */ +class TextAndGraphicManager extends BaseTextAndGraphicManager { + + TextAndGraphicManager(@NonNull ISdl internalInterface, @NonNull FileManager fileManager, @NonNull SoftButtonManager softButtonManager) { + super(internalInterface, fileManager, softButtonManager); + } + + @Override + SdlArtwork getBlankArtwork(){ + if (blankArtwork == null){ + blankArtwork = new SdlArtwork(); + blankArtwork.setType(FileType.GRAPHIC_PNG); + blankArtwork.setName("blankArtwork"); + blankArtwork.setFileData(new byte[50]); + } + return blankArtwork; + } +} diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSetManager.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSetManager.java new file mode 100644 index 000000000..804054373 --- /dev/null +++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSetManager.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2019 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. + */ + +package com.smartdevicelink.managers.screen.choiceset; + +import androidx.annotation.NonNull; +import com.smartdevicelink.managers.file.FileManager; +import com.smartdevicelink.proxy.interfaces.ISdl; + +/** + * ChoiceSetManager
+ * ChoiceSetManager gives the developer the ability to control how soft choice sets are displayed on the head unit.
+ * Note: This class must be accessed through the SdlManager->ScreenManager. Do not instantiate it by itself.
+ */ +public class ChoiceSetManager extends BaseChoiceSetManager { + + /** + * Creates a new instance of the ChoiceSetManager + * + * @param internalInterface + */ + public ChoiceSetManager(@NonNull ISdl internalInterface, @NonNull FileManager fileManager) { + super(internalInterface, fileManager); + } +} diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/menu/MenuManager.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/menu/MenuManager.java new file mode 100644 index 000000000..4a28a2792 --- /dev/null +++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/menu/MenuManager.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2019 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. + */ + +package com.smartdevicelink.managers.screen.menu; + +import com.smartdevicelink.managers.file.FileManager; +import com.smartdevicelink.proxy.interfaces.ISdl; + +/** + * MenuManager
+ * + * Note: This class must be accessed through the ScreenManager via the SdlManager. Do not instantiate it by itself.
+ * + * The MenuManager takes MenuCell objects and creates and sends all necessary RPCs to build out a menu + */ +public class MenuManager extends BaseMenuManager { + + public MenuManager(ISdl internalInterface, FileManager fileManager) { + // setup + super(internalInterface, fileManager); + } + +} diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/menu/VoiceCommandManager.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/menu/VoiceCommandManager.java new file mode 100644 index 000000000..a892d3a2c --- /dev/null +++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/screen/menu/VoiceCommandManager.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2019 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. + */ + +package com.smartdevicelink.managers.screen.menu; + +import com.smartdevicelink.proxy.interfaces.ISdl; + +/** + * VoiceCommandManager
+ * + * Note: This class must be accessed through the ScreenManager via the SdlManager. Do not instantiate it by itself.
+ * + * The VoiceCommandManager takes a List of VoiceCommand objects and sets them on the Head unit for you. + */ +public class VoiceCommandManager extends BaseVoiceCommandManager { + + public VoiceCommandManager(ISdl internalInterface) { + // setup + super(internalInterface); + } + +} diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/protocol/SdlPacket.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/protocol/SdlPacket.java new file mode 100644 index 000000000..4f37da493 --- /dev/null +++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/protocol/SdlPacket.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ +package com.smartdevicelink.protocol; + + +public class SdlPacket extends BaseSdlPacket { + + public SdlPacket(int version, boolean encryption, int frameType, + int serviceType, int frameInfo, int sessionId, + int dataSize, int messageId, byte[] payload) { + super(version, encryption, frameType, serviceType, frameInfo, sessionId, dataSize, messageId, payload); + } + + public SdlPacket(int version, boolean encryption, int frameType, + int serviceType, int frameInfo, int sessionId, + int dataSize, int messageId, byte[] payload, int offset, int bytesToWrite) { + super(version, encryption, frameType, serviceType, frameInfo, sessionId, dataSize, messageId, payload, offset, bytesToWrite); + } + + protected SdlPacket() { + super(); + } + + protected SdlPacket(BaseSdlPacket packet) { + super(packet); + } +} diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/protocol/SdlProtocol.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/protocol/SdlProtocol.java new file mode 100644 index 000000000..67ea25cc1 --- /dev/null +++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/protocol/SdlProtocol.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2018 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. + */ + +package com.smartdevicelink.protocol; + + +import com.smartdevicelink.transport.BaseTransportConfig; +import com.smartdevicelink.transport.TransportManager; + + +@SuppressWarnings("WeakerAccess") +public class SdlProtocol extends SdlProtocolBase { + private static final String TAG ="SdlProtocol"; + + public SdlProtocol( ISdlProtocol iSdlProtocol, BaseTransportConfig config) { + super(iSdlProtocol, config); + this.setTransportManager(new TransportManager(config, transportEventListener)); + } + + + +} diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/security/SdlSecurityBase.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/security/SdlSecurityBase.java new file mode 100644 index 000000000..e8ed85b70 --- /dev/null +++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/security/SdlSecurityBase.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ +package com.smartdevicelink.security; + +public abstract class SdlSecurityBase extends AbstractSdlSecurityBase { + +} diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/trace/SdlTrace.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/trace/SdlTrace.java new file mode 100644 index 000000000..482b4a846 --- /dev/null +++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/trace/SdlTrace.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ +package com.smartdevicelink.trace; + + +/* This class handles the global TraceSettings as requested by the users either through the combination of the following + 1. System defaults + 2. Application XML config + 3. Programmatic requests from application itself + + It is manifested in the ... tags + */ + +public class SdlTrace extends SdlTraceBase{ + private static String getPid(){ + //Default implementation is not able to get this information + return "UNKNOWN"; + } +} // end-class \ No newline at end of file diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/CustomTransport.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/CustomTransport.java new file mode 100644 index 000000000..ad02f96d2 --- /dev/null +++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/CustomTransport.java @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2019 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. + */ + +package com.smartdevicelink.transport; + +import com.smartdevicelink.protocol.SdlPacket; +import com.smartdevicelink.transport.enums.TransportType; +import com.smartdevicelink.transport.utl.TransportRecord; +import com.smartdevicelink.util.DebugTool; + +import java.nio.ByteBuffer; + +public abstract class CustomTransport implements TransportInterface{ + private static final String TAG = "CustomTransport"; + + final TransportRecord transportRecord; + final SdlPsm psm; + TransportCallback transportCallback; + + + + public CustomTransport(String address) { + //Creates a callback for when packets + psm = new SdlPsm(); + transportRecord = new TransportRecord(TransportType.CUSTOM,address); + } + + public TransportRecord getTransportRecord(){ + return this.transportRecord; + } + + + /** + * Call this method when reading a byte array off the transport + * @param bytes the bytes read off the transport + */ + public synchronized void onByteArrayReceived (byte[] bytes, int offset, int length) { + + if(bytes != null && bytes.length > 0){ + boolean stateProgress; + for(int i = 0; i < length; i++){ + stateProgress = psm.handleByte(bytes[i]); + if (!stateProgress) {//We are trying to weed through the bad packet info until we get something + //Log.w(TAG, "Packet State Machine did not move forward from state - "+ psm.getState()+". PSM being Reset."); + psm.reset(); + } + + if (psm.getState() == SdlPsm.FINISHED_STATE) { + SdlPacket packet = psm.getFormedPacket(); + if (transportCallback != null && packet != null) { + packet.setTransportRecord(transportRecord); + transportCallback.onPacketReceived(packet); + } + //We put a trace statement in the message read so we can avoid all the extra bytes + psm.reset(); + } + } + + } + } + + /** + * Call this method when reading a ByteBuffer off the transport + * @param message the byte buffer that was read off the transport + */ + public synchronized void onByteBufferReceived (ByteBuffer message) { + if(message != null){ + boolean stateProgress; + while (message.hasRemaining()) { + stateProgress = psm.handleByte(message.get()); + if (!stateProgress) {//We are trying to weed through the bad packet info until we get something + + //Log.w(TAG, "Packet State Machine did not move forward from state - "+ psm.getState()+". PSM being Reset."); + psm.reset(); + } + + if (psm.getState() == SdlPsm.FINISHED_STATE) { + SdlPacket packet = psm.getFormedPacket(); + if (transportCallback != null && packet != null) { + packet.setTransportRecord(transportRecord); + transportCallback.onPacketReceived(packet); + } + //We put a trace statement in the message read so we can avoid all the extra bytes + psm.reset(); + } + } + + } + } + + @Override + public void start() { + if (transportCallback != null) { + transportCallback.onConnectionEstablished(); + } + } + + @Override + public void stop() { + if (transportCallback != null) { + transportCallback.onConnectionTerminated("Transport told to stop"); + } + } + + @Override + public void write(SdlPacket packet) { + byte[] bytes = packet.constructPacket(); + if(bytes != null && bytes.length > 0) { + try { + onWrite(bytes, 0, bytes.length); + } catch (Exception exc) { + DebugTool.logError(TAG, "Error attempting to write packet", exc); + } + } + } + + @Override + public void setCallback(TransportCallback transportCallback) { + this.transportCallback = transportCallback; + } + + public void onError(){ + if (transportCallback != null) { + transportCallback.onError(); + } + } + + + /** + * Integrator should write out these bytes to whatever actual transport there is. This will be called from the + * internals of the library. + * @param bytes a deconstructed packet into a byte array that needs to be written out + * @param offset in bytes + * @param length in bytes + */ + public abstract void onWrite(byte[] bytes, int offset, int length); + + + + + +} diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/CustomTransportConfig.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/CustomTransportConfig.java new file mode 100644 index 000000000..af0613aa1 --- /dev/null +++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/CustomTransportConfig.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2019 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. + */ + +package com.smartdevicelink.transport; + +import com.smartdevicelink.transport.enums.TransportType; + +public class CustomTransportConfig extends BaseTransportConfig { + + final CustomTransport customTransport; + + public CustomTransportConfig(CustomTransport customTransport){ + this.customTransport = customTransport; + } + + @Override + public TransportType getTransportType() { + return TransportType.CUSTOM; + } + + public TransportInterface getTransportInterface(){ + return this.customTransport; + } +} diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/TransportCallback.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/TransportCallback.java new file mode 100644 index 000000000..551ed9d29 --- /dev/null +++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/TransportCallback.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ +package com.smartdevicelink.transport; + +import com.smartdevicelink.protocol.SdlPacket; + +/** + * This interface is used to receive callbacks from a transport class + */ +public interface TransportCallback { + void onConnectionEstablished(); + void onError(); + void onConnectionTerminated(String reason); + void onPacketReceived(SdlPacket packet); +} \ No newline at end of file diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/TransportInterface.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/TransportInterface.java new file mode 100644 index 000000000..989b2df33 --- /dev/null +++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/TransportInterface.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2019 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. + */ + +package com.smartdevicelink.transport; + +import com.smartdevicelink.protocol.SdlPacket; +import com.smartdevicelink.transport.utl.TransportRecord; + +/** + * This interface defines the basic methods that a transport must implement + */ +public interface TransportInterface { + void start(); + void stop(); + void write(SdlPacket packet); + void setCallback(TransportCallback callback); + TransportRecord getTransportRecord(); +} \ No newline at end of file diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/TransportManager.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/TransportManager.java new file mode 100644 index 000000000..c8a07a1cc --- /dev/null +++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/TransportManager.java @@ -0,0 +1,214 @@ +/* + * Copyright (c) 2018 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. + */ + +package com.smartdevicelink.transport; + + +import com.smartdevicelink.protocol.SdlPacket; +import com.smartdevicelink.transport.enums.TransportType; +import com.smartdevicelink.transport.utl.TransportRecord; +import com.smartdevicelink.util.DebugTool; + +import java.util.Collections; +import java.util.List; + +@SuppressWarnings("unused") +public class TransportManager extends TransportManagerBase{ + private static final String TAG = "TransportManager"; + + TransportInterface transport; + + /** + * Managing transports + * List for status of all transports + * If transport is not connected. Request Router service connect to it. Get connected message + */ + + public TransportManager(BaseTransportConfig config, TransportEventListener listener){ + super(config, listener); + + //Start the new transport + switch (config.getTransportType()){ + case WEB_SOCKET_SERVER: + transport = new WebSocketServer((WebSocketServerConfig)config, new SingleTransportCallbackImpl(new TransportRecord(TransportType.WEB_SOCKET_SERVER,"127.0.0.1:"+((WebSocketServerConfig)config).port))); + break; + case CUSTOM: + transport = ((CustomTransportConfig) config).getTransportInterface(); + transport.setCallback(new SingleTransportCallbackImpl(transport.getTransportRecord())); + break; + } + + } + + @Override + public void start(){ + if(transport != null){ + transport.start(); + }else{ + System.out.print("Unable to start transport."); + } + } + + @Override + public void close(long sessionId){ + if(transport != null) { + transport.stop(); + } + } + + @Deprecated + @Override + public void resetSession(){ + + } + + /** + * Check to see if a transport is connected. + * @param transportType the transport to have its connection status returned. If `null` is + * passed in, all transports will be checked and if any are connected a + * true value will be returned. + * @param address the address associated with the transport type. If null, the first transport + * of supplied type will be used to return if connected. + * @return if a transport is connected based on included variables + */ + @Override + public boolean isConnected(TransportType transportType, String address){ + synchronized (TRANSPORT_STATUS_LOCK) { + if (transportType == null) { + return !transportStatus.isEmpty(); + } + for (TransportRecord record : transportStatus) { + if (record.getType().equals(transportType)) { + if (address != null) { + if (address.equals(record.getAddress())) { + return true; + } // Address doesn't match, move forward + } else { + //If no address is included, assume any transport of correct type is acceptable + return true; + } + } + } + return false; + } + } + /** + * Retrieve a transport record with the supplied params + * @param transportType the transport to have its connection status returned. + * @param address the address associated with the transport type. If null, the first transport + * of supplied type will be returned. + * @return the transport record for the transport type and address if supplied + */ + @Override + public TransportRecord getTransportRecord(TransportType transportType, String address){ + synchronized (TRANSPORT_STATUS_LOCK) { + if (transportType == null) { + return null; + } + for (TransportRecord record : transportStatus) { + if (record.getType().equals(transportType)) { + if (address != null) { + if (address.equals(record.getAddress())) { + return record; + } // Address doesn't match, move forward + } else { + //If no address is included, assume any transport of correct type is acceptable + return record; + } + } + } + return null; + } + } + + + @Override + public void sendPacket(SdlPacket packet){ + if(transport !=null){ + transport.write(packet); + }else { + + } + } + + class SingleTransportCallbackImpl implements TransportCallback { + + final List finalList; + final TransportRecord record; + protected SingleTransportCallbackImpl(TransportRecord transportRecord){ + record = transportRecord; + finalList = Collections.singletonList(record); + } + + @Override + public void onConnectionEstablished() { + synchronized (TRANSPORT_STATUS_LOCK){ + transportStatus.clear(); + transportStatus.addAll(finalList); + } + transportListener.onTransportConnected(finalList); + } + + @Override + public void onError() { + DebugTool.logError(TAG, "Error in the transport manager from the web socket server"); + if(transportListener != null){ + transportListener.onError(""); + } + } + + @Override + public void onConnectionTerminated(String reason) { + if(record != null){ + DebugTool.logInfo(TAG, "Transport disconnected - " + record); + }else{ + DebugTool.logInfo(TAG, "Transport disconnected"); + + } + + synchronized (TRANSPORT_STATUS_LOCK){ + TransportManager.this.transportStatus.remove(record); + //Might check connectedTransports vs transportStatus to ensure they are equal + } + //Inform the transport listener that a transport has disconnected + transportListener.onTransportDisconnected(reason, record, Collections.EMPTY_LIST); + } + + @Override + public void onPacketReceived(SdlPacket packet) { + if(packet!=null){ + transportListener.onPacketReceived(packet); + } + } + } + +} diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/WebSocketServer.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/WebSocketServer.java new file mode 100644 index 000000000..8f5411ce0 --- /dev/null +++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/WebSocketServer.java @@ -0,0 +1,198 @@ +/* + * Copyright (c) 2019 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. + */ + +package com.smartdevicelink.transport; + +import com.smartdevicelink.protocol.SdlPacket; +import com.smartdevicelink.transport.enums.TransportType; +import com.smartdevicelink.transport.utl.SSLWebSocketFactoryGenerator; +import com.smartdevicelink.transport.utl.TransportRecord; +import com.smartdevicelink.util.DebugTool; +import org.java_websocket.WebSocket; +import org.java_websocket.WebSocketServerFactory; +import org.java_websocket.handshake.ClientHandshake; + +import java.net.InetSocketAddress; +import java.nio.ByteBuffer; + +public class WebSocketServer extends org.java_websocket.server.WebSocketServer implements TransportInterface{ + private static final String TAG = "WebSocketServer"; + TransportCallback callback; + WebSocketServerConfig config; + WebSocket webSocket; + SdlPsm psm; + + final TransportRecord transportRecord; + + public WebSocketServer(WebSocketServerConfig config, TransportCallback callback){ + super((new InetSocketAddress(config.port))); + + this.config = config; + this.callback = callback; + transportRecord = new TransportRecord(TransportType.WEB_SOCKET_SERVER,"127.0.0.1:" + config.port); //If changed, change in transport manager as well + //This will set the connection lost timeout to not occur. So we might ping, but not pong + this.setConnectionLostTimeout(config.connectionLostTimeout); + if(config.getSslConfig() != null){ + WebSocketServerFactory factory = SSLWebSocketFactoryGenerator.generateWebSocketServer(config.getSslConfig()); + if(factory!=null){ + this.setWebSocketFactory(factory); + }else{ + DebugTool.logError(TAG, "WebSocketServer: Unable to generate SSL Web Socket Server Factory"); + } + } + + } + + public TransportRecord getTransportRecord(){ + return this.transportRecord; + } + + @Override + public void stop(){ + try { + this.stop(500); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + @Override + public void write(SdlPacket packet){ + //DebugTool.logInfo(TAG, "Atttempt to write packet " + packet); + if(packet != null + && this.webSocket != null + && this.webSocket.isOpen()) { + this.webSocket.send(packet.constructPacket()); + } + + } + + @Override + public void setCallback(TransportCallback callback) { + + } + + @Override + public void onOpen(WebSocket webSocket, ClientHandshake clientHandshake) { + DebugTool.logInfo(TAG, "onOpen"); + this.webSocket = webSocket; + + if(callback!=null){ + callback.onConnectionEstablished(); + } + } + + @Override + public void onClose(WebSocket webSocket, int i, String s, boolean b) { + DebugTool.logInfo(TAG, "onClose"); + try{ + DebugTool.logInfo(TAG, "Closing id - " + i); + DebugTool.logInfo(TAG, "Closing string - " + s); + DebugTool.logInfo(TAG, "Closing from remote? " + b); + }catch (Exception e){ + e.printStackTrace(); + } + + if(callback!=null) { + callback.onConnectionTerminated(s); + } + } + + + @Override + public void onWebsocketCloseInitiated(WebSocket conn, int code, String reason) { + super.onWebsocketCloseInitiated(conn, code, reason); + try{ + DebugTool.logInfo(TAG, "Code - " + code + " Reason - " + reason); + }catch (Exception e){} + } + + @Override + public void onMessage(WebSocket webSocket, String s) { + DebugTool.logError(TAG, "Incorrect message type received, dropping. - String: " + s); + } + + @Override + public void onMessage(WebSocket conn, ByteBuffer message) { + super.onMessage(conn, message); + //DebugTool.logInfo(TAG, "on Message - ByteBuffer"); + byte input; + + if(message != null){ + synchronized (WebSocketServer.this) { + boolean stateProgress; + while (message.hasRemaining()) { + input = message.get(); + stateProgress = psm.handleByte(input); + if (!stateProgress) {//We are trying to weed through the bad packet info until we get something + + //DebugTool.logWarning("Packet State Machine did not move forward from state - "+ psm.getState()+". PSM being Reset."); + psm.reset(); + } + + if (psm.getState() == SdlPsm.FINISHED_STATE) { + synchronized (WebSocketServer.this) { + SdlPacket packet = psm.getFormedPacket(); + if (callback != null && packet != null) { + /// DebugTool.logInfo(TAG, "Read a packet: " + packet); + packet.setTransportRecord(transportRecord); + callback.onPacketReceived(packet); + } + } + //We put a trace statement in the message read so we can avoid all the extra bytes + psm.reset(); + } + } + } + + } + + } + + + + @Override + public void onError(WebSocket webSocket, Exception e) { + DebugTool.logError(TAG, "bad", e); + if(callback!=null) { + callback.onError(); + } + } + + @Override + public void onStart() { + DebugTool.logInfo(TAG, "onStart"); + psm = new SdlPsm(); + + } + +} diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/WebSocketServerConfig.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/WebSocketServerConfig.java new file mode 100644 index 000000000..6add5ae71 --- /dev/null +++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/WebSocketServerConfig.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2019, 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. + */ +package com.smartdevicelink.transport; + +import com.smartdevicelink.transport.enums.TransportType; +import com.smartdevicelink.transport.utl.SSLConfig; + +public class WebSocketServerConfig extends BaseTransportConfig{ + + final int port, connectionLostTimeout; + SSLConfig sslConfig; + /** + * Default constructor for WebsocketConfig + * @param port the port this web socket should listen on + * @param connectionLostTimeout the timeout for a connection lost, default would be 60 seconds. If a value less than + * 0 is used, then the websocket will wait indefinitely. + */ + public WebSocketServerConfig(int port, int connectionLostTimeout){ + this.port = port; + this.shareConnection = false; + this.connectionLostTimeout = connectionLostTimeout; + } + + public SSLConfig getSslConfig() { + return sslConfig; + } + + public void setSslConfig(SSLConfig sslConfig) { + this.sslConfig = sslConfig; + } + + @Override + public TransportType getTransportType() { + return TransportType.WEB_SOCKET_SERVER; + } +} diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/utl/SSLConfig.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/utl/SSLConfig.java new file mode 100644 index 000000000..d46e8aac6 --- /dev/null +++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/utl/SSLConfig.java @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2019, 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. + */ +package com.smartdevicelink.transport.utl; + +import androidx.annotation.IntDef; +import androidx.annotation.NonNull; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.io.File; + +public class SSLConfig { + + @IntDef({JKS, PEM}) + @Retention(RetentionPolicy.SOURCE) + public @interface SSLCertificateType {} + public static final int JKS = 0; + public static final int PEM = 1; + + + final @SSLCertificateType int sslCertificateType; + String pemCertificate, privateKey, password; + String storePassword, keyPassword; + File jksFile; + + + /** + * This creates an SSLConfig using a PEM type certificate. + * @param pemCertificate string representation of a PEM file that should be used for the SSL session + * @param privateKey the private key used with the PEM file + * @param password the password used with the PEN file + */ + public SSLConfig(@NonNull String pemCertificate, @NonNull String privateKey, @NonNull String password){ + this.sslCertificateType = PEM; + this.pemCertificate = pemCertificate; + this.privateKey = privateKey; + this.password = password; + } + + + /** + * This creates an SSLConfig using a JKS file. + * @param jksFile File that contains the JKS that should be used for the SSL session + * @param storePassword the password associated with the JKS + * @param keyPassword the key password used with the JKS + */ + public SSLConfig(@NonNull File jksFile, @NonNull String storePassword, @NonNull String keyPassword){ + this.sslCertificateType = JKS; + this.jksFile = jksFile; + this.storePassword = storePassword; + this.keyPassword = keyPassword; + } + + public @SSLCertificateType int getSslCertificateType() { + return sslCertificateType; + } + + public String getPemCertificate() { + return pemCertificate; + } + + public String getPrivateKey() { + return privateKey; + } + + public String getPassword() { + return password; + } + + + public File getJksFile() { + return jksFile; + } + + public String getStorePassword() { + return storePassword; + } + + public String getKeyPassword() { + return keyPassword; + } +} diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/utl/SSLWebSocketFactoryGenerator.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/utl/SSLWebSocketFactoryGenerator.java new file mode 100644 index 000000000..95d0ceac2 --- /dev/null +++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/utl/SSLWebSocketFactoryGenerator.java @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2019, 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. + */ +package com.smartdevicelink.transport.utl; + +import com.smartdevicelink.util.DebugTool; +import org.java_websocket.WebSocketServerFactory; +import org.java_websocket.server.DefaultSSLWebSocketServerFactory; + +import javax.net.ssl.KeyManager; +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManagerFactory; +import javax.xml.bind.DatatypeConverter; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.security.KeyFactory; +import java.security.KeyStore; +import java.security.NoSuchAlgorithmException; +import java.security.cert.Certificate; +import java.security.cert.CertificateException; +import java.security.cert.CertificateFactory; +import java.security.cert.X509Certificate; +import java.security.interfaces.RSAPrivateKey; +import java.security.spec.InvalidKeySpecException; +import java.security.spec.PKCS8EncodedKeySpec; + +public class SSLWebSocketFactoryGenerator { + private static final String TAG = "SSLWebSocketFactoryGenerator"; + private static final String JAVA_KEY_STORE = "JKS"; + private static final String TLS = "TLS"; + private static final String SUNX509 = "SunX509"; + + public static WebSocketServerFactory generateWebSocketServer(SSLConfig config){ + SSLContext context = null; + switch (config.getSslCertificateType()){ + case SSLConfig.JKS: + context = getSSLContextFromJKS(config); + break; + case SSLConfig.PEM: + context = getSSLContextFromPem(config); + break; + default: + DebugTool.logError(TAG, "Unable to generateWebSocketServer. Unsupported cert type."); + return null; + } + if(context != null) { + return new DefaultSSLWebSocketServerFactory(context); + }else{ + DebugTool.logError(TAG, "SSLWebSocketFactoryGenerator: Unable to create SSL Context"); + return null; + } + } + +/* ******************************************* JKS ********************************************/ + + private static SSLContext getSSLContextFromJKS(SSLConfig config){ + + try { + KeyStore ks = KeyStore.getInstance(JAVA_KEY_STORE); + File kf = config.getJksFile();//= new File(PATHNAME + File.separator + KEYSTORE); + ks.load(new FileInputStream(kf), config.getStorePassword().toCharArray()); + + KeyManagerFactory kmf = KeyManagerFactory.getInstance(SUNX509); + kmf.init(ks, config.getKeyPassword().toCharArray()); + TrustManagerFactory tmf = TrustManagerFactory.getInstance(SUNX509); + tmf.init(ks); + + SSLContext sslContext = null; + sslContext = SSLContext.getInstance(TLS); + sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null); + return sslContext; + } + catch(Exception e){ + DebugTool.logError(TAG, "Issue creating SSLContext with JKS : " , e); + } + return null; + } + + /* ******************************************* PEM ********************************************/ + + private static SSLContext getSSLContextFromPem(SSLConfig config) { + SSLContext context; + + try { + context = SSLContext.getInstance( TLS ); + + byte[] certBytes = parseDERFromPEM( config.getPemCertificate().getBytes(), "-----BEGIN CERTIFICATE-----", "-----END CERTIFICATE-----" ); + byte[] keyBytes = parseDERFromPEM( config.getPrivateKey().getBytes(), "-----BEGIN PRIVATE KEY-----", "-----END PRIVATE KEY-----" ); + + X509Certificate cert = generateCertificateFromDER( certBytes ); + RSAPrivateKey key = generatePrivateKeyFromDER( keyBytes ); + + KeyStore keystore = KeyStore.getInstance( JAVA_KEY_STORE ); + keystore.load( null ); + keystore.setCertificateEntry( "cert-alias", cert ); + keystore.setKeyEntry( "key-alias", key, config.getPassword().toCharArray(), new Certificate[]{ cert } ); + + KeyManagerFactory kmf = KeyManagerFactory.getInstance( SUNX509 ); + kmf.init( keystore, config.getPassword().toCharArray() ); + + KeyManager[] km = kmf.getKeyManagers(); + + context.init( km, null, null ); + } catch ( Exception e ) { + context = null; + DebugTool.logError(TAG, "Issue creating SSLContext with PEM Cert : " , e); + } + return context; + } + + private static byte[] parseDERFromPEM( byte[] pem, String beginDelimiter, String endDelimiter ) { + String data = new String( pem ); + String[] tokens = data.split( beginDelimiter ); + tokens = tokens[1].split( endDelimiter ); + return DatatypeConverter.parseBase64Binary( tokens[0] ); + } + + private static RSAPrivateKey generatePrivateKeyFromDER( byte[] keyBytes ) throws InvalidKeySpecException, NoSuchAlgorithmException { + PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec( keyBytes ); + + KeyFactory factory = KeyFactory.getInstance( "RSA" ); + + return ( RSAPrivateKey ) factory.generatePrivate( spec ); + } + + private static X509Certificate generateCertificateFromDER( byte[] certBytes ) throws CertificateException { + CertificateFactory factory = CertificateFactory.getInstance( "X.509" ); + + return ( X509Certificate ) factory.generateCertificate( new ByteArrayInputStream( certBytes ) ); + } + + +} diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/utl/TransportRecord.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/utl/TransportRecord.java new file mode 100644 index 000000000..d8155c2fd --- /dev/null +++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/transport/utl/TransportRecord.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ +package com.smartdevicelink.transport.utl; + +import com.smartdevicelink.transport.enums.TransportType; + +public class TransportRecord extends BaseTransportRecord { + + public TransportRecord(TransportType transportType, String address) { + super(transportType, address); + } +} diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/util/Log.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/util/Log.java new file mode 100644 index 000000000..2de00692c --- /dev/null +++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/util/Log.java @@ -0,0 +1,19 @@ +package com.smartdevicelink.util; + +public class Log { + public static void i(String tag, String message) { + System.out.print("\r\nINFO: " + tag + " - " + message); + } + + public static void w(String tag, String message) { + System.out.print("\r\nWARN: " + tag + " - " + message); + } + + public static void e(String tag, String message, Throwable t) { + if (t != null) { + System.out.print("\r\nERROR: " + tag + " - " + message + " - " + t.getMessage()); + } else { + System.out.print("\r\nERROR: " + tag + " - " + message); + } + } +} \ No newline at end of file diff --git a/javaSE/javaSE/src/main/java/org/json/JSON.java b/javaSE/javaSE/src/main/java/org/json/JSON.java new file mode 100644 index 000000000..1b32e698d --- /dev/null +++ b/javaSE/javaSE/src/main/java/org/json/JSON.java @@ -0,0 +1,116 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.json; + +class JSON { + /** + * Returns the input if it is a JSON-permissible value; throws otherwise. + */ + static double checkDouble(double d) throws JSONException { + if (Double.isInfinite(d) || Double.isNaN(d)) { + throw new JSONException("Forbidden numeric value: " + d); + } + return d; + } + + static Boolean toBoolean(Object value) { + if (value instanceof Boolean) { + return (Boolean) value; + } else if (value instanceof String) { + String stringValue = (String) value; + if ("true".equalsIgnoreCase(stringValue)) { + return true; + } else if ("false".equalsIgnoreCase(stringValue)) { + return false; + } + } + return null; + } + + static Double toDouble(Object value) { + if (value instanceof Double) { + return (Double) value; + } else if (value instanceof Number) { + return ((Number) value).doubleValue(); + } else if (value instanceof String) { + try { + return Double.valueOf((String) value); + } catch (NumberFormatException ignored) { + } + } + return null; + } + + static Integer toInteger(Object value) { + if (value instanceof Integer) { + return (Integer) value; + } else if (value instanceof Number) { + return ((Number) value).intValue(); + } else if (value instanceof String) { + try { + return (int) Double.parseDouble((String) value); + } catch (NumberFormatException ignored) { + } + } + return null; + } + + static Long toLong(Object value) { + if (value instanceof Long) { + return (Long) value; + } else if (value instanceof Number) { + return ((Number) value).longValue(); + } else if (value instanceof String) { + try { + return (long) Double.parseDouble((String) value); + } catch (NumberFormatException ignored) { + } + } + return null; + } + + static String toString(Object value) { + if (value instanceof String) { + return (String) value; + } else if (value != null) { + return String.valueOf(value); + } + return null; + } + + public static JSONException typeMismatch(Object indexOrName, Object actual, + String requiredType) throws JSONException { + if (actual == null) { + throw new JSONException("Value at " + indexOrName + " is null."); + } else { + throw new JSONException("Value " + actual + " at " + indexOrName + + " of type " + actual.getClass().getName() + + " cannot be converted to " + requiredType); + } + } + + public static JSONException typeMismatch(Object actual, String requiredType) + throws JSONException { + if (actual == null) { + throw new JSONException("Value is null."); + } else { + throw new JSONException("Value " + actual + + " of type " + actual.getClass().getName() + + " cannot be converted to " + requiredType); + } + } +} diff --git a/javaSE/javaSE/src/main/java/org/json/JSONArray.java b/javaSE/javaSE/src/main/java/org/json/JSONArray.java new file mode 100644 index 000000000..996f44909 --- /dev/null +++ b/javaSE/javaSE/src/main/java/org/json/JSONArray.java @@ -0,0 +1,626 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.json; + +import java.lang.reflect.Array; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; + +// Note: this class was written without inspecting the non-free org.json sourcecode. + +/** + * A dense indexed sequence of values. Values may be any mix of + * {@link JSONObject JSONObjects}, other {@link JSONArray JSONArrays}, Strings, + * Booleans, Integers, Longs, Doubles, {@code null} or {@link JSONObject#NULL}. + * Values may not be {@link Double#isNaN() NaNs}, {@link Double#isInfinite() + * infinities}, or of any type not listed here. + * + *

{@code JSONArray} has the same type coercion behavior and + * optional/mandatory accessors as {@link JSONObject}. See that class' + * documentation for details. + * + *

Warning: this class represents null in two incompatible + * ways: the standard Java {@code null} reference, and the sentinel value {@link + * JSONObject#NULL}. In particular, {@code get} fails if the requested index + * holds the null reference, but succeeds if it holds {@code JSONObject.NULL}. + * + *

Instances of this class are not thread safe. Although this class is + * nonfinal, it was not designed for inheritance and should not be subclassed. + * In particular, self-use by overridable methods is not specified. See + * Effective Java Item 17, "Design and Document or inheritance or else + * prohibit it" for further information. + */ +public class JSONArray { + + private final List values; + + /** + * Creates a {@code JSONArray} with no values. + */ + public JSONArray() { + values = new ArrayList(); + } + + /** + * Creates a new {@code JSONArray} by copying all values from the given + * collection. + * + * @param copyFrom a collection whose values are of supported types. + * Unsupported values are not permitted and will yield an array in an + * inconsistent state. + */ + /* Accept a raw type for API compatibility */ + public JSONArray(Collection copyFrom) { + this(); + if (copyFrom != null) { + for (Iterator it = copyFrom.iterator(); it.hasNext();) { + put(JSONObject.wrap(it.next())); + } + } + } + + /** + * Creates a new {@code JSONArray} with values from the next array in the + * tokener. + * + * @param readFrom a tokener whose nextValue() method will yield a + * {@code JSONArray}. + * @throws JSONException if the parse fails or doesn't yield a + * {@code JSONArray}. + */ + public JSONArray(JSONTokener readFrom) throws JSONException { + /* + * Getting the parser to populate this could get tricky. Instead, just + * parse to temporary JSONArray and then steal the data from that. + */ + Object object = readFrom.nextValue(); + if (object instanceof JSONArray) { + values = ((JSONArray) object).values; + } else { + throw JSON.typeMismatch(object, "JSONArray"); + } + } + + /** + * Creates a new {@code JSONArray} with values from the JSON string. + * + * @param json a JSON-encoded string containing an array. + * @throws JSONException if the parse fails or doesn't yield a {@code + * JSONArray}. + */ + public JSONArray(String json) throws JSONException { + this(new JSONTokener(json)); + } + + /** + * Creates a new {@code JSONArray} with values from the given primitive array. + */ + public JSONArray(Object array) throws JSONException { + if (!array.getClass().isArray()) { + throw new JSONException("Not a primitive array: " + array.getClass()); + } + final int length = Array.getLength(array); + values = new ArrayList(length); + for (int i = 0; i < length; ++i) { + put(JSONObject.wrap(Array.get(array, i))); + } + } + + /** + * Returns the number of values in this array. + */ + public int length() { + return values.size(); + } + + /** + * Appends {@code value} to the end of this array. + * + * @return this array. + */ + public JSONArray put(boolean value) { + values.add(value); + return this; + } + + /** + * Appends {@code value} to the end of this array. + * + * @param value a finite value. May not be {@link Double#isNaN() NaNs} or + * {@link Double#isInfinite() infinities}. + * @return this array. + */ + public JSONArray put(double value) throws JSONException { + values.add(JSON.checkDouble(value)); + return this; + } + + /** + * Appends {@code value} to the end of this array. + * + * @return this array. + */ + public JSONArray put(int value) { + values.add(value); + return this; + } + + /** + * Appends {@code value} to the end of this array. + * + * @return this array. + */ + public JSONArray put(long value) { + values.add(value); + return this; + } + + /** + * Appends {@code value} to the end of this array. + * + * @param value a {@link JSONObject}, {@link JSONArray}, String, Boolean, + * Integer, Long, Double, {@link JSONObject#NULL}, or {@code null}. May + * not be {@link Double#isNaN() NaNs} or {@link Double#isInfinite() + * infinities}. Unsupported values are not permitted and will cause the + * array to be in an inconsistent state. + * @return this array. + */ + public JSONArray put(Object value) { + values.add(value); + return this; + } + + /** + * Same as {@link #put}, with added validity checks. + */ + void checkedPut(Object value) throws JSONException { + if (value instanceof Number) { + JSON.checkDouble(((Number) value).doubleValue()); + } + + put(value); + } + + /** + * Sets the value at {@code index} to {@code value}, null padding this array + * to the required length if necessary. If a value already exists at {@code + * index}, it will be replaced. + * + * @return this array. + */ + public JSONArray put(int index, boolean value) throws JSONException { + return put(index, (Boolean) value); + } + + /** + * Sets the value at {@code index} to {@code value}, null padding this array + * to the required length if necessary. If a value already exists at {@code + * index}, it will be replaced. + * + * @param value a finite value. May not be {@link Double#isNaN() NaNs} or + * {@link Double#isInfinite() infinities}. + * @return this array. + */ + public JSONArray put(int index, double value) throws JSONException { + return put(index, (Double) value); + } + + /** + * Sets the value at {@code index} to {@code value}, null padding this array + * to the required length if necessary. If a value already exists at {@code + * index}, it will be replaced. + * + * @return this array. + */ + public JSONArray put(int index, int value) throws JSONException { + return put(index, (Integer) value); + } + + /** + * Sets the value at {@code index} to {@code value}, null padding this array + * to the required length if necessary. If a value already exists at {@code + * index}, it will be replaced. + * + * @return this array. + */ + public JSONArray put(int index, long value) throws JSONException { + return put(index, (Long) value); + } + + /** + * Sets the value at {@code index} to {@code value}, null padding this array + * to the required length if necessary. If a value already exists at {@code + * index}, it will be replaced. + * + * @param value a {@link JSONObject}, {@link JSONArray}, String, Boolean, + * Integer, Long, Double, {@link JSONObject#NULL}, or {@code null}. May + * not be {@link Double#isNaN() NaNs} or {@link Double#isInfinite() + * infinities}. + * @return this array. + */ + public JSONArray put(int index, Object value) throws JSONException { + if (value instanceof Number) { + // deviate from the original by checking all Numbers, not just floats & doubles + JSON.checkDouble(((Number) value).doubleValue()); + } + while (values.size() <= index) { + values.add(null); + } + values.set(index, value); + return this; + } + + /** + * Returns true if this array has no value at {@code index}, or if its value + * is the {@code null} reference or {@link JSONObject#NULL}. + */ + public boolean isNull(int index) { + Object value = opt(index); + return value == null || value == JSONObject.NULL; + } + + /** + * Returns the value at {@code index}. + * + * @throws JSONException if this array has no value at {@code index}, or if + * that value is the {@code null} reference. This method returns + * normally if the value is {@code JSONObject#NULL}. + */ + public Object get(int index) throws JSONException { + try { + Object value = values.get(index); + if (value == null) { + throw new JSONException("Value at " + index + " is null."); + } + return value; + } catch (IndexOutOfBoundsException e) { + throw new JSONException("Index " + index + " out of range [0.." + values.size() + ")", e); + } + } + + /** + * Returns the value at {@code index}, or null if the array has no value + * at {@code index}. + */ + public Object opt(int index) { + if (index < 0 || index >= values.size()) { + return null; + } + return values.get(index); + } + + /** + * Removes and returns the value at {@code index}, or null if the array has no value + * at {@code index}. + */ + public Object remove(int index) { + if (index < 0 || index >= values.size()) { + return null; + } + return values.remove(index); + } + + /** + * Returns the value at {@code index} if it exists and is a boolean or can + * be coerced to a boolean. + * + * @throws JSONException if the value at {@code index} doesn't exist or + * cannot be coerced to a boolean. + */ + public boolean getBoolean(int index) throws JSONException { + Object object = get(index); + Boolean result = JSON.toBoolean(object); + if (result == null) { + throw JSON.typeMismatch(index, object, "boolean"); + } + return result; + } + + /** + * Returns the value at {@code index} if it exists and is a boolean or can + * be coerced to a boolean. Returns false otherwise. + */ + public boolean optBoolean(int index) { + return optBoolean(index, false); + } + + /** + * Returns the value at {@code index} if it exists and is a boolean or can + * be coerced to a boolean. Returns {@code fallback} otherwise. + */ + public boolean optBoolean(int index, boolean fallback) { + Object object = opt(index); + Boolean result = JSON.toBoolean(object); + return result != null ? result : fallback; + } + + /** + * Returns the value at {@code index} if it exists and is a double or can + * be coerced to a double. + * + * @throws JSONException if the value at {@code index} doesn't exist or + * cannot be coerced to a double. + */ + public double getDouble(int index) throws JSONException { + Object object = get(index); + Double result = JSON.toDouble(object); + if (result == null) { + throw JSON.typeMismatch(index, object, "double"); + } + return result; + } + + /** + * Returns the value at {@code index} if it exists and is a double or can + * be coerced to a double. Returns {@code NaN} otherwise. + */ + public double optDouble(int index) { + return optDouble(index, Double.NaN); + } + + /** + * Returns the value at {@code index} if it exists and is a double or can + * be coerced to a double. Returns {@code fallback} otherwise. + */ + public double optDouble(int index, double fallback) { + Object object = opt(index); + Double result = JSON.toDouble(object); + return result != null ? result : fallback; + } + + /** + * Returns the value at {@code index} if it exists and is an int or + * can be coerced to an int. + * + * @throws JSONException if the value at {@code index} doesn't exist or + * cannot be coerced to a int. + */ + public int getInt(int index) throws JSONException { + Object object = get(index); + Integer result = JSON.toInteger(object); + if (result == null) { + throw JSON.typeMismatch(index, object, "int"); + } + return result; + } + + /** + * Returns the value at {@code index} if it exists and is an int or + * can be coerced to an int. Returns 0 otherwise. + */ + public int optInt(int index) { + return optInt(index, 0); + } + + /** + * Returns the value at {@code index} if it exists and is an int or + * can be coerced to an int. Returns {@code fallback} otherwise. + */ + public int optInt(int index, int fallback) { + Object object = opt(index); + Integer result = JSON.toInteger(object); + return result != null ? result : fallback; + } + + /** + * Returns the value at {@code index} if it exists and is a long or + * can be coerced to a long. + * + * @throws JSONException if the value at {@code index} doesn't exist or + * cannot be coerced to a long. + */ + public long getLong(int index) throws JSONException { + Object object = get(index); + Long result = JSON.toLong(object); + if (result == null) { + throw JSON.typeMismatch(index, object, "long"); + } + return result; + } + + /** + * Returns the value at {@code index} if it exists and is a long or + * can be coerced to a long. Returns 0 otherwise. + */ + public long optLong(int index) { + return optLong(index, 0L); + } + + /** + * Returns the value at {@code index} if it exists and is a long or + * can be coerced to a long. Returns {@code fallback} otherwise. + */ + public long optLong(int index, long fallback) { + Object object = opt(index); + Long result = JSON.toLong(object); + return result != null ? result : fallback; + } + + /** + * Returns the value at {@code index} if it exists, coercing it if + * necessary. + * + * @throws JSONException if no such value exists. + */ + public String getString(int index) throws JSONException { + Object object = get(index); + String result = JSON.toString(object); + if (result == null) { + throw JSON.typeMismatch(index, object, "String"); + } + return result; + } + + /** + * Returns the value at {@code index} if it exists, coercing it if + * necessary. Returns the empty string if no such value exists. + */ + public String optString(int index) { + return optString(index, ""); + } + + /** + * Returns the value at {@code index} if it exists, coercing it if + * necessary. Returns {@code fallback} if no such value exists. + */ + public String optString(int index, String fallback) { + Object object = opt(index); + String result = JSON.toString(object); + return result != null ? result : fallback; + } + + /** + * Returns the value at {@code index} if it exists and is a {@code + * JSONArray}. + * + * @throws JSONException if the value doesn't exist or is not a {@code + * JSONArray}. + */ + public JSONArray getJSONArray(int index) throws JSONException { + Object object = get(index); + if (object instanceof JSONArray) { + return (JSONArray) object; + } else { + throw JSON.typeMismatch(index, object, "JSONArray"); + } + } + + /** + * Returns the value at {@code index} if it exists and is a {@code + * JSONArray}. Returns null otherwise. + */ + public JSONArray optJSONArray(int index) { + Object object = opt(index); + return object instanceof JSONArray ? (JSONArray) object : null; + } + + /** + * Returns the value at {@code index} if it exists and is a {@code + * JSONObject}. + * + * @throws JSONException if the value doesn't exist or is not a {@code + * JSONObject}. + */ + public JSONObject getJSONObject(int index) throws JSONException { + Object object = get(index); + if (object instanceof JSONObject) { + return (JSONObject) object; + } else { + throw JSON.typeMismatch(index, object, "JSONObject"); + } + } + + /** + * Returns the value at {@code index} if it exists and is a {@code + * JSONObject}. Returns null otherwise. + */ + public JSONObject optJSONObject(int index) { + Object object = opt(index); + return object instanceof JSONObject ? (JSONObject) object : null; + } + + /** + * Returns a new object whose values are the values in this array, and whose + * names are the values in {@code names}. Names and values are paired up by + * index from 0 through to the shorter array's length. Names that are not + * strings will be coerced to strings. This method returns null if either + * array is empty. + */ + public JSONObject toJSONObject(JSONArray names) throws JSONException { + JSONObject result = new JSONObject(); + int length = Math.min(names.length(), values.size()); + if (length == 0) { + return null; + } + for (int i = 0; i < length; i++) { + String name = JSON.toString(names.opt(i)); + result.put(name, opt(i)); + } + return result; + } + + /** + * Returns a new string by alternating this array's values with {@code + * separator}. This array's string values are quoted and have their special + * characters escaped. For example, the array containing the strings '12" + * pizza', 'taco' and 'soda' joined on '+' returns this: + *
"12\" pizza"+"taco"+"soda"
+ */ + public String join(String separator) throws JSONException { + JSONStringer stringer = new JSONStringer(); + stringer.open(JSONStringer.Scope.NULL, ""); + for (int i = 0, size = values.size(); i < size; i++) { + if (i > 0) { + stringer.out.append(separator); + } + stringer.value(values.get(i)); + } + stringer.close(JSONStringer.Scope.NULL, JSONStringer.Scope.NULL, ""); + return stringer.out.toString(); + } + + /** + * Encodes this array as a compact JSON string, such as: + *
[94043,90210]
+ */ + @Override public String toString() { + try { + JSONStringer stringer = new JSONStringer(); + writeTo(stringer); + return stringer.toString(); + } catch (JSONException e) { + return null; + } + } + + /** + * Encodes this array as a human readable JSON string for debugging, such + * as: + *
+     * [
+     *     94043,
+     *     90210
+     * ]
+ * + * @param indentSpaces the number of spaces to indent for each level of + * nesting. + */ + public String toString(int indentSpaces) throws JSONException { + JSONStringer stringer = new JSONStringer(indentSpaces); + writeTo(stringer); + return stringer.toString(); + } + + void writeTo(JSONStringer stringer) throws JSONException { + stringer.array(); + for (Object value : values) { + stringer.value(value); + } + stringer.endArray(); + } + + @Override public boolean equals(Object o) { + return o instanceof JSONArray && ((JSONArray) o).values.equals(values); + } + + @Override public int hashCode() { + // diverge from the original, which doesn't implement hashCode + return values.hashCode(); + } +} diff --git a/javaSE/javaSE/src/main/java/org/json/JSONException.java b/javaSE/javaSE/src/main/java/org/json/JSONException.java new file mode 100644 index 000000000..05e1dddc9 --- /dev/null +++ b/javaSE/javaSE/src/main/java/org/json/JSONException.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.json; + +// Note: this class was written without inspecting the non-free org.json sourcecode. + +/** + * Thrown to indicate a problem with the JSON API. Such problems include: + *
    + *
  • Attempts to parse or construct malformed documents + *
  • Use of null as a name + *
  • Use of numeric types not available to JSON, such as {@link + * Double#isNaN() NaNs} or {@link Double#isInfinite() infinities}. + *
  • Lookups using an out of range index or nonexistent name + *
  • Type mismatches on lookups + *
+ * + *

Although this is a checked exception, it is rarely recoverable. Most + * callers should simply wrap this exception in an unchecked exception and + * rethrow: + *

  public JSONArray toJSONObject() {
+ *     try {
+ *         JSONObject result = new JSONObject();
+ *         ...
+ *     } catch (JSONException e) {
+ *         throw new RuntimeException(e);
+ *     }
+ * }
+ */ +public class JSONException extends Exception { + + public JSONException(String s) { + super(s); + } + + public JSONException(String message, Throwable cause) { + super(message, cause); + } + + public JSONException(Throwable cause) { + super(cause); + } + +} diff --git a/javaSE/javaSE/src/main/java/org/json/JSONObject.java b/javaSE/javaSE/src/main/java/org/json/JSONObject.java new file mode 100644 index 000000000..74ea973c2 --- /dev/null +++ b/javaSE/javaSE/src/main/java/org/json/JSONObject.java @@ -0,0 +1,829 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.json; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +// Note: this class was written without inspecting the non-free org.json sourcecode. + +/** + * A modifiable set of name/value mappings. Names are unique, non-null strings. + * Values may be any mix of {@link JSONObject JSONObjects}, {@link JSONArray + * JSONArrays}, Strings, Booleans, Integers, Longs, Doubles or {@link #NULL}. + * Values may not be {@code null}, {@link Double#isNaN() NaNs}, {@link + * Double#isInfinite() infinities}, or of any type not listed here. + * + *

This class can coerce values to another type when requested. + *

+ * + *

This class can look up both mandatory and optional values: + *

    + *
  • Use getType() to retrieve a mandatory value. This + * fails with a {@code JSONException} if the requested name has no value + * or if the value cannot be coerced to the requested type. + *
  • Use optType() to retrieve an optional value. This + * returns a system- or user-supplied default if the requested name has no + * value or if the value cannot be coerced to the requested type. + *
+ * + *

Warning: this class represents null in two incompatible + * ways: the standard Java {@code null} reference, and the sentinel value {@link + * JSONObject#NULL}. In particular, calling {@code put(name, null)} removes the + * named entry from the object but {@code put(name, JSONObject.NULL)} stores an + * entry whose value is {@code JSONObject.NULL}. + * + *

Instances of this class are not thread safe. Although this class is + * nonfinal, it was not designed for inheritance and should not be subclassed. + * In particular, self-use by overrideable methods is not specified. See + * Effective Java Item 17, "Design and Document or inheritance or else + * prohibit it" for further information. + */ +public class JSONObject { + + private static final Double NEGATIVE_ZERO = -0d; + + /** + * A sentinel value used to explicitly define a name with no value. Unlike + * {@code null}, names with this value: + *

    + *
  • show up in the {@link #names} array + *
  • show up in the {@link #keys} iterator + *
  • return {@code true} for {@link #has(String)} + *
  • do not throw on {@link #get(String)} + *
  • are included in the encoded JSON string. + *
+ * + *

This value violates the general contract of {@link Object#equals} by + * returning true when compared to {@code null}. Its {@link #toString} + * method returns "null". + */ + @NonNull + public static final Object NULL = new Object() { + @Override public boolean equals(Object o) { + return o == this || o == null; // API specifies this broken equals implementation + } + // at least make the broken equals(null) consistent with Objects.hashCode(null). + @Override public int hashCode() { return Objects.hashCode(null); } + @Override public String toString() { + return "null"; + } + }; + + + private final LinkedHashMap nameValuePairs; + + /** + * Creates a {@code JSONObject} with no name/value mappings. + */ + public JSONObject() { + nameValuePairs = new LinkedHashMap(); + } + + /** + * Creates a new {@code JSONObject} by copying all name/value mappings from + * the given map. + * + * @param copyFrom a map whose keys are of type {@link String} and whose + * values are of supported types. + * @throws NullPointerException if any of the map's keys are null. + */ + /* (accept a raw type for API compatibility) */ + public JSONObject(@NonNull Map copyFrom) { + this(); + Map contentsTyped = (Map) copyFrom; + for (Map.Entry entry : contentsTyped.entrySet()) { + /* + * Deviate from the original by checking that keys are non-null and + * of the proper type. (We still defer validating the values). + */ + String key = (String) entry.getKey(); + if (key == null) { + throw new NullPointerException("key == null"); + } + nameValuePairs.put(key, wrap(entry.getValue())); + } + } + + /** + * Creates a new {@code JSONObject} with name/value mappings from the next + * object in the tokener. + * + * @param readFrom a tokener whose nextValue() method will yield a + * {@code JSONObject}. + * @throws JSONException if the parse fails or doesn't yield a + * {@code JSONObject}. + */ + public JSONObject(@NonNull JSONTokener readFrom) throws JSONException { + /* + * Getting the parser to populate this could get tricky. Instead, just + * parse to temporary JSONObject and then steal the data from that. + */ + Object object = readFrom.nextValue(); + if (object instanceof JSONObject) { + this.nameValuePairs = ((JSONObject) object).nameValuePairs; + } else { + throw JSON.typeMismatch(object, "JSONObject"); + } + } + + /** + * Creates a new {@code JSONObject} with name/value mappings from the JSON + * string. + * + * @param json a JSON-encoded string containing an object. + * @throws JSONException if the parse fails or doesn't yield a {@code + * JSONObject}. + */ + public JSONObject(@NonNull String json) throws JSONException { + this(new JSONTokener(json)); + } + + /** + * Creates a new {@code JSONObject} by copying mappings for the listed names + * from the given object. Names that aren't present in {@code copyFrom} will + * be skipped. + */ + public JSONObject(@NonNull JSONObject copyFrom, @NonNull String [] names) throws JSONException { + this(); + for (String name : names) { + Object value = copyFrom.opt(name); + if (value != null) { + nameValuePairs.put(name, value); + } + } + } + + /** + * Returns the number of name/value mappings in this object. + */ + public int length() { + return nameValuePairs.size(); + } + + /** + * Maps {@code name} to {@code value}, clobbering any existing name/value + * mapping with the same name. + * + * @return this object. + */ + @NonNull public JSONObject put(@NonNull String name, boolean value) throws JSONException { + nameValuePairs.put(checkName(name), value); + return this; + } + + /** + * Maps {@code name} to {@code value}, clobbering any existing name/value + * mapping with the same name. + * + * @param value a finite value. May not be {@link Double#isNaN() NaNs} or + * {@link Double#isInfinite() infinities}. + * @return this object. + */ + @NonNull public JSONObject put(@NonNull String name, double value) throws JSONException { + nameValuePairs.put(checkName(name), JSON.checkDouble(value)); + return this; + } + + /** + * Maps {@code name} to {@code value}, clobbering any existing name/value + * mapping with the same name. + * + * @return this object. + */ + @NonNull public JSONObject put(@NonNull String name, int value) throws JSONException { + nameValuePairs.put(checkName(name), value); + return this; + } + + /** + * Maps {@code name} to {@code value}, clobbering any existing name/value + * mapping with the same name. + * + * @return this object. + */ + @NonNull public JSONObject put(@NonNull String name, long value) throws JSONException { + nameValuePairs.put(checkName(name), value); + return this; + } + + /** + * Maps {@code name} to {@code value}, clobbering any existing name/value + * mapping with the same name. If the value is {@code null}, any existing + * mapping for {@code name} is removed. + * + * @param value a {@link JSONObject}, {@link JSONArray}, String, Boolean, + * Integer, Long, Double, {@link #NULL}, or {@code null}. May not be + * {@link Double#isNaN() NaNs} or {@link Double#isInfinite() + * infinities}. + * @return this object. + */ + @NonNull public JSONObject put(@NonNull String name, @Nullable Object value) throws JSONException { + if (value == null) { + nameValuePairs.remove(name); + return this; + } + if (value instanceof Number) { + // deviate from the original by checking all Numbers, not just floats & doubles + JSON.checkDouble(((Number) value).doubleValue()); + } + nameValuePairs.put(checkName(name), value); + return this; + } + + /** + * Equivalent to {@code put(name, value)} when both parameters are non-null; + * does nothing otherwise. + */ + @NonNull public JSONObject putOpt(@Nullable String name, @Nullable Object value) throws JSONException { + if (name == null || value == null) { + return this; + } + return put(name, value); + } + + /** + * Appends {@code value} to the array already mapped to {@code name}. If + * this object has no mapping for {@code name}, this inserts a new mapping. + * If the mapping exists but its value is not an array, the existing + * and new values are inserted in order into a new array which is itself + * mapped to {@code name}. In aggregate, this allows values to be added to a + * mapping one at a time. + * + *

Note that {@code append(String, Object)} provides better semantics. + * In particular, the mapping for {@code name} will always be a + * {@link JSONArray}. Using {@code accumulate} will result in either a + * {@link JSONArray} or a mapping whose type is the type of {@code value} + * depending on the number of calls to it. + * + * @param value a {@link JSONObject}, {@link JSONArray}, String, Boolean, + * Integer, Long, Double, {@link #NULL} or null. May not be {@link + * Double#isNaN() NaNs} or {@link Double#isInfinite() infinities}. + */ + // TODO: Change {@code append) to {@link #append} when append is + // unhidden. + @NonNull public JSONObject accumulate(@NonNull String name, @Nullable Object value) throws JSONException { + Object current = nameValuePairs.get(checkName(name)); + if (current == null) { + return put(name, value); + } + + if (current instanceof JSONArray) { + JSONArray array = (JSONArray) current; + array.checkedPut(value); + } else { + JSONArray array = new JSONArray(); + array.checkedPut(current); + array.checkedPut(value); + nameValuePairs.put(name, array); + } + return this; + } + + /** + * Appends values to the array mapped to {@code name}. A new {@link JSONArray} + * mapping for {@code name} will be inserted if no mapping exists. If the existing + * mapping for {@code name} is not a {@link JSONArray}, a {@link JSONException} + * will be thrown. + * + * @throws JSONException if {@code name} is {@code null} or if the mapping for + * {@code name} is non-null and is not a {@link JSONArray}. + * + */ + public JSONObject append(String name, Object value) throws JSONException { + Object current = nameValuePairs.get(checkName(name)); + + final JSONArray array; + if (current instanceof JSONArray) { + array = (JSONArray) current; + } else if (current == null) { + JSONArray newArray = new JSONArray(); + nameValuePairs.put(name, newArray); + array = newArray; + } else { + throw new JSONException("Key " + name + " is not a JSONArray"); + } + + array.checkedPut(value); + + return this; + } + + String checkName(String name) throws JSONException { + if (name == null) { + throw new JSONException("Names must be non-null"); + } + return name; + } + + /** + * Removes the named mapping if it exists; does nothing otherwise. + * + * @return the value previously mapped by {@code name}, or null if there was + * no such mapping. + */ + @Nullable public Object remove(@Nullable String name) { + return nameValuePairs.remove(name); + } + + /** + * Returns true if this object has no mapping for {@code name} or if it has + * a mapping whose value is {@link #NULL}. + */ + public boolean isNull(@Nullable String name) { + Object value = nameValuePairs.get(name); + return value == null || value == NULL; + } + + /** + * Returns true if this object has a mapping for {@code name}. The mapping + * may be {@link #NULL}. + */ + public boolean has(@Nullable String name) { + return nameValuePairs.containsKey(name); + } + + /** + * Returns the value mapped by {@code name}, or throws if no such mapping exists. + * + * @throws JSONException if no such mapping exists. + */ + @NonNull public Object get(@NonNull String name) throws JSONException { + Object result = nameValuePairs.get(name); + if (result == null) { + throw new JSONException("No value for " + name); + } + return result; + } + + /** + * Returns the value mapped by {@code name}, or null if no such mapping + * exists. + */ + @Nullable public Object opt(@Nullable String name) { + return nameValuePairs.get(name); + } + + /** + * Returns the value mapped by {@code name} if it exists and is a boolean or + * can be coerced to a boolean, or throws otherwise. + * + * @throws JSONException if the mapping doesn't exist or cannot be coerced + * to a boolean. + */ + public boolean getBoolean(@NonNull String name) throws JSONException { + Object object = get(name); + Boolean result = JSON.toBoolean(object); + if (result == null) { + throw JSON.typeMismatch(name, object, "boolean"); + } + return result; + } + + /** + * Returns the value mapped by {@code name} if it exists and is a boolean or + * can be coerced to a boolean, or false otherwise. + */ + public boolean optBoolean(@Nullable String name) { + return optBoolean(name, false); + } + + /** + * Returns the value mapped by {@code name} if it exists and is a boolean or + * can be coerced to a boolean, or {@code fallback} otherwise. + */ + public boolean optBoolean(@Nullable String name, boolean fallback) { + Object object = opt(name); + Boolean result = JSON.toBoolean(object); + return result != null ? result : fallback; + } + + /** + * Returns the value mapped by {@code name} if it exists and is a double or + * can be coerced to a double, or throws otherwise. + * + * @throws JSONException if the mapping doesn't exist or cannot be coerced + * to a double. + */ + public double getDouble(@NonNull String name) throws JSONException { + Object object = get(name); + Double result = JSON.toDouble(object); + if (result == null) { + throw JSON.typeMismatch(name, object, "double"); + } + return result; + } + + /** + * Returns the value mapped by {@code name} if it exists and is a double or + * can be coerced to a double, or {@code NaN} otherwise. + */ + public double optDouble(@Nullable String name) { + return optDouble(name, Double.NaN); + } + + /** + * Returns the value mapped by {@code name} if it exists and is a double or + * can be coerced to a double, or {@code fallback} otherwise. + */ + public double optDouble(@Nullable String name, double fallback) { + Object object = opt(name); + Double result = JSON.toDouble(object); + return result != null ? result : fallback; + } + + /** + * Returns the value mapped by {@code name} if it exists and is an int or + * can be coerced to an int, or throws otherwise. + * + * @throws JSONException if the mapping doesn't exist or cannot be coerced + * to an int. + */ + public int getInt(@NonNull String name) throws JSONException { + Object object = get(name); + Integer result = JSON.toInteger(object); + if (result == null) { + throw JSON.typeMismatch(name, object, "int"); + } + return result; + } + + /** + * Returns the value mapped by {@code name} if it exists and is an int or + * can be coerced to an int, or 0 otherwise. + */ + public int optInt(@Nullable String name) { + return optInt(name, 0); + } + + /** + * Returns the value mapped by {@code name} if it exists and is an int or + * can be coerced to an int, or {@code fallback} otherwise. + */ + public int optInt(@Nullable String name, int fallback) { + Object object = opt(name); + Integer result = JSON.toInteger(object); + return result != null ? result : fallback; + } + + /** + * Returns the value mapped by {@code name} if it exists and is a long or + * can be coerced to a long, or throws otherwise. + * Note that JSON represents numbers as doubles, + * so this is lossy; use strings to transfer numbers via JSON. + * + * @throws JSONException if the mapping doesn't exist or cannot be coerced + * to a long. + */ + public long getLong(@NonNull String name) throws JSONException { + Object object = get(name); + Long result = JSON.toLong(object); + if (result == null) { + throw JSON.typeMismatch(name, object, "long"); + } + return result; + } + + /** + * Returns the value mapped by {@code name} if it exists and is a long or + * can be coerced to a long, or 0 otherwise. Note that JSON represents numbers as doubles, + * so this is lossy; use strings to transfer numbers via JSON. + */ + public long optLong(@Nullable String name) { + return optLong(name, 0L); + } + + /** + * Returns the value mapped by {@code name} if it exists and is a long or + * can be coerced to a long, or {@code fallback} otherwise. Note that JSON represents + * numbers as doubles, so this is lossy; use strings to transfer + * numbers via JSON. + */ + public long optLong(@Nullable String name, long fallback) { + Object object = opt(name); + Long result = JSON.toLong(object); + return result != null ? result : fallback; + } + + /** + * Returns the value mapped by {@code name} if it exists, coercing it if + * necessary, or throws if no such mapping exists. + * + * @throws JSONException if no such mapping exists. + */ + @NonNull public String getString(@NonNull String name) throws JSONException { + Object object = get(name); + String result = JSON.toString(object); + if (result == null) { + throw JSON.typeMismatch(name, object, "String"); + } + return result; + } + + /** + * Returns the value mapped by {@code name} if it exists, coercing it if + * necessary, or the empty string if no such mapping exists. + */ + @NonNull public String optString(@Nullable String name) { + return optString(name, ""); + } + + /** + * Returns the value mapped by {@code name} if it exists, coercing it if + * necessary, or {@code fallback} if no such mapping exists. + */ + @NonNull public String optString(@Nullable String name, @NonNull String fallback) { + Object object = opt(name); + String result = JSON.toString(object); + return result != null ? result : fallback; + } + + /** + * Returns the value mapped by {@code name} if it exists and is a {@code + * JSONArray}, or throws otherwise. + * + * @throws JSONException if the mapping doesn't exist or is not a {@code + * JSONArray}. + */ + @NonNull public JSONArray getJSONArray(@NonNull String name) throws JSONException { + Object object = get(name); + if (object instanceof JSONArray) { + return (JSONArray) object; + } else { + throw JSON.typeMismatch(name, object, "JSONArray"); + } + } + + /** + * Returns the value mapped by {@code name} if it exists and is a {@code + * JSONArray}, or null otherwise. + */ + @Nullable public JSONArray optJSONArray(@Nullable String name) { + Object object = opt(name); + return object instanceof JSONArray ? (JSONArray) object : null; + } + + /** + * Returns the value mapped by {@code name} if it exists and is a {@code + * JSONObject}, or throws otherwise. + * + * @throws JSONException if the mapping doesn't exist or is not a {@code + * JSONObject}. + */ + @NonNull public JSONObject getJSONObject(@NonNull String name) throws JSONException { + Object object = get(name); + if (object instanceof JSONObject) { + return (JSONObject) object; + } else { + throw JSON.typeMismatch(name, object, "JSONObject"); + } + } + + /** + * Returns the value mapped by {@code name} if it exists and is a {@code + * JSONObject}, or null otherwise. + */ + @Nullable public JSONObject optJSONObject(@Nullable String name) { + Object object = opt(name); + return object instanceof JSONObject ? (JSONObject) object : null; + } + + /** + * Returns an array with the values corresponding to {@code names}. The + * array contains null for names that aren't mapped. This method returns + * null if {@code names} is either null or empty. + */ + @Nullable public JSONArray toJSONArray(@Nullable JSONArray names) throws JSONException { + JSONArray result = new JSONArray(); + if (names == null) { + return null; + } + int length = names.length(); + if (length == 0) { + return null; + } + for (int i = 0; i < length; i++) { + String name = JSON.toString(names.opt(i)); + result.put(opt(name)); + } + return result; + } + + /** + * Returns an iterator of the {@code String} names in this object. The + * returned iterator supports {@link Iterator#remove() remove}, which will + * remove the corresponding mapping from this object. If this object is + * modified after the iterator is returned, the iterator's behavior is + * undefined. The order of the keys is undefined. + */ + @NonNull public Iterator keys() { + return nameValuePairs.keySet().iterator(); + } + + /** + * Returns the set of {@code String} names in this object. The returned set + * is a view of the keys in this object. {@link Set#remove(Object)} will remove + * the corresponding mapping from this object and set iterator behaviour + * is undefined if this object is modified after it is returned. + * + * See {@link #keys()}. + * + */ + public Set keySet() { + return nameValuePairs.keySet(); + } + + /** + * Returns an array containing the string names in this object. This method + * returns null if this object contains no mappings. + */ + @Nullable public JSONArray names() { + return nameValuePairs.isEmpty() + ? null + : new JSONArray(new ArrayList(nameValuePairs.keySet())); + } + + /** + * Encodes this object as a compact JSON string, such as: + *

{"query":"Pizza","locations":[94043,90210]}
+ */ + @Override @NonNull public String toString() { + try { + JSONStringer stringer = new JSONStringer(); + writeTo(stringer); + return stringer.toString(); + } catch (JSONException e) { + return null; + } + } + + /** + * Encodes this object as a human readable JSON string for debugging, such + * as: + *
+     * {
+     *     "query": "Pizza",
+     *     "locations": [
+     *         94043,
+     *         90210
+     *     ]
+     * }
+ * + * @param indentSpaces the number of spaces to indent for each level of + * nesting. + */ + @NonNull public String toString(int indentSpaces) throws JSONException { + JSONStringer stringer = new JSONStringer(indentSpaces); + writeTo(stringer); + return stringer.toString(); + } + + + void writeTo(JSONStringer stringer) throws JSONException { + stringer.object(); + for (Map.Entry entry : nameValuePairs.entrySet()) { + stringer.key(entry.getKey()).value(entry.getValue()); + } + stringer.endObject(); + } + + /** + * Encodes the number as a JSON string. + * + * @param number a finite value. May not be {@link Double#isNaN() NaNs} or + * {@link Double#isInfinite() infinities}. + */ + @NonNull public static String numberToString(@NonNull Number number) throws JSONException { + if (number == null) { + throw new JSONException("Number must be non-null"); + } + + double doubleValue = number.doubleValue(); + JSON.checkDouble(doubleValue); + + // the original returns "-0" instead of "-0.0" for negative zero + if (number.equals(NEGATIVE_ZERO)) { + return "-0"; + } + + long longValue = number.longValue(); + if (doubleValue == (double) longValue) { + return Long.toString(longValue); + } + + return number.toString(); + } + + /** + * Encodes {@code data} as a JSON string. This applies quotes and any + * necessary character escaping. + * + * @param data the string to encode. Null will be interpreted as an empty + * string. + */ + @NonNull public static String quote(@Nullable String data) { + if (data == null) { + return "\"\""; + } + try { + JSONStringer stringer = new JSONStringer(); + stringer.open(JSONStringer.Scope.NULL, ""); + stringer.value(data); + stringer.close(JSONStringer.Scope.NULL, JSONStringer.Scope.NULL, ""); + return stringer.toString(); + } catch (JSONException e) { + throw new AssertionError(); + } + } + + /** + * Wraps the given object if necessary. + * + *

If the object is null or , returns {@link #NULL}. + * If the object is a {@code JSONArray} or {@code JSONObject}, no wrapping is necessary. + * If the object is {@code NULL}, no wrapping is necessary. + * If the object is an array or {@code Collection}, returns an equivalent {@code JSONArray}. + * If the object is a {@code Map}, returns an equivalent {@code JSONObject}. + * If the object is a primitive wrapper type or {@code String}, returns the object. + * Otherwise if the object is from a {@code java} package, returns the result of {@code toString}. + * If wrapping fails, returns null. + */ + @Nullable public static Object wrap(@Nullable Object o) { + if (o == null) { + return NULL; + } + if (o instanceof JSONArray || o instanceof JSONObject) { + return o; + } + if (o.equals(NULL)) { + return o; + } + try { + if (o instanceof Collection) { + return new JSONArray((Collection) o); + } else if (o.getClass().isArray()) { + return new JSONArray(o); + } + if (o instanceof Map) { + return new JSONObject((Map) o); + } + if (o instanceof Boolean || + o instanceof Byte || + o instanceof Character || + o instanceof Double || + o instanceof Float || + o instanceof Integer || + o instanceof Long || + o instanceof Short || + o instanceof String) { + return o; + } + if (o.getClass().getPackage().getName().startsWith("java.")) { + return o.toString(); + } + } catch (Exception ignored) { + } + return null; + } +} diff --git a/javaSE/javaSE/src/main/java/org/json/JSONStringer.java b/javaSE/javaSE/src/main/java/org/json/JSONStringer.java new file mode 100644 index 000000000..dd3b2a7d8 --- /dev/null +++ b/javaSE/javaSE/src/main/java/org/json/JSONStringer.java @@ -0,0 +1,432 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.json; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +// Note: this class was written without inspecting the non-free org.json sourcecode. + +/** + * Implements {@link JSONObject#toString} and {@link JSONArray#toString}. Most + * application developers should use those methods directly and disregard this + * API. For example:

+ * JSONObject object = ...
+ * String json = object.toString();
+ * + *

Stringers only encode well-formed JSON strings. In particular: + *

    + *
  • The stringer must have exactly one top-level array or object. + *
  • Lexical scopes must be balanced: every call to {@link #array} must + * have a matching call to {@link #endArray} and every call to {@link + * #object} must have a matching call to {@link #endObject}. + *
  • Arrays may not contain keys (property names). + *
  • Objects must alternate keys (property names) and values. + *
  • Values are inserted with either literal {@link #value(Object) value} + * calls, or by nesting arrays or objects. + *
+ * Calls that would result in a malformed JSON string will fail with a + * {@link JSONException}. + * + *

This class provides no facility for pretty-printing (ie. indenting) + * output. To encode indented output, use {@link JSONObject#toString(int)} or + * {@link JSONArray#toString(int)}. + * + *

Some implementations of the API support at most 20 levels of nesting. + * Attempts to create more than 20 levels of nesting may fail with a {@link + * JSONException}. + * + *

Each stringer may be used to encode a single top level value. Instances of + * this class are not thread safe. Although this class is nonfinal, it was not + * designed for inheritance and should not be subclassed. In particular, + * self-use by overrideable methods is not specified. See Effective Java + * Item 17, "Design and Document or inheritance or else prohibit it" for further + * information. + */ +public class JSONStringer { + + /** The output data, containing at most one top-level array or object. */ + final StringBuilder out = new StringBuilder(); + + /** + * Lexical scoping elements within this stringer, necessary to insert the + * appropriate separator characters (ie. commas and colons) and to detect + * nesting errors. + */ + enum Scope { + + /** + * An array with no elements requires no separators or newlines before + * it is closed. + */ + EMPTY_ARRAY, + + /** + * A array with at least one value requires a comma and newline before + * the next element. + */ + NONEMPTY_ARRAY, + + /** + * An object with no keys or values requires no separators or newlines + * before it is closed. + */ + EMPTY_OBJECT, + + /** + * An object whose most recent element is a key. The next element must + * be a value. + */ + DANGLING_KEY, + + /** + * An object with at least one name/value pair requires a comma and + * newline before the next element. + */ + NONEMPTY_OBJECT, + + /** + * A special bracketless array needed by JSONStringer.join() and + * JSONObject.quote() only. Not used for JSON encoding. + */ + NULL, + } + + /** + * Unlike the original implementation, this stack isn't limited to 20 + * levels of nesting. + */ + private final List stack = new ArrayList(); + + /** + * A string containing a full set of spaces for a single level of + * indentation, or null for no pretty printing. + */ + private final String indent; + + public JSONStringer() { + indent = null; + } + + JSONStringer(int indentSpaces) { + char[] indentChars = new char[indentSpaces]; + Arrays.fill(indentChars, ' '); + indent = new String(indentChars); + } + + /** + * Begins encoding a new array. Each call to this method must be paired with + * a call to {@link #endArray}. + * + * @return this stringer. + */ + public JSONStringer array() throws JSONException { + return open(Scope.EMPTY_ARRAY, "["); + } + + /** + * Ends encoding the current array. + * + * @return this stringer. + */ + public JSONStringer endArray() throws JSONException { + return close(Scope.EMPTY_ARRAY, Scope.NONEMPTY_ARRAY, "]"); + } + + /** + * Begins encoding a new object. Each call to this method must be paired + * with a call to {@link #endObject}. + * + * @return this stringer. + */ + public JSONStringer object() throws JSONException { + return open(Scope.EMPTY_OBJECT, "{"); + } + + /** + * Ends encoding the current object. + * + * @return this stringer. + */ + public JSONStringer endObject() throws JSONException { + return close(Scope.EMPTY_OBJECT, Scope.NONEMPTY_OBJECT, "}"); + } + + /** + * Enters a new scope by appending any necessary whitespace and the given + * bracket. + */ + JSONStringer open(Scope empty, String openBracket) throws JSONException { + if (stack.isEmpty() && out.length() > 0) { + throw new JSONException("Nesting problem: multiple top-level roots"); + } + beforeValue(); + stack.add(empty); + out.append(openBracket); + return this; + } + + /** + * Closes the current scope by appending any necessary whitespace and the + * given bracket. + */ + JSONStringer close(Scope empty, Scope nonempty, String closeBracket) throws JSONException { + Scope context = peek(); + if (context != nonempty && context != empty) { + throw new JSONException("Nesting problem"); + } + + stack.remove(stack.size() - 1); + if (context == nonempty) { + newline(); + } + out.append(closeBracket); + return this; + } + + /** + * Returns the value on the top of the stack. + */ + private Scope peek() throws JSONException { + if (stack.isEmpty()) { + throw new JSONException("Nesting problem"); + } + return stack.get(stack.size() - 1); + } + + /** + * Replace the value on the top of the stack with the given value. + */ + private void replaceTop(Scope topOfStack) { + stack.set(stack.size() - 1, topOfStack); + } + + /** + * Encodes {@code value}. + * + * @param value a {@link JSONObject}, {@link JSONArray}, String, Boolean, + * Integer, Long, Double or null. May not be {@link Double#isNaN() NaNs} + * or {@link Double#isInfinite() infinities}. + * @return this stringer. + */ + public JSONStringer value(Object value) throws JSONException { + if (stack.isEmpty()) { + throw new JSONException("Nesting problem"); + } + + if (value instanceof JSONArray) { + ((JSONArray) value).writeTo(this); + return this; + + } else if (value instanceof JSONObject) { + ((JSONObject) value).writeTo(this); + return this; + } + + beforeValue(); + + if (value == null + || value instanceof Boolean + || value == JSONObject.NULL) { + out.append(value); + + } else if (value instanceof Number) { + out.append(JSONObject.numberToString((Number) value)); + + } else { + string(value.toString()); + } + + return this; + } + + /** + * Encodes {@code value} to this stringer. + * + * @return this stringer. + */ + public JSONStringer value(boolean value) throws JSONException { + if (stack.isEmpty()) { + throw new JSONException("Nesting problem"); + } + beforeValue(); + out.append(value); + return this; + } + + /** + * Encodes {@code value} to this stringer. + * + * @param value a finite value. May not be {@link Double#isNaN() NaNs} or + * {@link Double#isInfinite() infinities}. + * @return this stringer. + */ + public JSONStringer value(double value) throws JSONException { + if (stack.isEmpty()) { + throw new JSONException("Nesting problem"); + } + beforeValue(); + out.append(JSONObject.numberToString(value)); + return this; + } + + /** + * Encodes {@code value} to this stringer. + * + * @return this stringer. + */ + public JSONStringer value(long value) throws JSONException { + if (stack.isEmpty()) { + throw new JSONException("Nesting problem"); + } + beforeValue(); + out.append(value); + return this; + } + + private void string(String value) { + out.append("\""); + for (int i = 0, length = value.length(); i < length; i++) { + char c = value.charAt(i); + + /* + * From RFC 4627, "All Unicode characters may be placed within the + * quotation marks except for the characters that must be escaped: + * quotation mark, reverse solidus, and the control characters + * (U+0000 through U+001F)." + */ + switch (c) { + case '"': + case '\\': + case '/': + out.append('\\').append(c); + break; + + case '\t': + out.append("\\t"); + break; + + case '\b': + out.append("\\b"); + break; + + case '\n': + out.append("\\n"); + break; + + case '\r': + out.append("\\r"); + break; + + case '\f': + out.append("\\f"); + break; + + default: + if (c <= 0x1F) { + out.append(String.format("\\u%04x", (int) c)); + } else { + out.append(c); + } + break; + } + + } + out.append("\""); + } + + private void newline() { + if (indent == null) { + return; + } + + out.append("\n"); + for (int i = 0; i < stack.size(); i++) { + out.append(indent); + } + } + + /** + * Encodes the key (property name) to this stringer. + * + * @param name the name of the forthcoming value. May not be null. + * @return this stringer. + */ + public JSONStringer key(String name) throws JSONException { + if (name == null) { + throw new JSONException("Names must be non-null"); + } + beforeKey(); + string(name); + return this; + } + + /** + * Inserts any necessary separators and whitespace before a name. Also + * adjusts the stack to expect the key's value. + */ + private void beforeKey() throws JSONException { + Scope context = peek(); + if (context == Scope.NONEMPTY_OBJECT) { // first in object + out.append(','); + } else if (context != Scope.EMPTY_OBJECT) { // not in an object! + throw new JSONException("Nesting problem"); + } + newline(); + replaceTop(Scope.DANGLING_KEY); + } + + /** + * Inserts any necessary separators and whitespace before a literal value, + * inline array, or inline object. Also adjusts the stack to expect either a + * closing bracket or another element. + */ + private void beforeValue() throws JSONException { + if (stack.isEmpty()) { + return; + } + + Scope context = peek(); + if (context == Scope.EMPTY_ARRAY) { // first in array + replaceTop(Scope.NONEMPTY_ARRAY); + newline(); + } else if (context == Scope.NONEMPTY_ARRAY) { // another in array + out.append(','); + newline(); + } else if (context == Scope.DANGLING_KEY) { // value for key + out.append(indent == null ? ":" : ": "); + replaceTop(Scope.NONEMPTY_OBJECT); + } else if (context != Scope.NULL) { + throw new JSONException("Nesting problem"); + } + } + + /** + * Returns the encoded JSON string. + * + *

If invoked with unterminated arrays or unclosed objects, this method's + * return value is undefined. + * + *

Warning: although it contradicts the general contract + * of {@link Object#toString}, this method returns null if the stringer + * contains no data. + */ + @Override public String toString() { + return out.length() == 0 ? null : out.toString(); + } +} diff --git a/javaSE/javaSE/src/main/java/org/json/JSONTokener.java b/javaSE/javaSE/src/main/java/org/json/JSONTokener.java new file mode 100644 index 000000000..4bdd9ad37 --- /dev/null +++ b/javaSE/javaSE/src/main/java/org/json/JSONTokener.java @@ -0,0 +1,611 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.json; + + +// Note: this class was written without inspecting the non-free org.json sourcecode. + +/** + * Parses a JSON (RFC 4627) + * encoded string into the corresponding object. Most clients of + * this class will use only need the {@link #JSONTokener(String) constructor} + * and {@link #nextValue} method. Example usage:

+ * String json = "{"
+ *         + "  \"query\": \"Pizza\", "
+ *         + "  \"locations\": [ 94043, 90210 ] "
+ *         + "}";
+ *
+ * JSONObject object = (JSONObject) new JSONTokener(json).nextValue();
+ * String query = object.getString("query");
+ * JSONArray locations = object.getJSONArray("locations");
+ * + *

For best interoperability and performance use JSON that complies with + * RFC 4627, such as that generated by {@link JSONStringer}. For legacy reasons + * this parser is lenient, so a successful parse does not indicate that the + * input string was valid JSON. All of the following syntax errors will be + * ignored: + *

    + *
  • End of line comments starting with {@code //} or {@code #} and ending + * with a newline character. + *
  • C-style comments starting with {@code /*} and ending with + * {@code *}{@code /}. Such comments may not be nested. + *
  • Strings that are unquoted or {@code 'single quoted'}. + *
  • Hexadecimal integers prefixed with {@code 0x} or {@code 0X}. + *
  • Octal integers prefixed with {@code 0}. + *
  • Array elements separated by {@code ;}. + *
  • Unnecessary array separators. These are interpreted as if null was the + * omitted value. + *
  • Key-value pairs separated by {@code =} or {@code =>}. + *
  • Key-value pairs separated by {@code ;}. + *
+ * + *

Each tokener may be used to parse a single JSON string. Instances of this + * class are not thread safe. Although this class is nonfinal, it was not + * designed for inheritance and should not be subclassed. In particular, + * self-use by overrideable methods is not specified. See Effective Java + * Item 17, "Design and Document or inheritance or else prohibit it" for further + * information. + */ +public class JSONTokener { + + /** The input JSON. */ + private final String in; + + /** + * The index of the next character to be returned by {@link #next}. When + * the input is exhausted, this equals the input's length. + */ + private int pos; + + /** + * @param in JSON encoded string. Null is not permitted and will yield a + * tokener that throws {@code NullPointerExceptions} when methods are + * called. + */ + public JSONTokener(String in) { + // consume an optional byte order mark (BOM) if it exists + if (in != null && in.startsWith("\ufeff")) { + in = in.substring(1); + } + this.in = in; + } + + /** + * Returns the next value from the input. + * + * @return a {@link JSONObject}, {@link JSONArray}, String, Boolean, + * Integer, Long, Double or {@link JSONObject#NULL}. + * @throws JSONException if the input is malformed. + */ + public Object nextValue() throws JSONException { + int c = nextCleanInternal(); + switch (c) { + case -1: + throw syntaxError("End of input"); + + case '{': + return readObject(); + + case '[': + return readArray(); + + case '\'': + case '"': + return nextString((char) c); + + default: + pos--; + return readLiteral(); + } + } + + private int nextCleanInternal() throws JSONException { + while (pos < in.length()) { + int c = in.charAt(pos++); + switch (c) { + case '\t': + case ' ': + case '\n': + case '\r': + continue; + + case '/': + if (pos == in.length()) { + return c; + } + + char peek = in.charAt(pos); + switch (peek) { + case '*': + // skip a /* c-style comment */ + pos++; + int commentEnd = in.indexOf("*/", pos); + if (commentEnd == -1) { + throw syntaxError("Unterminated comment"); + } + pos = commentEnd + 2; + continue; + + case '/': + // skip a // end-of-line comment + pos++; + skipToEndOfLine(); + continue; + + default: + return c; + } + + case '#': + /* + * Skip a # hash end-of-line comment. The JSON RFC doesn't + * specify this behavior, but it's required to parse + * existing documents. See http://b/2571423. + */ + skipToEndOfLine(); + continue; + + default: + return c; + } + } + + return -1; + } + + /** + * Advances the position until after the next newline character. If the line + * is terminated by "\r\n", the '\n' must be consumed as whitespace by the + * caller. + */ + private void skipToEndOfLine() { + for (; pos < in.length(); pos++) { + char c = in.charAt(pos); + if (c == '\r' || c == '\n') { + pos++; + break; + } + } + } + + /** + * Returns the string up to but not including {@code quote}, unescaping any + * character escape sequences encountered along the way. The opening quote + * should have already been read. This consumes the closing quote, but does + * not include it in the returned string. + * + * @param quote either ' or ". + */ + public String nextString(char quote) throws JSONException { + /* + * For strings that are free of escape sequences, we can just extract + * the result as a substring of the input. But if we encounter an escape + * sequence, we need to use a StringBuilder to compose the result. + */ + StringBuilder builder = null; + + /* the index of the first character not yet appended to the builder. */ + int start = pos; + + while (pos < in.length()) { + int c = in.charAt(pos++); + if (c == quote) { + if (builder == null) { + // a new string avoids leaking memory + return new String(in.substring(start, pos - 1)); + } else { + builder.append(in, start, pos - 1); + return builder.toString(); + } + } + + if (c == '\\') { + if (pos == in.length()) { + throw syntaxError("Unterminated escape sequence"); + } + if (builder == null) { + builder = new StringBuilder(); + } + builder.append(in, start, pos - 1); + builder.append(readEscapeCharacter()); + start = pos; + } + } + + throw syntaxError("Unterminated string"); + } + + /** + * Unescapes the character identified by the character or characters that + * immediately follow a backslash. The backslash '\' should have already + * been read. This supports both unicode escapes "u000A" and two-character + * escapes "\n". + */ + private char readEscapeCharacter() throws JSONException { + char escaped = in.charAt(pos++); + switch (escaped) { + case 'u': + if (pos + 4 > in.length()) { + throw syntaxError("Unterminated escape sequence"); + } + String hex = in.substring(pos, pos + 4); + pos += 4; + try { + return (char) Integer.parseInt(hex, 16); + } catch (NumberFormatException nfe) { + throw syntaxError("Invalid escape sequence: " + hex); + } + + case 't': + return '\t'; + + case 'b': + return '\b'; + + case 'n': + return '\n'; + + case 'r': + return '\r'; + + case 'f': + return '\f'; + + case '\'': + case '"': + case '\\': + default: + return escaped; + } + } + + /** + * Reads a null, boolean, numeric or unquoted string literal value. Numeric + * values will be returned as an Integer, Long, or Double, in that order of + * preference. + */ + private Object readLiteral() throws JSONException { + String literal = nextToInternal("{}[]/\\:,=;# \t\f"); + + if (literal.length() == 0) { + throw syntaxError("Expected literal value"); + } else if ("null".equalsIgnoreCase(literal)) { + return JSONObject.NULL; + } else if ("true".equalsIgnoreCase(literal)) { + return Boolean.TRUE; + } else if ("false".equalsIgnoreCase(literal)) { + return Boolean.FALSE; + } + + /* try to parse as an integral type... */ + if (literal.indexOf('.') == -1) { + int base = 10; + String number = literal; + if (number.startsWith("0x") || number.startsWith("0X")) { + number = number.substring(2); + base = 16; + } else if (number.startsWith("0") && number.length() > 1) { + number = number.substring(1); + base = 8; + } + try { + long longValue = Long.parseLong(number, base); + if (longValue <= Integer.MAX_VALUE && longValue >= Integer.MIN_VALUE) { + return (int) longValue; + } else { + return longValue; + } + } catch (NumberFormatException e) { + /* + * This only happens for integral numbers greater than + * Long.MAX_VALUE, numbers in exponential form (5e-10) and + * unquoted strings. Fall through to try floating point. + */ + } + } + + /* ...next try to parse as a floating point... */ + try { + return Double.valueOf(literal); + } catch (NumberFormatException ignored) { + } + + /* ... finally give up. We have an unquoted string */ + return new String(literal); // a new string avoids leaking memory + } + + /** + * Returns the string up to but not including any of the given characters or + * a newline character. This does not consume the excluded character. + */ + private String nextToInternal(String excluded) { + int start = pos; + for (; pos < in.length(); pos++) { + char c = in.charAt(pos); + if (c == '\r' || c == '\n' || excluded.indexOf(c) != -1) { + return in.substring(start, pos); + } + } + return in.substring(start); + } + + /** + * Reads a sequence of key/value pairs and the trailing closing brace '}' of + * an object. The opening brace '{' should have already been read. + */ + private JSONObject readObject() throws JSONException { + JSONObject result = new JSONObject(); + + /* Peek to see if this is the empty object. */ + int first = nextCleanInternal(); + if (first == '}') { + return result; + } else if (first != -1) { + pos--; + } + + while (true) { + Object name = nextValue(); + if (!(name instanceof String)) { + if (name == null) { + throw syntaxError("Names cannot be null"); + } else { + throw syntaxError("Names must be strings, but " + name + + " is of type " + name.getClass().getName()); + } + } + + /* + * Expect the name/value separator to be either a colon ':', an + * equals sign '=', or an arrow "=>". The last two are bogus but we + * include them because that's what the original implementation did. + */ + int separator = nextCleanInternal(); + if (separator != ':' && separator != '=') { + throw syntaxError("Expected ':' after " + name); + } + if (pos < in.length() && in.charAt(pos) == '>') { + pos++; + } + + result.put((String) name, nextValue()); + + switch (nextCleanInternal()) { + case '}': + return result; + case ';': + case ',': + continue; + default: + throw syntaxError("Unterminated object"); + } + } + } + + /** + * Reads a sequence of values and the trailing closing brace ']' of an + * array. The opening brace '[' should have already been read. Note that + * "[]" yields an empty array, but "[,]" returns a two-element array + * equivalent to "[null,null]". + */ + private JSONArray readArray() throws JSONException { + JSONArray result = new JSONArray(); + + /* to cover input that ends with ",]". */ + boolean hasTrailingSeparator = false; + + while (true) { + switch (nextCleanInternal()) { + case -1: + throw syntaxError("Unterminated array"); + case ']': + if (hasTrailingSeparator) { + result.put(null); + } + return result; + case ',': + case ';': + /* A separator without a value first means "null". */ + result.put(null); + hasTrailingSeparator = true; + continue; + default: + pos--; + } + + result.put(nextValue()); + + switch (nextCleanInternal()) { + case ']': + return result; + case ',': + case ';': + hasTrailingSeparator = true; + continue; + default: + throw syntaxError("Unterminated array"); + } + } + } + + /** + * Returns an exception containing the given message plus the current + * position and the entire input string. + */ + public JSONException syntaxError(String message) { + return new JSONException(message + this); + } + + /** + * Returns the current position and the entire input string. + */ + @Override public String toString() { + // consistent with the original implementation + return " at character " + pos + " of " + in; + } + + /* + * Legacy APIs. + * + * None of the methods below are on the critical path of parsing JSON + * documents. They exist only because they were exposed by the original + * implementation and may be used by some clients. + */ + + /** + * Returns true until the input has been exhausted. + */ + public boolean more() { + return pos < in.length(); + } + + /** + * Returns the next available character, or the null character '\0' if all + * input has been exhausted. The return value of this method is ambiguous + * for JSON strings that contain the character '\0'. + */ + public char next() { + return pos < in.length() ? in.charAt(pos++) : '\0'; + } + + /** + * Returns the next available character if it equals {@code c}. Otherwise an + * exception is thrown. + */ + public char next(char c) throws JSONException { + char result = next(); + if (result != c) { + throw syntaxError("Expected " + c + " but was " + result); + } + return result; + } + + /** + * Returns the next character that is not whitespace and does not belong to + * a comment. If the input is exhausted before such a character can be + * found, the null character '\0' is returned. The return value of this + * method is ambiguous for JSON strings that contain the character '\0'. + */ + public char nextClean() throws JSONException { + int nextCleanInt = nextCleanInternal(); + return nextCleanInt == -1 ? '\0' : (char) nextCleanInt; + } + + /** + * Returns the next {@code length} characters of the input. + * + *

The returned string shares its backing character array with this + * tokener's input string. If a reference to the returned string may be held + * indefinitely, you should use {@code new String(result)} to copy it first + * to avoid memory leaks. + * + * @throws JSONException if the remaining input is not long enough to + * satisfy this request. + */ + public String next(int length) throws JSONException { + if (pos + length > in.length()) { + throw syntaxError(length + " is out of bounds"); + } + String result = in.substring(pos, pos + length); + pos += length; + return result; + } + + /** + * Returns the {@link String#trim trimmed} string holding the characters up + * to but not including the first of: + *

    + *
  • any character in {@code excluded} + *
  • a newline character '\n' + *
  • a carriage return '\r' + *
+ * + *

The returned string shares its backing character array with this + * tokener's input string. If a reference to the returned string may be held + * indefinitely, you should use {@code new String(result)} to copy it first + * to avoid memory leaks. + * + * @return a possibly-empty string + */ + public String nextTo(String excluded) { + if (excluded == null) { + throw new NullPointerException("excluded == null"); + } + return nextToInternal(excluded).trim(); + } + + /** + * Equivalent to {@code nextTo(String.valueOf(excluded))}. + */ + public String nextTo(char excluded) { + return nextToInternal(String.valueOf(excluded)).trim(); + } + + /** + * Advances past all input up to and including the next occurrence of + * {@code thru}. If the remaining input doesn't contain {@code thru}, the + * input is exhausted. + */ + public void skipPast(String thru) { + int thruStart = in.indexOf(thru, pos); + pos = thruStart == -1 ? in.length() : (thruStart + thru.length()); + } + + /** + * Advances past all input up to but not including the next occurrence of + * {@code to}. If the remaining input doesn't contain {@code to}, the input + * is unchanged. + */ + public char skipTo(char to) { + int index = in.indexOf(to, pos); + if (index != -1) { + pos = index; + return to; + } else { + return '\0'; + } + } + + /** + * Unreads the most recent character of input. If no input characters have + * been read, the input is unchanged. + */ + public void back() { + if (--pos == -1) { + pos = 0; + } + } + + /** + * Returns the integer [0..15] value for the given hex character, or -1 + * for non-hex input. + * + * @param hex a character in the ranges [0-9], [A-F] or [a-f]. Any other + * character will yield a -1 result. + */ + public static int dehexchar(char hex) { + if (hex >= '0' && hex <= '9') { + return hex - '0'; + } else if (hex >= 'A' && hex <= 'F') { + return hex - 'A' + 10; + } else if (hex >= 'a' && hex <= 'f') { + return hex - 'a' + 10; + } else { + return -1; + } + } +} diff --git a/javaSE/settings.gradle b/javaSE/settings.gradle deleted file mode 100644 index f7ac48020..000000000 --- a/javaSE/settings.gradle +++ /dev/null @@ -1,2 +0,0 @@ -rootProject.name = 'javaSE' - diff --git a/javaSE/src/main/java/com/livio/BSON/BsonEncoder.java b/javaSE/src/main/java/com/livio/BSON/BsonEncoder.java deleted file mode 100644 index 22c47f6cb..000000000 --- a/javaSE/src/main/java/com/livio/BSON/BsonEncoder.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2019, 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. - */ -package com.livio.BSON; - -import com.smartdevicelink.util.DebugTool; -import org.bson.*; - -import java.util.*; - -public class BsonEncoder { - private static final String TAG = "BsonEncoder"; - - public static byte[] encodeToBytes(HashMap map) throws ClassCastException { - if(map != null) { - BasicBSONObject bson = new BasicBSONObject(); - bson.putAll(sanitizeMap(map)); - BasicBSONEncoder encoder = new BasicBSONEncoder(); - - return encoder.encode(bson); - } - DebugTool.logError(TAG, "Something went wrong encoding the map into BSON bytes"); - - return null; - } - - public static HashMap decodeFromBytes(byte[] bytes) { - if(bytes != null) { - BasicBSONDecoder decoder = new BasicBSONDecoder(); - BSONObject object = decoder.readObject(bytes); - if (object != null) { - Map map = object.toMap(); - if (map != null) { - return sanitizeMap(new HashMap<>(map)); - } - } - } - DebugTool.logError(TAG, "Something went wrong decoding bytes into BSON"); - return null; - } - - /** - * Goes thorugh the map and ensures that all the values included are supported by SDL. If they are not of a supported - * value it is removed from the map - * @param map the map to be sanitized - * @return a sanitized HashMap with non-supported object type removes - */ - private static HashMap sanitizeMap(HashMap map){ - Set keys = map.keySet(); - Object value; - for(String key : keys){ - value = map.get(key); - - //First check to see if it value is a valid type used in SDL - if(isSupportedType(value)){ - continue; - }else if(value instanceof List){ //Next, check to see if it is a list of values - List list = (List)value; - - //If the list is empty, there shouldn't be a problem leaving it in the map - if(list.isEmpty()){ - continue; - } - - //Since the list isn't empty, check the first item - if(isSupportedType(list.get(0))){ - continue; - } - } - //If the item isn't valid, remove it from the map - map.remove(key); - - } - return map; - } - - /** - * Checks the value to ensure it is of a supported type - * @param value the generic object value - * @return if the object is an instanceOf one of the supported SDL BSON objects - */ - private static boolean isSupportedType(Object value){ - return value instanceof Integer - || value instanceof Long - || value instanceof Double - || value instanceof String - || value instanceof Boolean; - } - -} diff --git a/javaSE/src/main/java/com/smartdevicelink/BuildConfig.java b/javaSE/src/main/java/com/smartdevicelink/BuildConfig.java deleted file mode 100644 index ecd7b1f9b..000000000 --- a/javaSE/src/main/java/com/smartdevicelink/BuildConfig.java +++ /dev/null @@ -1,36 +0,0 @@ -/* -* Copyright (c) 2017 - 2020, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. -* -*/ -package com.smartdevicelink; - -// THIS FILE IS AUTO GENERATED, DO NOT MODIFY!! -public final class BuildConfig { - public static final String VERSION_NAME = "4.12.0"; -} \ No newline at end of file diff --git a/javaSE/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java b/javaSE/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java deleted file mode 100644 index 542ff6b35..000000000 --- a/javaSE/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2019 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. - */ - -package com.smartdevicelink.SdlConnection; - - -import com.smartdevicelink.protocol.SdlPacket; -import com.smartdevicelink.protocol.SdlProtocol; -import com.smartdevicelink.protocol.SdlProtocolBase; -import com.smartdevicelink.protocol.enums.SessionType; -import com.smartdevicelink.proxy.interfaces.ISdlServiceListener; -import com.smartdevicelink.transport.BaseTransportConfig; -import com.smartdevicelink.util.DebugTool; -import com.smartdevicelink.util.Version; - -import java.util.concurrent.CopyOnWriteArrayList; - -public class SdlSession extends BaseSdlSession { - - private static final String TAG = "SdlSession"; - - - public SdlSession(ISdlSessionListener listener, BaseTransportConfig config) { - super(listener, config); - } - - @Override - protected SdlProtocolBase getSdlProtocolImplementation() { - return new SdlProtocol(this, transportConfig); - } - - @Override - public void onServiceStarted(SdlPacket packet, SessionType serviceType, int sessionID, Version version, boolean isEncrypted) { - DebugTool.logInfo(TAG, serviceType.getName() + " service started"); - - if (serviceType != null && serviceType.eq(SessionType.RPC) && this.sessionId == -1) { - this.sessionId = sessionID; - this.sessionListener.onSessionStarted(sessionID, version); - } - - if (isEncrypted) { - encryptedServices.addIfAbsent(serviceType); - } - - if (serviceListeners != null && serviceListeners.containsKey(serviceType)) { - CopyOnWriteArrayList listeners = serviceListeners.get(serviceType); - for (ISdlServiceListener listener : listeners) { - listener.onServiceStarted(this, serviceType, isEncrypted); - } - } - } - - @Override - public void onServiceEnded(SdlPacket packet, SessionType serviceType, int sessionID) { - - if (SessionType.RPC.equals(serviceType)) { - this.sessionListener.onSessionEnded(sessionID); - } - - if (serviceListeners != null && serviceListeners.containsKey(serviceType)) { - CopyOnWriteArrayList listeners = serviceListeners.get(serviceType); - for (ISdlServiceListener listener : listeners) { - listener.onServiceEnded(this, serviceType); - } - } - - encryptedServices.remove(serviceType); - } - - @Override - public void onServiceError(SdlPacket packet, SessionType sessionType, int sessionID, String error) { - if (serviceListeners != null && serviceListeners.containsKey(sessionType)) { - CopyOnWriteArrayList listeners = serviceListeners.get(sessionType); - for (ISdlServiceListener listener : listeners) { - listener.onServiceError(this, sessionType, "End " + sessionType.toString() + " Service NACK'ed"); - } - } - } - -} \ No newline at end of file diff --git a/javaSE/src/main/java/com/smartdevicelink/managers/SdlManager.java b/javaSE/src/main/java/com/smartdevicelink/managers/SdlManager.java deleted file mode 100644 index 4dae813f6..000000000 --- a/javaSE/src/main/java/com/smartdevicelink/managers/SdlManager.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (c) 2019 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. - */ - -package com.smartdevicelink.managers; - -import androidx.annotation.NonNull; -import com.smartdevicelink.util.Log; - -import com.smartdevicelink.managers.file.FileManager; -import com.smartdevicelink.managers.permission.PermissionManager; -import com.smartdevicelink.managers.screen.ScreenManager; -import com.smartdevicelink.proxy.rpc.enums.SdlDisconnectedReason; -import com.smartdevicelink.transport.enums.TransportType; -import com.smartdevicelink.util.DebugTool; - -/** - * SDLManager
- *

- * This is the main point of contact between an application and SDL
- *

- * It is broken down to these areas:
- *

- * 1. SDLManagerBuilder
- * 2. ISdl Interface along with its overridden methods - This can be passed into attached managers
- * 3. Sending Requests
- * 4. Helper methods - */ -public class SdlManager extends BaseSdlManager { - - /** - * Starts up a SdlManager, and calls provided callback called once all BaseSubManagers are done setting up - */ - @Override - public void start() { - Runtime.getRuntime().addShutdownHook(new Thread() { - @Override - public void run() { - dispose(); - } - }); - - DebugTool.logInfo(TAG, "start"); - if (lifecycleManager == null) { - if (transport != null && (transport.getTransportType().equals(TransportType.WEB_SOCKET_SERVER) || transport.getTransportType().equals(TransportType.CUSTOM))) { - super.start(); - lifecycleManager.start(); - } else { - throw new RuntimeException("No transport provided"); - } - } - } - - @Override - protected void initialize() { - // Instantiate sub managers - this.permissionManager = new PermissionManager(_internalInterface); - this.fileManager = new FileManager(_internalInterface, fileManagerConfig); - this.screenManager = new ScreenManager(_internalInterface, this.fileManager); - - // Start sub managers - this.permissionManager.start(subManagerListener); - this.fileManager.start(subManagerListener); - this.screenManager.start(subManagerListener); - } - - @Override - void checkState() { - if (permissionManager != null && fileManager != null && screenManager != null) { - if (permissionManager.getState() == BaseSubManager.READY && fileManager.getState() == BaseSubManager.READY && screenManager.getState() == BaseSubManager.READY) { - DebugTool.logInfo(TAG, "Starting sdl manager, all sub managers are in ready state"); - transitionToState(BaseSubManager.READY); - handleQueuedNotifications(); - notifyDevListener(null); - onReady(); - } else if (permissionManager.getState() == BaseSubManager.ERROR && fileManager.getState() == BaseSubManager.ERROR && screenManager.getState() == BaseSubManager.ERROR) { - String info = "ERROR starting sdl manager, all sub managers are in error state"; - DebugTool.logError(TAG, info); - transitionToState(BaseSubManager.ERROR); - notifyDevListener(info); - } else if (permissionManager.getState() == BaseSubManager.SETTING_UP || fileManager.getState() == BaseSubManager.SETTING_UP || screenManager.getState() == BaseSubManager.SETTING_UP) { - DebugTool.logInfo(TAG, "SETTING UP sdl manager, some sub managers are still setting up"); - transitionToState(BaseSubManager.SETTING_UP); - // No need to notify developer here! - } else { - DebugTool.logWarning(TAG, "LIMITED starting sdl manager, some sub managers are in error or limited state and the others finished setting up"); - transitionToState(BaseSubManager.LIMITED); - handleQueuedNotifications(); - notifyDevListener(null); - onReady(); - } - } else { - // We should never be here, but somehow one of the sub-sub managers is null - String info = "ERROR one of the sdl sub managers is null"; - DebugTool.logError(TAG, info); - transitionToState(BaseSubManager.ERROR); - notifyDevListener(info); - } - } - - private void notifyDevListener(String info) { - if (managerListener != null) { - if (getState() == BaseSubManager.ERROR) { - managerListener.onError((SdlManager) this, info, null); - } else { - managerListener.onStart((SdlManager) this); - } - } - } - - @Override - void retryChangeRegistration() { - // Do nothing - } - - @Override - public void dispose() { - if (this.permissionManager != null) { - this.permissionManager.dispose(); - } - - if (this.fileManager != null) { - this.fileManager.dispose(); - } - - if (this.screenManager != null) { - this.screenManager.dispose(); - } - - if (this.lifecycleManager != null) { - this.lifecycleManager.stop(); - } - - if (managerListener != null) { - managerListener.onDestroy((SdlManager) this); - managerListener = null; - } - - transitionToState(BaseSubManager.SHUTDOWN); - } - - // BUILDER - public static class Builder extends BaseSdlManager.Builder { - /** - * Builder for the SdlManager. Parameters in the constructor are required. - * - * @param appId the app's ID - * @param appName the app's name - * @param listener a SdlManagerListener object - */ - public Builder(@NonNull final String appId, @NonNull final String appName, @NonNull final SdlManagerListener listener) { - super(appId, appName, listener); - } - } -} diff --git a/javaSE/src/main/java/com/smartdevicelink/managers/SdlManagerListener.java b/javaSE/src/main/java/com/smartdevicelink/managers/SdlManagerListener.java deleted file mode 100644 index 8118a9c93..000000000 --- a/javaSE/src/main/java/com/smartdevicelink/managers/SdlManagerListener.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2019 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. - */ -package com.smartdevicelink.managers; - -import com.smartdevicelink.managers.lifecycle.LifecycleConfigurationUpdate; -import com.smartdevicelink.proxy.rpc.enums.Language; - -public interface SdlManagerListener extends BaseSdlManagerListener { - - /** - * Called when a manager is ready for use - */ - void onStart(SdlManager manager); - - /** - * Called when the manager is destroyed - */ - void onDestroy(SdlManager manager); - - /** - * Called when the manager encounters an error - * @param info info regarding the error - * @param e the exception - */ - void onError(SdlManager manager, String info, Exception e); - - /** - * Called when the SDL manager detected a language mismatch. In case of a language mismatch the - * manager should change the apps registration by updating the lifecycle configuration to the - * specified language. If the app can support the specified language it should return an Object - * of LifecycleConfigurationUpdate, otherwise it should return null to indicate that the language - * is not supported. - * - * @param language The language of the connected head unit the manager is trying to update the configuration. - * @return An object of LifecycleConfigurationUpdate if the head unit language is supported, - * otherwise null to indicate that the language is not supported. - * @deprecated use {@link #managerShouldUpdateLifecycle(Language language, Language hmiLanguage)} instead - */ - @Deprecated - LifecycleConfigurationUpdate managerShouldUpdateLifecycle(Language language); - - /** - * Called when the SDL manager detected a language mismatch. In case of a language mismatch the - * manager should change the apps registration by updating the lifecycle configuration to the - * specified language. If the app can support the specified language it should return an Object - * of LifecycleConfigurationUpdate, otherwise it should return null to indicate that the language - * is not supported. - * - * @param language The VR+TTS language of the connected head unit the manager is trying to update the configuration. - * @param hmiLanguage The HMI display language of the connected head unit the manager is trying to update the configuration. - * @return An object of LifecycleConfigurationUpdate if the head unit language is supported, - * otherwise null to indicate that the language is not supported. - */ - LifecycleConfigurationUpdate managerShouldUpdateLifecycle(Language language, Language hmiLanguage); -} diff --git a/javaSE/src/main/java/com/smartdevicelink/managers/file/FileManager.java b/javaSE/src/main/java/com/smartdevicelink/managers/file/FileManager.java deleted file mode 100644 index 54896f273..000000000 --- a/javaSE/src/main/java/com/smartdevicelink/managers/file/FileManager.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright (c) 2019 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. - */ -package com.smartdevicelink.managers.file; - - -import androidx.annotation.NonNull; -import com.smartdevicelink.managers.file.filetypes.SdlFile; -import com.smartdevicelink.proxy.interfaces.ISdl; -import com.smartdevicelink.proxy.rpc.PutFile; -import com.smartdevicelink.util.DebugTool; -import com.smartdevicelink.util.FileUtls; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URI; - -/** - * FileManager
- * - * Note: This class must be accessed through the SdlManager. Do not instantiate it by itself.
- * - * The SDLFileManager uploads files and keeps track of all the uploaded files names during a session.
- * - * We need to add the following struct: SDLFile
- * - * It is broken down to these areas:
- * - * 1. Getters
- * 2. Deletion methods
- * 3. Uploading Files / Artwork - */ -public class FileManager extends BaseFileManager { - - @Deprecated - public FileManager(ISdl internalInterface) { - - // setup - super(internalInterface); - } - - /** - * Constructor for FileManager - * @param internalInterface an instance of the ISdl interface that can be used for common SDL operations (sendRpc, addRpcListener, etc) - * @param fileManagerConfig an instance of the FileManagerConfig gives access to artworkRetryCount and fileRetryCount to let us if those file types can be re-upload if they fail - */ - public FileManager(ISdl internalInterface, FileManagerConfig fileManagerConfig) { - // setup - super(internalInterface, fileManagerConfig); - } - - /** - * Creates and returns a PutFile request that would upload a given SdlFile - * @param file SdlFile with fileName and one of A) fileData, B) Uri, or C) resourceID set - * @return a valid PutFile request if SdlFile contained a fileName and sufficient data - */ - @Override - PutFile createPutFile(@NonNull final SdlFile file){ - PutFile putFile = new PutFile(); - if(file.getName() == null){ - throw new IllegalArgumentException("You must specify an file name in the SdlFile"); - }else{ - putFile.setSdlFileName(file.getName()); - } - - if(file.getFilePath() != null){ - //Attempt to access the file via a path - byte[] data = FileUtls.getFileData(file.getFilePath()); - if(data != null ){ - putFile.setFileData(data); - }else{ - throw new IllegalArgumentException("File at path was empty"); - } - }else if(file.getURI() != null){ - // Use URI to upload file - byte[] data = contentsOfUri(file.getURI()); - if(data != null){ - putFile.setFileData(data); - }else{ - throw new IllegalArgumentException("Uri was empty"); - } - }else if(file.getFileData() != null){ - // Use file data (raw bytes) to upload file - putFile.setFileData(file.getFileData()); - }else{ - throw new IllegalArgumentException("The SdlFile to upload does " + - "not specify its resourceId, Uri, or file data"); - } - - if(file.getType() != null){ - putFile.setFileType(file.getType()); - } - putFile.setPersistentFile(file.isPersistent()); - - return putFile; - } - - - /** - * Helper method to take Uri and turn it into byte array - * @param uri Uri for desired file - * @return Resulting byte array - */ - private byte[] contentsOfUri(URI uri){ - InputStream is = null; - try{ - is = uri.toURL().openStream(); - return contentsOfInputStream(is); - } catch (IOException e){ - DebugTool.logError(TAG, "Can't read from URI", e); - return null; - } finally { - if (is != null) { - try { - is.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - } -} diff --git a/javaSE/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlArtwork.java b/javaSE/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlArtwork.java deleted file mode 100644 index a63c3e27b..000000000 --- a/javaSE/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlArtwork.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (c) 2019 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. - */ -package com.smartdevicelink.managers.file.filetypes; - -import androidx.annotation.NonNull; -import com.smartdevicelink.proxy.rpc.Image; -import com.smartdevicelink.proxy.rpc.enums.FileType; -import com.smartdevicelink.proxy.rpc.enums.ImageType; -import com.smartdevicelink.proxy.rpc.enums.StaticIconName; -import com.smartdevicelink.util.DebugTool; - -import java.net.URI; - -/** - * A class that extends SdlFile, representing artwork (JPEG, PNG, or BMP) to be uploaded to core - */ -public class SdlArtwork extends SdlFile implements Cloneable{ - private boolean isTemplate; - private Image imageRPC; - - /** - * Creates a new instance of SdlArtwork - */ - public SdlArtwork(){} - - /** - * Creates a new instance of SdlArtwork - * @param fileName a String value representing the name that will be used to store the file in the head unit. You can pass null if you want the library to auto generate the name - * @param fileType a FileType enum value representing the type of the file - * @param filePath a String value representing the the location of the file - * @param persistentFile a boolean value that indicates if the file is meant to persist between sessions / ignition cycles - */ - public SdlArtwork(String fileName, @NonNull FileType fileType, String filePath, boolean persistentFile) { - super(fileName, fileType, filePath, persistentFile); - } - - /** - * Creates a new instance of SdlArtwork - * @param fileName a String value representing the name that will be used to store the file in the head unit. You can pass null if you want the library to auto generate the name - * @param fileType a FileType enum value representing the type of the file - * @param uri a URI value representing a file's location. Currently, it only supports local files - * @param persistentFile a boolean value that indicates if the file is meant to persist between sessions / ignition cycles - */ - public SdlArtwork(String fileName, @NonNull FileType fileType, URI uri, boolean persistentFile) { - super(fileName, fileType, uri, persistentFile); - } - - /** - * Creates a new instance of SdlArtwork - * @param fileName a String value representing the name that will be used to store the file in the head unit. You can pass null if you want the library to auto generate the name - * @param fileType a FileType enum value representing the type of the file - * @param data a byte array representing the data of the file - * @param persistentFile a boolean value that indicates if the file is meant to persist between sessions / ignition cycles - */ - public SdlArtwork(String fileName, @NonNull FileType fileType, byte[] data, boolean persistentFile) { - super(fileName, fileType, data, persistentFile); - } - - /** - * Creates a new instance of SdlArtwork - * @param staticIconName a StaticIconName enum value representing the name of a static file that comes pre-shipped with the head unit - */ - public SdlArtwork(@NonNull StaticIconName staticIconName) { - super(staticIconName); - } - - /** - * Sets whether this SdlArtwork is a template image whose coloring should be decided by the HMI - * @param isTemplate boolean that tells whether this SdlArtwork is a template image - */ - public void setTemplateImage(boolean isTemplate){ - this.isTemplate = isTemplate; - } - - /** - * Gets whether this SdlArtwork is a template image whose coloring should be decided by the HMI - * @return boolean that tells whether this SdlArtwork is a template image - */ - public boolean isTemplateImage(){ - return isTemplate; - } - - - @Override - public void setType(FileType fileType) { - if(fileType == null || fileType.equals(FileType.GRAPHIC_JPEG) || fileType.equals(FileType.GRAPHIC_PNG) - || fileType.equals(FileType.GRAPHIC_BMP)){ - super.setType(fileType); - }else{ - throw new IllegalArgumentException("Only JPEG, PNG, and BMP image types are supported."); - } - } - - /** - * Gets the Image RPC representing this artwork. Generally for use internally, you should instead pass an artwork to a Screen Manager method - * @return The Image RPC representing this artwork. - */ - public Image getImageRPC() { - if (imageRPC == null) { - imageRPC = createImageRPC(); - } - return imageRPC; - } - - private Image createImageRPC(){ - Image image; - if (isStaticIcon()) { - image = new Image(getName(), ImageType.STATIC); - image.setIsTemplate(true); - } else { - image = new Image(getName(), ImageType.DYNAMIC); - image.setIsTemplate(isTemplate); - } - return image; - } - - /** - * Creates a deep copy of the object - * @return deep copy of the object - */ - @Override - public SdlArtwork clone() { - try{ - SdlArtwork artwork = (SdlArtwork) super.clone(); - if(artwork != null){ - artwork.imageRPC = artwork.createImageRPC(); - } - return artwork; - } catch (CloneNotSupportedException e) { - if(DebugTool.isDebugEnabled()){ - throw new RuntimeException("Clone not supported by super class"); - } - } - return null; - } -} \ No newline at end of file diff --git a/javaSE/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlFile.java b/javaSE/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlFile.java deleted file mode 100644 index bb1c170d4..000000000 --- a/javaSE/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlFile.java +++ /dev/null @@ -1,342 +0,0 @@ -/* - * Copyright (c) 2019 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. - */ -package com.smartdevicelink.managers.file.filetypes; - -import androidx.annotation.NonNull; - -import com.smartdevicelink.proxy.rpc.enums.FileType; -import com.smartdevicelink.proxy.rpc.enums.StaticIconName; - -import java.net.URI; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; - -/** - * A class representing data to be uploaded to core - */ -public class SdlFile{ - private String fileName; - private String filePath; - private URI uri; - private byte[] fileData; - private FileType fileType; - private boolean persistentFile; - private boolean isStaticIcon; - private boolean shouldAutoGenerateName; - // Overwrite property by default is set to true in SdlFile constructors indicating that a file can be overwritten - private boolean overwrite = true; - - /** - * Creates a new instance of SdlFile - */ - public SdlFile(){} - - /** - * Creates a new instance of SdlFile - * @param fileName a String value representing the name that will be used to store the file in the head unit. You can pass null if you want the library to auto generate the name - * @param fileType a FileType enum value representing the type of the file - * @param filePath a String value representing the the location of the file - * @param persistentFile a boolean value that indicates if the file is meant to persist between sessions / ignition cycles - */ - public SdlFile(String fileName, @NonNull FileType fileType, String filePath, boolean persistentFile){ - setName(fileName); - setType(fileType); - setFilePath(filePath); - setPersistent(persistentFile); - } - - /** - * Creates a new instance of SdlFile - * @param fileName a String value representing the name that will be used to store the file in the head unit. You can pass null if you want the library to auto generate the name - * @param fileType a FileType enum value representing the type of the file - * @param uri a URI value representing a file's location. Currently, it only supports local files - * @param persistentFile a boolean value that indicates if the file is meant to persist between sessions / ignition cycles - */ - public SdlFile(String fileName, @NonNull FileType fileType, URI uri, boolean persistentFile){ - setName(fileName); - setType(fileType); - setURI(uri); - setPersistent(persistentFile); - } - - /** - * Creates a new instance of SdlFile - * @param fileName a String value representing the name that will be used to store the file in the head unit. You can pass null if you want the library to auto generate the name - * @param fileType a FileType enum value representing the type of the file - * @param data a byte array representing the data of the file - * @param persistentFile a boolean value that indicates if the file is meant to persist between sessions / ignition cycles - */ - public SdlFile(String fileName, @NonNull FileType fileType, byte[] data, boolean persistentFile){ - setName(fileName); - setType(fileType); - setFileData(data); - setPersistent(persistentFile); - } - - /** - * Creates a new instance of SdlFile - * @param staticIconName a StaticIconName enum value representing the name of a static file that comes pre-shipped with the head unit - */ - public SdlFile(@NonNull StaticIconName staticIconName){ - setName(staticIconName.toString()); - setFileData(staticIconName.toString().getBytes()); - setPersistent(false); - setStaticIcon(true); - } - - /** - * Sets the name of the file - * @param fileName a String value representing the name that will be used to store the file in the head unit. You can pass null if you want the library to auto generate the name - */ - public void setName(String fileName) { - if (fileName != null) { - this.shouldAutoGenerateName = false; - this.fileName = fileName; - } else { - this.shouldAutoGenerateName = true; - if (this.getFileData() != null) { - this.fileName = generateFileNameFromData(this.getFileData()); - } else if (this.getURI() != null) { - this.fileName = generateFileNameFromUri(this.getURI()); - } else if (this.getFilePath() != null) { - this.fileName = generateFileNameFromFilePath(this.getFilePath()); - } - } - } - - /** - * Gets the name of the file - * @return a String value representing the name that will be used to store the file in the head unit - */ - public String getName(){ - return fileName; - } - - /** - * Sets the location of the file - * @param filePath a String value representing the the location of the file - */ - public void setFilePath(String filePath){ - this.filePath = filePath; - if (shouldAutoGenerateName && filePath != null) { - this.fileName = generateFileNameFromFilePath(filePath); - } - } - - /** - * Gets the location of the file - * @return - */ - public String getFilePath(){ - return this.filePath; - } - - /** - * Sets the uri of the file - * @param uri a URI value representing a file's location. Currently, it only supports local files - */ - public void setURI(URI uri){ - this.uri = uri; - if (shouldAutoGenerateName && uri != null) { - this.fileName = generateFileNameFromUri(uri); - } - } - - /** - * Gets the uri of the file - * @return a URI value representing a file's location. Currently, it only supports local files - */ - public URI getURI(){ - return uri; - } - - /** - * Sets the byte array that represents the content of the file - * @param data a byte array representing the data of the file - */ - public void setFileData(byte[] data){ - this.fileData = data; - if (shouldAutoGenerateName && data != null) { - this.fileName = generateFileNameFromData(data); - } - } - - /** - * Gets the byte array that represents the content of the file - * @return a byte array representing the data of the file - */ - public byte[] getFileData(){ - return fileData; - } - - /** - * Sets the type of the file - * @param fileType a FileType enum value representing the type of the file - */ - public void setType(@NonNull FileType fileType){ - this.fileType = fileType; - } - - /** - * Gets the type of the file - * @return a FileType enum value representing the type of the file - */ - public FileType getType(){ - return fileType; - } - - /** - * Sets whether the file should persist between sessions / ignition cycles - * @param persistentFile a boolean value that indicates if the file is meant to persist between sessions / ignition cycles - */ - public void setPersistent(boolean persistentFile){ - this.persistentFile = persistentFile; - } - - /** - * Gets whether the file should persist between sessions / ignition cycles - * @return a boolean value that indicates if the file is meant to persist between sessions / ignition cycles - */ - public boolean isPersistent(){ - return this.persistentFile; - } - - /** - * Sets the the name of the static file. Static files comes pre-shipped with the head unit - * @param staticIcon a StaticIconName enum value representing the name of a static file that comes pre-shipped with the head unit - */ - public void setStaticIcon(boolean staticIcon) { - isStaticIcon = staticIcon; - } - - /** - * Gets the the name of the static file. Static files comes pre-shipped with the head unit - * @return a StaticIconName enum value representing the name of a static file that comes pre-shipped with the head unit - */ - public boolean isStaticIcon() { - return isStaticIcon; - } - - /** - * Gets the overwrite property for an SdlFile by default its set to true - * @return a boolean value that indicates if a file can be overwritten. - */ - public boolean getOverwrite() { - return overwrite; - } - - /** - * Sets the overwrite property for an SdlFile by default its set to true - * @param overwrite a boolean value that indicates if a file can be overwritten - */ - public void setOverwrite(boolean overwrite) { - this.overwrite = overwrite; - } - - /** - * Generates a file name from data by hashing the data and returning the last 16 chars - * @param data a byte array representing the data of the file - * @return a String value representing the name that will be used to store the file in the head unit - */ - private String generateFileNameFromData(@NonNull byte[] data) { - String result; - MessageDigest messageDigest; - try { - messageDigest = MessageDigest.getInstance("md5"); - } catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - return null; - } - byte[] hash = new byte[0]; - if (messageDigest != null) { - hash = messageDigest.digest(data); - } - StringBuilder stringBuilder = new StringBuilder(2 * hash.length); - for (byte b : hash) { - stringBuilder.append(String.format("%02x", b & 0xff)); - } - String hashString = stringBuilder.toString(); - result = hashString.substring(hashString.length() - 16); - return result; - } - - /** - * Generates a file name from filePath by hashing the filePath and returning the last 16 chars - * @param filePath a String value representing the the location of the file - * @return a String value representing the name that will be used to store the file in the head unit - */ - private String generateFileNameFromFilePath(String filePath) { - return generateFileNameFromData(filePath.getBytes()); - } - - /** - * Generates a file name from uri by hashing the uri string and returning the last 16 chars - * @param uri a URI value representing a file's location - * @return a String value representing the name that will be used to store the file in the head unit - */ - private String generateFileNameFromUri(@NonNull URI uri) { - return generateFileNameFromData(uri.toString().getBytes()); - } - - /** - * Used to compile hashcode for SdlFile for use to compare in equals method - * @return Custom hashcode of SdlFile variables - */ - @Override - public int hashCode() { - int result = 1; - result += ((getName() == null) ? 0 : Integer.rotateLeft(getName().hashCode(), 1)); - result += ((getURI() == null) ? 0 : Integer.rotateLeft(getURI().hashCode(), 2)); - result += ((getFilePath() == null) ? 0 : Integer.rotateLeft(getFilePath().hashCode(), 3)); - result += ((getFileData() == null) ? 0 : Integer.rotateLeft(getFileData().hashCode(), 4)); - result += ((getType() == null) ? 0 : Integer.rotateLeft(getType().hashCode(), 5)); - result += Integer.rotateLeft(Boolean.valueOf(isStaticIcon()).hashCode(), 6); - result += Integer.rotateLeft(Boolean.valueOf(isPersistent()).hashCode(), 7); - return result; - } - - /** - * Uses our custom hashCode for SdlFile objects - * @param o - The object to compare - * @return boolean of whether the objects are the same or not - */ - @Override - public boolean equals(Object o) { - if (o == null) return false; - // if this is the same memory address, it's the same - if (this == o) return true; - // if this is not an instance of SdlFile, not the same - if (!(o instanceof SdlFile)) return false; - // return comparison - return hashCode() == o.hashCode(); - } -} diff --git a/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/EncryptionLifecycleManager.java b/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/EncryptionLifecycleManager.java deleted file mode 100644 index eda411dc5..000000000 --- a/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/EncryptionLifecycleManager.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2019 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. - */ - -package com.smartdevicelink.managers.lifecycle; - -import androidx.annotation.NonNull; - -import com.smartdevicelink.managers.ServiceEncryptionListener; -import com.smartdevicelink.proxy.interfaces.ISdl; - -class EncryptionLifecycleManager extends BaseEncryptionLifecycleManager { - - EncryptionLifecycleManager(@NonNull ISdl internalInterface, ServiceEncryptionListener listener) { - super(internalInterface, listener); - } -} diff --git a/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java b/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java deleted file mode 100644 index b7167b81c..000000000 --- a/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2019 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. - */ - -package com.smartdevicelink.managers.lifecycle; - -import androidx.annotation.RestrictTo; - -import com.smartdevicelink.SdlConnection.SdlSession; -import com.smartdevicelink.exception.SdlException; -import com.smartdevicelink.proxy.rpc.enums.SdlDisconnectedReason; -import com.smartdevicelink.transport.BaseTransportConfig; - -/** - * The lifecycle manager creates a central point for all SDL session logic to converge. It should only be used by - * the library itself. Usage outside the library is not permitted and will not be protected for in the future. - */ -@RestrictTo(RestrictTo.Scope.LIBRARY) -public class LifecycleManager extends BaseLifecycleManager { - public LifecycleManager(AppConfig appConfig, BaseTransportConfig config, LifecycleListener listener) { - super(appConfig, config, listener); - } - - @Override - void initialize() { - super.initialize(); - this.session = new SdlSession(this.sdlSessionListener, _transportConfig); - } - - @Override - void cycle(SdlDisconnectedReason disconnectedReason) { - clean(); - if (session != null) { - try { - session.startSession(); - } catch (SdlException e) { - e.printStackTrace(); - } - } - } - - @Override - void onTransportDisconnected(String info, boolean availablePrimary, BaseTransportConfig transportConfig) { - super.onTransportDisconnected(info, availablePrimary, transportConfig); - if (!availablePrimary) { - onClose(info, null, null); - } - } -} diff --git a/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/SystemCapabilityManager.java b/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/SystemCapabilityManager.java deleted file mode 100644 index e4e635883..000000000 --- a/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/SystemCapabilityManager.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2020 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. - */ -package com.smartdevicelink.managers.lifecycle; - -import com.smartdevicelink.proxy.interfaces.ISdl; - -/** - * SystemCapabilityManager
- * - * Note: This class must be accessed through the SdlManager. Do not instantiate it by itself.
- */ -public class SystemCapabilityManager extends BaseSystemCapabilityManager { - SystemCapabilityManager(ISdl callback) { - super(callback); - } -} diff --git a/javaSE/src/main/java/com/smartdevicelink/managers/permission/PermissionManager.java b/javaSE/src/main/java/com/smartdevicelink/managers/permission/PermissionManager.java deleted file mode 100644 index 2918e0161..000000000 --- a/javaSE/src/main/java/com/smartdevicelink/managers/permission/PermissionManager.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2019 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. - */ -package com.smartdevicelink.managers.permission; - -import androidx.annotation.NonNull; -import com.smartdevicelink.proxy.interfaces.ISdl; - -/** - PermissionManager gives the developer information about what permissions are permitted in specific HMI level - and helps developers setup listeners to be called when specific permissions become allowed.
- - This should be used through the {@link com.smartdevicelink.managers.SdlManager} and not be instantiated by itself -**/ - - public class PermissionManager extends BasePermissionManager{ - - - /** - * Creates a new instance of the PermissionManager - * - * @param internalInterface an instance of the FileManager so that button graphics can be sent - */ - public PermissionManager(@NonNull ISdl internalInterface) { - super(internalInterface); - } -} diff --git a/javaSE/src/main/java/com/smartdevicelink/managers/screen/ScreenManager.java b/javaSE/src/main/java/com/smartdevicelink/managers/screen/ScreenManager.java deleted file mode 100644 index 38e17d0dc..000000000 --- a/javaSE/src/main/java/com/smartdevicelink/managers/screen/ScreenManager.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2019 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. - */ -package com.smartdevicelink.managers.screen; - -import androidx.annotation.NonNull; -import com.smartdevicelink.managers.file.FileManager; -import com.smartdevicelink.proxy.interfaces.ISdl; - -/** - * ScreenManager
- * - * Note: This class must be accessed through the SdlManager. Do not instantiate it by itself.
-*/ -public class ScreenManager extends BaseScreenManager { - - public ScreenManager(@NonNull ISdl internalInterface, @NonNull FileManager fileManager) { - super(internalInterface, fileManager); - } -} diff --git a/javaSE/src/main/java/com/smartdevicelink/managers/screen/SoftButtonManager.java b/javaSE/src/main/java/com/smartdevicelink/managers/screen/SoftButtonManager.java deleted file mode 100644 index 0b95d1aa5..000000000 --- a/javaSE/src/main/java/com/smartdevicelink/managers/screen/SoftButtonManager.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2019 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. - */ -package com.smartdevicelink.managers.screen; - -import androidx.annotation.NonNull; -import com.smartdevicelink.managers.file.FileManager; -import com.smartdevicelink.proxy.interfaces.ISdl; - -/** - * SoftButtonManager
- * SoftButtonManager gives the developer the ability to control how soft buttons are displayed on the head unit.
- * Note: This class must be accessed through the SdlManager->ScreenManager. Do not instantiate it by itself.
- */ -class SoftButtonManager extends BaseSoftButtonManager { - - /** - * Creates a new instance of the SoftButtonManager - * - * @param internalInterface an instance of the ISdl interface that can be used for common SDL operations (sendRpc, addRpcListener, etc) - * @param fileManager an instance of the FileManager so that button graphics can be sent - */ - SoftButtonManager(@NonNull ISdl internalInterface, @NonNull FileManager fileManager) { - super(internalInterface, fileManager); - } -} diff --git a/javaSE/src/main/java/com/smartdevicelink/managers/screen/SubscribeButtonManager.java b/javaSE/src/main/java/com/smartdevicelink/managers/screen/SubscribeButtonManager.java deleted file mode 100644 index 49d41d495..000000000 --- a/javaSE/src/main/java/com/smartdevicelink/managers/screen/SubscribeButtonManager.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.smartdevicelink.managers.screen; - -import androidx.annotation.NonNull; -import com.smartdevicelink.proxy.interfaces.ISdl; - -public class SubscribeButtonManager extends BaseSubscribeButtonManager { - - public SubscribeButtonManager(@NonNull ISdl internalInterface) { - super(internalInterface); - } -} diff --git a/javaSE/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicManager.java b/javaSE/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicManager.java deleted file mode 100644 index b84734a52..000000000 --- a/javaSE/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicManager.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2019 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. - */ -package com.smartdevicelink.managers.screen; - -import androidx.annotation.NonNull; -import com.smartdevicelink.managers.file.FileManager; -import com.smartdevicelink.managers.file.filetypes.SdlArtwork; -import com.smartdevicelink.proxy.interfaces.ISdl; -import com.smartdevicelink.proxy.rpc.enums.FileType; - -/** - * TextAndGraphicManager
- * - * Note: This class must be accessed through the SdlManager. Do not instantiate it by itself.
- * - */ -class TextAndGraphicManager extends BaseTextAndGraphicManager { - - TextAndGraphicManager(@NonNull ISdl internalInterface, @NonNull FileManager fileManager, @NonNull SoftButtonManager softButtonManager) { - super(internalInterface, fileManager, softButtonManager); - } - - @Override - SdlArtwork getBlankArtwork(){ - if (blankArtwork == null){ - blankArtwork = new SdlArtwork(); - blankArtwork.setType(FileType.GRAPHIC_PNG); - blankArtwork.setName("blankArtwork"); - blankArtwork.setFileData(new byte[50]); - } - return blankArtwork; - } -} diff --git a/javaSE/src/main/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSetManager.java b/javaSE/src/main/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSetManager.java deleted file mode 100644 index 804054373..000000000 --- a/javaSE/src/main/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSetManager.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2019 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. - */ - -package com.smartdevicelink.managers.screen.choiceset; - -import androidx.annotation.NonNull; -import com.smartdevicelink.managers.file.FileManager; -import com.smartdevicelink.proxy.interfaces.ISdl; - -/** - * ChoiceSetManager
- * ChoiceSetManager gives the developer the ability to control how soft choice sets are displayed on the head unit.
- * Note: This class must be accessed through the SdlManager->ScreenManager. Do not instantiate it by itself.
- */ -public class ChoiceSetManager extends BaseChoiceSetManager { - - /** - * Creates a new instance of the ChoiceSetManager - * - * @param internalInterface - */ - public ChoiceSetManager(@NonNull ISdl internalInterface, @NonNull FileManager fileManager) { - super(internalInterface, fileManager); - } -} diff --git a/javaSE/src/main/java/com/smartdevicelink/managers/screen/menu/MenuManager.java b/javaSE/src/main/java/com/smartdevicelink/managers/screen/menu/MenuManager.java deleted file mode 100644 index 4a28a2792..000000000 --- a/javaSE/src/main/java/com/smartdevicelink/managers/screen/menu/MenuManager.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2019 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. - */ - -package com.smartdevicelink.managers.screen.menu; - -import com.smartdevicelink.managers.file.FileManager; -import com.smartdevicelink.proxy.interfaces.ISdl; - -/** - * MenuManager
- * - * Note: This class must be accessed through the ScreenManager via the SdlManager. Do not instantiate it by itself.
- * - * The MenuManager takes MenuCell objects and creates and sends all necessary RPCs to build out a menu - */ -public class MenuManager extends BaseMenuManager { - - public MenuManager(ISdl internalInterface, FileManager fileManager) { - // setup - super(internalInterface, fileManager); - } - -} diff --git a/javaSE/src/main/java/com/smartdevicelink/managers/screen/menu/VoiceCommandManager.java b/javaSE/src/main/java/com/smartdevicelink/managers/screen/menu/VoiceCommandManager.java deleted file mode 100644 index a892d3a2c..000000000 --- a/javaSE/src/main/java/com/smartdevicelink/managers/screen/menu/VoiceCommandManager.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2019 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. - */ - -package com.smartdevicelink.managers.screen.menu; - -import com.smartdevicelink.proxy.interfaces.ISdl; - -/** - * VoiceCommandManager
- * - * Note: This class must be accessed through the ScreenManager via the SdlManager. Do not instantiate it by itself.
- * - * The VoiceCommandManager takes a List of VoiceCommand objects and sets them on the Head unit for you. - */ -public class VoiceCommandManager extends BaseVoiceCommandManager { - - public VoiceCommandManager(ISdl internalInterface) { - // setup - super(internalInterface); - } - -} diff --git a/javaSE/src/main/java/com/smartdevicelink/protocol/SdlPacket.java b/javaSE/src/main/java/com/smartdevicelink/protocol/SdlPacket.java deleted file mode 100644 index 4f37da493..000000000 --- a/javaSE/src/main/java/com/smartdevicelink/protocol/SdlPacket.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ -package com.smartdevicelink.protocol; - - -public class SdlPacket extends BaseSdlPacket { - - public SdlPacket(int version, boolean encryption, int frameType, - int serviceType, int frameInfo, int sessionId, - int dataSize, int messageId, byte[] payload) { - super(version, encryption, frameType, serviceType, frameInfo, sessionId, dataSize, messageId, payload); - } - - public SdlPacket(int version, boolean encryption, int frameType, - int serviceType, int frameInfo, int sessionId, - int dataSize, int messageId, byte[] payload, int offset, int bytesToWrite) { - super(version, encryption, frameType, serviceType, frameInfo, sessionId, dataSize, messageId, payload, offset, bytesToWrite); - } - - protected SdlPacket() { - super(); - } - - protected SdlPacket(BaseSdlPacket packet) { - super(packet); - } -} diff --git a/javaSE/src/main/java/com/smartdevicelink/protocol/SdlProtocol.java b/javaSE/src/main/java/com/smartdevicelink/protocol/SdlProtocol.java deleted file mode 100644 index 67ea25cc1..000000000 --- a/javaSE/src/main/java/com/smartdevicelink/protocol/SdlProtocol.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2018 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. - */ - -package com.smartdevicelink.protocol; - - -import com.smartdevicelink.transport.BaseTransportConfig; -import com.smartdevicelink.transport.TransportManager; - - -@SuppressWarnings("WeakerAccess") -public class SdlProtocol extends SdlProtocolBase { - private static final String TAG ="SdlProtocol"; - - public SdlProtocol( ISdlProtocol iSdlProtocol, BaseTransportConfig config) { - super(iSdlProtocol, config); - this.setTransportManager(new TransportManager(config, transportEventListener)); - } - - - -} diff --git a/javaSE/src/main/java/com/smartdevicelink/security/SdlSecurityBase.java b/javaSE/src/main/java/com/smartdevicelink/security/SdlSecurityBase.java deleted file mode 100644 index f65f98720..000000000 --- a/javaSE/src/main/java/com/smartdevicelink/security/SdlSecurityBase.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ -package com.smartdevicelink.security; - -public abstract class SdlSecurityBase extends AbstractSdlSecurityBase { - -} diff --git a/javaSE/src/main/java/com/smartdevicelink/trace/SdlTrace.java b/javaSE/src/main/java/com/smartdevicelink/trace/SdlTrace.java deleted file mode 100644 index 482b4a846..000000000 --- a/javaSE/src/main/java/com/smartdevicelink/trace/SdlTrace.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ -package com.smartdevicelink.trace; - - -/* This class handles the global TraceSettings as requested by the users either through the combination of the following - 1. System defaults - 2. Application XML config - 3. Programmatic requests from application itself - - It is manifested in the ... tags - */ - -public class SdlTrace extends SdlTraceBase{ - private static String getPid(){ - //Default implementation is not able to get this information - return "UNKNOWN"; - } -} // end-class \ No newline at end of file diff --git a/javaSE/src/main/java/com/smartdevicelink/transport/CustomTransport.java b/javaSE/src/main/java/com/smartdevicelink/transport/CustomTransport.java deleted file mode 100644 index ad02f96d2..000000000 --- a/javaSE/src/main/java/com/smartdevicelink/transport/CustomTransport.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright (c) 2019 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. - */ - -package com.smartdevicelink.transport; - -import com.smartdevicelink.protocol.SdlPacket; -import com.smartdevicelink.transport.enums.TransportType; -import com.smartdevicelink.transport.utl.TransportRecord; -import com.smartdevicelink.util.DebugTool; - -import java.nio.ByteBuffer; - -public abstract class CustomTransport implements TransportInterface{ - private static final String TAG = "CustomTransport"; - - final TransportRecord transportRecord; - final SdlPsm psm; - TransportCallback transportCallback; - - - - public CustomTransport(String address) { - //Creates a callback for when packets - psm = new SdlPsm(); - transportRecord = new TransportRecord(TransportType.CUSTOM,address); - } - - public TransportRecord getTransportRecord(){ - return this.transportRecord; - } - - - /** - * Call this method when reading a byte array off the transport - * @param bytes the bytes read off the transport - */ - public synchronized void onByteArrayReceived (byte[] bytes, int offset, int length) { - - if(bytes != null && bytes.length > 0){ - boolean stateProgress; - for(int i = 0; i < length; i++){ - stateProgress = psm.handleByte(bytes[i]); - if (!stateProgress) {//We are trying to weed through the bad packet info until we get something - //Log.w(TAG, "Packet State Machine did not move forward from state - "+ psm.getState()+". PSM being Reset."); - psm.reset(); - } - - if (psm.getState() == SdlPsm.FINISHED_STATE) { - SdlPacket packet = psm.getFormedPacket(); - if (transportCallback != null && packet != null) { - packet.setTransportRecord(transportRecord); - transportCallback.onPacketReceived(packet); - } - //We put a trace statement in the message read so we can avoid all the extra bytes - psm.reset(); - } - } - - } - } - - /** - * Call this method when reading a ByteBuffer off the transport - * @param message the byte buffer that was read off the transport - */ - public synchronized void onByteBufferReceived (ByteBuffer message) { - if(message != null){ - boolean stateProgress; - while (message.hasRemaining()) { - stateProgress = psm.handleByte(message.get()); - if (!stateProgress) {//We are trying to weed through the bad packet info until we get something - - //Log.w(TAG, "Packet State Machine did not move forward from state - "+ psm.getState()+". PSM being Reset."); - psm.reset(); - } - - if (psm.getState() == SdlPsm.FINISHED_STATE) { - SdlPacket packet = psm.getFormedPacket(); - if (transportCallback != null && packet != null) { - packet.setTransportRecord(transportRecord); - transportCallback.onPacketReceived(packet); - } - //We put a trace statement in the message read so we can avoid all the extra bytes - psm.reset(); - } - } - - } - } - - @Override - public void start() { - if (transportCallback != null) { - transportCallback.onConnectionEstablished(); - } - } - - @Override - public void stop() { - if (transportCallback != null) { - transportCallback.onConnectionTerminated("Transport told to stop"); - } - } - - @Override - public void write(SdlPacket packet) { - byte[] bytes = packet.constructPacket(); - if(bytes != null && bytes.length > 0) { - try { - onWrite(bytes, 0, bytes.length); - } catch (Exception exc) { - DebugTool.logError(TAG, "Error attempting to write packet", exc); - } - } - } - - @Override - public void setCallback(TransportCallback transportCallback) { - this.transportCallback = transportCallback; - } - - public void onError(){ - if (transportCallback != null) { - transportCallback.onError(); - } - } - - - /** - * Integrator should write out these bytes to whatever actual transport there is. This will be called from the - * internals of the library. - * @param bytes a deconstructed packet into a byte array that needs to be written out - * @param offset in bytes - * @param length in bytes - */ - public abstract void onWrite(byte[] bytes, int offset, int length); - - - - - -} diff --git a/javaSE/src/main/java/com/smartdevicelink/transport/CustomTransportConfig.java b/javaSE/src/main/java/com/smartdevicelink/transport/CustomTransportConfig.java deleted file mode 100644 index af0613aa1..000000000 --- a/javaSE/src/main/java/com/smartdevicelink/transport/CustomTransportConfig.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2019 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. - */ - -package com.smartdevicelink.transport; - -import com.smartdevicelink.transport.enums.TransportType; - -public class CustomTransportConfig extends BaseTransportConfig { - - final CustomTransport customTransport; - - public CustomTransportConfig(CustomTransport customTransport){ - this.customTransport = customTransport; - } - - @Override - public TransportType getTransportType() { - return TransportType.CUSTOM; - } - - public TransportInterface getTransportInterface(){ - return this.customTransport; - } -} diff --git a/javaSE/src/main/java/com/smartdevicelink/transport/TransportCallback.java b/javaSE/src/main/java/com/smartdevicelink/transport/TransportCallback.java deleted file mode 100644 index 551ed9d29..000000000 --- a/javaSE/src/main/java/com/smartdevicelink/transport/TransportCallback.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ -package com.smartdevicelink.transport; - -import com.smartdevicelink.protocol.SdlPacket; - -/** - * This interface is used to receive callbacks from a transport class - */ -public interface TransportCallback { - void onConnectionEstablished(); - void onError(); - void onConnectionTerminated(String reason); - void onPacketReceived(SdlPacket packet); -} \ No newline at end of file diff --git a/javaSE/src/main/java/com/smartdevicelink/transport/TransportInterface.java b/javaSE/src/main/java/com/smartdevicelink/transport/TransportInterface.java deleted file mode 100644 index 989b2df33..000000000 --- a/javaSE/src/main/java/com/smartdevicelink/transport/TransportInterface.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2019 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. - */ - -package com.smartdevicelink.transport; - -import com.smartdevicelink.protocol.SdlPacket; -import com.smartdevicelink.transport.utl.TransportRecord; - -/** - * This interface defines the basic methods that a transport must implement - */ -public interface TransportInterface { - void start(); - void stop(); - void write(SdlPacket packet); - void setCallback(TransportCallback callback); - TransportRecord getTransportRecord(); -} \ No newline at end of file diff --git a/javaSE/src/main/java/com/smartdevicelink/transport/TransportManager.java b/javaSE/src/main/java/com/smartdevicelink/transport/TransportManager.java deleted file mode 100644 index c8a07a1cc..000000000 --- a/javaSE/src/main/java/com/smartdevicelink/transport/TransportManager.java +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Copyright (c) 2018 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. - */ - -package com.smartdevicelink.transport; - - -import com.smartdevicelink.protocol.SdlPacket; -import com.smartdevicelink.transport.enums.TransportType; -import com.smartdevicelink.transport.utl.TransportRecord; -import com.smartdevicelink.util.DebugTool; - -import java.util.Collections; -import java.util.List; - -@SuppressWarnings("unused") -public class TransportManager extends TransportManagerBase{ - private static final String TAG = "TransportManager"; - - TransportInterface transport; - - /** - * Managing transports - * List for status of all transports - * If transport is not connected. Request Router service connect to it. Get connected message - */ - - public TransportManager(BaseTransportConfig config, TransportEventListener listener){ - super(config, listener); - - //Start the new transport - switch (config.getTransportType()){ - case WEB_SOCKET_SERVER: - transport = new WebSocketServer((WebSocketServerConfig)config, new SingleTransportCallbackImpl(new TransportRecord(TransportType.WEB_SOCKET_SERVER,"127.0.0.1:"+((WebSocketServerConfig)config).port))); - break; - case CUSTOM: - transport = ((CustomTransportConfig) config).getTransportInterface(); - transport.setCallback(new SingleTransportCallbackImpl(transport.getTransportRecord())); - break; - } - - } - - @Override - public void start(){ - if(transport != null){ - transport.start(); - }else{ - System.out.print("Unable to start transport."); - } - } - - @Override - public void close(long sessionId){ - if(transport != null) { - transport.stop(); - } - } - - @Deprecated - @Override - public void resetSession(){ - - } - - /** - * Check to see if a transport is connected. - * @param transportType the transport to have its connection status returned. If `null` is - * passed in, all transports will be checked and if any are connected a - * true value will be returned. - * @param address the address associated with the transport type. If null, the first transport - * of supplied type will be used to return if connected. - * @return if a transport is connected based on included variables - */ - @Override - public boolean isConnected(TransportType transportType, String address){ - synchronized (TRANSPORT_STATUS_LOCK) { - if (transportType == null) { - return !transportStatus.isEmpty(); - } - for (TransportRecord record : transportStatus) { - if (record.getType().equals(transportType)) { - if (address != null) { - if (address.equals(record.getAddress())) { - return true; - } // Address doesn't match, move forward - } else { - //If no address is included, assume any transport of correct type is acceptable - return true; - } - } - } - return false; - } - } - /** - * Retrieve a transport record with the supplied params - * @param transportType the transport to have its connection status returned. - * @param address the address associated with the transport type. If null, the first transport - * of supplied type will be returned. - * @return the transport record for the transport type and address if supplied - */ - @Override - public TransportRecord getTransportRecord(TransportType transportType, String address){ - synchronized (TRANSPORT_STATUS_LOCK) { - if (transportType == null) { - return null; - } - for (TransportRecord record : transportStatus) { - if (record.getType().equals(transportType)) { - if (address != null) { - if (address.equals(record.getAddress())) { - return record; - } // Address doesn't match, move forward - } else { - //If no address is included, assume any transport of correct type is acceptable - return record; - } - } - } - return null; - } - } - - - @Override - public void sendPacket(SdlPacket packet){ - if(transport !=null){ - transport.write(packet); - }else { - - } - } - - class SingleTransportCallbackImpl implements TransportCallback { - - final List finalList; - final TransportRecord record; - protected SingleTransportCallbackImpl(TransportRecord transportRecord){ - record = transportRecord; - finalList = Collections.singletonList(record); - } - - @Override - public void onConnectionEstablished() { - synchronized (TRANSPORT_STATUS_LOCK){ - transportStatus.clear(); - transportStatus.addAll(finalList); - } - transportListener.onTransportConnected(finalList); - } - - @Override - public void onError() { - DebugTool.logError(TAG, "Error in the transport manager from the web socket server"); - if(transportListener != null){ - transportListener.onError(""); - } - } - - @Override - public void onConnectionTerminated(String reason) { - if(record != null){ - DebugTool.logInfo(TAG, "Transport disconnected - " + record); - }else{ - DebugTool.logInfo(TAG, "Transport disconnected"); - - } - - synchronized (TRANSPORT_STATUS_LOCK){ - TransportManager.this.transportStatus.remove(record); - //Might check connectedTransports vs transportStatus to ensure they are equal - } - //Inform the transport listener that a transport has disconnected - transportListener.onTransportDisconnected(reason, record, Collections.EMPTY_LIST); - } - - @Override - public void onPacketReceived(SdlPacket packet) { - if(packet!=null){ - transportListener.onPacketReceived(packet); - } - } - } - -} diff --git a/javaSE/src/main/java/com/smartdevicelink/transport/WebSocketServer.java b/javaSE/src/main/java/com/smartdevicelink/transport/WebSocketServer.java deleted file mode 100644 index 8f5411ce0..000000000 --- a/javaSE/src/main/java/com/smartdevicelink/transport/WebSocketServer.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright (c) 2019 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. - */ - -package com.smartdevicelink.transport; - -import com.smartdevicelink.protocol.SdlPacket; -import com.smartdevicelink.transport.enums.TransportType; -import com.smartdevicelink.transport.utl.SSLWebSocketFactoryGenerator; -import com.smartdevicelink.transport.utl.TransportRecord; -import com.smartdevicelink.util.DebugTool; -import org.java_websocket.WebSocket; -import org.java_websocket.WebSocketServerFactory; -import org.java_websocket.handshake.ClientHandshake; - -import java.net.InetSocketAddress; -import java.nio.ByteBuffer; - -public class WebSocketServer extends org.java_websocket.server.WebSocketServer implements TransportInterface{ - private static final String TAG = "WebSocketServer"; - TransportCallback callback; - WebSocketServerConfig config; - WebSocket webSocket; - SdlPsm psm; - - final TransportRecord transportRecord; - - public WebSocketServer(WebSocketServerConfig config, TransportCallback callback){ - super((new InetSocketAddress(config.port))); - - this.config = config; - this.callback = callback; - transportRecord = new TransportRecord(TransportType.WEB_SOCKET_SERVER,"127.0.0.1:" + config.port); //If changed, change in transport manager as well - //This will set the connection lost timeout to not occur. So we might ping, but not pong - this.setConnectionLostTimeout(config.connectionLostTimeout); - if(config.getSslConfig() != null){ - WebSocketServerFactory factory = SSLWebSocketFactoryGenerator.generateWebSocketServer(config.getSslConfig()); - if(factory!=null){ - this.setWebSocketFactory(factory); - }else{ - DebugTool.logError(TAG, "WebSocketServer: Unable to generate SSL Web Socket Server Factory"); - } - } - - } - - public TransportRecord getTransportRecord(){ - return this.transportRecord; - } - - @Override - public void stop(){ - try { - this.stop(500); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - @Override - public void write(SdlPacket packet){ - //DebugTool.logInfo(TAG, "Atttempt to write packet " + packet); - if(packet != null - && this.webSocket != null - && this.webSocket.isOpen()) { - this.webSocket.send(packet.constructPacket()); - } - - } - - @Override - public void setCallback(TransportCallback callback) { - - } - - @Override - public void onOpen(WebSocket webSocket, ClientHandshake clientHandshake) { - DebugTool.logInfo(TAG, "onOpen"); - this.webSocket = webSocket; - - if(callback!=null){ - callback.onConnectionEstablished(); - } - } - - @Override - public void onClose(WebSocket webSocket, int i, String s, boolean b) { - DebugTool.logInfo(TAG, "onClose"); - try{ - DebugTool.logInfo(TAG, "Closing id - " + i); - DebugTool.logInfo(TAG, "Closing string - " + s); - DebugTool.logInfo(TAG, "Closing from remote? " + b); - }catch (Exception e){ - e.printStackTrace(); - } - - if(callback!=null) { - callback.onConnectionTerminated(s); - } - } - - - @Override - public void onWebsocketCloseInitiated(WebSocket conn, int code, String reason) { - super.onWebsocketCloseInitiated(conn, code, reason); - try{ - DebugTool.logInfo(TAG, "Code - " + code + " Reason - " + reason); - }catch (Exception e){} - } - - @Override - public void onMessage(WebSocket webSocket, String s) { - DebugTool.logError(TAG, "Incorrect message type received, dropping. - String: " + s); - } - - @Override - public void onMessage(WebSocket conn, ByteBuffer message) { - super.onMessage(conn, message); - //DebugTool.logInfo(TAG, "on Message - ByteBuffer"); - byte input; - - if(message != null){ - synchronized (WebSocketServer.this) { - boolean stateProgress; - while (message.hasRemaining()) { - input = message.get(); - stateProgress = psm.handleByte(input); - if (!stateProgress) {//We are trying to weed through the bad packet info until we get something - - //DebugTool.logWarning("Packet State Machine did not move forward from state - "+ psm.getState()+". PSM being Reset."); - psm.reset(); - } - - if (psm.getState() == SdlPsm.FINISHED_STATE) { - synchronized (WebSocketServer.this) { - SdlPacket packet = psm.getFormedPacket(); - if (callback != null && packet != null) { - /// DebugTool.logInfo(TAG, "Read a packet: " + packet); - packet.setTransportRecord(transportRecord); - callback.onPacketReceived(packet); - } - } - //We put a trace statement in the message read so we can avoid all the extra bytes - psm.reset(); - } - } - } - - } - - } - - - - @Override - public void onError(WebSocket webSocket, Exception e) { - DebugTool.logError(TAG, "bad", e); - if(callback!=null) { - callback.onError(); - } - } - - @Override - public void onStart() { - DebugTool.logInfo(TAG, "onStart"); - psm = new SdlPsm(); - - } - -} diff --git a/javaSE/src/main/java/com/smartdevicelink/transport/WebSocketServerConfig.java b/javaSE/src/main/java/com/smartdevicelink/transport/WebSocketServerConfig.java deleted file mode 100644 index 6add5ae71..000000000 --- a/javaSE/src/main/java/com/smartdevicelink/transport/WebSocketServerConfig.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2019, 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. - */ -package com.smartdevicelink.transport; - -import com.smartdevicelink.transport.enums.TransportType; -import com.smartdevicelink.transport.utl.SSLConfig; - -public class WebSocketServerConfig extends BaseTransportConfig{ - - final int port, connectionLostTimeout; - SSLConfig sslConfig; - /** - * Default constructor for WebsocketConfig - * @param port the port this web socket should listen on - * @param connectionLostTimeout the timeout for a connection lost, default would be 60 seconds. If a value less than - * 0 is used, then the websocket will wait indefinitely. - */ - public WebSocketServerConfig(int port, int connectionLostTimeout){ - this.port = port; - this.shareConnection = false; - this.connectionLostTimeout = connectionLostTimeout; - } - - public SSLConfig getSslConfig() { - return sslConfig; - } - - public void setSslConfig(SSLConfig sslConfig) { - this.sslConfig = sslConfig; - } - - @Override - public TransportType getTransportType() { - return TransportType.WEB_SOCKET_SERVER; - } -} diff --git a/javaSE/src/main/java/com/smartdevicelink/transport/utl/SSLConfig.java b/javaSE/src/main/java/com/smartdevicelink/transport/utl/SSLConfig.java deleted file mode 100644 index d46e8aac6..000000000 --- a/javaSE/src/main/java/com/smartdevicelink/transport/utl/SSLConfig.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2019, 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. - */ -package com.smartdevicelink.transport.utl; - -import androidx.annotation.IntDef; -import androidx.annotation.NonNull; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.io.File; - -public class SSLConfig { - - @IntDef({JKS, PEM}) - @Retention(RetentionPolicy.SOURCE) - public @interface SSLCertificateType {} - public static final int JKS = 0; - public static final int PEM = 1; - - - final @SSLCertificateType int sslCertificateType; - String pemCertificate, privateKey, password; - String storePassword, keyPassword; - File jksFile; - - - /** - * This creates an SSLConfig using a PEM type certificate. - * @param pemCertificate string representation of a PEM file that should be used for the SSL session - * @param privateKey the private key used with the PEM file - * @param password the password used with the PEN file - */ - public SSLConfig(@NonNull String pemCertificate, @NonNull String privateKey, @NonNull String password){ - this.sslCertificateType = PEM; - this.pemCertificate = pemCertificate; - this.privateKey = privateKey; - this.password = password; - } - - - /** - * This creates an SSLConfig using a JKS file. - * @param jksFile File that contains the JKS that should be used for the SSL session - * @param storePassword the password associated with the JKS - * @param keyPassword the key password used with the JKS - */ - public SSLConfig(@NonNull File jksFile, @NonNull String storePassword, @NonNull String keyPassword){ - this.sslCertificateType = JKS; - this.jksFile = jksFile; - this.storePassword = storePassword; - this.keyPassword = keyPassword; - } - - public @SSLCertificateType int getSslCertificateType() { - return sslCertificateType; - } - - public String getPemCertificate() { - return pemCertificate; - } - - public String getPrivateKey() { - return privateKey; - } - - public String getPassword() { - return password; - } - - - public File getJksFile() { - return jksFile; - } - - public String getStorePassword() { - return storePassword; - } - - public String getKeyPassword() { - return keyPassword; - } -} diff --git a/javaSE/src/main/java/com/smartdevicelink/transport/utl/SSLWebSocketFactoryGenerator.java b/javaSE/src/main/java/com/smartdevicelink/transport/utl/SSLWebSocketFactoryGenerator.java deleted file mode 100644 index 95d0ceac2..000000000 --- a/javaSE/src/main/java/com/smartdevicelink/transport/utl/SSLWebSocketFactoryGenerator.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (c) 2019, 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. - */ -package com.smartdevicelink.transport.utl; - -import com.smartdevicelink.util.DebugTool; -import org.java_websocket.WebSocketServerFactory; -import org.java_websocket.server.DefaultSSLWebSocketServerFactory; - -import javax.net.ssl.KeyManager; -import javax.net.ssl.KeyManagerFactory; -import javax.net.ssl.SSLContext; -import javax.net.ssl.TrustManagerFactory; -import javax.xml.bind.DatatypeConverter; -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.security.KeyFactory; -import java.security.KeyStore; -import java.security.NoSuchAlgorithmException; -import java.security.cert.Certificate; -import java.security.cert.CertificateException; -import java.security.cert.CertificateFactory; -import java.security.cert.X509Certificate; -import java.security.interfaces.RSAPrivateKey; -import java.security.spec.InvalidKeySpecException; -import java.security.spec.PKCS8EncodedKeySpec; - -public class SSLWebSocketFactoryGenerator { - private static final String TAG = "SSLWebSocketFactoryGenerator"; - private static final String JAVA_KEY_STORE = "JKS"; - private static final String TLS = "TLS"; - private static final String SUNX509 = "SunX509"; - - public static WebSocketServerFactory generateWebSocketServer(SSLConfig config){ - SSLContext context = null; - switch (config.getSslCertificateType()){ - case SSLConfig.JKS: - context = getSSLContextFromJKS(config); - break; - case SSLConfig.PEM: - context = getSSLContextFromPem(config); - break; - default: - DebugTool.logError(TAG, "Unable to generateWebSocketServer. Unsupported cert type."); - return null; - } - if(context != null) { - return new DefaultSSLWebSocketServerFactory(context); - }else{ - DebugTool.logError(TAG, "SSLWebSocketFactoryGenerator: Unable to create SSL Context"); - return null; - } - } - -/* ******************************************* JKS ********************************************/ - - private static SSLContext getSSLContextFromJKS(SSLConfig config){ - - try { - KeyStore ks = KeyStore.getInstance(JAVA_KEY_STORE); - File kf = config.getJksFile();//= new File(PATHNAME + File.separator + KEYSTORE); - ks.load(new FileInputStream(kf), config.getStorePassword().toCharArray()); - - KeyManagerFactory kmf = KeyManagerFactory.getInstance(SUNX509); - kmf.init(ks, config.getKeyPassword().toCharArray()); - TrustManagerFactory tmf = TrustManagerFactory.getInstance(SUNX509); - tmf.init(ks); - - SSLContext sslContext = null; - sslContext = SSLContext.getInstance(TLS); - sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null); - return sslContext; - } - catch(Exception e){ - DebugTool.logError(TAG, "Issue creating SSLContext with JKS : " , e); - } - return null; - } - - /* ******************************************* PEM ********************************************/ - - private static SSLContext getSSLContextFromPem(SSLConfig config) { - SSLContext context; - - try { - context = SSLContext.getInstance( TLS ); - - byte[] certBytes = parseDERFromPEM( config.getPemCertificate().getBytes(), "-----BEGIN CERTIFICATE-----", "-----END CERTIFICATE-----" ); - byte[] keyBytes = parseDERFromPEM( config.getPrivateKey().getBytes(), "-----BEGIN PRIVATE KEY-----", "-----END PRIVATE KEY-----" ); - - X509Certificate cert = generateCertificateFromDER( certBytes ); - RSAPrivateKey key = generatePrivateKeyFromDER( keyBytes ); - - KeyStore keystore = KeyStore.getInstance( JAVA_KEY_STORE ); - keystore.load( null ); - keystore.setCertificateEntry( "cert-alias", cert ); - keystore.setKeyEntry( "key-alias", key, config.getPassword().toCharArray(), new Certificate[]{ cert } ); - - KeyManagerFactory kmf = KeyManagerFactory.getInstance( SUNX509 ); - kmf.init( keystore, config.getPassword().toCharArray() ); - - KeyManager[] km = kmf.getKeyManagers(); - - context.init( km, null, null ); - } catch ( Exception e ) { - context = null; - DebugTool.logError(TAG, "Issue creating SSLContext with PEM Cert : " , e); - } - return context; - } - - private static byte[] parseDERFromPEM( byte[] pem, String beginDelimiter, String endDelimiter ) { - String data = new String( pem ); - String[] tokens = data.split( beginDelimiter ); - tokens = tokens[1].split( endDelimiter ); - return DatatypeConverter.parseBase64Binary( tokens[0] ); - } - - private static RSAPrivateKey generatePrivateKeyFromDER( byte[] keyBytes ) throws InvalidKeySpecException, NoSuchAlgorithmException { - PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec( keyBytes ); - - KeyFactory factory = KeyFactory.getInstance( "RSA" ); - - return ( RSAPrivateKey ) factory.generatePrivate( spec ); - } - - private static X509Certificate generateCertificateFromDER( byte[] certBytes ) throws CertificateException { - CertificateFactory factory = CertificateFactory.getInstance( "X.509" ); - - return ( X509Certificate ) factory.generateCertificate( new ByteArrayInputStream( certBytes ) ); - } - - -} diff --git a/javaSE/src/main/java/com/smartdevicelink/transport/utl/TransportRecord.java b/javaSE/src/main/java/com/smartdevicelink/transport/utl/TransportRecord.java deleted file mode 100644 index d8155c2fd..000000000 --- a/javaSE/src/main/java/com/smartdevicelink/transport/utl/TransportRecord.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ -package com.smartdevicelink.transport.utl; - -import com.smartdevicelink.transport.enums.TransportType; - -public class TransportRecord extends BaseTransportRecord { - - public TransportRecord(TransportType transportType, String address) { - super(transportType, address); - } -} diff --git a/javaSE/src/main/java/com/smartdevicelink/util/Log.java b/javaSE/src/main/java/com/smartdevicelink/util/Log.java deleted file mode 100644 index 2de00692c..000000000 --- a/javaSE/src/main/java/com/smartdevicelink/util/Log.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.smartdevicelink.util; - -public class Log { - public static void i(String tag, String message) { - System.out.print("\r\nINFO: " + tag + " - " + message); - } - - public static void w(String tag, String message) { - System.out.print("\r\nWARN: " + tag + " - " + message); - } - - public static void e(String tag, String message, Throwable t) { - if (t != null) { - System.out.print("\r\nERROR: " + tag + " - " + message + " - " + t.getMessage()); - } else { - System.out.print("\r\nERROR: " + tag + " - " + message); - } - } -} \ No newline at end of file diff --git a/javaSE/src/main/java/org/json/JSON.java b/javaSE/src/main/java/org/json/JSON.java deleted file mode 100644 index 1b32e698d..000000000 --- a/javaSE/src/main/java/org/json/JSON.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.json; - -class JSON { - /** - * Returns the input if it is a JSON-permissible value; throws otherwise. - */ - static double checkDouble(double d) throws JSONException { - if (Double.isInfinite(d) || Double.isNaN(d)) { - throw new JSONException("Forbidden numeric value: " + d); - } - return d; - } - - static Boolean toBoolean(Object value) { - if (value instanceof Boolean) { - return (Boolean) value; - } else if (value instanceof String) { - String stringValue = (String) value; - if ("true".equalsIgnoreCase(stringValue)) { - return true; - } else if ("false".equalsIgnoreCase(stringValue)) { - return false; - } - } - return null; - } - - static Double toDouble(Object value) { - if (value instanceof Double) { - return (Double) value; - } else if (value instanceof Number) { - return ((Number) value).doubleValue(); - } else if (value instanceof String) { - try { - return Double.valueOf((String) value); - } catch (NumberFormatException ignored) { - } - } - return null; - } - - static Integer toInteger(Object value) { - if (value instanceof Integer) { - return (Integer) value; - } else if (value instanceof Number) { - return ((Number) value).intValue(); - } else if (value instanceof String) { - try { - return (int) Double.parseDouble((String) value); - } catch (NumberFormatException ignored) { - } - } - return null; - } - - static Long toLong(Object value) { - if (value instanceof Long) { - return (Long) value; - } else if (value instanceof Number) { - return ((Number) value).longValue(); - } else if (value instanceof String) { - try { - return (long) Double.parseDouble((String) value); - } catch (NumberFormatException ignored) { - } - } - return null; - } - - static String toString(Object value) { - if (value instanceof String) { - return (String) value; - } else if (value != null) { - return String.valueOf(value); - } - return null; - } - - public static JSONException typeMismatch(Object indexOrName, Object actual, - String requiredType) throws JSONException { - if (actual == null) { - throw new JSONException("Value at " + indexOrName + " is null."); - } else { - throw new JSONException("Value " + actual + " at " + indexOrName - + " of type " + actual.getClass().getName() - + " cannot be converted to " + requiredType); - } - } - - public static JSONException typeMismatch(Object actual, String requiredType) - throws JSONException { - if (actual == null) { - throw new JSONException("Value is null."); - } else { - throw new JSONException("Value " + actual - + " of type " + actual.getClass().getName() - + " cannot be converted to " + requiredType); - } - } -} diff --git a/javaSE/src/main/java/org/json/JSONArray.java b/javaSE/src/main/java/org/json/JSONArray.java deleted file mode 100644 index 996f44909..000000000 --- a/javaSE/src/main/java/org/json/JSONArray.java +++ /dev/null @@ -1,626 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.json; - -import java.lang.reflect.Array; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; - -// Note: this class was written without inspecting the non-free org.json sourcecode. - -/** - * A dense indexed sequence of values. Values may be any mix of - * {@link JSONObject JSONObjects}, other {@link JSONArray JSONArrays}, Strings, - * Booleans, Integers, Longs, Doubles, {@code null} or {@link JSONObject#NULL}. - * Values may not be {@link Double#isNaN() NaNs}, {@link Double#isInfinite() - * infinities}, or of any type not listed here. - * - *

{@code JSONArray} has the same type coercion behavior and - * optional/mandatory accessors as {@link JSONObject}. See that class' - * documentation for details. - * - *

Warning: this class represents null in two incompatible - * ways: the standard Java {@code null} reference, and the sentinel value {@link - * JSONObject#NULL}. In particular, {@code get} fails if the requested index - * holds the null reference, but succeeds if it holds {@code JSONObject.NULL}. - * - *

Instances of this class are not thread safe. Although this class is - * nonfinal, it was not designed for inheritance and should not be subclassed. - * In particular, self-use by overridable methods is not specified. See - * Effective Java Item 17, "Design and Document or inheritance or else - * prohibit it" for further information. - */ -public class JSONArray { - - private final List values; - - /** - * Creates a {@code JSONArray} with no values. - */ - public JSONArray() { - values = new ArrayList(); - } - - /** - * Creates a new {@code JSONArray} by copying all values from the given - * collection. - * - * @param copyFrom a collection whose values are of supported types. - * Unsupported values are not permitted and will yield an array in an - * inconsistent state. - */ - /* Accept a raw type for API compatibility */ - public JSONArray(Collection copyFrom) { - this(); - if (copyFrom != null) { - for (Iterator it = copyFrom.iterator(); it.hasNext();) { - put(JSONObject.wrap(it.next())); - } - } - } - - /** - * Creates a new {@code JSONArray} with values from the next array in the - * tokener. - * - * @param readFrom a tokener whose nextValue() method will yield a - * {@code JSONArray}. - * @throws JSONException if the parse fails or doesn't yield a - * {@code JSONArray}. - */ - public JSONArray(JSONTokener readFrom) throws JSONException { - /* - * Getting the parser to populate this could get tricky. Instead, just - * parse to temporary JSONArray and then steal the data from that. - */ - Object object = readFrom.nextValue(); - if (object instanceof JSONArray) { - values = ((JSONArray) object).values; - } else { - throw JSON.typeMismatch(object, "JSONArray"); - } - } - - /** - * Creates a new {@code JSONArray} with values from the JSON string. - * - * @param json a JSON-encoded string containing an array. - * @throws JSONException if the parse fails or doesn't yield a {@code - * JSONArray}. - */ - public JSONArray(String json) throws JSONException { - this(new JSONTokener(json)); - } - - /** - * Creates a new {@code JSONArray} with values from the given primitive array. - */ - public JSONArray(Object array) throws JSONException { - if (!array.getClass().isArray()) { - throw new JSONException("Not a primitive array: " + array.getClass()); - } - final int length = Array.getLength(array); - values = new ArrayList(length); - for (int i = 0; i < length; ++i) { - put(JSONObject.wrap(Array.get(array, i))); - } - } - - /** - * Returns the number of values in this array. - */ - public int length() { - return values.size(); - } - - /** - * Appends {@code value} to the end of this array. - * - * @return this array. - */ - public JSONArray put(boolean value) { - values.add(value); - return this; - } - - /** - * Appends {@code value} to the end of this array. - * - * @param value a finite value. May not be {@link Double#isNaN() NaNs} or - * {@link Double#isInfinite() infinities}. - * @return this array. - */ - public JSONArray put(double value) throws JSONException { - values.add(JSON.checkDouble(value)); - return this; - } - - /** - * Appends {@code value} to the end of this array. - * - * @return this array. - */ - public JSONArray put(int value) { - values.add(value); - return this; - } - - /** - * Appends {@code value} to the end of this array. - * - * @return this array. - */ - public JSONArray put(long value) { - values.add(value); - return this; - } - - /** - * Appends {@code value} to the end of this array. - * - * @param value a {@link JSONObject}, {@link JSONArray}, String, Boolean, - * Integer, Long, Double, {@link JSONObject#NULL}, or {@code null}. May - * not be {@link Double#isNaN() NaNs} or {@link Double#isInfinite() - * infinities}. Unsupported values are not permitted and will cause the - * array to be in an inconsistent state. - * @return this array. - */ - public JSONArray put(Object value) { - values.add(value); - return this; - } - - /** - * Same as {@link #put}, with added validity checks. - */ - void checkedPut(Object value) throws JSONException { - if (value instanceof Number) { - JSON.checkDouble(((Number) value).doubleValue()); - } - - put(value); - } - - /** - * Sets the value at {@code index} to {@code value}, null padding this array - * to the required length if necessary. If a value already exists at {@code - * index}, it will be replaced. - * - * @return this array. - */ - public JSONArray put(int index, boolean value) throws JSONException { - return put(index, (Boolean) value); - } - - /** - * Sets the value at {@code index} to {@code value}, null padding this array - * to the required length if necessary. If a value already exists at {@code - * index}, it will be replaced. - * - * @param value a finite value. May not be {@link Double#isNaN() NaNs} or - * {@link Double#isInfinite() infinities}. - * @return this array. - */ - public JSONArray put(int index, double value) throws JSONException { - return put(index, (Double) value); - } - - /** - * Sets the value at {@code index} to {@code value}, null padding this array - * to the required length if necessary. If a value already exists at {@code - * index}, it will be replaced. - * - * @return this array. - */ - public JSONArray put(int index, int value) throws JSONException { - return put(index, (Integer) value); - } - - /** - * Sets the value at {@code index} to {@code value}, null padding this array - * to the required length if necessary. If a value already exists at {@code - * index}, it will be replaced. - * - * @return this array. - */ - public JSONArray put(int index, long value) throws JSONException { - return put(index, (Long) value); - } - - /** - * Sets the value at {@code index} to {@code value}, null padding this array - * to the required length if necessary. If a value already exists at {@code - * index}, it will be replaced. - * - * @param value a {@link JSONObject}, {@link JSONArray}, String, Boolean, - * Integer, Long, Double, {@link JSONObject#NULL}, or {@code null}. May - * not be {@link Double#isNaN() NaNs} or {@link Double#isInfinite() - * infinities}. - * @return this array. - */ - public JSONArray put(int index, Object value) throws JSONException { - if (value instanceof Number) { - // deviate from the original by checking all Numbers, not just floats & doubles - JSON.checkDouble(((Number) value).doubleValue()); - } - while (values.size() <= index) { - values.add(null); - } - values.set(index, value); - return this; - } - - /** - * Returns true if this array has no value at {@code index}, or if its value - * is the {@code null} reference or {@link JSONObject#NULL}. - */ - public boolean isNull(int index) { - Object value = opt(index); - return value == null || value == JSONObject.NULL; - } - - /** - * Returns the value at {@code index}. - * - * @throws JSONException if this array has no value at {@code index}, or if - * that value is the {@code null} reference. This method returns - * normally if the value is {@code JSONObject#NULL}. - */ - public Object get(int index) throws JSONException { - try { - Object value = values.get(index); - if (value == null) { - throw new JSONException("Value at " + index + " is null."); - } - return value; - } catch (IndexOutOfBoundsException e) { - throw new JSONException("Index " + index + " out of range [0.." + values.size() + ")", e); - } - } - - /** - * Returns the value at {@code index}, or null if the array has no value - * at {@code index}. - */ - public Object opt(int index) { - if (index < 0 || index >= values.size()) { - return null; - } - return values.get(index); - } - - /** - * Removes and returns the value at {@code index}, or null if the array has no value - * at {@code index}. - */ - public Object remove(int index) { - if (index < 0 || index >= values.size()) { - return null; - } - return values.remove(index); - } - - /** - * Returns the value at {@code index} if it exists and is a boolean or can - * be coerced to a boolean. - * - * @throws JSONException if the value at {@code index} doesn't exist or - * cannot be coerced to a boolean. - */ - public boolean getBoolean(int index) throws JSONException { - Object object = get(index); - Boolean result = JSON.toBoolean(object); - if (result == null) { - throw JSON.typeMismatch(index, object, "boolean"); - } - return result; - } - - /** - * Returns the value at {@code index} if it exists and is a boolean or can - * be coerced to a boolean. Returns false otherwise. - */ - public boolean optBoolean(int index) { - return optBoolean(index, false); - } - - /** - * Returns the value at {@code index} if it exists and is a boolean or can - * be coerced to a boolean. Returns {@code fallback} otherwise. - */ - public boolean optBoolean(int index, boolean fallback) { - Object object = opt(index); - Boolean result = JSON.toBoolean(object); - return result != null ? result : fallback; - } - - /** - * Returns the value at {@code index} if it exists and is a double or can - * be coerced to a double. - * - * @throws JSONException if the value at {@code index} doesn't exist or - * cannot be coerced to a double. - */ - public double getDouble(int index) throws JSONException { - Object object = get(index); - Double result = JSON.toDouble(object); - if (result == null) { - throw JSON.typeMismatch(index, object, "double"); - } - return result; - } - - /** - * Returns the value at {@code index} if it exists and is a double or can - * be coerced to a double. Returns {@code NaN} otherwise. - */ - public double optDouble(int index) { - return optDouble(index, Double.NaN); - } - - /** - * Returns the value at {@code index} if it exists and is a double or can - * be coerced to a double. Returns {@code fallback} otherwise. - */ - public double optDouble(int index, double fallback) { - Object object = opt(index); - Double result = JSON.toDouble(object); - return result != null ? result : fallback; - } - - /** - * Returns the value at {@code index} if it exists and is an int or - * can be coerced to an int. - * - * @throws JSONException if the value at {@code index} doesn't exist or - * cannot be coerced to a int. - */ - public int getInt(int index) throws JSONException { - Object object = get(index); - Integer result = JSON.toInteger(object); - if (result == null) { - throw JSON.typeMismatch(index, object, "int"); - } - return result; - } - - /** - * Returns the value at {@code index} if it exists and is an int or - * can be coerced to an int. Returns 0 otherwise. - */ - public int optInt(int index) { - return optInt(index, 0); - } - - /** - * Returns the value at {@code index} if it exists and is an int or - * can be coerced to an int. Returns {@code fallback} otherwise. - */ - public int optInt(int index, int fallback) { - Object object = opt(index); - Integer result = JSON.toInteger(object); - return result != null ? result : fallback; - } - - /** - * Returns the value at {@code index} if it exists and is a long or - * can be coerced to a long. - * - * @throws JSONException if the value at {@code index} doesn't exist or - * cannot be coerced to a long. - */ - public long getLong(int index) throws JSONException { - Object object = get(index); - Long result = JSON.toLong(object); - if (result == null) { - throw JSON.typeMismatch(index, object, "long"); - } - return result; - } - - /** - * Returns the value at {@code index} if it exists and is a long or - * can be coerced to a long. Returns 0 otherwise. - */ - public long optLong(int index) { - return optLong(index, 0L); - } - - /** - * Returns the value at {@code index} if it exists and is a long or - * can be coerced to a long. Returns {@code fallback} otherwise. - */ - public long optLong(int index, long fallback) { - Object object = opt(index); - Long result = JSON.toLong(object); - return result != null ? result : fallback; - } - - /** - * Returns the value at {@code index} if it exists, coercing it if - * necessary. - * - * @throws JSONException if no such value exists. - */ - public String getString(int index) throws JSONException { - Object object = get(index); - String result = JSON.toString(object); - if (result == null) { - throw JSON.typeMismatch(index, object, "String"); - } - return result; - } - - /** - * Returns the value at {@code index} if it exists, coercing it if - * necessary. Returns the empty string if no such value exists. - */ - public String optString(int index) { - return optString(index, ""); - } - - /** - * Returns the value at {@code index} if it exists, coercing it if - * necessary. Returns {@code fallback} if no such value exists. - */ - public String optString(int index, String fallback) { - Object object = opt(index); - String result = JSON.toString(object); - return result != null ? result : fallback; - } - - /** - * Returns the value at {@code index} if it exists and is a {@code - * JSONArray}. - * - * @throws JSONException if the value doesn't exist or is not a {@code - * JSONArray}. - */ - public JSONArray getJSONArray(int index) throws JSONException { - Object object = get(index); - if (object instanceof JSONArray) { - return (JSONArray) object; - } else { - throw JSON.typeMismatch(index, object, "JSONArray"); - } - } - - /** - * Returns the value at {@code index} if it exists and is a {@code - * JSONArray}. Returns null otherwise. - */ - public JSONArray optJSONArray(int index) { - Object object = opt(index); - return object instanceof JSONArray ? (JSONArray) object : null; - } - - /** - * Returns the value at {@code index} if it exists and is a {@code - * JSONObject}. - * - * @throws JSONException if the value doesn't exist or is not a {@code - * JSONObject}. - */ - public JSONObject getJSONObject(int index) throws JSONException { - Object object = get(index); - if (object instanceof JSONObject) { - return (JSONObject) object; - } else { - throw JSON.typeMismatch(index, object, "JSONObject"); - } - } - - /** - * Returns the value at {@code index} if it exists and is a {@code - * JSONObject}. Returns null otherwise. - */ - public JSONObject optJSONObject(int index) { - Object object = opt(index); - return object instanceof JSONObject ? (JSONObject) object : null; - } - - /** - * Returns a new object whose values are the values in this array, and whose - * names are the values in {@code names}. Names and values are paired up by - * index from 0 through to the shorter array's length. Names that are not - * strings will be coerced to strings. This method returns null if either - * array is empty. - */ - public JSONObject toJSONObject(JSONArray names) throws JSONException { - JSONObject result = new JSONObject(); - int length = Math.min(names.length(), values.size()); - if (length == 0) { - return null; - } - for (int i = 0; i < length; i++) { - String name = JSON.toString(names.opt(i)); - result.put(name, opt(i)); - } - return result; - } - - /** - * Returns a new string by alternating this array's values with {@code - * separator}. This array's string values are quoted and have their special - * characters escaped. For example, the array containing the strings '12" - * pizza', 'taco' and 'soda' joined on '+' returns this: - *
"12\" pizza"+"taco"+"soda"
- */ - public String join(String separator) throws JSONException { - JSONStringer stringer = new JSONStringer(); - stringer.open(JSONStringer.Scope.NULL, ""); - for (int i = 0, size = values.size(); i < size; i++) { - if (i > 0) { - stringer.out.append(separator); - } - stringer.value(values.get(i)); - } - stringer.close(JSONStringer.Scope.NULL, JSONStringer.Scope.NULL, ""); - return stringer.out.toString(); - } - - /** - * Encodes this array as a compact JSON string, such as: - *
[94043,90210]
- */ - @Override public String toString() { - try { - JSONStringer stringer = new JSONStringer(); - writeTo(stringer); - return stringer.toString(); - } catch (JSONException e) { - return null; - } - } - - /** - * Encodes this array as a human readable JSON string for debugging, such - * as: - *
-     * [
-     *     94043,
-     *     90210
-     * ]
- * - * @param indentSpaces the number of spaces to indent for each level of - * nesting. - */ - public String toString(int indentSpaces) throws JSONException { - JSONStringer stringer = new JSONStringer(indentSpaces); - writeTo(stringer); - return stringer.toString(); - } - - void writeTo(JSONStringer stringer) throws JSONException { - stringer.array(); - for (Object value : values) { - stringer.value(value); - } - stringer.endArray(); - } - - @Override public boolean equals(Object o) { - return o instanceof JSONArray && ((JSONArray) o).values.equals(values); - } - - @Override public int hashCode() { - // diverge from the original, which doesn't implement hashCode - return values.hashCode(); - } -} diff --git a/javaSE/src/main/java/org/json/JSONException.java b/javaSE/src/main/java/org/json/JSONException.java deleted file mode 100644 index 05e1dddc9..000000000 --- a/javaSE/src/main/java/org/json/JSONException.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.json; - -// Note: this class was written without inspecting the non-free org.json sourcecode. - -/** - * Thrown to indicate a problem with the JSON API. Such problems include: - *
    - *
  • Attempts to parse or construct malformed documents - *
  • Use of null as a name - *
  • Use of numeric types not available to JSON, such as {@link - * Double#isNaN() NaNs} or {@link Double#isInfinite() infinities}. - *
  • Lookups using an out of range index or nonexistent name - *
  • Type mismatches on lookups - *
- * - *

Although this is a checked exception, it is rarely recoverable. Most - * callers should simply wrap this exception in an unchecked exception and - * rethrow: - *

  public JSONArray toJSONObject() {
- *     try {
- *         JSONObject result = new JSONObject();
- *         ...
- *     } catch (JSONException e) {
- *         throw new RuntimeException(e);
- *     }
- * }
- */ -public class JSONException extends Exception { - - public JSONException(String s) { - super(s); - } - - public JSONException(String message, Throwable cause) { - super(message, cause); - } - - public JSONException(Throwable cause) { - super(cause); - } - -} diff --git a/javaSE/src/main/java/org/json/JSONObject.java b/javaSE/src/main/java/org/json/JSONObject.java deleted file mode 100644 index 74ea973c2..000000000 --- a/javaSE/src/main/java/org/json/JSONObject.java +++ /dev/null @@ -1,829 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.json; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -// Note: this class was written without inspecting the non-free org.json sourcecode. - -/** - * A modifiable set of name/value mappings. Names are unique, non-null strings. - * Values may be any mix of {@link JSONObject JSONObjects}, {@link JSONArray - * JSONArrays}, Strings, Booleans, Integers, Longs, Doubles or {@link #NULL}. - * Values may not be {@code null}, {@link Double#isNaN() NaNs}, {@link - * Double#isInfinite() infinities}, or of any type not listed here. - * - *

This class can coerce values to another type when requested. - *

- * - *

This class can look up both mandatory and optional values: - *

    - *
  • Use getType() to retrieve a mandatory value. This - * fails with a {@code JSONException} if the requested name has no value - * or if the value cannot be coerced to the requested type. - *
  • Use optType() to retrieve an optional value. This - * returns a system- or user-supplied default if the requested name has no - * value or if the value cannot be coerced to the requested type. - *
- * - *

Warning: this class represents null in two incompatible - * ways: the standard Java {@code null} reference, and the sentinel value {@link - * JSONObject#NULL}. In particular, calling {@code put(name, null)} removes the - * named entry from the object but {@code put(name, JSONObject.NULL)} stores an - * entry whose value is {@code JSONObject.NULL}. - * - *

Instances of this class are not thread safe. Although this class is - * nonfinal, it was not designed for inheritance and should not be subclassed. - * In particular, self-use by overrideable methods is not specified. See - * Effective Java Item 17, "Design and Document or inheritance or else - * prohibit it" for further information. - */ -public class JSONObject { - - private static final Double NEGATIVE_ZERO = -0d; - - /** - * A sentinel value used to explicitly define a name with no value. Unlike - * {@code null}, names with this value: - *

    - *
  • show up in the {@link #names} array - *
  • show up in the {@link #keys} iterator - *
  • return {@code true} for {@link #has(String)} - *
  • do not throw on {@link #get(String)} - *
  • are included in the encoded JSON string. - *
- * - *

This value violates the general contract of {@link Object#equals} by - * returning true when compared to {@code null}. Its {@link #toString} - * method returns "null". - */ - @NonNull - public static final Object NULL = new Object() { - @Override public boolean equals(Object o) { - return o == this || o == null; // API specifies this broken equals implementation - } - // at least make the broken equals(null) consistent with Objects.hashCode(null). - @Override public int hashCode() { return Objects.hashCode(null); } - @Override public String toString() { - return "null"; - } - }; - - - private final LinkedHashMap nameValuePairs; - - /** - * Creates a {@code JSONObject} with no name/value mappings. - */ - public JSONObject() { - nameValuePairs = new LinkedHashMap(); - } - - /** - * Creates a new {@code JSONObject} by copying all name/value mappings from - * the given map. - * - * @param copyFrom a map whose keys are of type {@link String} and whose - * values are of supported types. - * @throws NullPointerException if any of the map's keys are null. - */ - /* (accept a raw type for API compatibility) */ - public JSONObject(@NonNull Map copyFrom) { - this(); - Map contentsTyped = (Map) copyFrom; - for (Map.Entry entry : contentsTyped.entrySet()) { - /* - * Deviate from the original by checking that keys are non-null and - * of the proper type. (We still defer validating the values). - */ - String key = (String) entry.getKey(); - if (key == null) { - throw new NullPointerException("key == null"); - } - nameValuePairs.put(key, wrap(entry.getValue())); - } - } - - /** - * Creates a new {@code JSONObject} with name/value mappings from the next - * object in the tokener. - * - * @param readFrom a tokener whose nextValue() method will yield a - * {@code JSONObject}. - * @throws JSONException if the parse fails or doesn't yield a - * {@code JSONObject}. - */ - public JSONObject(@NonNull JSONTokener readFrom) throws JSONException { - /* - * Getting the parser to populate this could get tricky. Instead, just - * parse to temporary JSONObject and then steal the data from that. - */ - Object object = readFrom.nextValue(); - if (object instanceof JSONObject) { - this.nameValuePairs = ((JSONObject) object).nameValuePairs; - } else { - throw JSON.typeMismatch(object, "JSONObject"); - } - } - - /** - * Creates a new {@code JSONObject} with name/value mappings from the JSON - * string. - * - * @param json a JSON-encoded string containing an object. - * @throws JSONException if the parse fails or doesn't yield a {@code - * JSONObject}. - */ - public JSONObject(@NonNull String json) throws JSONException { - this(new JSONTokener(json)); - } - - /** - * Creates a new {@code JSONObject} by copying mappings for the listed names - * from the given object. Names that aren't present in {@code copyFrom} will - * be skipped. - */ - public JSONObject(@NonNull JSONObject copyFrom, @NonNull String [] names) throws JSONException { - this(); - for (String name : names) { - Object value = copyFrom.opt(name); - if (value != null) { - nameValuePairs.put(name, value); - } - } - } - - /** - * Returns the number of name/value mappings in this object. - */ - public int length() { - return nameValuePairs.size(); - } - - /** - * Maps {@code name} to {@code value}, clobbering any existing name/value - * mapping with the same name. - * - * @return this object. - */ - @NonNull public JSONObject put(@NonNull String name, boolean value) throws JSONException { - nameValuePairs.put(checkName(name), value); - return this; - } - - /** - * Maps {@code name} to {@code value}, clobbering any existing name/value - * mapping with the same name. - * - * @param value a finite value. May not be {@link Double#isNaN() NaNs} or - * {@link Double#isInfinite() infinities}. - * @return this object. - */ - @NonNull public JSONObject put(@NonNull String name, double value) throws JSONException { - nameValuePairs.put(checkName(name), JSON.checkDouble(value)); - return this; - } - - /** - * Maps {@code name} to {@code value}, clobbering any existing name/value - * mapping with the same name. - * - * @return this object. - */ - @NonNull public JSONObject put(@NonNull String name, int value) throws JSONException { - nameValuePairs.put(checkName(name), value); - return this; - } - - /** - * Maps {@code name} to {@code value}, clobbering any existing name/value - * mapping with the same name. - * - * @return this object. - */ - @NonNull public JSONObject put(@NonNull String name, long value) throws JSONException { - nameValuePairs.put(checkName(name), value); - return this; - } - - /** - * Maps {@code name} to {@code value}, clobbering any existing name/value - * mapping with the same name. If the value is {@code null}, any existing - * mapping for {@code name} is removed. - * - * @param value a {@link JSONObject}, {@link JSONArray}, String, Boolean, - * Integer, Long, Double, {@link #NULL}, or {@code null}. May not be - * {@link Double#isNaN() NaNs} or {@link Double#isInfinite() - * infinities}. - * @return this object. - */ - @NonNull public JSONObject put(@NonNull String name, @Nullable Object value) throws JSONException { - if (value == null) { - nameValuePairs.remove(name); - return this; - } - if (value instanceof Number) { - // deviate from the original by checking all Numbers, not just floats & doubles - JSON.checkDouble(((Number) value).doubleValue()); - } - nameValuePairs.put(checkName(name), value); - return this; - } - - /** - * Equivalent to {@code put(name, value)} when both parameters are non-null; - * does nothing otherwise. - */ - @NonNull public JSONObject putOpt(@Nullable String name, @Nullable Object value) throws JSONException { - if (name == null || value == null) { - return this; - } - return put(name, value); - } - - /** - * Appends {@code value} to the array already mapped to {@code name}. If - * this object has no mapping for {@code name}, this inserts a new mapping. - * If the mapping exists but its value is not an array, the existing - * and new values are inserted in order into a new array which is itself - * mapped to {@code name}. In aggregate, this allows values to be added to a - * mapping one at a time. - * - *

Note that {@code append(String, Object)} provides better semantics. - * In particular, the mapping for {@code name} will always be a - * {@link JSONArray}. Using {@code accumulate} will result in either a - * {@link JSONArray} or a mapping whose type is the type of {@code value} - * depending on the number of calls to it. - * - * @param value a {@link JSONObject}, {@link JSONArray}, String, Boolean, - * Integer, Long, Double, {@link #NULL} or null. May not be {@link - * Double#isNaN() NaNs} or {@link Double#isInfinite() infinities}. - */ - // TODO: Change {@code append) to {@link #append} when append is - // unhidden. - @NonNull public JSONObject accumulate(@NonNull String name, @Nullable Object value) throws JSONException { - Object current = nameValuePairs.get(checkName(name)); - if (current == null) { - return put(name, value); - } - - if (current instanceof JSONArray) { - JSONArray array = (JSONArray) current; - array.checkedPut(value); - } else { - JSONArray array = new JSONArray(); - array.checkedPut(current); - array.checkedPut(value); - nameValuePairs.put(name, array); - } - return this; - } - - /** - * Appends values to the array mapped to {@code name}. A new {@link JSONArray} - * mapping for {@code name} will be inserted if no mapping exists. If the existing - * mapping for {@code name} is not a {@link JSONArray}, a {@link JSONException} - * will be thrown. - * - * @throws JSONException if {@code name} is {@code null} or if the mapping for - * {@code name} is non-null and is not a {@link JSONArray}. - * - */ - public JSONObject append(String name, Object value) throws JSONException { - Object current = nameValuePairs.get(checkName(name)); - - final JSONArray array; - if (current instanceof JSONArray) { - array = (JSONArray) current; - } else if (current == null) { - JSONArray newArray = new JSONArray(); - nameValuePairs.put(name, newArray); - array = newArray; - } else { - throw new JSONException("Key " + name + " is not a JSONArray"); - } - - array.checkedPut(value); - - return this; - } - - String checkName(String name) throws JSONException { - if (name == null) { - throw new JSONException("Names must be non-null"); - } - return name; - } - - /** - * Removes the named mapping if it exists; does nothing otherwise. - * - * @return the value previously mapped by {@code name}, or null if there was - * no such mapping. - */ - @Nullable public Object remove(@Nullable String name) { - return nameValuePairs.remove(name); - } - - /** - * Returns true if this object has no mapping for {@code name} or if it has - * a mapping whose value is {@link #NULL}. - */ - public boolean isNull(@Nullable String name) { - Object value = nameValuePairs.get(name); - return value == null || value == NULL; - } - - /** - * Returns true if this object has a mapping for {@code name}. The mapping - * may be {@link #NULL}. - */ - public boolean has(@Nullable String name) { - return nameValuePairs.containsKey(name); - } - - /** - * Returns the value mapped by {@code name}, or throws if no such mapping exists. - * - * @throws JSONException if no such mapping exists. - */ - @NonNull public Object get(@NonNull String name) throws JSONException { - Object result = nameValuePairs.get(name); - if (result == null) { - throw new JSONException("No value for " + name); - } - return result; - } - - /** - * Returns the value mapped by {@code name}, or null if no such mapping - * exists. - */ - @Nullable public Object opt(@Nullable String name) { - return nameValuePairs.get(name); - } - - /** - * Returns the value mapped by {@code name} if it exists and is a boolean or - * can be coerced to a boolean, or throws otherwise. - * - * @throws JSONException if the mapping doesn't exist or cannot be coerced - * to a boolean. - */ - public boolean getBoolean(@NonNull String name) throws JSONException { - Object object = get(name); - Boolean result = JSON.toBoolean(object); - if (result == null) { - throw JSON.typeMismatch(name, object, "boolean"); - } - return result; - } - - /** - * Returns the value mapped by {@code name} if it exists and is a boolean or - * can be coerced to a boolean, or false otherwise. - */ - public boolean optBoolean(@Nullable String name) { - return optBoolean(name, false); - } - - /** - * Returns the value mapped by {@code name} if it exists and is a boolean or - * can be coerced to a boolean, or {@code fallback} otherwise. - */ - public boolean optBoolean(@Nullable String name, boolean fallback) { - Object object = opt(name); - Boolean result = JSON.toBoolean(object); - return result != null ? result : fallback; - } - - /** - * Returns the value mapped by {@code name} if it exists and is a double or - * can be coerced to a double, or throws otherwise. - * - * @throws JSONException if the mapping doesn't exist or cannot be coerced - * to a double. - */ - public double getDouble(@NonNull String name) throws JSONException { - Object object = get(name); - Double result = JSON.toDouble(object); - if (result == null) { - throw JSON.typeMismatch(name, object, "double"); - } - return result; - } - - /** - * Returns the value mapped by {@code name} if it exists and is a double or - * can be coerced to a double, or {@code NaN} otherwise. - */ - public double optDouble(@Nullable String name) { - return optDouble(name, Double.NaN); - } - - /** - * Returns the value mapped by {@code name} if it exists and is a double or - * can be coerced to a double, or {@code fallback} otherwise. - */ - public double optDouble(@Nullable String name, double fallback) { - Object object = opt(name); - Double result = JSON.toDouble(object); - return result != null ? result : fallback; - } - - /** - * Returns the value mapped by {@code name} if it exists and is an int or - * can be coerced to an int, or throws otherwise. - * - * @throws JSONException if the mapping doesn't exist or cannot be coerced - * to an int. - */ - public int getInt(@NonNull String name) throws JSONException { - Object object = get(name); - Integer result = JSON.toInteger(object); - if (result == null) { - throw JSON.typeMismatch(name, object, "int"); - } - return result; - } - - /** - * Returns the value mapped by {@code name} if it exists and is an int or - * can be coerced to an int, or 0 otherwise. - */ - public int optInt(@Nullable String name) { - return optInt(name, 0); - } - - /** - * Returns the value mapped by {@code name} if it exists and is an int or - * can be coerced to an int, or {@code fallback} otherwise. - */ - public int optInt(@Nullable String name, int fallback) { - Object object = opt(name); - Integer result = JSON.toInteger(object); - return result != null ? result : fallback; - } - - /** - * Returns the value mapped by {@code name} if it exists and is a long or - * can be coerced to a long, or throws otherwise. - * Note that JSON represents numbers as doubles, - * so this is lossy; use strings to transfer numbers via JSON. - * - * @throws JSONException if the mapping doesn't exist or cannot be coerced - * to a long. - */ - public long getLong(@NonNull String name) throws JSONException { - Object object = get(name); - Long result = JSON.toLong(object); - if (result == null) { - throw JSON.typeMismatch(name, object, "long"); - } - return result; - } - - /** - * Returns the value mapped by {@code name} if it exists and is a long or - * can be coerced to a long, or 0 otherwise. Note that JSON represents numbers as doubles, - * so this is lossy; use strings to transfer numbers via JSON. - */ - public long optLong(@Nullable String name) { - return optLong(name, 0L); - } - - /** - * Returns the value mapped by {@code name} if it exists and is a long or - * can be coerced to a long, or {@code fallback} otherwise. Note that JSON represents - * numbers as doubles, so this is lossy; use strings to transfer - * numbers via JSON. - */ - public long optLong(@Nullable String name, long fallback) { - Object object = opt(name); - Long result = JSON.toLong(object); - return result != null ? result : fallback; - } - - /** - * Returns the value mapped by {@code name} if it exists, coercing it if - * necessary, or throws if no such mapping exists. - * - * @throws JSONException if no such mapping exists. - */ - @NonNull public String getString(@NonNull String name) throws JSONException { - Object object = get(name); - String result = JSON.toString(object); - if (result == null) { - throw JSON.typeMismatch(name, object, "String"); - } - return result; - } - - /** - * Returns the value mapped by {@code name} if it exists, coercing it if - * necessary, or the empty string if no such mapping exists. - */ - @NonNull public String optString(@Nullable String name) { - return optString(name, ""); - } - - /** - * Returns the value mapped by {@code name} if it exists, coercing it if - * necessary, or {@code fallback} if no such mapping exists. - */ - @NonNull public String optString(@Nullable String name, @NonNull String fallback) { - Object object = opt(name); - String result = JSON.toString(object); - return result != null ? result : fallback; - } - - /** - * Returns the value mapped by {@code name} if it exists and is a {@code - * JSONArray}, or throws otherwise. - * - * @throws JSONException if the mapping doesn't exist or is not a {@code - * JSONArray}. - */ - @NonNull public JSONArray getJSONArray(@NonNull String name) throws JSONException { - Object object = get(name); - if (object instanceof JSONArray) { - return (JSONArray) object; - } else { - throw JSON.typeMismatch(name, object, "JSONArray"); - } - } - - /** - * Returns the value mapped by {@code name} if it exists and is a {@code - * JSONArray}, or null otherwise. - */ - @Nullable public JSONArray optJSONArray(@Nullable String name) { - Object object = opt(name); - return object instanceof JSONArray ? (JSONArray) object : null; - } - - /** - * Returns the value mapped by {@code name} if it exists and is a {@code - * JSONObject}, or throws otherwise. - * - * @throws JSONException if the mapping doesn't exist or is not a {@code - * JSONObject}. - */ - @NonNull public JSONObject getJSONObject(@NonNull String name) throws JSONException { - Object object = get(name); - if (object instanceof JSONObject) { - return (JSONObject) object; - } else { - throw JSON.typeMismatch(name, object, "JSONObject"); - } - } - - /** - * Returns the value mapped by {@code name} if it exists and is a {@code - * JSONObject}, or null otherwise. - */ - @Nullable public JSONObject optJSONObject(@Nullable String name) { - Object object = opt(name); - return object instanceof JSONObject ? (JSONObject) object : null; - } - - /** - * Returns an array with the values corresponding to {@code names}. The - * array contains null for names that aren't mapped. This method returns - * null if {@code names} is either null or empty. - */ - @Nullable public JSONArray toJSONArray(@Nullable JSONArray names) throws JSONException { - JSONArray result = new JSONArray(); - if (names == null) { - return null; - } - int length = names.length(); - if (length == 0) { - return null; - } - for (int i = 0; i < length; i++) { - String name = JSON.toString(names.opt(i)); - result.put(opt(name)); - } - return result; - } - - /** - * Returns an iterator of the {@code String} names in this object. The - * returned iterator supports {@link Iterator#remove() remove}, which will - * remove the corresponding mapping from this object. If this object is - * modified after the iterator is returned, the iterator's behavior is - * undefined. The order of the keys is undefined. - */ - @NonNull public Iterator keys() { - return nameValuePairs.keySet().iterator(); - } - - /** - * Returns the set of {@code String} names in this object. The returned set - * is a view of the keys in this object. {@link Set#remove(Object)} will remove - * the corresponding mapping from this object and set iterator behaviour - * is undefined if this object is modified after it is returned. - * - * See {@link #keys()}. - * - */ - public Set keySet() { - return nameValuePairs.keySet(); - } - - /** - * Returns an array containing the string names in this object. This method - * returns null if this object contains no mappings. - */ - @Nullable public JSONArray names() { - return nameValuePairs.isEmpty() - ? null - : new JSONArray(new ArrayList(nameValuePairs.keySet())); - } - - /** - * Encodes this object as a compact JSON string, such as: - *

{"query":"Pizza","locations":[94043,90210]}
- */ - @Override @NonNull public String toString() { - try { - JSONStringer stringer = new JSONStringer(); - writeTo(stringer); - return stringer.toString(); - } catch (JSONException e) { - return null; - } - } - - /** - * Encodes this object as a human readable JSON string for debugging, such - * as: - *
-     * {
-     *     "query": "Pizza",
-     *     "locations": [
-     *         94043,
-     *         90210
-     *     ]
-     * }
- * - * @param indentSpaces the number of spaces to indent for each level of - * nesting. - */ - @NonNull public String toString(int indentSpaces) throws JSONException { - JSONStringer stringer = new JSONStringer(indentSpaces); - writeTo(stringer); - return stringer.toString(); - } - - - void writeTo(JSONStringer stringer) throws JSONException { - stringer.object(); - for (Map.Entry entry : nameValuePairs.entrySet()) { - stringer.key(entry.getKey()).value(entry.getValue()); - } - stringer.endObject(); - } - - /** - * Encodes the number as a JSON string. - * - * @param number a finite value. May not be {@link Double#isNaN() NaNs} or - * {@link Double#isInfinite() infinities}. - */ - @NonNull public static String numberToString(@NonNull Number number) throws JSONException { - if (number == null) { - throw new JSONException("Number must be non-null"); - } - - double doubleValue = number.doubleValue(); - JSON.checkDouble(doubleValue); - - // the original returns "-0" instead of "-0.0" for negative zero - if (number.equals(NEGATIVE_ZERO)) { - return "-0"; - } - - long longValue = number.longValue(); - if (doubleValue == (double) longValue) { - return Long.toString(longValue); - } - - return number.toString(); - } - - /** - * Encodes {@code data} as a JSON string. This applies quotes and any - * necessary character escaping. - * - * @param data the string to encode. Null will be interpreted as an empty - * string. - */ - @NonNull public static String quote(@Nullable String data) { - if (data == null) { - return "\"\""; - } - try { - JSONStringer stringer = new JSONStringer(); - stringer.open(JSONStringer.Scope.NULL, ""); - stringer.value(data); - stringer.close(JSONStringer.Scope.NULL, JSONStringer.Scope.NULL, ""); - return stringer.toString(); - } catch (JSONException e) { - throw new AssertionError(); - } - } - - /** - * Wraps the given object if necessary. - * - *

If the object is null or , returns {@link #NULL}. - * If the object is a {@code JSONArray} or {@code JSONObject}, no wrapping is necessary. - * If the object is {@code NULL}, no wrapping is necessary. - * If the object is an array or {@code Collection}, returns an equivalent {@code JSONArray}. - * If the object is a {@code Map}, returns an equivalent {@code JSONObject}. - * If the object is a primitive wrapper type or {@code String}, returns the object. - * Otherwise if the object is from a {@code java} package, returns the result of {@code toString}. - * If wrapping fails, returns null. - */ - @Nullable public static Object wrap(@Nullable Object o) { - if (o == null) { - return NULL; - } - if (o instanceof JSONArray || o instanceof JSONObject) { - return o; - } - if (o.equals(NULL)) { - return o; - } - try { - if (o instanceof Collection) { - return new JSONArray((Collection) o); - } else if (o.getClass().isArray()) { - return new JSONArray(o); - } - if (o instanceof Map) { - return new JSONObject((Map) o); - } - if (o instanceof Boolean || - o instanceof Byte || - o instanceof Character || - o instanceof Double || - o instanceof Float || - o instanceof Integer || - o instanceof Long || - o instanceof Short || - o instanceof String) { - return o; - } - if (o.getClass().getPackage().getName().startsWith("java.")) { - return o.toString(); - } - } catch (Exception ignored) { - } - return null; - } -} diff --git a/javaSE/src/main/java/org/json/JSONStringer.java b/javaSE/src/main/java/org/json/JSONStringer.java deleted file mode 100644 index dd3b2a7d8..000000000 --- a/javaSE/src/main/java/org/json/JSONStringer.java +++ /dev/null @@ -1,432 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.json; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -// Note: this class was written without inspecting the non-free org.json sourcecode. - -/** - * Implements {@link JSONObject#toString} and {@link JSONArray#toString}. Most - * application developers should use those methods directly and disregard this - * API. For example:

- * JSONObject object = ...
- * String json = object.toString();
- * - *

Stringers only encode well-formed JSON strings. In particular: - *

    - *
  • The stringer must have exactly one top-level array or object. - *
  • Lexical scopes must be balanced: every call to {@link #array} must - * have a matching call to {@link #endArray} and every call to {@link - * #object} must have a matching call to {@link #endObject}. - *
  • Arrays may not contain keys (property names). - *
  • Objects must alternate keys (property names) and values. - *
  • Values are inserted with either literal {@link #value(Object) value} - * calls, or by nesting arrays or objects. - *
- * Calls that would result in a malformed JSON string will fail with a - * {@link JSONException}. - * - *

This class provides no facility for pretty-printing (ie. indenting) - * output. To encode indented output, use {@link JSONObject#toString(int)} or - * {@link JSONArray#toString(int)}. - * - *

Some implementations of the API support at most 20 levels of nesting. - * Attempts to create more than 20 levels of nesting may fail with a {@link - * JSONException}. - * - *

Each stringer may be used to encode a single top level value. Instances of - * this class are not thread safe. Although this class is nonfinal, it was not - * designed for inheritance and should not be subclassed. In particular, - * self-use by overrideable methods is not specified. See Effective Java - * Item 17, "Design and Document or inheritance or else prohibit it" for further - * information. - */ -public class JSONStringer { - - /** The output data, containing at most one top-level array or object. */ - final StringBuilder out = new StringBuilder(); - - /** - * Lexical scoping elements within this stringer, necessary to insert the - * appropriate separator characters (ie. commas and colons) and to detect - * nesting errors. - */ - enum Scope { - - /** - * An array with no elements requires no separators or newlines before - * it is closed. - */ - EMPTY_ARRAY, - - /** - * A array with at least one value requires a comma and newline before - * the next element. - */ - NONEMPTY_ARRAY, - - /** - * An object with no keys or values requires no separators or newlines - * before it is closed. - */ - EMPTY_OBJECT, - - /** - * An object whose most recent element is a key. The next element must - * be a value. - */ - DANGLING_KEY, - - /** - * An object with at least one name/value pair requires a comma and - * newline before the next element. - */ - NONEMPTY_OBJECT, - - /** - * A special bracketless array needed by JSONStringer.join() and - * JSONObject.quote() only. Not used for JSON encoding. - */ - NULL, - } - - /** - * Unlike the original implementation, this stack isn't limited to 20 - * levels of nesting. - */ - private final List stack = new ArrayList(); - - /** - * A string containing a full set of spaces for a single level of - * indentation, or null for no pretty printing. - */ - private final String indent; - - public JSONStringer() { - indent = null; - } - - JSONStringer(int indentSpaces) { - char[] indentChars = new char[indentSpaces]; - Arrays.fill(indentChars, ' '); - indent = new String(indentChars); - } - - /** - * Begins encoding a new array. Each call to this method must be paired with - * a call to {@link #endArray}. - * - * @return this stringer. - */ - public JSONStringer array() throws JSONException { - return open(Scope.EMPTY_ARRAY, "["); - } - - /** - * Ends encoding the current array. - * - * @return this stringer. - */ - public JSONStringer endArray() throws JSONException { - return close(Scope.EMPTY_ARRAY, Scope.NONEMPTY_ARRAY, "]"); - } - - /** - * Begins encoding a new object. Each call to this method must be paired - * with a call to {@link #endObject}. - * - * @return this stringer. - */ - public JSONStringer object() throws JSONException { - return open(Scope.EMPTY_OBJECT, "{"); - } - - /** - * Ends encoding the current object. - * - * @return this stringer. - */ - public JSONStringer endObject() throws JSONException { - return close(Scope.EMPTY_OBJECT, Scope.NONEMPTY_OBJECT, "}"); - } - - /** - * Enters a new scope by appending any necessary whitespace and the given - * bracket. - */ - JSONStringer open(Scope empty, String openBracket) throws JSONException { - if (stack.isEmpty() && out.length() > 0) { - throw new JSONException("Nesting problem: multiple top-level roots"); - } - beforeValue(); - stack.add(empty); - out.append(openBracket); - return this; - } - - /** - * Closes the current scope by appending any necessary whitespace and the - * given bracket. - */ - JSONStringer close(Scope empty, Scope nonempty, String closeBracket) throws JSONException { - Scope context = peek(); - if (context != nonempty && context != empty) { - throw new JSONException("Nesting problem"); - } - - stack.remove(stack.size() - 1); - if (context == nonempty) { - newline(); - } - out.append(closeBracket); - return this; - } - - /** - * Returns the value on the top of the stack. - */ - private Scope peek() throws JSONException { - if (stack.isEmpty()) { - throw new JSONException("Nesting problem"); - } - return stack.get(stack.size() - 1); - } - - /** - * Replace the value on the top of the stack with the given value. - */ - private void replaceTop(Scope topOfStack) { - stack.set(stack.size() - 1, topOfStack); - } - - /** - * Encodes {@code value}. - * - * @param value a {@link JSONObject}, {@link JSONArray}, String, Boolean, - * Integer, Long, Double or null. May not be {@link Double#isNaN() NaNs} - * or {@link Double#isInfinite() infinities}. - * @return this stringer. - */ - public JSONStringer value(Object value) throws JSONException { - if (stack.isEmpty()) { - throw new JSONException("Nesting problem"); - } - - if (value instanceof JSONArray) { - ((JSONArray) value).writeTo(this); - return this; - - } else if (value instanceof JSONObject) { - ((JSONObject) value).writeTo(this); - return this; - } - - beforeValue(); - - if (value == null - || value instanceof Boolean - || value == JSONObject.NULL) { - out.append(value); - - } else if (value instanceof Number) { - out.append(JSONObject.numberToString((Number) value)); - - } else { - string(value.toString()); - } - - return this; - } - - /** - * Encodes {@code value} to this stringer. - * - * @return this stringer. - */ - public JSONStringer value(boolean value) throws JSONException { - if (stack.isEmpty()) { - throw new JSONException("Nesting problem"); - } - beforeValue(); - out.append(value); - return this; - } - - /** - * Encodes {@code value} to this stringer. - * - * @param value a finite value. May not be {@link Double#isNaN() NaNs} or - * {@link Double#isInfinite() infinities}. - * @return this stringer. - */ - public JSONStringer value(double value) throws JSONException { - if (stack.isEmpty()) { - throw new JSONException("Nesting problem"); - } - beforeValue(); - out.append(JSONObject.numberToString(value)); - return this; - } - - /** - * Encodes {@code value} to this stringer. - * - * @return this stringer. - */ - public JSONStringer value(long value) throws JSONException { - if (stack.isEmpty()) { - throw new JSONException("Nesting problem"); - } - beforeValue(); - out.append(value); - return this; - } - - private void string(String value) { - out.append("\""); - for (int i = 0, length = value.length(); i < length; i++) { - char c = value.charAt(i); - - /* - * From RFC 4627, "All Unicode characters may be placed within the - * quotation marks except for the characters that must be escaped: - * quotation mark, reverse solidus, and the control characters - * (U+0000 through U+001F)." - */ - switch (c) { - case '"': - case '\\': - case '/': - out.append('\\').append(c); - break; - - case '\t': - out.append("\\t"); - break; - - case '\b': - out.append("\\b"); - break; - - case '\n': - out.append("\\n"); - break; - - case '\r': - out.append("\\r"); - break; - - case '\f': - out.append("\\f"); - break; - - default: - if (c <= 0x1F) { - out.append(String.format("\\u%04x", (int) c)); - } else { - out.append(c); - } - break; - } - - } - out.append("\""); - } - - private void newline() { - if (indent == null) { - return; - } - - out.append("\n"); - for (int i = 0; i < stack.size(); i++) { - out.append(indent); - } - } - - /** - * Encodes the key (property name) to this stringer. - * - * @param name the name of the forthcoming value. May not be null. - * @return this stringer. - */ - public JSONStringer key(String name) throws JSONException { - if (name == null) { - throw new JSONException("Names must be non-null"); - } - beforeKey(); - string(name); - return this; - } - - /** - * Inserts any necessary separators and whitespace before a name. Also - * adjusts the stack to expect the key's value. - */ - private void beforeKey() throws JSONException { - Scope context = peek(); - if (context == Scope.NONEMPTY_OBJECT) { // first in object - out.append(','); - } else if (context != Scope.EMPTY_OBJECT) { // not in an object! - throw new JSONException("Nesting problem"); - } - newline(); - replaceTop(Scope.DANGLING_KEY); - } - - /** - * Inserts any necessary separators and whitespace before a literal value, - * inline array, or inline object. Also adjusts the stack to expect either a - * closing bracket or another element. - */ - private void beforeValue() throws JSONException { - if (stack.isEmpty()) { - return; - } - - Scope context = peek(); - if (context == Scope.EMPTY_ARRAY) { // first in array - replaceTop(Scope.NONEMPTY_ARRAY); - newline(); - } else if (context == Scope.NONEMPTY_ARRAY) { // another in array - out.append(','); - newline(); - } else if (context == Scope.DANGLING_KEY) { // value for key - out.append(indent == null ? ":" : ": "); - replaceTop(Scope.NONEMPTY_OBJECT); - } else if (context != Scope.NULL) { - throw new JSONException("Nesting problem"); - } - } - - /** - * Returns the encoded JSON string. - * - *

If invoked with unterminated arrays or unclosed objects, this method's - * return value is undefined. - * - *

Warning: although it contradicts the general contract - * of {@link Object#toString}, this method returns null if the stringer - * contains no data. - */ - @Override public String toString() { - return out.length() == 0 ? null : out.toString(); - } -} diff --git a/javaSE/src/main/java/org/json/JSONTokener.java b/javaSE/src/main/java/org/json/JSONTokener.java deleted file mode 100644 index 4bdd9ad37..000000000 --- a/javaSE/src/main/java/org/json/JSONTokener.java +++ /dev/null @@ -1,611 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.json; - - -// Note: this class was written without inspecting the non-free org.json sourcecode. - -/** - * Parses a JSON (RFC 4627) - * encoded string into the corresponding object. Most clients of - * this class will use only need the {@link #JSONTokener(String) constructor} - * and {@link #nextValue} method. Example usage:

- * String json = "{"
- *         + "  \"query\": \"Pizza\", "
- *         + "  \"locations\": [ 94043, 90210 ] "
- *         + "}";
- *
- * JSONObject object = (JSONObject) new JSONTokener(json).nextValue();
- * String query = object.getString("query");
- * JSONArray locations = object.getJSONArray("locations");
- * - *

For best interoperability and performance use JSON that complies with - * RFC 4627, such as that generated by {@link JSONStringer}. For legacy reasons - * this parser is lenient, so a successful parse does not indicate that the - * input string was valid JSON. All of the following syntax errors will be - * ignored: - *

    - *
  • End of line comments starting with {@code //} or {@code #} and ending - * with a newline character. - *
  • C-style comments starting with {@code /*} and ending with - * {@code *}{@code /}. Such comments may not be nested. - *
  • Strings that are unquoted or {@code 'single quoted'}. - *
  • Hexadecimal integers prefixed with {@code 0x} or {@code 0X}. - *
  • Octal integers prefixed with {@code 0}. - *
  • Array elements separated by {@code ;}. - *
  • Unnecessary array separators. These are interpreted as if null was the - * omitted value. - *
  • Key-value pairs separated by {@code =} or {@code =>}. - *
  • Key-value pairs separated by {@code ;}. - *
- * - *

Each tokener may be used to parse a single JSON string. Instances of this - * class are not thread safe. Although this class is nonfinal, it was not - * designed for inheritance and should not be subclassed. In particular, - * self-use by overrideable methods is not specified. See Effective Java - * Item 17, "Design and Document or inheritance or else prohibit it" for further - * information. - */ -public class JSONTokener { - - /** The input JSON. */ - private final String in; - - /** - * The index of the next character to be returned by {@link #next}. When - * the input is exhausted, this equals the input's length. - */ - private int pos; - - /** - * @param in JSON encoded string. Null is not permitted and will yield a - * tokener that throws {@code NullPointerExceptions} when methods are - * called. - */ - public JSONTokener(String in) { - // consume an optional byte order mark (BOM) if it exists - if (in != null && in.startsWith("\ufeff")) { - in = in.substring(1); - } - this.in = in; - } - - /** - * Returns the next value from the input. - * - * @return a {@link JSONObject}, {@link JSONArray}, String, Boolean, - * Integer, Long, Double or {@link JSONObject#NULL}. - * @throws JSONException if the input is malformed. - */ - public Object nextValue() throws JSONException { - int c = nextCleanInternal(); - switch (c) { - case -1: - throw syntaxError("End of input"); - - case '{': - return readObject(); - - case '[': - return readArray(); - - case '\'': - case '"': - return nextString((char) c); - - default: - pos--; - return readLiteral(); - } - } - - private int nextCleanInternal() throws JSONException { - while (pos < in.length()) { - int c = in.charAt(pos++); - switch (c) { - case '\t': - case ' ': - case '\n': - case '\r': - continue; - - case '/': - if (pos == in.length()) { - return c; - } - - char peek = in.charAt(pos); - switch (peek) { - case '*': - // skip a /* c-style comment */ - pos++; - int commentEnd = in.indexOf("*/", pos); - if (commentEnd == -1) { - throw syntaxError("Unterminated comment"); - } - pos = commentEnd + 2; - continue; - - case '/': - // skip a // end-of-line comment - pos++; - skipToEndOfLine(); - continue; - - default: - return c; - } - - case '#': - /* - * Skip a # hash end-of-line comment. The JSON RFC doesn't - * specify this behavior, but it's required to parse - * existing documents. See http://b/2571423. - */ - skipToEndOfLine(); - continue; - - default: - return c; - } - } - - return -1; - } - - /** - * Advances the position until after the next newline character. If the line - * is terminated by "\r\n", the '\n' must be consumed as whitespace by the - * caller. - */ - private void skipToEndOfLine() { - for (; pos < in.length(); pos++) { - char c = in.charAt(pos); - if (c == '\r' || c == '\n') { - pos++; - break; - } - } - } - - /** - * Returns the string up to but not including {@code quote}, unescaping any - * character escape sequences encountered along the way. The opening quote - * should have already been read. This consumes the closing quote, but does - * not include it in the returned string. - * - * @param quote either ' or ". - */ - public String nextString(char quote) throws JSONException { - /* - * For strings that are free of escape sequences, we can just extract - * the result as a substring of the input. But if we encounter an escape - * sequence, we need to use a StringBuilder to compose the result. - */ - StringBuilder builder = null; - - /* the index of the first character not yet appended to the builder. */ - int start = pos; - - while (pos < in.length()) { - int c = in.charAt(pos++); - if (c == quote) { - if (builder == null) { - // a new string avoids leaking memory - return new String(in.substring(start, pos - 1)); - } else { - builder.append(in, start, pos - 1); - return builder.toString(); - } - } - - if (c == '\\') { - if (pos == in.length()) { - throw syntaxError("Unterminated escape sequence"); - } - if (builder == null) { - builder = new StringBuilder(); - } - builder.append(in, start, pos - 1); - builder.append(readEscapeCharacter()); - start = pos; - } - } - - throw syntaxError("Unterminated string"); - } - - /** - * Unescapes the character identified by the character or characters that - * immediately follow a backslash. The backslash '\' should have already - * been read. This supports both unicode escapes "u000A" and two-character - * escapes "\n". - */ - private char readEscapeCharacter() throws JSONException { - char escaped = in.charAt(pos++); - switch (escaped) { - case 'u': - if (pos + 4 > in.length()) { - throw syntaxError("Unterminated escape sequence"); - } - String hex = in.substring(pos, pos + 4); - pos += 4; - try { - return (char) Integer.parseInt(hex, 16); - } catch (NumberFormatException nfe) { - throw syntaxError("Invalid escape sequence: " + hex); - } - - case 't': - return '\t'; - - case 'b': - return '\b'; - - case 'n': - return '\n'; - - case 'r': - return '\r'; - - case 'f': - return '\f'; - - case '\'': - case '"': - case '\\': - default: - return escaped; - } - } - - /** - * Reads a null, boolean, numeric or unquoted string literal value. Numeric - * values will be returned as an Integer, Long, or Double, in that order of - * preference. - */ - private Object readLiteral() throws JSONException { - String literal = nextToInternal("{}[]/\\:,=;# \t\f"); - - if (literal.length() == 0) { - throw syntaxError("Expected literal value"); - } else if ("null".equalsIgnoreCase(literal)) { - return JSONObject.NULL; - } else if ("true".equalsIgnoreCase(literal)) { - return Boolean.TRUE; - } else if ("false".equalsIgnoreCase(literal)) { - return Boolean.FALSE; - } - - /* try to parse as an integral type... */ - if (literal.indexOf('.') == -1) { - int base = 10; - String number = literal; - if (number.startsWith("0x") || number.startsWith("0X")) { - number = number.substring(2); - base = 16; - } else if (number.startsWith("0") && number.length() > 1) { - number = number.substring(1); - base = 8; - } - try { - long longValue = Long.parseLong(number, base); - if (longValue <= Integer.MAX_VALUE && longValue >= Integer.MIN_VALUE) { - return (int) longValue; - } else { - return longValue; - } - } catch (NumberFormatException e) { - /* - * This only happens for integral numbers greater than - * Long.MAX_VALUE, numbers in exponential form (5e-10) and - * unquoted strings. Fall through to try floating point. - */ - } - } - - /* ...next try to parse as a floating point... */ - try { - return Double.valueOf(literal); - } catch (NumberFormatException ignored) { - } - - /* ... finally give up. We have an unquoted string */ - return new String(literal); // a new string avoids leaking memory - } - - /** - * Returns the string up to but not including any of the given characters or - * a newline character. This does not consume the excluded character. - */ - private String nextToInternal(String excluded) { - int start = pos; - for (; pos < in.length(); pos++) { - char c = in.charAt(pos); - if (c == '\r' || c == '\n' || excluded.indexOf(c) != -1) { - return in.substring(start, pos); - } - } - return in.substring(start); - } - - /** - * Reads a sequence of key/value pairs and the trailing closing brace '}' of - * an object. The opening brace '{' should have already been read. - */ - private JSONObject readObject() throws JSONException { - JSONObject result = new JSONObject(); - - /* Peek to see if this is the empty object. */ - int first = nextCleanInternal(); - if (first == '}') { - return result; - } else if (first != -1) { - pos--; - } - - while (true) { - Object name = nextValue(); - if (!(name instanceof String)) { - if (name == null) { - throw syntaxError("Names cannot be null"); - } else { - throw syntaxError("Names must be strings, but " + name - + " is of type " + name.getClass().getName()); - } - } - - /* - * Expect the name/value separator to be either a colon ':', an - * equals sign '=', or an arrow "=>". The last two are bogus but we - * include them because that's what the original implementation did. - */ - int separator = nextCleanInternal(); - if (separator != ':' && separator != '=') { - throw syntaxError("Expected ':' after " + name); - } - if (pos < in.length() && in.charAt(pos) == '>') { - pos++; - } - - result.put((String) name, nextValue()); - - switch (nextCleanInternal()) { - case '}': - return result; - case ';': - case ',': - continue; - default: - throw syntaxError("Unterminated object"); - } - } - } - - /** - * Reads a sequence of values and the trailing closing brace ']' of an - * array. The opening brace '[' should have already been read. Note that - * "[]" yields an empty array, but "[,]" returns a two-element array - * equivalent to "[null,null]". - */ - private JSONArray readArray() throws JSONException { - JSONArray result = new JSONArray(); - - /* to cover input that ends with ",]". */ - boolean hasTrailingSeparator = false; - - while (true) { - switch (nextCleanInternal()) { - case -1: - throw syntaxError("Unterminated array"); - case ']': - if (hasTrailingSeparator) { - result.put(null); - } - return result; - case ',': - case ';': - /* A separator without a value first means "null". */ - result.put(null); - hasTrailingSeparator = true; - continue; - default: - pos--; - } - - result.put(nextValue()); - - switch (nextCleanInternal()) { - case ']': - return result; - case ',': - case ';': - hasTrailingSeparator = true; - continue; - default: - throw syntaxError("Unterminated array"); - } - } - } - - /** - * Returns an exception containing the given message plus the current - * position and the entire input string. - */ - public JSONException syntaxError(String message) { - return new JSONException(message + this); - } - - /** - * Returns the current position and the entire input string. - */ - @Override public String toString() { - // consistent with the original implementation - return " at character " + pos + " of " + in; - } - - /* - * Legacy APIs. - * - * None of the methods below are on the critical path of parsing JSON - * documents. They exist only because they were exposed by the original - * implementation and may be used by some clients. - */ - - /** - * Returns true until the input has been exhausted. - */ - public boolean more() { - return pos < in.length(); - } - - /** - * Returns the next available character, or the null character '\0' if all - * input has been exhausted. The return value of this method is ambiguous - * for JSON strings that contain the character '\0'. - */ - public char next() { - return pos < in.length() ? in.charAt(pos++) : '\0'; - } - - /** - * Returns the next available character if it equals {@code c}. Otherwise an - * exception is thrown. - */ - public char next(char c) throws JSONException { - char result = next(); - if (result != c) { - throw syntaxError("Expected " + c + " but was " + result); - } - return result; - } - - /** - * Returns the next character that is not whitespace and does not belong to - * a comment. If the input is exhausted before such a character can be - * found, the null character '\0' is returned. The return value of this - * method is ambiguous for JSON strings that contain the character '\0'. - */ - public char nextClean() throws JSONException { - int nextCleanInt = nextCleanInternal(); - return nextCleanInt == -1 ? '\0' : (char) nextCleanInt; - } - - /** - * Returns the next {@code length} characters of the input. - * - *

The returned string shares its backing character array with this - * tokener's input string. If a reference to the returned string may be held - * indefinitely, you should use {@code new String(result)} to copy it first - * to avoid memory leaks. - * - * @throws JSONException if the remaining input is not long enough to - * satisfy this request. - */ - public String next(int length) throws JSONException { - if (pos + length > in.length()) { - throw syntaxError(length + " is out of bounds"); - } - String result = in.substring(pos, pos + length); - pos += length; - return result; - } - - /** - * Returns the {@link String#trim trimmed} string holding the characters up - * to but not including the first of: - *

    - *
  • any character in {@code excluded} - *
  • a newline character '\n' - *
  • a carriage return '\r' - *
- * - *

The returned string shares its backing character array with this - * tokener's input string. If a reference to the returned string may be held - * indefinitely, you should use {@code new String(result)} to copy it first - * to avoid memory leaks. - * - * @return a possibly-empty string - */ - public String nextTo(String excluded) { - if (excluded == null) { - throw new NullPointerException("excluded == null"); - } - return nextToInternal(excluded).trim(); - } - - /** - * Equivalent to {@code nextTo(String.valueOf(excluded))}. - */ - public String nextTo(char excluded) { - return nextToInternal(String.valueOf(excluded)).trim(); - } - - /** - * Advances past all input up to and including the next occurrence of - * {@code thru}. If the remaining input doesn't contain {@code thru}, the - * input is exhausted. - */ - public void skipPast(String thru) { - int thruStart = in.indexOf(thru, pos); - pos = thruStart == -1 ? in.length() : (thruStart + thru.length()); - } - - /** - * Advances past all input up to but not including the next occurrence of - * {@code to}. If the remaining input doesn't contain {@code to}, the input - * is unchanged. - */ - public char skipTo(char to) { - int index = in.indexOf(to, pos); - if (index != -1) { - pos = index; - return to; - } else { - return '\0'; - } - } - - /** - * Unreads the most recent character of input. If no input characters have - * been read, the input is unchanged. - */ - public void back() { - if (--pos == -1) { - pos = 0; - } - } - - /** - * Returns the integer [0..15] value for the given hex character, or -1 - * for non-hex input. - * - * @param hex a character in the ranges [0-9], [A-F] or [a-f]. Any other - * character will yield a -1 result. - */ - public static int dehexchar(char hex) { - if (hex >= '0' && hex <= '9') { - return hex - '0'; - } else if (hex >= 'A' && hex <= 'F') { - return hex - 'A' + 10; - } else if (hex >= 'a' && hex <= 'f') { - return hex - 'a' + 10; - } else { - return -1; - } - } -} -- cgit v1.2.1 From 12c636266ff1b0d83928da1c6d7520e1fbd79546 Mon Sep 17 00:00:00 2001 From: Joey Grover Date: Thu, 3 Sep 2020 11:32:22 -0400 Subject: Refactor javaEE lib and sample to one directory --- hello_sdl_java_ee/assets | 1 - hello_sdl_java_ee/build.gradle | 26 -- .../gradle/wrapper/gradle-wrapper.jar | Bin 56172 -> 0 bytes .../gradle/wrapper/gradle-wrapper.properties | 6 - hello_sdl_java_ee/gradlew | 172 ---------- hello_sdl_java_ee/gradlew.bat | 84 ----- hello_sdl_java_ee/settings.gradle | 3 - .../src/main/java/com/smartdevicelink/Main.java | 51 --- .../main/java/com/smartdevicelink/SdlService.java | 354 --------------------- javaEE/README.md | 25 -- javaEE/bintray.gradle | 96 ------ javaEE/bintray.properties | 8 - javaEE/build.gradle | 80 ----- javaEE/gradle/wrapper/gradle-wrapper.jar | Bin 55190 -> 0 bytes javaEE/gradle/wrapper/gradle-wrapper.properties | 6 - javaEE/gradlew | 172 ---------- javaEE/gradlew.bat | 84 ----- javaEE/hello_sdl_java_ee/assets | 1 + javaEE/hello_sdl_java_ee/build.gradle | 26 ++ javaEE/hello_sdl_java_ee/settings.gradle | 3 + .../src/main/java/com/smartdevicelink/Main.java | 51 +++ .../main/java/com/smartdevicelink/SdlService.java | 354 +++++++++++++++++++++ javaEE/javaEE/README.md | 25 ++ javaEE/javaEE/bintray.gradle | 96 ++++++ javaEE/javaEE/bintray.properties | 8 + javaEE/javaEE/build.gradle | 80 +++++ javaEE/javaEE/settings.gradle | 1 + javaEE/settings.gradle | 1 - 28 files changed, 645 insertions(+), 1169 deletions(-) delete mode 120000 hello_sdl_java_ee/assets delete mode 100644 hello_sdl_java_ee/build.gradle delete mode 100644 hello_sdl_java_ee/gradle/wrapper/gradle-wrapper.jar delete mode 100644 hello_sdl_java_ee/gradle/wrapper/gradle-wrapper.properties delete mode 100755 hello_sdl_java_ee/gradlew delete mode 100644 hello_sdl_java_ee/gradlew.bat delete mode 100644 hello_sdl_java_ee/settings.gradle delete mode 100644 hello_sdl_java_ee/src/main/java/com/smartdevicelink/Main.java delete mode 100644 hello_sdl_java_ee/src/main/java/com/smartdevicelink/SdlService.java delete mode 100644 javaEE/README.md delete mode 100644 javaEE/bintray.gradle delete mode 100644 javaEE/bintray.properties delete mode 100644 javaEE/build.gradle delete mode 100644 javaEE/gradle/wrapper/gradle-wrapper.jar delete mode 100644 javaEE/gradle/wrapper/gradle-wrapper.properties delete mode 100755 javaEE/gradlew delete mode 100644 javaEE/gradlew.bat create mode 120000 javaEE/hello_sdl_java_ee/assets create mode 100644 javaEE/hello_sdl_java_ee/build.gradle create mode 100644 javaEE/hello_sdl_java_ee/settings.gradle create mode 100644 javaEE/hello_sdl_java_ee/src/main/java/com/smartdevicelink/Main.java create mode 100644 javaEE/hello_sdl_java_ee/src/main/java/com/smartdevicelink/SdlService.java create mode 100644 javaEE/javaEE/README.md create mode 100644 javaEE/javaEE/bintray.gradle create mode 100644 javaEE/javaEE/bintray.properties create mode 100644 javaEE/javaEE/build.gradle create mode 100644 javaEE/javaEE/settings.gradle delete mode 100644 javaEE/settings.gradle diff --git a/hello_sdl_java_ee/assets b/hello_sdl_java_ee/assets deleted file mode 120000 index 386a9bd31..000000000 --- a/hello_sdl_java_ee/assets +++ /dev/null @@ -1 +0,0 @@ -../hello_sdl_java/assets \ No newline at end of file diff --git a/hello_sdl_java_ee/build.gradle b/hello_sdl_java_ee/build.gradle deleted file mode 100644 index 5c1b1eb70..000000000 --- a/hello_sdl_java_ee/build.gradle +++ /dev/null @@ -1,26 +0,0 @@ -plugins { - id 'java' -} - -version '1.0-SNAPSHOT' - -sourceCompatibility = 1.8 - -repositories { - mavenCentral() - mavenLocal() - google() - jcenter() -} -// This extraLibs solution is explained here: https://discuss.gradle.org/t/how-to-include-dependencies-in-jar/19571/5 -configurations { - // configuration that holds jars to include in the jar - extraLibs -} -dependencies { - extraLibs fileTree(dir: 'libs', include: ['*.jar']) - //testCompile group: 'junit', name: 'junit', version: '4.12' - extraLibs project(path: ':sdl_java_ee') - configurations.implementation.extendsFrom(configurations.extraLibs) - -} diff --git a/hello_sdl_java_ee/gradle/wrapper/gradle-wrapper.jar b/hello_sdl_java_ee/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 28861d273..000000000 Binary files a/hello_sdl_java_ee/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/hello_sdl_java_ee/gradle/wrapper/gradle-wrapper.properties b/hello_sdl_java_ee/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 16f7ff6d1..000000000 --- a/hello_sdl_java_ee/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Mon Mar 18 15:56:54 EDT 2019 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-all.zip diff --git a/hello_sdl_java_ee/gradlew b/hello_sdl_java_ee/gradlew deleted file mode 100755 index cccdd3d51..000000000 --- a/hello_sdl_java_ee/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/hello_sdl_java_ee/gradlew.bat b/hello_sdl_java_ee/gradlew.bat deleted file mode 100644 index f9553162f..000000000 --- a/hello_sdl_java_ee/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/hello_sdl_java_ee/settings.gradle b/hello_sdl_java_ee/settings.gradle deleted file mode 100644 index 8a8a05513..000000000 --- a/hello_sdl_java_ee/settings.gradle +++ /dev/null @@ -1,3 +0,0 @@ -rootProject.name = 'hello_sdl_java_ee' -include ":sdl_java_ee" -project (":sdl_java_ee").projectDir = new File(rootProject.projectDir, "../javaEE/") \ No newline at end of file diff --git a/hello_sdl_java_ee/src/main/java/com/smartdevicelink/Main.java b/hello_sdl_java_ee/src/main/java/com/smartdevicelink/Main.java deleted file mode 100644 index 8f685e984..000000000 --- a/hello_sdl_java_ee/src/main/java/com/smartdevicelink/Main.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.smartdevicelink; - -/** - * This is a sample of how to get Java EE Bean to work with an SDL application - * The code can be uncommented out with the proper gradle dependencies added - */ - - -// @ServerEndpoint("/") - // @Stateful(name = "SDLSessionEJB") - public class Main { - - /* Session session; - static Thread thread = null, mainThread; - static Object LOCK; - - static com.smartdevicelink.SdlService sdlService; - CustomTransport websocket; - - @OnOpen - public void onOpen (Session session, EndpointConfig config) { - websocket = new CustomTransport("http://localhost") { - @Override - public void onWrite(byte[] bytes, int offset, int length) { - try { - session.getBasicRemote().sendBinary(ByteBuffer.wrap(bytes)); - } - catch (IOException e) { - - } - } - }; - this.session = session; - sdlService = new com.smartdevicelink.SdlService(new CustomTransportConfig(websocket), sdlServiceCallback); - sdlService.start(); - } - - @OnMessage - public void onMessage (ByteBuffer message, Session session) { - websocket.onByteBufferReceived(message); - } - - - static final com.smartdevicelink.SdlService.SdlServiceCallback sdlServiceCallback = new com.smartdevicelink.SdlService.SdlServiceCallback() { - @Override - public void onEnd() { - - } - }; - */ - } diff --git a/hello_sdl_java_ee/src/main/java/com/smartdevicelink/SdlService.java b/hello_sdl_java_ee/src/main/java/com/smartdevicelink/SdlService.java deleted file mode 100644 index 779c357ee..000000000 --- a/hello_sdl_java_ee/src/main/java/com/smartdevicelink/SdlService.java +++ /dev/null @@ -1,354 +0,0 @@ -/* - * Copyright (c) 2019. 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. - */ - -package com.smartdevicelink; - -import android.util.Log; -import com.smartdevicelink.managers.CompletionListener; -import com.smartdevicelink.managers.SdlManager; -import com.smartdevicelink.managers.SdlManagerListener; -import com.smartdevicelink.managers.file.filetypes.SdlArtwork; -import com.smartdevicelink.managers.lifecycle.LifecycleConfigurationUpdate; -import com.smartdevicelink.managers.screen.choiceset.ChoiceCell; -import com.smartdevicelink.managers.screen.choiceset.ChoiceSet; -import com.smartdevicelink.managers.screen.choiceset.ChoiceSetSelectionListener; -import com.smartdevicelink.managers.screen.menu.MenuCell; -import com.smartdevicelink.managers.screen.menu.MenuSelectionListener; -import com.smartdevicelink.managers.screen.menu.VoiceCommand; -import com.smartdevicelink.managers.screen.menu.VoiceCommandSelectionListener; -import com.smartdevicelink.protocol.enums.FunctionID; -import com.smartdevicelink.proxy.RPCNotification; -import com.smartdevicelink.proxy.TTSChunkFactory; -import com.smartdevicelink.proxy.rpc.*; -import com.smartdevicelink.proxy.rpc.enums.*; -import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener; -import com.smartdevicelink.transport.BaseTransportConfig; -import com.smartdevicelink.util.DebugTool; - -import java.util.*; - -public class SdlService { - - - private static final String TAG = "SDL Service"; - - private static final String APP_NAME = "Hello Sdl"; - private static final String APP_NAME_ES = "Hola Sdl"; - private static final String APP_NAME_FR = "Bonjour Sdl"; - private static final String APP_ID = "8678309"; - - private static final String ICON_FILENAME = "hello_sdl_icon.png"; - private static final String SDL_IMAGE_FILENAME = "sdl_full_image.png"; - - private static final String WELCOME_SHOW = "Welcome to HelloSDL"; - private static final String WELCOME_SPEAK = "Welcome to Hello S D L"; - - private static final String TEST_COMMAND_NAME = "Test Command"; - - private static final String IMAGE_DIR = "assets/images/"; - - - - // variable to create and call functions of the SyncProxy - private SdlManager sdlManager = null; - private List choiceCellList; - - private SdlServiceCallback callback; - - - public SdlService(BaseTransportConfig config, SdlServiceCallback callback){ - this.callback = callback; - buildSdlManager(config); - } - - public void start() { - DebugTool.logInfo("SdlService start() "); - if(sdlManager != null){ - sdlManager.start(); - } - } - - public void stop() { - if (sdlManager != null) { - sdlManager.dispose(); - sdlManager = null; - } - } - - private void buildSdlManager(BaseTransportConfig transport) { - // This logic is to select the correct transport and security levels defined in the selected build flavor - // Build flavors are selected by the "build variants" tab typically located in the bottom left of Android Studio - // Typically in your app, you will only set one of these. - if (sdlManager == null) { - DebugTool.logInfo("Creating SDL Manager"); - - //FIXME add the transport type - // The app type to be used - Vector appType = new Vector<>(); - appType.add(AppHMIType.MEDIA); - - // The manager listener helps you know when certain events that pertain to the SDL Manager happen - // Here we will listen for ON_HMI_STATUS and ON_COMMAND notifications - SdlManagerListener listener = new SdlManagerListener() { - @Override - public void onStart(SdlManager sdlManager) { - DebugTool.logInfo("SdlManager onStart"); - } - - @Override - public void onDestroy(SdlManager sdlManager) { - DebugTool.logInfo("SdlManager onDestroy "); - SdlService.this.sdlManager = null; - if(SdlService.this.callback != null){ - SdlService.this.callback.onEnd(); - } - } - - @Override - public void onError(SdlManager sdlManager, String info, Exception e) { - } - - @Override - public LifecycleConfigurationUpdate managerShouldUpdateLifecycle(Language language){ - String appName; - switch (language) { - case ES_MX: - appName = APP_NAME_ES; - break; - case FR_CA: - appName = APP_NAME_FR; - break; - default: - return null; - } - - return new LifecycleConfigurationUpdate(appName,null,TTSChunkFactory.createSimpleTTSChunks(appName), null); - } - }; - - - HashMap notificationListenerHashMap = new HashMap(); - notificationListenerHashMap.put(FunctionID.ON_HMI_STATUS, new OnRPCNotificationListener() { - @Override - public void onNotified(RPCNotification notification) { - OnHMIStatus status = (OnHMIStatus) notification; - if (status.getHmiLevel() == HMILevel.HMI_FULL && ((OnHMIStatus) notification).getFirstRun()) { - setVoiceCommands(); - sendMenus(); - performWelcomeSpeak(); - performWelcomeShow(); - preloadChoices(); - } - } - }); - - // Create App Icon, this is set in the SdlManager builder - SdlArtwork appIcon = new SdlArtwork(ICON_FILENAME, FileType.GRAPHIC_PNG, IMAGE_DIR+"sdl_s_green.png", true); - - // The manager builder sets options for your session - SdlManager.Builder builder = new SdlManager.Builder(APP_ID, APP_NAME, listener); - builder.setAppTypes(appType); - builder.setTransportType(transport); - builder.setAppIcon(appIcon); - builder.setRPCNotificationListeners(notificationListenerHashMap); - sdlManager = builder.build(); - } - } - - /** - * Send some voice commands - */ - private void setVoiceCommands(){ - - List list1 = Collections.singletonList("Command One"); - List list2 = Collections.singletonList("Command two"); - - VoiceCommand voiceCommand1 = new VoiceCommand(list1, new VoiceCommandSelectionListener() { - @Override - public void onVoiceCommandSelected() { - Log.i(TAG, "Voice Command 1 triggered"); - } - }); - - VoiceCommand voiceCommand2 = new VoiceCommand(list2, new VoiceCommandSelectionListener() { - @Override - public void onVoiceCommandSelected() { - Log.i(TAG, "Voice Command 2 triggered"); - } - }); - - sdlManager.getScreenManager().setVoiceCommands(Arrays.asList(voiceCommand1,voiceCommand2)); - } - - /** - * Add menus for the app on SDL. - */ - private void sendMenus(){ - - // some arts - SdlArtwork livio = new SdlArtwork(ICON_FILENAME, FileType.GRAPHIC_PNG, IMAGE_DIR+"sdl_s_green.png", true); - - // some voice commands - List voice2 = Collections.singletonList("Cell two"); - - MenuCell mainCell1 = new MenuCell("Test Cell 1 (speak)", livio, null, new MenuSelectionListener() { - @Override - public void onTriggered(TriggerSource trigger) { - Log.i(TAG, "Test cell 1 triggered. Source: "+ trigger.toString()); - showTest(); - } - }); - - MenuCell mainCell2 = new MenuCell("Test Cell 2", null, voice2, new MenuSelectionListener() { - @Override - public void onTriggered(TriggerSource trigger) { - Log.i(TAG, "Test cell 2 triggered. Source: "+ trigger.toString()); - } - }); - - // SUB MENU - - MenuCell subCell1 = new MenuCell("SubCell 1",null, null, new MenuSelectionListener() { - @Override - public void onTriggered(TriggerSource trigger) { - Log.i(TAG, "Sub cell 1 triggered. Source: "+ trigger.toString()); - } - }); - - MenuCell subCell2 = new MenuCell("SubCell 2",null, null, new MenuSelectionListener() { - @Override - public void onTriggered(TriggerSource trigger) { - Log.i(TAG, "Sub cell 2 triggered. Source: "+ trigger.toString()); - } - }); - - // sub menu parent cell - MenuCell mainCell3 = new MenuCell("Test Cell 3 (sub menu)", null, Arrays.asList(subCell1,subCell2)); - - MenuCell mainCell4 = new MenuCell("Show Perform Interaction", null, null, new MenuSelectionListener() { - @Override - public void onTriggered(TriggerSource trigger) { - showPerformInteraction(); - } - }); - - MenuCell mainCell5 = new MenuCell("Clear the menu",null, null, new MenuSelectionListener() { - @Override - public void onTriggered(TriggerSource trigger) { - Log.i(TAG, "Clearing Menu. Source: "+ trigger.toString()); - // Clear this thing - sdlManager.getScreenManager().setMenu(Collections.emptyList()); - showAlert("Menu Cleared"); - } - }); - - // Send the entire menu off to be created - sdlManager.getScreenManager().setMenu(Arrays.asList(mainCell1, mainCell2, mainCell3, mainCell4, mainCell5)); - } - - /** - * Will speak a sample welcome message - */ - private void performWelcomeSpeak(){ - sdlManager.sendRPC(new Speak(TTSChunkFactory.createSimpleTTSChunks(WELCOME_SPEAK))); - } - - /** - * Use the Screen Manager to set the initial screen text and set the image. - * Because we are setting multiple items, we will call beginTransaction() first, - * and finish with commit() when we are done. - */ - private void performWelcomeShow() { - sdlManager.getScreenManager().beginTransaction(); - sdlManager.getScreenManager().setTextField1(APP_NAME); - sdlManager.getScreenManager().setTextField2(WELCOME_SHOW); - sdlManager.getScreenManager().setPrimaryGraphic(new SdlArtwork(SDL_IMAGE_FILENAME, FileType.GRAPHIC_PNG, IMAGE_DIR+"sdl.png", true)); - sdlManager.getScreenManager().commit(new CompletionListener() { - @Override - public void onComplete(boolean success) { - if (success){ - Log.i(TAG, "welcome show successful"); - } - } - }); - } - - /** - * Will show a sample test message on screen as well as speak a sample test message - */ - private void showTest(){ - sdlManager.getScreenManager().beginTransaction(); - sdlManager.getScreenManager().setTextField1("Test Cell 1 has been selected"); - sdlManager.getScreenManager().setTextField2(""); - sdlManager.getScreenManager().commit(null); - - sdlManager.sendRPC(new Speak(TTSChunkFactory.createSimpleTTSChunks(TEST_COMMAND_NAME))); - } - - private void showAlert(String text){ - Alert alert = new Alert(); - alert.setAlertText1(text); - alert.setDuration(5000); - sdlManager.sendRPC(alert); - } - - public interface SdlServiceCallback{ - void onEnd(); - } - - // Choice Set - - private void preloadChoices(){ - ChoiceCell cell1 = new ChoiceCell("Item 1"); - ChoiceCell cell2 = new ChoiceCell("Item 2"); - ChoiceCell cell3 = new ChoiceCell("Item 3"); - choiceCellList = new ArrayList<>(Arrays.asList(cell1,cell2,cell3)); - sdlManager.getScreenManager().preloadChoices(choiceCellList, null); - } - - private void showPerformInteraction(){ - if (choiceCellList != null) { - ChoiceSet choiceSet = new ChoiceSet("Choose an Item from the list", choiceCellList, new ChoiceSetSelectionListener() { - @Override - public void onChoiceSelected(ChoiceCell choiceCell, TriggerSource triggerSource, int rowIndex) { - showAlert(choiceCell.getText() + " was selected"); - } - - @Override - public void onError(String error) { - Log.e(TAG, "There was an error showing the perform interaction: "+ error); - } - }); - sdlManager.getScreenManager().presentChoiceSet(choiceSet, InteractionMode.MANUAL_ONLY); - } - } -} diff --git a/javaEE/README.md b/javaEE/README.md deleted file mode 100644 index 8e7c3699d..000000000 --- a/javaEE/README.md +++ /dev/null @@ -1,25 +0,0 @@ -## SmartDeviceLink JavaEE - -The JavaEE project is meant to allow SDL compatibility for web applications. - -#### Dependency Managers - -To compile with the latest release of SDL JavaSE, include the following in your app's `build.gradle` file, - -```sh -repositories { - jcenter() -} -dependencies { - implementation 'com.smartdevicelink:sdl_java_se:4.+' -} -``` - -#### Manually building a JAR - -If you prefer making a JAR, simply call: - -```sh -gradle build -``` -from within the project and a JAR should be generated in the `build/libs` folder \ No newline at end of file diff --git a/javaEE/bintray.gradle b/javaEE/bintray.gradle deleted file mode 100644 index 4756d4d70..000000000 --- a/javaEE/bintray.gradle +++ /dev/null @@ -1,96 +0,0 @@ -apply plugin: "com.jfrog.bintray" -apply plugin: 'maven-publish' -apply plugin: 'maven' - -def siteUrl = 'https://github.com/smartdevicelink/sdl_java_suite' // Homepage URL of the library -def gitUrl = 'https://github.com/smartdevicelink/sdl_java_suite.git' // Git repository URL -def libDescription = 'SmartDeviceLink mobile library' -def libVersion = new File(projectDir.path, ('/../VERSION')).text.trim() - -task sourcesJar(type: Jar, dependsOn: classes) { - classifier = 'sources' - from sourceSets.main.allSource -} - -javadoc.failOnError = false -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -artifacts { - archives sourcesJar - archives javadocJar -} - -bintray { - Properties props = new Properties() - props.load(new FileInputStream("$projectDir/bintray.properties")) - - // Authorization - user = props.getProperty("bintray.user") - key = props.getProperty("bintray.key") - version = libVersion - publications = ['mavenPublication'] - - - pkg { - repo = props.getProperty("bintray.repo") - name = props.getProperty("bintray.package") - websiteUrl = siteUrl - vcsUrl = gitUrl - userOrg = props.getProperty("bintray.userorg") - licenses = ["BSD 3-Clause"] - publish = props.getProperty("bintray.publish") // Will upload to jCenter - version { - name = libVersion // Change to release version - desc = libDescription - released = new Date() // Will be the current date & time - vcsTag = libVersion // Should match git tag - } - } -} - -def pomConfig = { - Properties props = new Properties() - props.load(new FileInputStream("$projectDir/bintray.properties")) - - licenses { - license { - name 'BSD 3-Clause' - url 'https://opensource.org/licenses/BSD-3-Clause' - distribution "repo" - } - } - - scm { - url siteUrl - } -} - -publishing { - publications { - mavenPublication(MavenPublication) { - Properties props = new Properties() - props.load(new FileInputStream("$projectDir/bintray.properties")) - - from components.java - artifact sourcesJar { - classifier "sources" - } - artifact javadocJar { - classifier "javadoc" - } - groupId props.getProperty("bintray.group") - artifactId props.getProperty("bintray.artifact") - version libVersion - pom.withXml { - def root = asNode() - root.appendNode('description', libDescription) - root.appendNode('name', props.getProperty("bintray.artifact")) - root.appendNode('url', siteUrl) - root.children().last() + pomConfig - } - } - } -} \ No newline at end of file diff --git a/javaEE/bintray.properties b/javaEE/bintray.properties deleted file mode 100644 index aa1926ba5..000000000 --- a/javaEE/bintray.properties +++ /dev/null @@ -1,8 +0,0 @@ -bintray.user=username -bintray.key=apikey -bintray.userorg=smartdevicelink -bintray.repo=sdl_java_ee -bintray.package=sdl_javaee -bintray.group=com.smartdevicelink -bintray.artifact=sdl_java_ee -bintray.publish=true \ No newline at end of file diff --git a/javaEE/build.gradle b/javaEE/build.gradle deleted file mode 100644 index c65af1324..000000000 --- a/javaEE/build.gradle +++ /dev/null @@ -1,80 +0,0 @@ -apply plugin: 'java-library' - -group 'com.smartdevicelink' -version new File(projectDir.path, ('/../VERSION')).text.trim() - -sourceCompatibility = 1.7 - -buildscript { - repositories { - jcenter() - } - dependencies { - classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4' - } -} - -repositories { - google() - jcenter() -} - -// This extraLibs solution is explained here: https://discuss.gradle.org/t/how-to-include-dependencies-in-jar/19571/5 -configurations { - // configuration that holds jars to include in the jar - extraLibs -} - -dependencies { - extraLibs fileTree(dir: 'libs', include: ['*.jar']) - extraLibs 'org.mongodb:bson:4.0.5' - extraLibs 'androidx.annotation:annotation:1.1.0' - extraLibs 'org.java-websocket:Java-WebSocket:1.3.9' - extraLibs 'com.livio.taskmaster:taskmaster:0.3.0' - configurations.api.extendsFrom(configurations.extraLibs) -} - -sourceSets { - main.java.srcDirs += '../base/src/main/java' - main.java.srcDirs += '../javaSE/src/main/java' -} - -jar { - dependsOn 'generateSources' - from { - configurations.extraLibs.collect { it.isDirectory() ? it : zipTree(it) } - } -} - -task generateSources { - outputs.upToDateWhen { false } - File outputDir = file("$buildDir/../../javaSE/src/main/java/com/smartdevicelink/") - outputs.dir outputDir - doFirst { - println "Generating BuildConfig.java ..." - def srcFile = new File(outputDir, "BuildConfig.java") - srcFile.parentFile.mkdirs() - File license = new File("$buildDir/../../LICENSE") - if (license.exists()) { - srcFile.write("/*\n") - def lines = license.readLines() - for (line in lines) { - srcFile.append("* ") - srcFile.append(line) - srcFile.append("\n") - } - srcFile.append("*/\n") - }else{ - srcFile.write("\n") - } - srcFile.append( - """package com.smartdevicelink; - -// THIS FILE IS AUTO GENERATED, DO NOT MODIFY!! -public final class BuildConfig { - public static final String VERSION_NAME = "$project.version"; -}""") - } -} - -apply from: 'bintray.gradle' \ No newline at end of file diff --git a/javaEE/gradle/wrapper/gradle-wrapper.jar b/javaEE/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 87b738cbd..000000000 Binary files a/javaEE/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/javaEE/gradle/wrapper/gradle-wrapper.properties b/javaEE/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index df8be2c19..000000000 --- a/javaEE/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Fri Jan 25 11:10:08 EST 2019 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip diff --git a/javaEE/gradlew b/javaEE/gradlew deleted file mode 100755 index af6708ff2..000000000 --- a/javaEE/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/javaEE/gradlew.bat b/javaEE/gradlew.bat deleted file mode 100644 index 0f8d5937c..000000000 --- a/javaEE/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/javaEE/hello_sdl_java_ee/assets b/javaEE/hello_sdl_java_ee/assets new file mode 120000 index 000000000..386a9bd31 --- /dev/null +++ b/javaEE/hello_sdl_java_ee/assets @@ -0,0 +1 @@ +../hello_sdl_java/assets \ No newline at end of file diff --git a/javaEE/hello_sdl_java_ee/build.gradle b/javaEE/hello_sdl_java_ee/build.gradle new file mode 100644 index 000000000..5c1b1eb70 --- /dev/null +++ b/javaEE/hello_sdl_java_ee/build.gradle @@ -0,0 +1,26 @@ +plugins { + id 'java' +} + +version '1.0-SNAPSHOT' + +sourceCompatibility = 1.8 + +repositories { + mavenCentral() + mavenLocal() + google() + jcenter() +} +// This extraLibs solution is explained here: https://discuss.gradle.org/t/how-to-include-dependencies-in-jar/19571/5 +configurations { + // configuration that holds jars to include in the jar + extraLibs +} +dependencies { + extraLibs fileTree(dir: 'libs', include: ['*.jar']) + //testCompile group: 'junit', name: 'junit', version: '4.12' + extraLibs project(path: ':sdl_java_ee') + configurations.implementation.extendsFrom(configurations.extraLibs) + +} diff --git a/javaEE/hello_sdl_java_ee/settings.gradle b/javaEE/hello_sdl_java_ee/settings.gradle new file mode 100644 index 000000000..8a8a05513 --- /dev/null +++ b/javaEE/hello_sdl_java_ee/settings.gradle @@ -0,0 +1,3 @@ +rootProject.name = 'hello_sdl_java_ee' +include ":sdl_java_ee" +project (":sdl_java_ee").projectDir = new File(rootProject.projectDir, "../javaEE/") \ No newline at end of file diff --git a/javaEE/hello_sdl_java_ee/src/main/java/com/smartdevicelink/Main.java b/javaEE/hello_sdl_java_ee/src/main/java/com/smartdevicelink/Main.java new file mode 100644 index 000000000..8f685e984 --- /dev/null +++ b/javaEE/hello_sdl_java_ee/src/main/java/com/smartdevicelink/Main.java @@ -0,0 +1,51 @@ +package com.smartdevicelink; + +/** + * This is a sample of how to get Java EE Bean to work with an SDL application + * The code can be uncommented out with the proper gradle dependencies added + */ + + +// @ServerEndpoint("/") + // @Stateful(name = "SDLSessionEJB") + public class Main { + + /* Session session; + static Thread thread = null, mainThread; + static Object LOCK; + + static com.smartdevicelink.SdlService sdlService; + CustomTransport websocket; + + @OnOpen + public void onOpen (Session session, EndpointConfig config) { + websocket = new CustomTransport("http://localhost") { + @Override + public void onWrite(byte[] bytes, int offset, int length) { + try { + session.getBasicRemote().sendBinary(ByteBuffer.wrap(bytes)); + } + catch (IOException e) { + + } + } + }; + this.session = session; + sdlService = new com.smartdevicelink.SdlService(new CustomTransportConfig(websocket), sdlServiceCallback); + sdlService.start(); + } + + @OnMessage + public void onMessage (ByteBuffer message, Session session) { + websocket.onByteBufferReceived(message); + } + + + static final com.smartdevicelink.SdlService.SdlServiceCallback sdlServiceCallback = new com.smartdevicelink.SdlService.SdlServiceCallback() { + @Override + public void onEnd() { + + } + }; + */ + } diff --git a/javaEE/hello_sdl_java_ee/src/main/java/com/smartdevicelink/SdlService.java b/javaEE/hello_sdl_java_ee/src/main/java/com/smartdevicelink/SdlService.java new file mode 100644 index 000000000..779c357ee --- /dev/null +++ b/javaEE/hello_sdl_java_ee/src/main/java/com/smartdevicelink/SdlService.java @@ -0,0 +1,354 @@ +/* + * Copyright (c) 2019. 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. + */ + +package com.smartdevicelink; + +import android.util.Log; +import com.smartdevicelink.managers.CompletionListener; +import com.smartdevicelink.managers.SdlManager; +import com.smartdevicelink.managers.SdlManagerListener; +import com.smartdevicelink.managers.file.filetypes.SdlArtwork; +import com.smartdevicelink.managers.lifecycle.LifecycleConfigurationUpdate; +import com.smartdevicelink.managers.screen.choiceset.ChoiceCell; +import com.smartdevicelink.managers.screen.choiceset.ChoiceSet; +import com.smartdevicelink.managers.screen.choiceset.ChoiceSetSelectionListener; +import com.smartdevicelink.managers.screen.menu.MenuCell; +import com.smartdevicelink.managers.screen.menu.MenuSelectionListener; +import com.smartdevicelink.managers.screen.menu.VoiceCommand; +import com.smartdevicelink.managers.screen.menu.VoiceCommandSelectionListener; +import com.smartdevicelink.protocol.enums.FunctionID; +import com.smartdevicelink.proxy.RPCNotification; +import com.smartdevicelink.proxy.TTSChunkFactory; +import com.smartdevicelink.proxy.rpc.*; +import com.smartdevicelink.proxy.rpc.enums.*; +import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener; +import com.smartdevicelink.transport.BaseTransportConfig; +import com.smartdevicelink.util.DebugTool; + +import java.util.*; + +public class SdlService { + + + private static final String TAG = "SDL Service"; + + private static final String APP_NAME = "Hello Sdl"; + private static final String APP_NAME_ES = "Hola Sdl"; + private static final String APP_NAME_FR = "Bonjour Sdl"; + private static final String APP_ID = "8678309"; + + private static final String ICON_FILENAME = "hello_sdl_icon.png"; + private static final String SDL_IMAGE_FILENAME = "sdl_full_image.png"; + + private static final String WELCOME_SHOW = "Welcome to HelloSDL"; + private static final String WELCOME_SPEAK = "Welcome to Hello S D L"; + + private static final String TEST_COMMAND_NAME = "Test Command"; + + private static final String IMAGE_DIR = "assets/images/"; + + + + // variable to create and call functions of the SyncProxy + private SdlManager sdlManager = null; + private List choiceCellList; + + private SdlServiceCallback callback; + + + public SdlService(BaseTransportConfig config, SdlServiceCallback callback){ + this.callback = callback; + buildSdlManager(config); + } + + public void start() { + DebugTool.logInfo("SdlService start() "); + if(sdlManager != null){ + sdlManager.start(); + } + } + + public void stop() { + if (sdlManager != null) { + sdlManager.dispose(); + sdlManager = null; + } + } + + private void buildSdlManager(BaseTransportConfig transport) { + // This logic is to select the correct transport and security levels defined in the selected build flavor + // Build flavors are selected by the "build variants" tab typically located in the bottom left of Android Studio + // Typically in your app, you will only set one of these. + if (sdlManager == null) { + DebugTool.logInfo("Creating SDL Manager"); + + //FIXME add the transport type + // The app type to be used + Vector appType = new Vector<>(); + appType.add(AppHMIType.MEDIA); + + // The manager listener helps you know when certain events that pertain to the SDL Manager happen + // Here we will listen for ON_HMI_STATUS and ON_COMMAND notifications + SdlManagerListener listener = new SdlManagerListener() { + @Override + public void onStart(SdlManager sdlManager) { + DebugTool.logInfo("SdlManager onStart"); + } + + @Override + public void onDestroy(SdlManager sdlManager) { + DebugTool.logInfo("SdlManager onDestroy "); + SdlService.this.sdlManager = null; + if(SdlService.this.callback != null){ + SdlService.this.callback.onEnd(); + } + } + + @Override + public void onError(SdlManager sdlManager, String info, Exception e) { + } + + @Override + public LifecycleConfigurationUpdate managerShouldUpdateLifecycle(Language language){ + String appName; + switch (language) { + case ES_MX: + appName = APP_NAME_ES; + break; + case FR_CA: + appName = APP_NAME_FR; + break; + default: + return null; + } + + return new LifecycleConfigurationUpdate(appName,null,TTSChunkFactory.createSimpleTTSChunks(appName), null); + } + }; + + + HashMap notificationListenerHashMap = new HashMap(); + notificationListenerHashMap.put(FunctionID.ON_HMI_STATUS, new OnRPCNotificationListener() { + @Override + public void onNotified(RPCNotification notification) { + OnHMIStatus status = (OnHMIStatus) notification; + if (status.getHmiLevel() == HMILevel.HMI_FULL && ((OnHMIStatus) notification).getFirstRun()) { + setVoiceCommands(); + sendMenus(); + performWelcomeSpeak(); + performWelcomeShow(); + preloadChoices(); + } + } + }); + + // Create App Icon, this is set in the SdlManager builder + SdlArtwork appIcon = new SdlArtwork(ICON_FILENAME, FileType.GRAPHIC_PNG, IMAGE_DIR+"sdl_s_green.png", true); + + // The manager builder sets options for your session + SdlManager.Builder builder = new SdlManager.Builder(APP_ID, APP_NAME, listener); + builder.setAppTypes(appType); + builder.setTransportType(transport); + builder.setAppIcon(appIcon); + builder.setRPCNotificationListeners(notificationListenerHashMap); + sdlManager = builder.build(); + } + } + + /** + * Send some voice commands + */ + private void setVoiceCommands(){ + + List list1 = Collections.singletonList("Command One"); + List list2 = Collections.singletonList("Command two"); + + VoiceCommand voiceCommand1 = new VoiceCommand(list1, new VoiceCommandSelectionListener() { + @Override + public void onVoiceCommandSelected() { + Log.i(TAG, "Voice Command 1 triggered"); + } + }); + + VoiceCommand voiceCommand2 = new VoiceCommand(list2, new VoiceCommandSelectionListener() { + @Override + public void onVoiceCommandSelected() { + Log.i(TAG, "Voice Command 2 triggered"); + } + }); + + sdlManager.getScreenManager().setVoiceCommands(Arrays.asList(voiceCommand1,voiceCommand2)); + } + + /** + * Add menus for the app on SDL. + */ + private void sendMenus(){ + + // some arts + SdlArtwork livio = new SdlArtwork(ICON_FILENAME, FileType.GRAPHIC_PNG, IMAGE_DIR+"sdl_s_green.png", true); + + // some voice commands + List voice2 = Collections.singletonList("Cell two"); + + MenuCell mainCell1 = new MenuCell("Test Cell 1 (speak)", livio, null, new MenuSelectionListener() { + @Override + public void onTriggered(TriggerSource trigger) { + Log.i(TAG, "Test cell 1 triggered. Source: "+ trigger.toString()); + showTest(); + } + }); + + MenuCell mainCell2 = new MenuCell("Test Cell 2", null, voice2, new MenuSelectionListener() { + @Override + public void onTriggered(TriggerSource trigger) { + Log.i(TAG, "Test cell 2 triggered. Source: "+ trigger.toString()); + } + }); + + // SUB MENU + + MenuCell subCell1 = new MenuCell("SubCell 1",null, null, new MenuSelectionListener() { + @Override + public void onTriggered(TriggerSource trigger) { + Log.i(TAG, "Sub cell 1 triggered. Source: "+ trigger.toString()); + } + }); + + MenuCell subCell2 = new MenuCell("SubCell 2",null, null, new MenuSelectionListener() { + @Override + public void onTriggered(TriggerSource trigger) { + Log.i(TAG, "Sub cell 2 triggered. Source: "+ trigger.toString()); + } + }); + + // sub menu parent cell + MenuCell mainCell3 = new MenuCell("Test Cell 3 (sub menu)", null, Arrays.asList(subCell1,subCell2)); + + MenuCell mainCell4 = new MenuCell("Show Perform Interaction", null, null, new MenuSelectionListener() { + @Override + public void onTriggered(TriggerSource trigger) { + showPerformInteraction(); + } + }); + + MenuCell mainCell5 = new MenuCell("Clear the menu",null, null, new MenuSelectionListener() { + @Override + public void onTriggered(TriggerSource trigger) { + Log.i(TAG, "Clearing Menu. Source: "+ trigger.toString()); + // Clear this thing + sdlManager.getScreenManager().setMenu(Collections.emptyList()); + showAlert("Menu Cleared"); + } + }); + + // Send the entire menu off to be created + sdlManager.getScreenManager().setMenu(Arrays.asList(mainCell1, mainCell2, mainCell3, mainCell4, mainCell5)); + } + + /** + * Will speak a sample welcome message + */ + private void performWelcomeSpeak(){ + sdlManager.sendRPC(new Speak(TTSChunkFactory.createSimpleTTSChunks(WELCOME_SPEAK))); + } + + /** + * Use the Screen Manager to set the initial screen text and set the image. + * Because we are setting multiple items, we will call beginTransaction() first, + * and finish with commit() when we are done. + */ + private void performWelcomeShow() { + sdlManager.getScreenManager().beginTransaction(); + sdlManager.getScreenManager().setTextField1(APP_NAME); + sdlManager.getScreenManager().setTextField2(WELCOME_SHOW); + sdlManager.getScreenManager().setPrimaryGraphic(new SdlArtwork(SDL_IMAGE_FILENAME, FileType.GRAPHIC_PNG, IMAGE_DIR+"sdl.png", true)); + sdlManager.getScreenManager().commit(new CompletionListener() { + @Override + public void onComplete(boolean success) { + if (success){ + Log.i(TAG, "welcome show successful"); + } + } + }); + } + + /** + * Will show a sample test message on screen as well as speak a sample test message + */ + private void showTest(){ + sdlManager.getScreenManager().beginTransaction(); + sdlManager.getScreenManager().setTextField1("Test Cell 1 has been selected"); + sdlManager.getScreenManager().setTextField2(""); + sdlManager.getScreenManager().commit(null); + + sdlManager.sendRPC(new Speak(TTSChunkFactory.createSimpleTTSChunks(TEST_COMMAND_NAME))); + } + + private void showAlert(String text){ + Alert alert = new Alert(); + alert.setAlertText1(text); + alert.setDuration(5000); + sdlManager.sendRPC(alert); + } + + public interface SdlServiceCallback{ + void onEnd(); + } + + // Choice Set + + private void preloadChoices(){ + ChoiceCell cell1 = new ChoiceCell("Item 1"); + ChoiceCell cell2 = new ChoiceCell("Item 2"); + ChoiceCell cell3 = new ChoiceCell("Item 3"); + choiceCellList = new ArrayList<>(Arrays.asList(cell1,cell2,cell3)); + sdlManager.getScreenManager().preloadChoices(choiceCellList, null); + } + + private void showPerformInteraction(){ + if (choiceCellList != null) { + ChoiceSet choiceSet = new ChoiceSet("Choose an Item from the list", choiceCellList, new ChoiceSetSelectionListener() { + @Override + public void onChoiceSelected(ChoiceCell choiceCell, TriggerSource triggerSource, int rowIndex) { + showAlert(choiceCell.getText() + " was selected"); + } + + @Override + public void onError(String error) { + Log.e(TAG, "There was an error showing the perform interaction: "+ error); + } + }); + sdlManager.getScreenManager().presentChoiceSet(choiceSet, InteractionMode.MANUAL_ONLY); + } + } +} diff --git a/javaEE/javaEE/README.md b/javaEE/javaEE/README.md new file mode 100644 index 000000000..8e7c3699d --- /dev/null +++ b/javaEE/javaEE/README.md @@ -0,0 +1,25 @@ +## SmartDeviceLink JavaEE + +The JavaEE project is meant to allow SDL compatibility for web applications. + +#### Dependency Managers + +To compile with the latest release of SDL JavaSE, include the following in your app's `build.gradle` file, + +```sh +repositories { + jcenter() +} +dependencies { + implementation 'com.smartdevicelink:sdl_java_se:4.+' +} +``` + +#### Manually building a JAR + +If you prefer making a JAR, simply call: + +```sh +gradle build +``` +from within the project and a JAR should be generated in the `build/libs` folder \ No newline at end of file diff --git a/javaEE/javaEE/bintray.gradle b/javaEE/javaEE/bintray.gradle new file mode 100644 index 000000000..f54efe333 --- /dev/null +++ b/javaEE/javaEE/bintray.gradle @@ -0,0 +1,96 @@ +apply plugin: "com.jfrog.bintray" +apply plugin: 'maven-publish' +apply plugin: 'maven' + +def siteUrl = 'https://github.com/smartdevicelink/sdl_java_suite' // Homepage URL of the library +def gitUrl = 'https://github.com/smartdevicelink/sdl_java_suite.git' // Git repository URL +def libDescription = 'SmartDeviceLink mobile library' +def libVersion = new File(projectDir.path, ('/../../VERSION')).text.trim() + +task sourcesJar(type: Jar, dependsOn: classes) { + classifier = 'sources' + from sourceSets.main.allSource +} + +javadoc.failOnError = false +task javadocJar(type: Jar, dependsOn: javadoc) { + classifier = 'javadoc' + from javadoc.destinationDir +} + +artifacts { + archives sourcesJar + archives javadocJar +} + +bintray { + Properties props = new Properties() + props.load(new FileInputStream("$projectDir/bintray.properties")) + + // Authorization + user = props.getProperty("bintray.user") + key = props.getProperty("bintray.key") + version = libVersion + publications = ['mavenPublication'] + + + pkg { + repo = props.getProperty("bintray.repo") + name = props.getProperty("bintray.package") + websiteUrl = siteUrl + vcsUrl = gitUrl + userOrg = props.getProperty("bintray.userorg") + licenses = ["BSD 3-Clause"] + publish = props.getProperty("bintray.publish") // Will upload to jCenter + version { + name = libVersion // Change to release version + desc = libDescription + released = new Date() // Will be the current date & time + vcsTag = libVersion // Should match git tag + } + } +} + +def pomConfig = { + Properties props = new Properties() + props.load(new FileInputStream("$projectDir/bintray.properties")) + + licenses { + license { + name 'BSD 3-Clause' + url 'https://opensource.org/licenses/BSD-3-Clause' + distribution "repo" + } + } + + scm { + url siteUrl + } +} + +publishing { + publications { + mavenPublication(MavenPublication) { + Properties props = new Properties() + props.load(new FileInputStream("$projectDir/bintray.properties")) + + from components.java + artifact sourcesJar { + classifier "sources" + } + artifact javadocJar { + classifier "javadoc" + } + groupId props.getProperty("bintray.group") + artifactId props.getProperty("bintray.artifact") + version libVersion + pom.withXml { + def root = asNode() + root.appendNode('description', libDescription) + root.appendNode('name', props.getProperty("bintray.artifact")) + root.appendNode('url', siteUrl) + root.children().last() + pomConfig + } + } + } +} \ No newline at end of file diff --git a/javaEE/javaEE/bintray.properties b/javaEE/javaEE/bintray.properties new file mode 100644 index 000000000..aa1926ba5 --- /dev/null +++ b/javaEE/javaEE/bintray.properties @@ -0,0 +1,8 @@ +bintray.user=username +bintray.key=apikey +bintray.userorg=smartdevicelink +bintray.repo=sdl_java_ee +bintray.package=sdl_javaee +bintray.group=com.smartdevicelink +bintray.artifact=sdl_java_ee +bintray.publish=true \ No newline at end of file diff --git a/javaEE/javaEE/build.gradle b/javaEE/javaEE/build.gradle new file mode 100644 index 000000000..c9386cffa --- /dev/null +++ b/javaEE/javaEE/build.gradle @@ -0,0 +1,80 @@ +apply plugin: 'java-library' + +group 'com.smartdevicelink' +version new File(projectDir.path, ('/../../VERSION')).text.trim() + +sourceCompatibility = 1.7 + +buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4' + } +} + +repositories { + google() + jcenter() +} + +// This extraLibs solution is explained here: https://discuss.gradle.org/t/how-to-include-dependencies-in-jar/19571/5 +configurations { + // configuration that holds jars to include in the jar + extraLibs +} + +dependencies { + extraLibs fileTree(dir: 'libs', include: ['*.jar']) + extraLibs 'org.mongodb:bson:4.0.5' + extraLibs 'androidx.annotation:annotation:1.1.0' + extraLibs 'org.java-websocket:Java-WebSocket:1.3.9' + extraLibs 'com.livio.taskmaster:taskmaster:0.3.0' + configurations.api.extendsFrom(configurations.extraLibs) +} + +sourceSets { + main.java.srcDirs += '../../base/src/main/java' + main.java.srcDirs += '../../javaSE/javaSE/src/main/java' +} + +jar { + dependsOn 'generateSources' + from { + configurations.extraLibs.collect { it.isDirectory() ? it : zipTree(it) } + } +} + +task generateSources { + outputs.upToDateWhen { false } + File outputDir = file("$buildDir/../../javaSE/src/main/java/com/smartdevicelink/") + outputs.dir outputDir + doFirst { + println "Generating BuildConfig.java ..." + def srcFile = new File(outputDir, "BuildConfig.java") + srcFile.parentFile.mkdirs() + File license = new File("$buildDir/../../LICENSE") + if (license.exists()) { + srcFile.write("/*\n") + def lines = license.readLines() + for (line in lines) { + srcFile.append("* ") + srcFile.append(line) + srcFile.append("\n") + } + srcFile.append("*/\n") + }else{ + srcFile.write("\n") + } + srcFile.append( + """package com.smartdevicelink; + +// THIS FILE IS AUTO GENERATED, DO NOT MODIFY!! +public final class BuildConfig { + public static final String VERSION_NAME = "$project.version"; +}""") + } +} + +apply from: 'bintray.gradle' \ No newline at end of file diff --git a/javaEE/javaEE/settings.gradle b/javaEE/javaEE/settings.gradle new file mode 100644 index 000000000..4da4ab327 --- /dev/null +++ b/javaEE/javaEE/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'javaEE' diff --git a/javaEE/settings.gradle b/javaEE/settings.gradle deleted file mode 100644 index 4da4ab327..000000000 --- a/javaEE/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -rootProject.name = 'javaEE' -- cgit v1.2.1 From b488e6e87ef76f895d3e40ba86f9372c4767f214 Mon Sep 17 00:00:00 2001 From: Joey Grover Date: Thu, 3 Sep 2020 11:33:24 -0400 Subject: Update gitignore --- .gitignore | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 3682f20b3..28594f757 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,12 @@ ############################## # Project Specific ############################## -javaSE/out/ -javaSE/build/ -javaSE/local.properties -javaEE/out/ -javaEE/build/ -javaEE/local.properties +javaSE/javaSE/out/ +javaSE/javaSE/build/ +javaSE/javaSE/local.properties +javaEE/javaEE/out/ +javaEE/javaEE/build/ +javaEE/javaEE/local.properties baseAndroid/windows/ -- cgit v1.2.1 From 37f7cfc6d98f679dc0f940c8ca8e3ec448305f73 Mon Sep 17 00:00:00 2001 From: Joey Grover Date: Thu, 3 Sep 2020 11:44:43 -0400 Subject: Update symlink for assets folder in javaEE app --- javaEE/hello_sdl_java_ee/assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/javaEE/hello_sdl_java_ee/assets b/javaEE/hello_sdl_java_ee/assets index 386a9bd31..5792e5ad9 120000 --- a/javaEE/hello_sdl_java_ee/assets +++ b/javaEE/hello_sdl_java_ee/assets @@ -1 +1 @@ -../hello_sdl_java/assets \ No newline at end of file +../../javaSE/hello_sdl_java/assets/ \ No newline at end of file -- cgit v1.2.1 From 6abc6cd65a034fb17de2561ae82c5518e7cf4e82 Mon Sep 17 00:00:00 2001 From: Joey Grover Date: Thu, 3 Sep 2020 12:03:37 -0400 Subject: Update github workflow yml --- .github/workflows/android.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 696200b8c..dcf311dff 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -28,13 +28,13 @@ jobs: run: ./android/gradlew -p ./android/hello_sdl_android test - name: Sdl JavaSE Tests - run: ./javaSE/gradlew -p ./javaSE test + run: ./javaSE/javaSE/gradlew -p ./javaSE/javaSE test - name: Hello Sdl JavaSE Tests - run: ./hello_sdl_java/gradlew -p ./hello_sdl_java test + run: ./javaSE/hello_sdl_java/gradlew -p ./javaSE/hello_sdl_java test - name: Sdl JavaEE Tests - run: ./javaEE/gradlew -p ./javaEE test + run: ./javaEE/javaEE/gradlew -p ./javaEE/javaEE test - name: RPC Generator Tests run: | -- cgit v1.2.1 From 37c5f44e9b50db697d420be7fc6ff1e2101dc605 Mon Sep 17 00:00:00 2001 From: Joey Grover Date: Thu, 3 Sep 2020 13:26:58 -0400 Subject: Fix directory for generating BuildConfig for java --- javaEE/javaEE/build.gradle | 2 +- javaSE/javaSE/build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/javaEE/javaEE/build.gradle b/javaEE/javaEE/build.gradle index c9386cffa..53b195e79 100644 --- a/javaEE/javaEE/build.gradle +++ b/javaEE/javaEE/build.gradle @@ -54,7 +54,7 @@ task generateSources { println "Generating BuildConfig.java ..." def srcFile = new File(outputDir, "BuildConfig.java") srcFile.parentFile.mkdirs() - File license = new File("$buildDir/../../LICENSE") + File license = new File("$buildDir/../../../LICENSE") if (license.exists()) { srcFile.write("/*\n") def lines = license.readLines() diff --git a/javaSE/javaSE/build.gradle b/javaSE/javaSE/build.gradle index 6c8fb5802..1e5525316 100644 --- a/javaSE/javaSE/build.gradle +++ b/javaSE/javaSE/build.gradle @@ -54,7 +54,7 @@ task generateSources { println "Generating BuildConfig.java ..." def srcFile = new File(outputDir, "BuildConfig.java") srcFile.parentFile.mkdirs() - File license = new File("$buildDir/../../LICENSE") + File license = new File("$buildDir/../../../LICENSE") if (license.exists()) { srcFile.write("/*\n") def lines = license.readLines() -- cgit v1.2.1 From df255e838f18714802d540a898779808fcb8ae12 Mon Sep 17 00:00:00 2001 From: Joey Grover Date: Thu, 3 Sep 2020 13:48:27 -0400 Subject: fix JavaEE buildconfig script --- javaEE/javaEE/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/javaEE/javaEE/build.gradle b/javaEE/javaEE/build.gradle index 53b195e79..e0bd3d93e 100644 --- a/javaEE/javaEE/build.gradle +++ b/javaEE/javaEE/build.gradle @@ -48,7 +48,7 @@ jar { task generateSources { outputs.upToDateWhen { false } - File outputDir = file("$buildDir/../../javaSE/src/main/java/com/smartdevicelink/") + File outputDir = file("$buildDir/../../../javaSE/javaSE/src/main/java/com/smartdevicelink/") outputs.dir outputDir doFirst { println "Generating BuildConfig.java ..." -- cgit v1.2.1 From 647bffdf0e1de935018937bc5b789285b3dddeee Mon Sep 17 00:00:00 2001 From: Joey Grover Date: Thu, 3 Sep 2020 13:49:13 -0400 Subject: Add gradle files to open lib+app as one project --- javaEE/build.gradle | 15 +++++++++++++++ javaEE/settings.gradle | 2 ++ javaSE/build.gradle | 15 +++++++++++++++ javaSE/settings.gradle | 2 ++ 4 files changed, 34 insertions(+) create mode 100644 javaEE/build.gradle create mode 100644 javaEE/settings.gradle create mode 100644 javaSE/build.gradle create mode 100644 javaSE/settings.gradle diff --git a/javaEE/build.gradle b/javaEE/build.gradle new file mode 100644 index 000000000..da3020478 --- /dev/null +++ b/javaEE/build.gradle @@ -0,0 +1,15 @@ +plugins { + id 'java' +} + +group 'com.smartdevicelink' + +sourceCompatibility = 1.7 + +repositories { + mavenCentral() +} + +dependencies { + testCompile group: 'junit', name: 'junit', version: '4.12' +} diff --git a/javaEE/settings.gradle b/javaEE/settings.gradle new file mode 100644 index 000000000..7ada092e5 --- /dev/null +++ b/javaEE/settings.gradle @@ -0,0 +1,2 @@ +include ':javaEE', ':hello_sdl_java_ee', ':sdl_java_ee' +project (":sdl_java_ee").projectDir = new File("/javaEE/") diff --git a/javaSE/build.gradle b/javaSE/build.gradle new file mode 100644 index 000000000..85f6e7e3e --- /dev/null +++ b/javaSE/build.gradle @@ -0,0 +1,15 @@ +plugins { + id 'java' +} + +group 'com.smartdevicelink' + +sourceCompatibility = 1.8 + +repositories { + mavenCentral() +} + +dependencies { + testCompile group: 'junit', name: 'junit', version: '4.12' +} diff --git a/javaSE/settings.gradle b/javaSE/settings.gradle new file mode 100644 index 000000000..0652c8ce8 --- /dev/null +++ b/javaSE/settings.gradle @@ -0,0 +1,2 @@ +include ':javaSE', ':hello_sdl_java', ':sdl_java_se' +project (":sdl_java_se").projectDir = new File("/javaSE/") -- cgit v1.2.1 From 4f9a8f62ca25c38591362a46f7ec87973da61ad0 Mon Sep 17 00:00:00 2001 From: Bilal Alsharifi Date: Thu, 3 Sep 2020 13:55:38 -0400 Subject: Remove createSimpleTTSChunks() --- .../main/java/com/sdl/hellosdlandroid/SdlService.java | 18 ++++++------------ .../managers/screen/choiceset/ChoiceSet.java | 17 ++++------------- .../main/java/com/smartdevicelink/java/SdlService.java | 18 ++++++------------ 3 files changed, 16 insertions(+), 37 deletions(-) diff --git a/android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlService.java b/android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlService.java index 4818423ab..7f5873fb0 100755 --- a/android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlService.java +++ b/android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlService.java @@ -238,7 +238,8 @@ public class SdlService extends Service { break; } if (isNeedUpdate) { - return new LifecycleConfigurationUpdate(appName, null, createSimpleTTSChunks(ttsName), null); + Vector chunks = new Vector<>(Collections.singletonList(new TTSChunk(ttsName, SpeechCapabilities.TEXT))); + return new LifecycleConfigurationUpdate(appName, null, chunks, null); } else { return null; } @@ -353,7 +354,8 @@ public class SdlService extends Service { * Will speak a sample welcome message */ private void performWelcomeSpeak(){ - sdlManager.sendRPC(new Speak(createSimpleTTSChunks(WELCOME_SPEAK))); + List chunks = Collections.singletonList(new TTSChunk(WELCOME_SPEAK, SpeechCapabilities.TEXT)); + sdlManager.sendRPC(new Speak(chunks)); } /** @@ -415,7 +417,8 @@ public class SdlService extends Service { sdlManager.getScreenManager().setTextField2(""); sdlManager.getScreenManager().commit(null); - sdlManager.sendRPC(new Speak(createSimpleTTSChunks(TEST_COMMAND_NAME))); + List chunks = Collections.singletonList(new TTSChunk(TEST_COMMAND_NAME, SpeechCapabilities.TEXT)); + sdlManager.sendRPC(new Speak(chunks)); } private void showAlert(String text){ @@ -451,13 +454,4 @@ public class SdlService extends Service { sdlManager.getScreenManager().presentChoiceSet(choiceSet, InteractionMode.MANUAL_ONLY); } } - - private Vector createSimpleTTSChunks(String simple) { - if (simple == null) { - return null; - } - Vector chunks = new Vector<>(); - chunks.add(new TTSChunk(simple, SpeechCapabilities.TEXT)); - return chunks; - } } diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSet.java b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSet.java index 3ada6368d..c85333cbe 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSet.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSet.java @@ -42,9 +42,9 @@ import com.smartdevicelink.proxy.rpc.enums.SpeechCapabilities; import com.smartdevicelink.util.DebugTool; import java.util.ArrayList; +import java.util.Collections; import java.util.Hashtable; import java.util.List; -import java.util.Vector; public class ChoiceSet { private static final String TAG = "ChoiceSet"; @@ -109,15 +109,15 @@ public class ChoiceSet { // Help the dev by creating TTS chunks for them if (initialPrompt != null){ - setInitialPrompt(createSimpleTTSChunks(initialPrompt)); + setInitialPrompt(Collections.singletonList(new TTSChunk(initialPrompt, SpeechCapabilities.TEXT))); } if (timeoutPrompt != null){ - setTimeoutPrompt(createSimpleTTSChunks(timeoutPrompt)); + setTimeoutPrompt(Collections.singletonList(new TTSChunk(timeoutPrompt, SpeechCapabilities.TEXT))); } if (helpPrompt != null){ - setHelpPrompt(createSimpleTTSChunks(helpPrompt)); + setHelpPrompt(Collections.singletonList(new TTSChunk(helpPrompt, SpeechCapabilities.TEXT))); } // things to do @@ -398,13 +398,4 @@ public class ChoiceSet { } return clonedHelpItems; } - - private Vector createSimpleTTSChunks(String simple) { - if (simple == null) { - return null; - } - Vector chunks = new Vector<>(); - chunks.add(new TTSChunk(simple, SpeechCapabilities.TEXT)); - return chunks; - } } diff --git a/hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java b/hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java index 0abd4ad81..2ac46def8 100644 --- a/hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java +++ b/hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java @@ -169,7 +169,8 @@ public class SdlService { break; } if (isNeedUpdate) { - return new LifecycleConfigurationUpdate(appName, null, createSimpleTTSChunks(ttsName), null); + Vector chunks = new Vector<>(Collections.singletonList(new TTSChunk(ttsName, SpeechCapabilities.TEXT))); + return new LifecycleConfigurationUpdate(appName, null, chunks, null); } else { return null; } @@ -301,7 +302,8 @@ public class SdlService { * Will speak a sample welcome message */ private void performWelcomeSpeak(){ - sdlManager.sendRPC(new Speak(createSimpleTTSChunks(WELCOME_SPEAK))); + List chunks = Collections.singletonList(new TTSChunk(WELCOME_SPEAK, SpeechCapabilities.TEXT)); + sdlManager.sendRPC(new Speak(chunks)); } /** @@ -364,7 +366,8 @@ public class SdlService { sdlManager.getScreenManager().setTextField2(""); sdlManager.getScreenManager().commit(null); - sdlManager.sendRPC(new Speak(createSimpleTTSChunks(TEST_COMMAND_NAME))); + List chunks = Collections.singletonList(new TTSChunk(TEST_COMMAND_NAME, SpeechCapabilities.TEXT)); + sdlManager.sendRPC(new Speak(chunks)); } private void showAlert(String text){ @@ -404,13 +407,4 @@ public class SdlService { sdlManager.getScreenManager().presentChoiceSet(choiceSet, InteractionMode.MANUAL_ONLY); } } - - private Vector createSimpleTTSChunks(String simple) { - if (simple == null) { - return null; - } - Vector chunks = new Vector<>(); - chunks.add(new TTSChunk(simple, SpeechCapabilities.TEXT)); - return chunks; - } } -- cgit v1.2.1 From 0f012d7a1789ff46329150d7b7cab50d5c52f53f Mon Sep 17 00:00:00 2001 From: Joey Grover Date: Thu, 3 Sep 2020 14:15:23 -0400 Subject: Add gradlew for github tasks --- javaEE/javaEE/gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 55190 bytes .../gradle/wrapper/gradle-wrapper.properties | 6 + javaEE/javaEE/gradlew | 172 +++++++++++++++++++++ javaEE/javaEE/gradlew.bat | 84 ++++++++++ javaSE/javaSE/gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 55190 bytes .../gradle/wrapper/gradle-wrapper.properties | 6 + javaSE/javaSE/gradlew | 172 +++++++++++++++++++++ javaSE/javaSE/gradlew.bat | 84 ++++++++++ 8 files changed, 524 insertions(+) create mode 100644 javaEE/javaEE/gradle/wrapper/gradle-wrapper.jar create mode 100644 javaEE/javaEE/gradle/wrapper/gradle-wrapper.properties create mode 100755 javaEE/javaEE/gradlew create mode 100644 javaEE/javaEE/gradlew.bat create mode 100644 javaSE/javaSE/gradle/wrapper/gradle-wrapper.jar create mode 100644 javaSE/javaSE/gradle/wrapper/gradle-wrapper.properties create mode 100755 javaSE/javaSE/gradlew create mode 100644 javaSE/javaSE/gradlew.bat diff --git a/javaEE/javaEE/gradle/wrapper/gradle-wrapper.jar b/javaEE/javaEE/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 000000000..87b738cbd Binary files /dev/null and b/javaEE/javaEE/gradle/wrapper/gradle-wrapper.jar differ diff --git a/javaEE/javaEE/gradle/wrapper/gradle-wrapper.properties b/javaEE/javaEE/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..df8be2c19 --- /dev/null +++ b/javaEE/javaEE/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Fri Jan 25 11:10:08 EST 2019 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip diff --git a/javaEE/javaEE/gradlew b/javaEE/javaEE/gradlew new file mode 100755 index 000000000..af6708ff2 --- /dev/null +++ b/javaEE/javaEE/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/javaEE/javaEE/gradlew.bat b/javaEE/javaEE/gradlew.bat new file mode 100644 index 000000000..6d57edc70 --- /dev/null +++ b/javaEE/javaEE/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/javaSE/javaSE/gradle/wrapper/gradle-wrapper.jar b/javaSE/javaSE/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 000000000..87b738cbd Binary files /dev/null and b/javaSE/javaSE/gradle/wrapper/gradle-wrapper.jar differ diff --git a/javaSE/javaSE/gradle/wrapper/gradle-wrapper.properties b/javaSE/javaSE/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..ca21d83d3 --- /dev/null +++ b/javaSE/javaSE/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Fri Jan 25 17:44:56 EST 2019 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip diff --git a/javaSE/javaSE/gradlew b/javaSE/javaSE/gradlew new file mode 100755 index 000000000..af6708ff2 --- /dev/null +++ b/javaSE/javaSE/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/javaSE/javaSE/gradlew.bat b/javaSE/javaSE/gradlew.bat new file mode 100644 index 000000000..6d57edc70 --- /dev/null +++ b/javaSE/javaSE/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega -- cgit v1.2.1 From f010e91e90551dd5f54cac8da3a05e4d37af0e4a Mon Sep 17 00:00:00 2001 From: Joey Grover Date: Thu, 3 Sep 2020 14:34:16 -0400 Subject: Add gradlew for github tasks for samples --- .../gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 56172 bytes .../gradle/wrapper/gradle-wrapper.properties | 6 + javaEE/hello_sdl_java_ee/gradlew | 172 +++++++++++++++++++++ javaEE/hello_sdl_java_ee/gradlew.bat | 84 ++++++++++ .../gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 56172 bytes .../gradle/wrapper/gradle-wrapper.properties | 6 + javaSE/hello_sdl_java/gradlew | 172 +++++++++++++++++++++ javaSE/hello_sdl_java/gradlew.bat | 84 ++++++++++ 8 files changed, 524 insertions(+) create mode 100644 javaEE/hello_sdl_java_ee/gradle/wrapper/gradle-wrapper.jar create mode 100644 javaEE/hello_sdl_java_ee/gradle/wrapper/gradle-wrapper.properties create mode 100755 javaEE/hello_sdl_java_ee/gradlew create mode 100644 javaEE/hello_sdl_java_ee/gradlew.bat create mode 100644 javaSE/hello_sdl_java/gradle/wrapper/gradle-wrapper.jar create mode 100644 javaSE/hello_sdl_java/gradle/wrapper/gradle-wrapper.properties create mode 100755 javaSE/hello_sdl_java/gradlew create mode 100644 javaSE/hello_sdl_java/gradlew.bat diff --git a/javaEE/hello_sdl_java_ee/gradle/wrapper/gradle-wrapper.jar b/javaEE/hello_sdl_java_ee/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 000000000..28861d273 Binary files /dev/null and b/javaEE/hello_sdl_java_ee/gradle/wrapper/gradle-wrapper.jar differ diff --git a/javaEE/hello_sdl_java_ee/gradle/wrapper/gradle-wrapper.properties b/javaEE/hello_sdl_java_ee/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..16f7ff6d1 --- /dev/null +++ b/javaEE/hello_sdl_java_ee/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Mon Mar 18 15:56:54 EDT 2019 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-all.zip diff --git a/javaEE/hello_sdl_java_ee/gradlew b/javaEE/hello_sdl_java_ee/gradlew new file mode 100755 index 000000000..cccdd3d51 --- /dev/null +++ b/javaEE/hello_sdl_java_ee/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/javaEE/hello_sdl_java_ee/gradlew.bat b/javaEE/hello_sdl_java_ee/gradlew.bat new file mode 100644 index 000000000..f9553162f --- /dev/null +++ b/javaEE/hello_sdl_java_ee/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/javaSE/hello_sdl_java/gradle/wrapper/gradle-wrapper.jar b/javaSE/hello_sdl_java/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 000000000..28861d273 Binary files /dev/null and b/javaSE/hello_sdl_java/gradle/wrapper/gradle-wrapper.jar differ diff --git a/javaSE/hello_sdl_java/gradle/wrapper/gradle-wrapper.properties b/javaSE/hello_sdl_java/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..fd6d42bd6 --- /dev/null +++ b/javaSE/hello_sdl_java/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Mon Mar 18 12:47:09 EDT 2019 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-all.zip diff --git a/javaSE/hello_sdl_java/gradlew b/javaSE/hello_sdl_java/gradlew new file mode 100755 index 000000000..cccdd3d51 --- /dev/null +++ b/javaSE/hello_sdl_java/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/javaSE/hello_sdl_java/gradlew.bat b/javaSE/hello_sdl_java/gradlew.bat new file mode 100644 index 000000000..f9553162f --- /dev/null +++ b/javaSE/hello_sdl_java/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega -- cgit v1.2.1 From 0bb42e3275615049697228c323a84ae3124d75ab Mon Sep 17 00:00:00 2001 From: Bilal Alsharifi <599206+bilal-alsharifi@users.noreply.github.com> Date: Thu, 3 Sep 2020 16:32:00 -0400 Subject: [SDL 0311] Make RPC Setters Chainable (#1467) * Make RPCs chainable (part 1) * Make RPCs chainable (part 2) * Add testParamsSettersAndGetters() * Add isMandatory to Parameter * Remove duplicate code in RPCConstructorsTests * Fix some issues in RPCConstructorsTests * Add more assertions to RPCConstructorsTests * Fix failing case in RPCConstructorsTests * Rename RPCConstructorsTests to RPCGenericTests * Extract TEST_VALUES_CLASS var * Update error messages in RPCGenericTests * Use MOBILE_API.XML from rpc_spec module in RPCGenericTests * Fix androidTest.assets.srcDirs path * Remove MOBILE_API.xml --- android/sdl_android/build.gradle | 1 + .../src/androidTest/assets/xml/MOBILE_API.xml | 8429 -------------------- .../test/rpc/RPCConstructorsTests.java | 339 - .../smartdevicelink/test/rpc/RPCGenericTests.java | 662 ++ .../java/com/smartdevicelink/proxy/RPCMessage.java | 6 +- .../java/com/smartdevicelink/proxy/RPCRequest.java | 68 +- .../com/smartdevicelink/proxy/RPCResponse.java | 74 +- .../java/com/smartdevicelink/proxy/RPCStruct.java | 9 +- .../com/smartdevicelink/proxy/rpc/AddCommand.java | 88 +- .../com/smartdevicelink/proxy/rpc/AddSubMenu.java | 52 +- .../smartdevicelink/proxy/rpc/AirbagStatus.java | 86 +- .../java/com/smartdevicelink/proxy/rpc/Alert.java | 90 +- .../smartdevicelink/proxy/rpc/AlertManeuver.java | 10 +- .../smartdevicelink/proxy/rpc/AlertResponse.java | 65 +- .../com/smartdevicelink/proxy/rpc/AppInfo.java | 28 +- .../proxy/rpc/AppServiceCapability.java | 14 +- .../smartdevicelink/proxy/rpc/AppServiceData.java | 35 +- .../proxy/rpc/AppServiceManifest.java | 80 +- .../proxy/rpc/AppServiceRecord.java | 28 +- .../proxy/rpc/AppServicesCapabilities.java | 7 +- .../proxy/rpc/AudioControlCapabilities.java | 49 +- .../proxy/rpc/AudioControlData.java | 28 +- .../proxy/rpc/AudioPassThruCapabilities.java | 77 +- .../com/smartdevicelink/proxy/rpc/BeltStatus.java | 45 +- .../smartdevicelink/proxy/rpc/BodyInformation.java | 91 +- .../proxy/rpc/ButtonCapabilities.java | 23 +- .../com/smartdevicelink/proxy/rpc/ButtonPress.java | 12 +- .../proxy/rpc/CancelInteraction.java | 6 +- .../proxy/rpc/ChangeRegistration.java | 94 +- .../java/com/smartdevicelink/proxy/rpc/Choice.java | 32 +- .../proxy/rpc/ClimateControlCapabilities.java | 54 +- .../proxy/rpc/ClimateControlData.java | 45 +- .../proxy/rpc/CloudAppProperties.java | 21 +- .../proxy/rpc/ClusterModeStatus.java | 90 +- .../com/smartdevicelink/proxy/rpc/Coordinate.java | 6 +- .../proxy/rpc/CreateInteractionChoiceSet.java | 84 +- .../smartdevicelink/proxy/rpc/CreateWindow.java | 15 +- .../com/smartdevicelink/proxy/rpc/DIDResult.java | 77 +- .../java/com/smartdevicelink/proxy/rpc/DTC.java | 72 +- .../com/smartdevicelink/proxy/rpc/DateTime.java | 79 +- .../smartdevicelink/proxy/rpc/DeleteCommand.java | 73 +- .../com/smartdevicelink/proxy/rpc/DeleteFile.java | 69 +- .../proxy/rpc/DeleteFileResponse.java | 3 +- .../proxy/rpc/DeleteInteractionChoiceSet.java | 69 +- .../smartdevicelink/proxy/rpc/DeleteSubMenu.java | 71 +- .../smartdevicelink/proxy/rpc/DeleteWindow.java | 3 +- .../com/smartdevicelink/proxy/rpc/DeviceInfo.java | 40 +- .../smartdevicelink/proxy/rpc/DeviceStatus.java | 95 +- .../proxy/rpc/DiagnosticMessage.java | 79 +- .../proxy/rpc/DiagnosticMessageResponse.java | 3 +- .../com/smartdevicelink/proxy/rpc/DialNumber.java | 3 +- .../proxy/rpc/DisplayCapabilities.java | 37 +- .../proxy/rpc/DisplayCapability.java | 9 +- .../proxy/rpc/DriverDistractionCapability.java | 6 +- .../proxy/rpc/DynamicUpdateCapabilities.java | 6 +- .../com/smartdevicelink/proxy/rpc/ECallInfo.java | 71 +- .../smartdevicelink/proxy/rpc/EmergencyEvent.java | 77 +- .../proxy/rpc/EqualizerSettings.java | 21 +- .../com/smartdevicelink/proxy/rpc/FuelRange.java | 20 +- .../com/smartdevicelink/proxy/rpc/GPSData.java | 133 +- .../com/smartdevicelink/proxy/rpc/GearStatus.java | 9 +- .../proxy/rpc/GetAppServiceData.java | 14 +- .../proxy/rpc/GetAppServiceDataResponse.java | 7 +- .../proxy/rpc/GetCloudAppProperties.java | 3 +- .../proxy/rpc/GetCloudAppPropertiesResponse.java | 3 +- .../com/smartdevicelink/proxy/rpc/GetDTCs.java | 74 +- .../smartdevicelink/proxy/rpc/GetDTCsResponse.java | 6 +- .../com/smartdevicelink/proxy/rpc/GetFile.java | 35 +- .../smartdevicelink/proxy/rpc/GetFileResponse.java | 28 +- .../proxy/rpc/GetInteriorVehicleData.java | 9 +- .../proxy/rpc/GetInteriorVehicleDataConsent.java | 6 +- .../rpc/GetInteriorVehicleDataConsentResponse.java | 3 +- .../proxy/rpc/GetInteriorVehicleDataResponse.java | 14 +- .../proxy/rpc/GetSystemCapability.java | 6 +- .../proxy/rpc/GetSystemCapabilityResponse.java | 3 +- .../smartdevicelink/proxy/rpc/GetVehicleData.java | 107 +- .../proxy/rpc/GetVehicleDataResponse.java | 111 +- .../smartdevicelink/proxy/rpc/GetWayPoints.java | 3 +- .../proxy/rpc/GetWayPointsResponse.java | 5 +- .../java/com/smartdevicelink/proxy/rpc/Grid.java | 18 +- .../smartdevicelink/proxy/rpc/HMICapabilities.java | 52 +- .../smartdevicelink/proxy/rpc/HMIPermissions.java | 72 +- .../proxy/rpc/HMISettingsControlCapabilities.java | 35 +- .../proxy/rpc/HMISettingsControlData.java | 27 +- .../com/smartdevicelink/proxy/rpc/HapticRect.java | 14 +- .../smartdevicelink/proxy/rpc/HeadLampStatus.java | 71 +- .../com/smartdevicelink/proxy/rpc/Headers.java | 92 +- .../java/com/smartdevicelink/proxy/rpc/Image.java | 71 +- .../com/smartdevicelink/proxy/rpc/ImageField.java | 75 +- .../smartdevicelink/proxy/rpc/ImageResolution.java | 80 +- .../proxy/rpc/KeyboardProperties.java | 21 +- .../proxy/rpc/LightCapabilities.java | 30 +- .../proxy/rpc/LightControlCapabilities.java | 21 +- .../proxy/rpc/LightControlData.java | 7 +- .../com/smartdevicelink/proxy/rpc/LightState.java | 32 +- .../proxy/rpc/ListFilesResponse.java | 6 +- .../smartdevicelink/proxy/rpc/LocationDetails.java | 21 +- .../proxy/rpc/MassageCushionFirmness.java | 14 +- .../smartdevicelink/proxy/rpc/MassageModeData.java | 14 +- .../proxy/rpc/MediaServiceData.java | 91 +- .../com/smartdevicelink/proxy/rpc/MenuParams.java | 79 +- .../smartdevicelink/proxy/rpc/MetadataTags.java | 56 +- .../com/smartdevicelink/proxy/rpc/ModuleData.java | 56 +- .../com/smartdevicelink/proxy/rpc/ModuleInfo.java | 12 +- .../java/com/smartdevicelink/proxy/rpc/MyKey.java | 65 +- .../proxy/rpc/NavigationCapability.java | 14 +- .../proxy/rpc/NavigationInstruction.java | 56 +- .../proxy/rpc/NavigationServiceData.java | 63 +- .../proxy/rpc/NavigationServiceManifest.java | 7 +- .../smartdevicelink/proxy/rpc/OasisAddress.java | 77 +- .../proxy/rpc/OnAppInterfaceUnregistered.java | 67 +- .../proxy/rpc/OnAppServiceData.java | 7 +- .../smartdevicelink/proxy/rpc/OnAudioPassThru.java | 65 +- .../smartdevicelink/proxy/rpc/OnButtonEvent.java | 77 +- .../smartdevicelink/proxy/rpc/OnButtonPress.java | 15 +- .../com/smartdevicelink/proxy/rpc/OnCommand.java | 76 +- .../proxy/rpc/OnDriverDistraction.java | 11 +- .../com/smartdevicelink/proxy/rpc/OnHMIStatus.java | 30 +- .../smartdevicelink/proxy/rpc/OnHashChange.java | 67 +- .../proxy/rpc/OnInteriorVehicleData.java | 3 +- .../smartdevicelink/proxy/rpc/OnKeyboardInput.java | 6 +- .../proxy/rpc/OnLanguageChange.java | 76 +- .../proxy/rpc/OnPermissionsChange.java | 18 +- .../com/smartdevicelink/proxy/rpc/OnRCStatus.java | 21 +- .../proxy/rpc/OnSystemCapabilityUpdated.java | 7 +- .../smartdevicelink/proxy/rpc/OnSystemRequest.java | 42 +- .../proxy/rpc/OnTBTClientState.java | 67 +- .../smartdevicelink/proxy/rpc/OnTouchEvent.java | 72 +- .../smartdevicelink/proxy/rpc/OnUpdateFile.java | 3 +- .../smartdevicelink/proxy/rpc/OnUpdateSubMenu.java | 6 +- .../smartdevicelink/proxy/rpc/OnVehicleData.java | 105 +- .../proxy/rpc/OnWayPointChange.java | 7 +- .../proxy/rpc/ParameterPermissions.java | 68 +- .../proxy/rpc/PerformAppServiceInteraction.java | 28 +- .../rpc/PerformAppServiceInteractionResponse.java | 7 +- .../proxy/rpc/PerformAudioPassThru.java | 122 +- .../proxy/rpc/PerformInteraction.java | 80 +- .../proxy/rpc/PerformInteractionResponse.java | 77 +- .../smartdevicelink/proxy/rpc/PermissionItem.java | 12 +- .../smartdevicelink/proxy/rpc/PhoneCapability.java | 7 +- .../proxy/rpc/PresetBankCapabilities.java | 67 +- .../proxy/rpc/PublishAppService.java | 7 +- .../proxy/rpc/PublishAppServiceResponse.java | 7 +- .../com/smartdevicelink/proxy/rpc/PutFile.java | 51 +- .../smartdevicelink/proxy/rpc/PutFileResponse.java | 3 +- .../com/smartdevicelink/proxy/rpc/RGBColor.java | 9 +- .../proxy/rpc/RadioControlCapabilities.java | 45 +- .../proxy/rpc/RadioControlData.java | 39 +- .../com/smartdevicelink/proxy/rpc/RdsData.java | 24 +- .../com/smartdevicelink/proxy/rpc/ReadDID.java | 76 +- .../smartdevicelink/proxy/rpc/ReadDIDResponse.java | 67 +- .../com/smartdevicelink/proxy/rpc/Rectangle.java | 28 +- .../proxy/rpc/RegisterAppInterface.java | 186 +- .../proxy/rpc/RegisterAppInterfaceResponse.java | 105 +- .../rpc/ReleaseInteriorVehicleDataModule.java | 6 +- .../proxy/rpc/RemoteControlCapabilities.java | 49 +- .../proxy/rpc/ResetGlobalProperties.java | 71 +- .../smartdevicelink/proxy/rpc/ScreenParams.java | 72 +- .../proxy/rpc/ScrollableMessage.java | 28 +- .../smartdevicelink/proxy/rpc/SdlMsgVersion.java | 13 +- .../proxy/rpc/SeatControlCapabilities.java | 119 +- .../smartdevicelink/proxy/rpc/SeatControlData.java | 112 +- .../smartdevicelink/proxy/rpc/SeatLocation.java | 3 +- .../proxy/rpc/SeatLocationCapability.java | 12 +- .../proxy/rpc/SeatMemoryAction.java | 21 +- .../smartdevicelink/proxy/rpc/SendHapticData.java | 7 +- .../smartdevicelink/proxy/rpc/SendLocation.java | 36 +- .../com/smartdevicelink/proxy/rpc/SetAppIcon.java | 69 +- .../proxy/rpc/SetCloudAppProperties.java | 3 +- .../proxy/rpc/SetDisplayLayout.java | 21 +- .../proxy/rpc/SetDisplayLayoutResponse.java | 12 +- .../proxy/rpc/SetGlobalProperties.java | 61 +- .../proxy/rpc/SetInteriorVehicleData.java | 3 +- .../proxy/rpc/SetInteriorVehicleDataResponse.java | 7 +- .../proxy/rpc/SetMediaClockTimer.java | 92 +- .../java/com/smartdevicelink/proxy/rpc/Show.java | 122 +- .../com/smartdevicelink/proxy/rpc/ShowAppMenu.java | 7 +- .../smartdevicelink/proxy/rpc/ShowConstantTbt.java | 57 +- .../proxy/rpc/SingleTireStatus.java | 77 +- .../com/smartdevicelink/proxy/rpc/SisData.java | 35 +- .../java/com/smartdevicelink/proxy/rpc/Slider.java | 42 +- .../smartdevicelink/proxy/rpc/SliderResponse.java | 67 +- .../com/smartdevicelink/proxy/rpc/SoftButton.java | 80 +- .../proxy/rpc/SoftButtonCapabilities.java | 19 +- .../java/com/smartdevicelink/proxy/rpc/Speak.java | 71 +- .../proxy/rpc/StabilityControlsStatus.java | 6 +- .../com/smartdevicelink/proxy/rpc/StartTime.java | 77 +- .../smartdevicelink/proxy/rpc/StationIDNumber.java | 14 +- .../smartdevicelink/proxy/rpc/SubscribeButton.java | 69 +- .../proxy/rpc/SubscribeVehicleData.java | 204 +- .../proxy/rpc/SubscribeVehicleDataResponse.java | 102 +- .../com/smartdevicelink/proxy/rpc/SubtleAlert.java | 21 +- .../proxy/rpc/SubtleAlertResponse.java | 3 +- .../proxy/rpc/SystemCapability.java | 10 +- .../smartdevicelink/proxy/rpc/SystemRequest.java | 78 +- .../com/smartdevicelink/proxy/rpc/TTSChunk.java | 74 +- .../com/smartdevicelink/proxy/rpc/Temperature.java | 6 +- .../proxy/rpc/TemplateColorScheme.java | 9 +- .../proxy/rpc/TemplateConfiguration.java | 9 +- .../com/smartdevicelink/proxy/rpc/TextField.java | 20 +- .../com/smartdevicelink/proxy/rpc/TireStatus.java | 35 +- .../com/smartdevicelink/proxy/rpc/TouchCoord.java | 68 +- .../com/smartdevicelink/proxy/rpc/TouchEvent.java | 85 +- .../proxy/rpc/TouchEventCapabilities.java | 71 +- .../java/com/smartdevicelink/proxy/rpc/Turn.java | 10 +- .../proxy/rpc/UnpublishAppService.java | 7 +- .../proxy/rpc/UnsubscribeButton.java | 71 +- .../proxy/rpc/UnsubscribeVehicleData.java | 204 +- .../proxy/rpc/UnsubscribeVehicleDataResponse.java | 102 +- .../smartdevicelink/proxy/rpc/UpdateTurnList.java | 10 +- .../proxy/rpc/VehicleDataResult.java | 21 +- .../com/smartdevicelink/proxy/rpc/VehicleType.java | 74 +- .../proxy/rpc/VideoStreamingCapability.java | 49 +- .../proxy/rpc/VideoStreamingFormat.java | 14 +- .../com/smartdevicelink/proxy/rpc/VrHelpItem.java | 71 +- .../smartdevicelink/proxy/rpc/WeatherAlert.java | 42 +- .../com/smartdevicelink/proxy/rpc/WeatherData.java | 154 +- .../proxy/rpc/WeatherServiceData.java | 42 +- .../proxy/rpc/WeatherServiceManifest.java | 35 +- .../proxy/rpc/WindowCapability.java | 30 +- .../com/smartdevicelink/proxy/rpc/WindowState.java | 6 +- .../smartdevicelink/proxy/rpc/WindowStatus.java | 6 +- .../proxy/rpc/WindowTypeCapabilities.java | 6 +- 223 files changed, 6094 insertions(+), 13032 deletions(-) delete mode 100644 android/sdl_android/src/androidTest/assets/xml/MOBILE_API.xml delete mode 100644 android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/RPCConstructorsTests.java create mode 100644 android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/RPCGenericTests.java diff --git a/android/sdl_android/build.gradle b/android/sdl_android/build.gradle index d35b06c49..e92009c2a 100644 --- a/android/sdl_android/build.gradle +++ b/android/sdl_android/build.gradle @@ -35,6 +35,7 @@ android { sourceSets { main.java.srcDirs += '../../base/src/main/java' + androidTest.assets.srcDirs += '../../generator/rpc_spec/' } } diff --git a/android/sdl_android/src/androidTest/assets/xml/MOBILE_API.xml b/android/sdl_android/src/androidTest/assets/xml/MOBILE_API.xml deleted file mode 100644 index 86cfe4f5c..000000000 --- a/android/sdl_android/src/androidTest/assets/xml/MOBILE_API.xml +++ /dev/null @@ -1,8429 +0,0 @@ - - - - - - - The request succeeded - - - The request is not supported by the headunit - - - - A button that was requested for subscription is not supported under the current system. - - - - RPC is not authorized in local policy table. - - - - The requested command was rejected, e.g. because mobile app is in background and cannot perform any HMI commands. - Or an HMI command (e.g. Speak) is rejected because a higher priority HMI command (e.g. Alert) is playing. - - - - - A command was aborted, for example due to user interaction (e.g. user pressed button). - Or an HMI command (e.g. Speak) is aborted because a higher priority HMI command (e.g. Alert) was requested. - - - - - A command was ignored, because the intended result is already in effect. - For example, SetMediaClockTimer was used to pause the media clock although the clock is paused already. - NOTE: potentially replaces SUBSCRIBED_ALREADY - - - - The user interrupted the RPC (e.g. PerformAudioPassThru) and indicated to start over. Note, the app must issue the new RPC. - - - - The data may not be changed, because it is currently in use. - For example when trying to delete a command set that is currently involved in an interaction. - - - - The requested vehicle data is not available on this vehicle or is not published. - - - Overlay reached the maximum timeout and closed. - - - - The data sent is invalid. For example: - Invalid Json syntax - Parameters out of bounds (number or enum range) - Mandatory parameters not provided - Parameter provided with wrong type - Invalid characters - Empty string - - - - - - One of the provided IDs is not valid. For example - This applies to CorrelationID, SubscriptionID, CommandID, MenuID, etc. - - - - There was a conflict with an registered name (application or menu item) or vr command - - - An command can not be executed because no application has been registered with RegisterApplication. - - - - The requested language is currently not supported. - Might be because of a mismatch of the currently active language on the headunit and the requested language - - - - The system could not process the request because the necessary memory couldn't be allocated - - - There are too many requests pending (means, that the response has not been delivered, yet).There may be a maximum of 1000 pending requests at a time. - - - There are already too many registered applications - - - RegisterApplication has been called again, after a RegisterApplication was successful before. - - - The RPC (e.g. SubscribeVehicleData) executed successfully but one or more items have a warning or failure. - - - Provided data is valid but something went wrong in the lower layers. - - - RPC is included in a functional group explicitly blocked by the user. - - - The RPC (e.g. ReadDID) executed successfully but the data exceeded the platform maximum threshold and thus, only part of the data is available. - - - Sync doesn't support the protocol that is requested by the mobile application - - - The user has turned off access to vehicle data, and it is globally unavailable to mobile applications. - - - A specified file could not be found on the headunit. - - - User selected to Cancel Route. - - - The RPC (e.g. Slider) executed successfully and the user elected to save the current position / value. - - - The certificate provided during authentication is invalid. - - - The certificate provided during authentication is expired. - - - The provided hash ID does not match the hash of the current set of registered data or the core could not resume the previous data. - - - The requested information is currently not available. This is different than UNSUPPORTED_RESOURCE because it implies the data is at some point available. - - - The value being set is read only - - - The data sent failed to pass CRC check in receiver end - - - SDL receives an un-encrypted RPC request that needs protection. - - - - - - - A button was released, after it was pressed for a long time - Actual timing is defined by the headunit and may vary - - - - - A button was released, after it was pressed for a short time - Actual timing is defined by the headunit and may vary - - - - - - - A button has been released up - - - A button has been pressed down - - - - - - English - US - - - Spanish - Mexico - - - French - Canada - - - German - Germany - - - Spanish - Spain - - - English - GB - - - Russian - Russia - - - Turkish - Turkey - - - Polish - Poland - - - French - France - - - Italian - Italy - - - Swedish - Sweden - - - Portuguese - Portugal - - - Dutch (Standard) - Netherlands - - - English - Australia - - - Mandarin - China - - - Mandarin - Taiwan - - - Japanese - Japan - - - Arabic - Saudi Arabia - - - Korean - South Korea - - - Portuguese - Brazil - - - Czech - Czech Republic - - - Danish - Denmark - - - Norwegian - Norway - - - Dutch (Flemish) - Belgium - - - Greek - Greece - - - Hungarian - Hungary - - - Finnish - Finland - - - Slovak - Slovakia - - - English - India - - - Thai - Thailand - - - English - Middle East - - - Hebrew - Israel - - - Romanian - Romania - - - Ukrainian - Ukraine - - - Indonesian - Indonesia - - - Vietnamese - Vietnam - - - Malay - Malaysia - - - Hindi - India - - - - - Describes how the media clock timer should behave on the platform - - Starts the media clock timer counting upwards, as in time elapsed. - - - Starts the media clock timer counting downwards, as in time remaining. - - - Pauses the media clock timer - - - Resume the media clock timer - - - Clears the media clock timer (previously done through Show->mediaClock) - - - - - - Causes the media clock timer to update from 0:00 to a specified time - - - Causes the media clock timer to update from a specified time to 0:00 - - - Indicates to not use the media clock timer - - - - - For application-requested interactions, this mode indicates the method in which the user is notified and uses the interaction. - - This mode causes the interaction to only occur on the display, meaning the choices are provided only via the display. No Voice Interaction. - - - This mode causes the interaction to only occur using the headunits VR system. Selections are made by saying the command. - - - This mode causes both a VR and display selection option for an interaction. The user will first be asked via Voice Interaction (if available). If this is unsuccessful, the system will switch to manual input. - - - - - For touchscreen interactions, the mode of how the choices are presented. - - This mode causes the interaction to display the previous set of choices as icons. - - - This mode causes the interaction to display the previous set of choices as icons along with a search field in the HMI. - - - This mode causes the interaction to display the previous set of choices as a list. - - - This mode causes the interaction to display the previous set of choices as a list along with a search field in the HMI. - - - This mode causes the interaction to immediately display a keyboard entry through the HMI. - - - - - - - This window type describes the main window on a display. - - - - - A widget is a small window that the app can create to provide information and soft buttons for quick app control. - - - - - - - The default window is a main window pre-created on behalf of the app. - - - The primary widget of the app. - - - - - Enumeration that describes current levels of HMI. - - - - - - - - Enumeration that describes possible states of audio streaming. - - - - - - - Enumeration that describes system actions that can be triggered. - - Default action occurs. Standard behavior (e.g. SoftButton clears overlay). - - - App is brought into HMI_FULL. - - - Current system context is maintained. An overlay is persisted even though a SoftButton has been pressed and the notification sent. - - - - - Enumeration that describes possible contexts an app's HMI might be in. Communicated to whichever app is in HMI FULL, except Alert. - - The app's persistent display (whether media/non-media/navigation) is fully visible onscreen. - - - The system is currently in a VR session (with whatever dedicated VR screen being overlaid onscreen). - - - The system is currently displaying an in-App menu onscreen. - - - The app's display HMI is currently being obscured by either a system or other app's overlay. - - - Broadcast only to whichever app has an alert currently being displayed. - - - - - Enumeration that describes possible states of video streaming. - - - - - - Contains information about the SoftButton capabilities. - - - - - - - Error code, which comes from the module side. - - - - - - - - - - - - - - - - - Indicates the source from where the command was triggered. - - - - - - - Contains information about the HMI zone capabilities. - For future use. - - - - - - Contains information about the TTS capabilities. - - - - - - - - - - Contains information about the VR capabilities. - - - - - Contains a list of prerecorded speech items present on the platform. - - - - - - - - - Describes different sampling options for PerformAudioPassThru. - - Sampling rate of 8000 Hz. - - - Sampling rate of 16000 Hz. - - - Sampling rate of 22050 Hz. - - - Sampling rate of 44100 Hz. - - - - - Describes different quality options for PerformAudioPassThru. - - Audio sample is 8 bits wide, unsigned. - - - Audio sample is 16 bits wide, signed, and in little endian. - - - - - Describes different audio type options for PerformAudioPassThru. - - Linear PCM. - - - - - - Describes different audio type configurations for PerformAudioPassThru. - e.g. {8kHz,8-bit,PCM} - The audio is recorded in monaural. - - - - - - - - Defines the data types that can be published and subscribed to. - - Notifies GPSData may be subscribed - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Enumeration for the user's preference of which app type to use when both are available - - - - - - - - An array of app names a cloud app is allowed to register with. If included in a SetCloudAppProperties request, this value will overwrite the existing "nicknames" field in the app policies section of the policy table. - - - - If true, cloud app will be included in HMI RPC UpdateAppList - - - Used to authenticate websocket connection on app activation - - - Specifies the connection type Core should use - - - Specifies the user preference to use the cloud app version or mobile app version when both are available - - - Specifies the endpoint which Core will attempt to connect to when this app is selected - - - - - Defines the hard (physical) and soft (touchscreen) buttons available from the module - - - - The button name for the physical Play/Pause - toggle that can be used by media apps. - - - Please use the physical OK button in order to - use a Play/Pause toggle for versions < 4.5.0. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - If supported, this toggles between a top-down view and an angled/3D view. If your app supports different, but substantially similar options, then you may implement those. If you don't implement these or similar options, do not subscribe to this button. - - - - - If supported, this toggles between locking the orientation to north or to the vehicle's heading. If your app supports different, but substantially similar options, then you may implement those. If you don't implement these or similar options, do not subscribe to this button. - - - - - - - minutesFieldWidth = 2;minutesFieldMax = 19;secondsFieldWidth = 2;secondsFieldMax = 99;maxHours = 19;maxMinutes = 59;maxSeconds = 59; - used for Type II and CID headunits - - - - - minutesFieldWidth = 3;minutesFieldMax = 199;secondsFieldWidth = 2;secondsFieldMax = 99;maxHours = 59;maxMinutes = 59;maxSeconds = 59; - used for Type V headunit - - - - - minutesFieldWidth = 2;minutesFieldMax = 59;secondsFieldWidth = 2;secondsFieldMax = 59;maxHours = 9;maxMinutes = 59;maxSeconds = 59; - used for GEN1.1 MFD3/4/5 headunits - - - - - 5 characters possible - Format: 1|sp c :|sp c c - 1|sp : digit "1" or space - c : character out of following character set: sp|0-9|[letters, see TypeII column in XLS. See [@TODO: create file ref]] - :|sp : colon or space - used for Type II headunit - - - - - 5 chars possible - Format: 1|sp c :|sp c c - 1|sp : digit "1" or space - c : character out of following character set: sp|0-9|[letters, see CID column in XLS. See [@TODO: create file ref]] - :|sp : colon or space - used for CID headunit - NOTE: difference between CLOCKTEXT1 and CLOCKTEXT2 is the supported character set - - - - - 6 chars possible - Format: 1|sp c c :|sp c c - 1|sp : digit "1" or space - c : character out of following character set: sp|0-9|[letters, see Type 5 column in XLS]. See [@TODO: create file ref] - :|sp : colon or space - used for Type V headunit - - - - - 6 chars possible - Format: c :|sp c c : c c - :|sp : colon or space - c : character out of following character set: sp|0-9|[letters]. - used for GEN1.1 MFD3/4/5 headunits - - - - - - See DAES for further infos regarding the displays - - - - - - - - - - - - - - - - - - - The first line of first set of main fields of the persistent display; applies to "Show" - - - - The second line of first set of main fields of the persistent display; applies to "Show" - - - - The first line of second set of main fields of persistent display; applies to "Show" - - - - The second line of second set of main fields of the persistent display; applies to "Show" - - - - The status bar on NGN; applies to "Show" - - - - Text value for MediaClock field; applies to "Show" - - - - The track field of NGN and GEN1.1 MFD displays. This field is only available for media applications; applies to "Show" - - - - The title of the new template that will be displayed; applies to "Show" - - - - The first line of the alert text field; applies to "Alert" - - - - The second line of the alert text field; applies to "Alert" - - - - The third line of the alert text field; applies to "Alert" - - - - Long form body of text that can include newlines and tabs; applies to "ScrollableMessage" - - - - First line suggestion for a user response (in the case of VR enabled interaction) - - - - First line of navigation text - - - - Second line of navigation text - - - - Estimated Time of Arrival time for navigation - - - - Total distance to destination for navigation - - - - First line of text for audio pass thru - - - - Second line of text for audio pass thru - - - - Header text for slider - - - - Footer text for slider - - - - Primary text for Choice - - - - Secondary text for Choice - - - - Tertiary text for Choice - - - - Optional text to label an app menu button (for certain touchscreen platforms). - - - - Optional name / title of intended location for SendLocation. - - - - Optional description of intended location / establishment (if applicable) for SendLocation. - - - - Optional location address (if applicable) for SendLocation. - - - - Optional hone number of intended location / establishment (if applicable) for SendLocation. - - - - - - - The image field for SoftButton - - - - The first image field for Choice - - - - The secondary image field for Choice - - - - The image field for vrHelpItem - - - - The image field for Turn - - - - The image field for the menu icon in SetGlobalProperties - - - - The image field for AddCommand - - - - The image field for the app icon (set by setAppIcon) - - - - The primary image field for Show - - - - The secondary image field for Show - - - - The primary image field for ShowConstantTBT - - - - The secondary image field for ShowConstantTBT - - - - The optional image of a destination / location - - - - The image field for Alert - - - - - - The list of potential character sets - - See [@TODO: create file ref] - - - See [@TODO: create file ref] - - - See [@TODO: create file ref] - - - See [@TODO: create file ref] - - - - - The list of possible alignments, left, right, or centered - - - - - - - Enumeration that describes possible states of turn-by-turn client or SmartDeviceLink app. - - - - - - - - - - - - - - Enumeration that describes possible states of driver distraction. - - - - - - Contains information about the type of image. - - - - - - The mode in which the SendLocation request is sent - - - - - - - Enum for each type of video streaming protocol type. - - Raw stream bytes that contains no timestamp data and is the lowest supported video streaming - - - RTP facilitates the transfer of real-time data. Information provided by this protocol include timestamps (for synchronization), sequence numbers (for packet loss and reordering detection) and the payload format which indicates the encoded format of the data. - - - The transmission of streaming data itself is not a task of RTSP. Most RTSP servers use the Real-time Transport Protocol (RTP) in conjunction with Real-time Control Protocol (RTCP) for media stream delivery. However, some vendors implement proprietary transport protocols. - - - Real-Time Messaging Protocol (RTMP) was initially a proprietary protocol developed by Macromedia for streaming audio, video and data over the Internet, between a Flash player and a server. Macromedia is now owned by Adobe, which has released an incomplete version of the specification of the protocol for public use. - - - The WebM container is based on a profile of Matroska. WebM initially supported VP8 video and Vorbis audio streams. In 2013 it was updated to accommodate VP9 video and Opus audio. - - - - - Enum for each type of video streaming codec. - - A block-oriented motion-compensation-based video compression standard. As of 2014 it is one of the most commonly used formats for the recording, compression, and distribution of video content. - - - High Efficiency Video Coding (HEVC), also known as H.265 and MPEG-H Part 2, is a video compression standard, one of several potential successors to the widely used AVC (H.264 or MPEG-4 Part 10). In comparison to AVC, HEVC offers about double the data compression ratio at the same level of video quality, or substantially improved video quality at the same bit rate. It supports resolutions up to 8192x4320, including 8K UHD. - - - Theora is derived from the formerly proprietary VP3 codec, released into the public domain by On2 Technologies. It is broadly comparable in design and bitrate efficiency to MPEG-4 Part 2, early versions of Windows Media Video, and RealVideo while lacking some of the features present in some of these other codecs. It is comparable in open standards philosophy to the BBC's Dirac codec. - - - VP8 can be multiplexed into the Matroska-based container format WebM along with Vorbis and Opus audio. The image format WebP is based on VP8's intra-frame coding. VP8's direct successor, VP9, and the emerging royalty-free internet video format AV1 from the Alliance for Open Media (AOMedia) are based on VP8. - - - Similar to VP8, but VP9 is customized for video resolutions beyond high-definition video (UHD) and also enables lossless compression. - - - - - - - Default playback indicator. - By default the playback indicator should be PLAY_PAUSE when: - - the media app is newly registered on the head unit (after RegisterAppInterface) - - the media app was closed by the user (App enters HMI_NONE) - - the app sends SetMediaClockTimer with audioStreamingIndicator not set to any value - - - - Indicates that a button press of the Play/Pause button starts the audio playback. - - - Indicates that a button press of the Play/Pause button pauses the current audio playback. - - - Indicates that a button press of the Play/Pause button stops the current audio playback. - - - - - - Either the static hex icon value or the binary image file name identifier (sent by PutFile). - - - Describes, whether it is a static or dynamic image. - - - If true, the image is a template image and can be recolored by the HMI - - - - - - Describes, whether it is text, highlighted text, icon, or dynamic image. See softButtonType - - - Optional text to display (if defined as TEXT or BOTH) - - - Optional image struct for SoftButton (if defined as IMAGE or BOTH) - - - - True, if highlighted - False, if not highlighted - - - - Value which is returned via OnButtonPress / OnButtonEvent - - - Parameter indicating whether selecting a SoftButton shall call a specific system action. This is intended to allow Notifications to bring the callee into full / focus; or in the case of persistent overlays, the overlay can persist when a SoftButton is pressed. - - - - - A choice is an option given to the user, which can be selected either by menu, or through voice recognition system. - - - - - - - - - - Optional secondary text to display; e.g. address of POI in a search result entry - - - Optional tertiary text to display; e.g. distance to POI for a search result entry - - - Optional secondary image struct for choice - - - - - - Text to display for VR Help item - - - Image struct for VR Help item - - - Position to display item in VR Help list - - - - - Specifies the version number of the SmartDeviceLink protocol that is supported by the mobile application - - - The major version indicates versions that is not-compatible to previous versions. - - - The minor version indicates a change to a previous version that should still allow to be run on an older version (with limited functionality) - - - The patch version indicates a fix to existing functionality in a previous version that should still be able to be run on an older version - - - - - The different global properties. - - Location of the user's seat of setGlobalProperties - - - The property helpPrompt of setGlobalProperties - - - The property timeoutPrompt of setGlobalProperties - - - The property vrHelpTitle of setGlobalProperties - - - The property array of vrHelp of setGlobalProperties - - - The property in-app menu name of setGlobalProperties - - - The property in-app menu icon of setGlobalProperties - - - The on-screen keyboard configuration of setGlobalProperties - - - - - The list of potential compass directions - - - - - - - - - - - - - - - - - - - - The supported dimensions of the GPS - - No GPS at all - - - Longitude and latitude - - - Longitude and latitude and altitude - - - - - The selected gear. - - Parking - - - Reverse gear - - - No gear - - - - - Drive Sport mode - - - 1st gear hold - - - - - - - - - - - - - - - - - - - - - - - - - The volume status of a vehicle component. - - - - - - - - - - - - - - - - - If set the status of the tire is not known. - - - TPMS does not function. - - - The sensor of the tire does not function. - - - TPMS is reporting a low tire pressure for the tire. - - - TPMS is active and the tire pressure is monitored. - - - TPMS is reporting that the tire must be trained. - - - TPMS reports the training for the tire is completed. - - - TPMS reports the tire is not trained. - - - - - - - - - For vehicles using compressed natural gas. - - - - - For vehicles using liquefied petroleum gas. - - - - For FCEV (fuel cell electric vehicle). - - - For BEV (Battery Electric Vehicle), PHEV (Plug-in Hybrid Electric Vehicle), solar vehicles and other vehicles which run on a battery. - - - - - - - - The estimate range in KM the vehicle can travel based on fuel level and consumption. - - - - - - - - Park brake actuators have been fully applied. - - - - - Park brake actuators are transitioning to either Apply/Closed or Release/Open state. - - - - - Park brake actuators are released. - - - - - When driver pulls the Electronic Park Brake switch while driving "at speed". - - - - - When system has a fault or is under maintenance. - - - - - - - See ComponentVolumeStatus. - - - - The status of TPMS according to the particular tire. - - - - The pressure value of the particular tire in kilo pascal. - - - - - Reflects the status of a cluster instrument warning light. - - - - - - - - - - - - Reflects the status of a vehicle data notification. - - - - - - - - - - - - Reflects the ignition switch stability. - - - - - - - - - - Reflects the status of ignition. - - - - - - - - - - - - - - - - Reflects the status of a vehicle data event; e.g. a seat belt event status. - - - - - - - - - - - - - - Reflects the reported battery status of the connected device, if reported. - - - - - - - - - - - - - - - - Reflects the current primary audio source (if selected). - - - - - - - - - - - - - - - - - - - - - - - - - - - - Reflects the status of the wipers. - - - - - - - - - - - - - - - - - - - Reflects the status of a binary vehicle data item. - - - - - - - - - - Reflects the status of a vehicle maintenance mode. - - - - - - - - - - - - Reflects the status of given vehicle component. - - - - - - - - - - - - - - Reflects the status of the ambient light sensor. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - References signal "VedsDrvBelt_D_Ltchd". See VehicleDataEventStatus. - - - References signal "VedsPasBelt_D_Ltchd". See VehicleDataEventStatus. - - - References signal "VedsRw1PasBckl_D_Ltchd". See VehicleDataEventStatus. - - - References signal "VedsRw1DrvBckl_D_Ltchd". See VehicleDataEventStatus. - - - References signal "VedsRw2lBckl_D_Ltchd". See VehicleDataEventStatus. - - - References signal "VedsRw1PasChld_D_Ltchd". See VehicleDataEventStatus. - - - References signal "VedsRw2rBckl_D_Ltchd". See VehicleDataEventStatus. - - - References signal "VedsRw2mBckl_D_Ltchd". See VehicleDataEventStatus. - - - References signal "VedsRw3mBckl_D_Ltchd". See VehicleDataEventStatus. - - - References signal "VedsRw3lBckl_D_Ltchd". See VehicleDataEventStatus. - - - References signal "VedsRw3rBckl_D_Ltchd". See VehicleDataEventStatus. - - - References signal "VedsRw2lRib_D_Ltchd". See VehicleDataEventStatus. - - - References signal "VedsRw2rRib_D_Ltchd". See VehicleDataEventStatus. - - - References signal "VedsRw1mBelt_D_Ltchd". See VehicleDataEventStatus. - - - References signal "VedsRw1mBckl_D_Ltchd". See VehicleDataEventStatus. - - - - - - References signal "PrkBrkActv_B_Actl". - - - References signal "Ignition_Switch_Stable". See IgnitionStableStatus. - - - References signal "Ignition_status". See IgnitionStatus. - - - References signal "DrStatDrv_B_Actl". - - - References signal "DrStatPsngr_B_Actl". - - - References signal "DrStatRl_B_Actl". - - - References signal "DrStatRr_B_Actl". - - - - - - References signal "CPM_VoiceRec_STAT". - - - References signal "BT_ICON". - - - References signal "CPM_Call_Active_STAT". - - - References signal "CPM_Phone_Roaming_STAT". - - - References signal "CPM_TextMsg_AVAL". - - - Device battery level status. References signal "CPM_Batt_Level_STAT". See DeviceLevelStatus. - - - References signal "CPM_Stereo_Audio_Output". - - - References signal "CPM_Mono_Audio_Output". - - - Device signal level status. References signal "CPM_Signal_Strength_STAT". See DeviceLevelStatus. - - - References signal "CPM_Stereo_PAS_Source". See PrimaryAudioSource. - - - References signal "eCall_Event". - - - - - - Status of the low beam lamps. References signal "HeadLampLoActv_B_Stat". - - - Status of the high beam lamps. References signal "HeadLghtHiOn_B_Stat". - - - Status of the ambient light sensor. - - - - - Contains detailed information about the registered application. - - - The name displayed for the mobile application on the mobile device (can differ from the app name set in the initial RAI request). - - - - The AppBundleID of an iOS application or package name of the Android application. This supports App Launch strategies for each platform. - - - - Represents the build version number of this particular mobile app. - - - - A file reference to the icon utilized by this app (simplifies the process of setting an app icon during app registration). - - - - - Enumeration listing possible file types. - - - - - - - - - - - - Reflects the status of the RCM fuel cutoff. - - - - - - - - - - Reflects the emergency event status of the vehicle. - - - - - - - - - - - - - - - - - - Reflects the status of the eCall Notification. - - - - - - - - - - - - - - - - - - Reflects the status of the current power mode qualification. - - - - - - - - - - - - Reflects the status of the current power mode. - - - - - - - - - - - - - - - - - - - - - - Reflects the status of the current car mode. - - - - - - - - - - - - - References signal "eCallNotification_4A". See VehicleDataNotificationStatus. - - - References signal "eCallNotification". See VehicleDataNotificationStatus. - - - References signal "eCallConfirmation". See ECallConfirmationStatus. - - - - - - References signal "VedsDrvBag_D_Ltchd". See VehicleDataEventStatus. - - - References signal "VedsDrvSideBag_D_Ltchd". See VehicleDataEventStatus. - - - References signal "VedsDrvCrtnBag_D_Ltchd". See VehicleDataEventStatus. - - - References signal "VedsPasBag_D_Ltchd". See VehicleDataEventStatus. - - - References signal "VedsPasCrtnBag_D_Ltchd". See VehicleDataEventStatus. - - - References signal "VedsKneeDrvBag_D_Ltchd". See VehicleDataEventStatus. - - - References signal "VedsPasSideBag_D_Ltchd". See VehicleDataEventStatus. - - - References signal "VedsKneePasBag_D_Ltchd". See VehicleDataEventStatus. - - - - - - References signal "VedsEvntType_D_Ltchd". See EmergencyEventType. - - - References signal "RCM_FuelCutoff". See FuelCutoffStatus. - - - References signal "VedsEvntRoll_D_Ltchd". See VehicleDataEventStatus. - - - - - References signal "VedsMaxDeltaV_D_Ltchd". Change in velocity in KPH. Additional reserved values: - 0x00 No event - 0xFE Not supported - 0xFF Fault - - - - References signal "VedsMultiEvnt_D_Ltchd". See VehicleDataEventStatus. - - - - - - References signal "PowerMode_UB". - - - References signal "PowerModeQF". See PowerModeQualificationStatus. - - - References signal "CarMode". See CarMode. - - - References signal "PowerMode". See PowerMode. - - - - - - Indicates whether e911 override is on. References signal "MyKey_e911Override_St". See VehicleDataStatus. - - - - - Enumeration that describes possible result codes of a vehicle data entry request. - - Individual vehicle data item / DTC / DID request or subscription successful - - - DTC / DID request successful, however, not all active DTCs or full contents of DID location available - - - This vehicle data item is not allowed for this app by the OEM/Manufactorer of the connected module. - - - The user has not granted access to this type of vehicle data item at this time. - - - The ECU ID referenced is not a valid ID on the bus / system. - - - The requested vehicle data item / DTC / DID is not currently available or responding on the bus / system. - - - The vehicle data item is already subscribed. - - - The vehicle data item cannot be unsubscribed because it is not currently subscribed. - - - The request for this item is ignored because it is already in progress. - - - - - The status and pressure of the tires. - - - Status of the Tire Pressure Telltale. See WarningLightStatus. - - - The status of the left front tire. - - - The status of the right front tire. - - - The status of the left rear tire. - - - The status of the right rear tire. - - - The status of the inner left rear. - - - The status of the inner right rear. - - - - - Enumeration that describes the status of the turn light indicator. - - Turn signal is OFF - - - Left turn signal is on - - - Right turn signal is on - - - Both signals (left and right) are on. - - - - - How the main menu or submenu is laid out on screen - - - - - - Struct with the GPS data. - - - - - - The current UTC year. - - - - - - The current UTC month. - - - - - - The current UTC day. - - - - - - The current UTC hour. - - - - - - The current UTC minute. - - - - - - The current UTC second. - - - - - - See CompassDirection. - - - - - - PDOP. If undefined or unavailable, then value shall be set to 0. - - - - - - HDOP. If value is unknown, value shall be set to 0. - - - - - - VDOP. If value is unknown, value shall be set to 0. - - - - - - - True, if actual. - False, if inferred. - - - - - - - Number of satellites in view - - - - - - See Dimension - - - - - - Altitude in meters - - - - - - The heading. North is 0. Resolution is 0.01 - - - - - - The speed in KPH - - - - - - - True, if GPS lat/long, time, and altitude have been purposefully shifted (requires a proprietary algorithm to unshift). - False, if the GPS data is raw and un-shifted. - If not provided, then value is assumed False. - - - - - - Individual published data request result - - Defined published data element type. - - - Published data result code. - - - Type of requested oem specific parameter - - - - - Individual requested DID result and data - - Individual DID result code. - - - Location of raw data from vehicle data DID - - - Raw DID-based data returned for requested element. - - - - - - - The hour of the media clock. - Some radios only support a max of 19 hours. If out of range, it will be rejected. - - - - - - - - - The name that identifies the field. See TextFieldName. - - - The character set that is supported in this field. See CharacterSet. - - - The number of characters in one row of this field. - - - The number of rows of this field. - - - - - - The image resolution width. - - - The image resolution height. - - - - - - The name that identifies the field. See ImageFieldName. - - - The image types that are supported in this field. See FileType. - - - The image resolution of this field. - - - - - - The x coordinate of the touch. - - - The y coordinate of the touch. - - - - - - - - - - - - - - A touch's unique identifier. The application can track the current touch events by id. - If a touch event has type begin, the id should be added to the set of touches. - If a touch event has type end, the id should be removed from the set of touches. - - - - - The time that the touch was recorded. This number can the time since the beginning of the session or something else as long as the units are in milliseconds. - The timestamp is used to determined the rate of change of position of a touch. - The application also uses the time to verify whether two touches, with different ids, are part of a single action by the user. - If there is only a single timestamp in this array, it is the same for every coordinate in the coordinates array. - - - - - - - - - - - - - - - - - - The resolution of the prescribed screen area. - - - Types of screen touch events available in screen area. - - - - - Enumeration that describes possible permission states of a policy table entry. - - - - - - - - - A set of all HMI levels that are permitted for this given RPC. - - - A set of all HMI levels that are prohibited for this given RPC. - - - - - - A set of all parameters that are permitted for this given RPC. - - - A set of all parameters that are prohibited for this given RPC. - - - - - - Name of the individual RPC in the policy table. - - - - - - - - - - - Contains information about the display capabilities. This struct is deprecated; please see the new SystemCapability DISPLAYS and corresponding struct DisplayCapability - - The type of the display. See DisplayType - - - - - - The name of the display the app is connected to. - - - A set of all fields that support text data. See TextField - - - A set of all fields that support images. See ImageField - - - A set of all supported formats of the media clock. See MediaClockFormat - - - The display's persistent screen supports referencing a static or dynamic image. - - - A set of all predefined persistent display templates available on headunit. To be referenced in SetDisplayLayout. - - - A set of all parameters related to a prescribed screen area (e.g. for video / touch input). - - - The number of on-screen custom presets available (if any); otherwise omitted. - - - - - - Describes a location (origin coordinates and span) of a vehicle component. - - - - - - - - - - - - - - - - Information about a RC module - - uuid of a module. "moduleId + moduleType" uniquely identify a module. - - - Location of a module. - - - Service area of a module. - - - allow multiple users/apps to access the module or not - - - - - Contains information about a button's capabilities. - - The name of the button. See ButtonName. - - - Information about a RC module, including its id. - - - - The button supports a short press. - Whenever the button is pressed short, onButtonPressed( SHORT) will be invoked. - - - - - The button supports a LONG press. - Whenever the button is pressed long, onButtonPressed( LONG) will be invoked. - - - - - The button supports "button down" and "button up". - Whenever the button is pressed, onButtonEvent( DOWN) will be invoked. - Whenever the button is released, onButtonEvent( UP) will be invoked. - - - - - - Contains information about a SoftButton's capabilities. - - - The button supports a short press. - Whenever the button is pressed short, onButtonPressed( SHORT) will be invoked. - - - - - The button supports a LONG press. - Whenever the button is pressed long, onButtonPressed( LONG) will be invoked. - - - - - The button supports "button down" and "button up". - Whenever the button is pressed, onButtonEvent( DOWN) will be invoked. - Whenever the button is released, onButtonEvent( UP) will be invoked. - - - - The button supports referencing a static or dynamic image. - - - - The button supports the use of text. - If not included, the default value should be considered true that the button will support text. - - - - - - Contains information about on-screen preset capabilities. - - Onscreen custom presets are available. - - - - - - - The specified ID of the window. This ID is either one used when sending the CreateWindow request, - or one of the predefined window ID values from the enum PredefinedWindows. If ommited, value is - assumed to be the main window on the main display. - - - - A set of all fields that support text data. See TextField - - - A set of all fields that support images. See ImageField - - - Provides information about image types supported by the system. - - - A set of all window templates available on the head unit. - - - The number of on-window custom presets available (if any); otherwise omitted. - - - The number of buttons and the capabilities of each on-window button. - - - The number of soft buttons available on-window and the capabilities for each button. - - - An array of available menu layouts. If this parameter is not provided, only the `LIST` layout is assumed to be available - - - - - - - - - - - - - Informs the application how many windows the app is allowed to create per type. - - - - - Contains a list of capabilities of all windows related to the app. - Once the app has registered the capabilities of all windows are provided. - GetSystemCapability still allows requesting window capabilities of all windows. - After registration, only windows with capabilities changed will be included. Following cases will cause only affected windows to be included: - 1. App creates a new window. After the window is created, a system capability notification will be sent related only to the created window. - 2. App sets a new layout to the window. The new layout changes window capabilties. The notification will reflect those changes to the single window. - - - - - - - Availability of build in Nav. True: Available, False: Not Available - - - Availability of build in phone. True: Available, False: Not Available - - - Availability of video streaming. - - - Availability of remote control feature. True: Available, False: Not Available - - - Availability of App Services functionality. True: Available, False: Not Available - - - Availability of displays capability. True: Available, False: Not Available - - - Availability of seat location feature. True: Available, False: Not Available - - - - - - - unique ID of the sub menu, the command will be added to. - If not provided, it will be provided to the top level of the in application menu. - - - - - Position within the items that are are at top level of the in application menu. - 0 will insert at the front. - 1 will insert at the second position. - if position is greater or equal than the number of items on top level, the sub menu will be appended to the end. - If this param was omitted the entry will be added at the end. - - - - Text to show in the menu for this sub menu. - - - - - A TTS chunk, that consists of text/phonemes to speak or the name of a file to play, and a TTS type (like text or SAPI) - - - The text or phonemes to speak, or the name of the audio file to play. - May not be empty. - - - - - Describes whether the TTS chunk is plain text, a specific phoneme set, or an audio file. See SpeechCapabilities - - - - - - Individual turn text. Must provide at least text or icon for a given turn. - - - Individual turn icon. Must provide at least text or icon for a given turn. - - - - - - Make of the vehicle, e.g. Ford - - - Model of the vehicle, e.g. Fiesta - - - Model Year of the vehicle, e.g. 2013 - - - Trim of the vehicle, e.g. SE - - - - - Enumeration listing possible keyboard layouts. - - - - - - - Enumeration listing possible keyboard events. - - - - - - - - - Enumeration listing possible keyboard events. - - Each keypress is individually sent as the user presses the keyboard keys. - - - The keypresses are queued and a string is eventually sent once the user chooses to submit their entry. - - - The keypresses are queue and a string is sent each time the user presses a keyboard key; the string contains the entire current entry. - - - - - Configuration of on-screen keyboard (if available). - - The keyboard language. - - - Desired keyboard layout. - - - - Desired keypress mode. - If omitted, this value will be set to RESEND_CURRENT_ENTRY. - - - - Array of keyboard characters to enable. - All omitted characters will be greyed out (disabled) on the keyboard. - If omitted, the entire keyboard will be enabled. - - - Deprecated, use autoCompleteList instead. - - - - - - - Allows an app to prepopulate the text field with a list of suggested or completed entries as the user types. - If empty, the auto-complete list will be removed from the screen. - - - - - - Various information about connecting device. - - Device model - - - Device firmware revision - - - Device OS - - - Device OS version - - - Device mobile carrier (if applicable) - - - Omitted if connected not via BT. - - - - - Enumeration listing possible asynchronous requests. - - - - - - - - - - - - - - - - - - - - - - - - - - Enumeration listing possible app types. - - - - - - - - - - - - - - - - Predefined screen layout. - - - Default media / non-media screen. - Can be set as a root screen. - - - - - Default Media screen. - Can be set as a root screen. - - - - - Default Non-media screen. - Can be set as a root screen. - - - - - Custom root media screen containing app-defined onscreen presets. - Can be set as a root screen. - - - - - Custom root template screen containing full screen map with navigation controls. - Can be set as a root screen. - - - - - Custom root template screen containing video represented list. - Can be set as a root screen. - - - - - Custom root template screen containing video represented keyboard. - Can be set as a root screen. - - - - - Custom root template screen containing half-screen graphic with lines of text. - Can be set as a root screen. - - - - - Custom root template screen containing lines of text with half-screen graphic. - Can be set as a root screen. - - - - - Custom root template screen containing only tiled SoftButtons. - Can be set as a root screen. - - - - - Custom root template screen containing only text SoftButtons. - Can be set as a root screen. - - - - - Custom root template screen containing half-screen graphic with tiled SoftButtons. - Can be set as a root screen. - - - - - Custom root template screen containing tiled SoftButtons with half-screen graphic. - Can be set as a root screen. - - - - - Custom root template screen containing half-screen graphic with text and SoftButtons. - Can be set as a root screen. - - - - - Custom root template screen containing text and SoftButtons with half-screen graphic. - Can be set as a root screen. - - - - - Custom root template screen containing half-screen graphic with text only SoftButtons. - Can be set as a root screen. - - - - - Custom root template screen containing text only SoftButtons with half-screen graphic. - Can be set as a root screen. - - - - - Custom root template screen containing a large graphic and SoftButtons. - Can be set as a root screen. - - - - - Custom root template screen containing two graphics and SoftButtons. - Can be set as a root screen. - - - - - Custom root template screen containing only a large graphic. - Can be set as a root screen. - - - - - - Enumeration linking function names with function IDs in SmartDeviceLink protocol. Assumes enumeration starts at value 0. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Enumeration linking message types with function types in WiPro protocol. - Assumes enumeration starts at value 0. - - - - - - - - - Milliseconds - - - Seconds part of time - - - - - - Minutes part of time - - - - - - Hours part of time. Note that this structure accepts time only in 24 Hr format - - - - - - Day of the month - - - - - - Month of the year - - - - - - The year in YYYY format - - - - - - Time zone offset in Hours wrt UTC. - - - - - - Time zone offset in Min wrt UTC. - - - - - - - - Describes what kind of waypoint is requested/provided. - - - - - - - Latitude of the location. - - - Longitude of the location. - - - - - - Name of the country (localized) - - - Name of country (ISO 3166-2) - - - (PLZ, ZIP, PIN, CAP etc.) - - - Portion of country (e.g. state) - - - Portion of e.g. state (e.g. county) - - - Hypernym for e.g. city/village - - - Hypernym for e.g. district - - - Hypernym for street, road etc. - - - Portion of thoroughfare e.g. house number - - - - - - Latitude/Longitude of the location. - - - Name of location. - - - Location address for display purposes only - - - Description intended location / establishment (if applicable) - - - Phone number of location / establishment. - - - Image / icon of intended location. - - - Address to be used by navigation engines for search - - - - - Enumerations of all available system capability types - - - - - - - - - - - Extended capabilities for an onboard navigation system - - If the module has the ability to add locations to the onboard nav - - - If the module has the ability to return way points from onboard nav - - - - - Extended capabilities of the module's phone feature - - If the module has the ability to perform dial number - - - - - Video streaming formats and their specifications. - - Protocol type, see VideoStreamingProtocol - - - Codec type, see VideoStreamingCodec - - - - - Contains information about this system's video streaming capabilities. - - The preferred resolution of a video stream for decoding and rendering on HMI. - - - The maximum bitrate of video stream that is supported, in kbps. - - - Detailed information on each format supported by this system, in its preferred order (i.e. the first element in the array is most preferable to the system). Each object will contain a VideoStreamingFormat that describes what can be expected. - - - True if the system can utilize the haptic spatial data from the source being streamed. If not included, it can be assumed the module doesn't support haptic spatial data'. - - - The diagonal screen size in inches. - - - PPI is the diagonal resolution in pixels divided by the diagonal screen size in inches. - - - The scaling factor the app should use to change the size of the projecting view. - - - - - - - - - - - - A color scheme for all display layout templates. - - - The primary "accent" color - - - The secondary "accent" color - - - The color of the background - - - - - - - Predefined or dynamically created window template. - Currently only predefined window template layouts are defined. - - - - - - - - - - Describes the location of a seat. - - - - - - Contains information about the locations of each seat - - - - - - Contains a list of SeatLocation in the vehicle - - - - - List possible zones of a multi-contour massage seat. - - The back of a multi-contour massage seat. or SEAT_BACK - - - The bottom a multi-contour massage seat. or SEAT_BOTTOM - - - - - List possible modes of a massage zone. - - - - - - - Specify the mode of a massage zone. - - - - - - List possible cushions of a multi-contour massage seat. - - - - - - - - - The intensity or firmness of a cushion. - - - - - - - Save current seat postions and settings to seat memory. - - - Restore / apply the seat memory settings to the current seat. - - - No action to be performed. - - - - - - - - - - - List possible seats that is a remote controllable seat. - - - - - - - - - Seat control data corresponds to "SEAT" ModuleType. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The short friendly name of the light control module. - It should not be used to identify a module by mobile application. - - - - Information about a RC module, including its id. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Temperature Unit - - - Temperature Value in TemperatureUnit specified unit. Range depends on OEM and is not checked by SDL. - - - - - - Program Service Name - - - Radio Text - - - The clock text in UTC format as YYYY-MM-DDThh:mm:ss.sTZD - - - Program Identification - the call sign for the radio station - - - The program type - The region should be used to differentiate between EU and North America program types - - - Traffic Program Identification - Identifies a station that offers traffic - - - Traffic Announcement Identification - Indicates an ongoing traffic announcement - - - Region - - - - - - Binary Representation of ITU Country Code. USA Code is 001. - - - Binary representation of unique facility ID assigned by the FCC; FCC controlled for U.S. territory - - - - - - Identifies the 4-alpha-character station call sign plus an optional (-FM) extension - - - Used for network Application. Consists of Country Code and FCC Facility ID. - - - Identifies the station call sign or other identifying information in the long format. - - - Provides the 3-dimensional geographic station location. - - - May be used to convey textual information of general interest to the consumer such as weather forecasts or public service announcements. Includes a high priority delivery feature to convey emergencies that may be in the listening area. - - - - - - The integer part of the frequency ie for 101.7 this value should be 101 - - - The fractional part of the frequency for 101.7 is 7 - - - - - - - True if the hd radio is on, false if the radio is off - - - Number of HD sub-channels if available - - - - - - - The list of available HD sub-channel indexes. Empty list means no Hd channel is available. Read-only. - - - Current HD sub-channel if available - - - - - - - - - If the signal strength falls below the set value for this parameter, the radio will tune to an alternative frequency - - - True if the radio is on, false if the radio is off. If set to false, no other data will be included. - - - - - Read-only Station Information Service (SIS) data provides basic information about the station such as call sign, as well as information not displayable to the consumer such as the station identification number - - - - - - - - - - - - - - - - - - - - - - - - - - value false means disabled/turn off, value true means enabled/turn on. - - - value false means disabled, value true means enabled. - - - value false means disabled, value true means enabled. - - - value false means disabled, value true means enabled. - - - True if the climate module is on, false if the climate module is off - - - - - Contains information about a radio control module's capabilities. - - - The short friendly name of the climate control module. - It should not be used to identify a module by mobile application. - - - - Information about a RC module, including its id. - - - - Availability of the control of enable/disable radio. - True: Available, False: Not Available, Not present: Not Available. - - - - - Availability of the control of radio band. - True: Available, False: Not Available, Not present: Not Available. - - - - - Availability of the control of radio frequency. - True: Available, False: Not Available, Not present: Not Available. - - - - - Availability of the control of HD radio channel. - True: Available, False: Not Available, Not present: Not Available. - - - - - Availability of the getting Radio Data System (RDS) data. - True: Available, False: Not Available, Not present: Not Available. - - - - - Availability of the getting the number of available HD channels. - True: Available, False: Not Available, Not present: Not Available. - - - - - - - - Availability of the list of available HD sub-channel indexes. - True: Available, False: Not Available, Not present: Not Available. - - - - - Availability of the getting the Radio state. - True: Available, False: Not Available, Not present: Not Available. - - - - - Availability of the getting the signal strength. - True: Available, False: Not Available, Not present: Not Available. - - - - - Availability of the getting the signal Change Threshold. - True: Available, False: Not Available, Not present: Not Available. - - - - - Availability of the getting HD radio Station Information Service (SIS) data. - True: Available, False: Not Available, Not present: Not Available. - - - - - Availability of the control of enable/disable HD radio. - True: Available, False: Not Available, Not present: Not Available. - - - - - Availability of sirius XM radio. - True: Available, False: Not Available, Not present: Not Available. - - - - - - Contains information about a climate control module's capabilities. - - The short friendly name of the climate control module. - It should not be used to identify a module by mobile application. - - - Information about a RC module, including its id. - - - - Availability of the reading of current temperature. - True: Available, False: Not Available, Not present: Not Available. - - - - - Availability of the control of fan speed. - True: Available, False: Not Available, Not present: Not Available. - - - - - Availability of the control of desired temperature. - True: Available, False: Not Available, Not present: Not Available. - - - - - Availability of the control of turn on/off AC. - True: Available, False: Not Available, Not present: Not Available. - - - - - Availability of the control of enable/disable air conditioning is ON on the maximum level. - True: Available, False: Not Available, Not present: Not Available. - - - - - Availability of the control of enable/disable circulate Air mode. - True: Available, False: Not Available, Not present: Not Available. - - - - - Availability of the control of enable/disable auto mode. - True: Available, False: Not Available, Not present: Not Available. - - - - - Availability of the control of enable/disable dual mode. - True: Available, False: Not Available, Not present: Not Available. - - - - - Availability of the control of defrost zones. - True: Available, False: Not Available, Not present: Not Available. - - - - - A set of all defrost zones that are controllable. - - - - - Availability of the control of air ventilation mode. - True: Available, False: Not Available, Not present: Not Available. - - - - - A set of all ventilation modes that are controllable. - - - - - Availability of the control (enable/disable) of heated Steering Wheel. - True: Available, False: Not Available, Not present: Not Available. - - - - - Availability of the control (enable/disable) of heated Windshield. - True: Available, False: Not Available, Not present: Not Available. - - - - - Availability of the control (enable/disable) of heated Rear Window. - True: Available, False: Not Available, Not present: Not Available. - - - - - Availability of the control (enable/disable) of heated Mirrors. - True: Available, False: Not Available, Not present: Not Available. - - - - - Availability of the control of enable/disable climate control. - True: Available, False: Not Available, Not present: Not Available. - - - - - - Defines the each Equalizer channel settings. - - - read-only channel / frequency name (e.i. "Treble, Midrange, Bass" or "125 Hz") - - - Reflects the setting, from 0%-100%. - - - - - - - In a getter response or a notification, it is the current primary audio source of the system. - In a setter request, it is the target audio source that the system shall switch to. - If the value is MOBILE_APP, the system shall switch to the mobile media app that issues the setter RPC. - - - - - This parameter shall not be present in any getter responses or notifications. - This parameter is optional in a setter request. The default value is false if it is not included. - If it is false, the system not only changes the audio source but also brings the default application or - system UI associated with the audio source to foreground. - If it is true, the system only changes the audio source, but keeps the current application in foreground. - - - - Reflects the volume of audio, from 0%-100%. - - - Defines the list of supported channels (band) and their current/desired settings on HMI - - - - - - - The short friendly name of the light control module. - It should not be used to identify a module by mobile application. - - - - Information about a RC module, including its id. - - - Availability of the control of audio source. - - - Availability of the keepContext parameter. - - - Availability of the control of audio volume. - - - Availability of the control of Equalizer Settings. - - - Must be included if equalizerAvailable=true, and assume all IDs starting from 1 to this value are valid - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Include all high beam lights: front_left and front_right. - - - Include all low beam lights: front_left and front_right. - - - Include all fog lights: front_left, front_right, rear_left and rear_right. - - - Include all daytime running lights: front_left and front_right. - - - Include all parking lights: front_left and front_right. - - - Include all brake lights: rear_left and rear_right. - - - - - Include all left turn signal lights: front_left, rear_left, left_side and mirror_mounted. - - - Include all right turn signal lights: front_right, rear_right, right_side and mirror_mounted. - - - Include all hazard lights: front_left, front_right, rear_left and rear_right. - - - Cargo lamps illuminate the cargo area. - - - Truck bed lamps light up the bed of the truck. - - - Trailer lights are lamps mounted on a trailer hitch. - - - It is the spotlights mounted on the left side of a vehicle. - - - It is the spotlights mounted on the right side of a vehicle. - - - Puddle lamps illuminate the ground beside the door as the customer is opening or approaching the door. - - - Puddle lamps illuminate the ground beside the door as the customer is opening or approaching the door. - - - - - - - - - - - Include exterior lights located in front of the vehicle. For example, fog lights and low beams. - - - Include exterior lights located at the back of the vehicle. For example, license plate lights, reverse lights, cargo lights, bed lights and trailer assist lights. - - - Include exterior lights located at the left side of the vehicle. For example, left puddle lights and spot lights. - - - Include exterior lights located at the right side of the vehicle. For example, right puddle lights and spot lights. - - - Include all exterior lights around the vehicle. - - - - - - - - - - - - - - - - - Indicates if the status (ON/OFF) can be set remotely. App shall not use read-only values (RAMP_UP/RAMP_DOWN/UNKNOWN/INVALID) in a setInteriorVehicleData request. - - - - - Indicates if the light's density can be set remotely (similar to a dimmer). - - - - - Indicates if the light's color can be set remotely by using the sRGB color space. - - - - - - - - The short friendly name of the light control module. - It should not be used to identify a module by mobile application. - - - - Information about a RC module, including its id. - - - An array of available LightCapabilities that are controllable. - - - - - - The name of a light or a group of lights. - - - - - - - - - An array of LightNames and their current or desired status. No change to the status of the LightNames that are not listed in the array. - - - - - - - - - - - - - - - - Corresponds to "HMI_SETTINGS" ModuleType - - - - - - - - - The short friendly name of the hmi setting module. - It should not be used to identify a module by mobile application. - - - - Information about a RC module, including its id. - - - Availability of the control of distance unit. - - - Availability of the control of temperature unit. - - - Availability of the control of HMI display mode. - - - - - The moduleType indicates which type of data should be changed and identifies which data object exists in this struct. For example, if the moduleType is CLIMATE then a "climateControlData" should exist - - - - Id of a module, published by System Capability. - - - - - - - - - - - - - - - - - - If included, the platform supports RC climate controls. For this baseline version, maxsize=1. i.e. only one climate control module is supported. - - - If included, the platform supports RC radio controls.For this baseline version, maxsize=1. i.e. only one radio control module is supported. - - - If included, the platform supports RC button controls with the included button names. - - - If included, the platform supports audio controls. - - - If included, the platform supports hmi setting controls. - - - If included, the platform supports light controls. - - - If included, the platform supports seat controls. - - - - - - - - The data in this field contains the title of the currently playing audio track. - - - The data in this field contains the artist or creator of the currently playing audio track. - - - The data in this field contains the album title of the currently playing audio track. - - - The data in this field contains the creation year of the currently playing audio track. - - - The data in this field contains the genre of the currently playing audio track. - - - The data in this field contains the name of the current source for the media. - - - The data in this field is a rating. - - - The data in this field is the current temperature. - - - The data in this field is the maximum temperature for the day. - - - The data in this field is the minimum temperature for the day. - - - The data in this field describes the current weather (ex. cloudy, clear, etc.). - - - The data in this field describes the current humidity value. - - - - - - The type of data contained in the "mainField1" text field. - - - The type of data contained in the "mainField2" text field. - - - The type of data contained in the "mainField3" text field. - - - The type of data contained in the "mainField4" text field. - - - - - - The upper left X-coordinate of the rectangle - - - The upper left Y-coordinate of the rectangle - - - The width of the rectangle - - - The height of the rectangle - - - - - Defines haptic data for each user control object for video streaming application - - A user control spatial identifier - - - The position of the haptic rectangle to be highlighted. The center of this rectangle will be "touched" when a press occurs. - - - - - - - - - - - - - - - - - - - - - - - This data is related to what a media service should provide - - - The type of the currently playing or paused track. - - - - - Music: The name of the current track - Podcast: The name of the current episode - Audiobook: The name of the current chapter - - - - - - Music: The name of the current album artist - Podcast: The provider of the podcast (hosts, network, company) - Audiobook: The book author's name - - - - - - Music: The name of the current album - Podcast: The name of the current podcast show - Audiobook: The name of the current book - - - - - - Music: The name of the playlist or radio station, if the user is playing from a playlist, otherwise, Null - Podcast: The name of the playlist, if the user is playing from a playlist, otherwise, Null - Audiobook: Likely not applicable, possibly a collection or "playlist" of books - - - - - Whether or not the content currently playing (e.g. the track, episode, or book) contains explicit content - - - - - Music: The current progress of the track in seconds - Podcast: The current progress of the episode in seconds - Audiobook: The current progress of the current segment (e.g. the chapter) in seconds - - - - - - Music: The total duration of the track in seconds - Podcast: The total duration of the episode in seconds - Audiobook: The total duration of the current segment (e.g. the chapter) in seconds - - - - - - Music: The current progress of the playback queue in seconds - Podcast: The current progress of the playback queue in seconds - Audiobook: The current progress of the playback queue (e.g. the book) in seconds - - - - - - Music: The total duration of the playback queue in seconds - Podcast: The total duration of the playback queue in seconds - Audiobook: The total duration of the playback queue (e.g. the book) in seconds - - - - - - Music: The current number (1 based) of the track in the playback queue - Podcast: The current number (1 based) of the episode in the playback queue - Audiobook: The current number (1 based) of the episode in the playback queue (e.g. the chapter number in the book) - - - - - - Music: The total number of tracks in the playback queue - Podcast: The total number of episodes in the playback queue - Audiobook: The total number of sections in the playback queue (e.g. the number of chapters in the book) - - - - - Music: The album art of the current track - Podcast: The podcast or chapter artwork of the current podcast episode - Audiobook: The book or chapter artwork of the current audiobook - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 to 1, percentage humidity - - - 0 to 1, percentage cloud cover - - - 0 to 1, percentage of the moon seen, e.g. 0 = no moon, 0.25 = quarter moon - - - - In degrees, true north at 0 degrees - - - km/hr - - - km/hr - - - - In degrees, true north at 0 degrees - - - In km - - - cm - - - cm of water per hour - - - 0 to 1, percentage chance - - - e.g. "rain", "snow", "sleet", "hail" - - - In km - - - - - - - This data is related to what a weather service would provide - - - - - - - This array should be ordered with the first object being the current day - - - - - - Informs the subscriber if this service can actually accept way points. - - - - - - Using this action plus a supplied direction can give the type of turn. - - - - - - - - - - - - A junction that represents a standard intersection with a single road crossing another. - - - A junction where the road splits off into two paths; a fork in the road. - - - A junction that has multiple intersections and paths. - - - A junction where traffic moves in a single direction around a central, non-traversable point to reach one of the connecting roads. - - - Similar to a roundabout, however the center of the roundabout is fully traversable. Also known as a mini-roundabout. - - - A junction where lefts diverge to the right, then curve to the left, converting a left turn to a crossing maneuver. - - - Multiple way intersection that allows traffic to flow based on priority; most commonly right of way and first in, first out. - - - A junction designated for traffic turn arounds. - - - - - - - - - - - - - - - - - The angle at which this instruction takes place. For example, 0 would mean straight, less than 45 is bearing right, greater than 135 is sharp right, between 45 and 135 is a regular right, and 180 is a U-Turn, etc. - - - - - - Used to infer which side of the road this instruction takes place. For a U-Turn (action=TURN, bearing=180) this will determine which direction the turn should take place. - - - - This is a string representation of this instruction, used to display instructions to the users. This is not intended to be read aloud to the users, see the param prompt in NavigationServiceData for that. - - - - An image representation of this instruction. - - - - - This data is related to what a navigation service would provide. - - - This is the timestamp of when the data was generated. This is to ensure any time or distance given in the data can accurately be adjusted if necessary. - - - - - - - - This array should be ordered with all remaining instructions. The start of this array should always contain the next instruction. - - - - - The distance to this instruction from current location. This should only be updated ever .1 unit of distance. For more accuracy the consumer can use the GPS location of itself and the next instruction. - - - Distance till next maneuver (starting from) from previous maneuver. - - - - This is a prompt message that should be conveyed to the user through either display or voice (TTS). This param will change often as it should represent the following: approaching instruction, post instruction, alerts that affect the current navigation session, etc. - - - - - This manifest contains all the information necessary for the service to be published, activated, and consumers able to interact with it - - - Unique name of this service - - - - The type of service that is to be offered by this app. See AppServiceType for known enum equivalent types. Parameter is a string to allow for new service types to be used by apps on older versions of SDL Core. - - - - The icon to be associated with this service. Most likely the same as the appIcon. - - - - If true, app service consumers beyond the IVI system will be able to access this service. If false, only the IVI system will be able consume the service. If not provided, it is assumed to be false. - - - - This is the max RPC Spec version the app service understands. This is important during the RPC passthrough functionality. If not included, it is assumed the max version of the module is acceptable. - - - - This field contains the Function IDs for the RPCs that this service intends to handle correctly. This means the service will provide meaningful responses. - - - - - - - - - This is the record of an app service publisher that the module has. It should contain the most up to date information including the service's active state - - - A unique ID tied to this specific service record. The ID is supplied by the module that services publish themselves. - - - - Manifest for the service that this record is for. - - - - If true, the service is published and available. If false, the service has likely just been unpublished, and should be considered unavailable. - - - - If true, the service is the active primary service of the supplied service type. It will receive all potential RPCs that are passed through to that service type. If false, it is not the primary service of the supplied type. See servicePublished for its availability. - - - - - Contains all the current data of the app service. The serviceType will link to which of the service data objects are included in this object (e.g. if the service type is MEDIA, the mediaServiceData param should be included). - - - The type of service that is to be offered by this app. See AppServiceType for known enum equivalent types. Parameter is a string to allow for new service types to be used by apps on older versions of SDL Core. - - - - - - - - - - - The service has just been published with the module and once activated to the primary service of its type, it will be ready for possible consumption. - - - The service has just been unpublished with the module and is no longer accessible - - - The service is activated as the primary service of this type. All requests dealing with this service type will be handled by this service. - - - The service has been deactivated as the primary service of its type - - - The service has updated its manifest. This could imply updated capabilities - - - - - - Only included in OnSystemCapabilityUpdated. Update reason for service record. - - - Service record for a specific app service provider - - - - - Capabilities of app services including what service types are supported and the current state of services. - - An array of currently available services. If this is an update to the capability the affected services will include an update reason in that item - - - - - - - The systemCapabilityType identifies which data object exists in this struct. For example, if the SystemCapability Type is NAVIGATION then a "navigationCapability" should exist - - Used as a descriptor of what data to expect in this struct. The corresponding param to this enum should be included and the only other param included. - - - Describes extended capabilities for onboard navigation system - - - Describes extended capabilities of the module's phone feature - - - Describes extended capabilities of the module's phone feature - - - Describes extended capabilities of the module's phone feature - - - An array of currently available services. If this is an update to the capability the affected services will include an update reason in that item - - - Contains information about the locations of each seat - - - - - - - - - Establishes an interface with a mobile application. - Before registerAppInterface no other commands will be accepted/executed. - - - - See SyncMsgVersion - - - - - The mobile application name, e.g. "My SDL App". - Needs to be unique over all applications from the same device. - May not be empty. - May not start with a new line character. - May not interfere with any name or synonym of previously registered applications from the same device and any predefined blacklist of words (global commands) - Additional applications with the same name from the same device will be rejected. - Only characters from char set [@TODO: Create char set (character/hex value) for each ACM and refer to] are supported. - - - - - - TTS string for VR recognition of the mobile application name, e.g. "My S D L App". - Meant to overcome any failing on speech engine in properly pronouncing / understanding app name. - Needs to be unique over all applications from the same device. - May not be empty. - May not start with a new line character. - Only characters from char set [@TODO: Create char set (character/hex value) for each ACM and refer to] are supported. - - - - - - Provides an abbreviated version of the app name (if needed), that will be displayed on the NGN media screen. - If not provided, the appName is used instead (and will be truncated if too long) - Only characters from char set [@TODO: Create char set (character/hex value) for each ACM and refer to] are supported. - - - - - - Defines an additional voice recognition command. - May not interfere with any app name of previously registered applications from the same device and any predefined blacklist of words (global commands) - Only characters from char set [@TODO: Create char set (character/hex value) for each ACM and refer to] are supported. - - - - - - Indicates if the application is a media or a non-media application. - Only media applications will be able to stream audio to the module that is audible outside of the BT media source. - - - - - See Language - Current app's expected VR+TTS language - If there is a mismatch with the module, the app will be able to change this registration with changeRegistration prior to app being brought into focus. - - - - - See Language - Current app's expected display language - If there is a mismatch with the module, the app will be able to change this registration with changeRegistration prior to app being brought into focus. - - - - - - See AppHMIType - List of all applicable app HMI types stating which HMI classifications to be given to the app. - - - - - - ID used to uniquely identify current state of all app data that can persist through connection cycles (e.g. ignition cycles). - This registered data (commands, submenus, choice sets, etc.) can be reestablished without needing to explicitly reregister each piece. - If omitted, then the previous state of an app's commands, etc. will not be restored. - When sending hashID, all RegisterAppInterface parameters should still be provided (e.g. ttsName, etc.). - - - - - See DeviceInfo. - - - - ID used to validate app with policy table entries - - - ID used to validate app with policy table entries - - - - See AppInfo. - - - - - - - - The response to registerAppInterface - - - true if successful; false, if failed - - - - See Result - - - - - - - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - See SyncMsgVersion - - - - The currently active VR+TTS language on the module. See "Language" for options. - - - - The currently active display language on the module. See "Language" for options. - - - - - See DisplayCapabilities. This parameter is deprecated and replaced by SystemCapability using DISPLAYS. - - - - - - - - - See ButtonCapabilities. This parameter is deprecated and replaced by SystemCapability using DISPLAYS. - - - - - - - - - If returned, the platform supports on-screen SoftButtons; see SoftButtonCapabilities. - This parameter is deprecated and replaced by SystemCapability using DISPLAYS. - - - - - - - - - If returned, the platform supports custom on-screen Presets; see PresetBankCapabilities. - This parameter is deprecated and replaced by SystemCapability using DISPLAYS. - - - - - - - - See HmiZoneCapabilities - - - See SpeechCapabilities - - - - See PrerecordedSpeech - - - - See VrCapabilities - - - - See AudioPassThruCapability - - - - See AudioPassThruCapability - - - - Specifies the vehicle's type. See VehicleType. - - - - - Specifies the white-list of supported diagnostic modes (0x00-0xFF) capable for DiagnosticMessage requests. - If a mode outside this list is requested, it will be rejected. - - - - - Specifies the HMI's capabilities. See HMICapabilities. - - - - The SmartDeviceLink version. - - - - The software version of the system that implements the SmartDeviceLink core. - - - - - Existence of apps icon at system. If true, apps icon - was resumed at system. If false, apps icon is not resumed at system - - - - - - - Closes an interface from a mobile application. - After unregisterAppInterface, no commands other than registerAppInterface will be accepted/executed. - Will fail, if no registerAppInterface was completed successfully before. - - - - - - - true if successful; false, if failed - - - - See Result - - - - - - - - - - Provides additional human readable info regarding the result. - - - - - - - Create a new window on the display with the specified window type. - - - - A unique ID to identify the window. The value of '0' will always be the default main window on the main display and should not be used in this context as it will already be created for the app. See PredefinedWindows enum. Creating a window with an ID that is already in use will be rejected with `INVALID_ID`. - - - - - - The window name to be used by the HMI. The name of the pre-created default window will match the app name. - Multiple apps can share the same window name except for the default main window. - Creating a window with a name which is already in use by the app will result in `DUPLICATE_NAME`. - - - - - The type of the window to be created. Main window or widget. - - - - - Allows an app to create a widget related to a specific service type. - As an example if a `MEDIA` app becomes active, this app becomes audible and is allowed to play audio. Actions such as skip or play/pause will be - directed to this active media app. In case of widgets, the system can provide a single "media" widget which will act as a placeholder for the active media app. - - It is only allowed to have one window per service type. This means that a media app can only have a single MEDIA widget. Still the app can create widgets omitting this parameter. Those widgets would be available as app specific widgets that are permanently included in the HMI. - - This parameter is related to widgets only. The default main window, which is pre-created during app registration, will be created based on the HMI types specified in the app registration request. - - - - - Optional parameter. Specify whether the content sent to an existing window - should be duplicated to the created window. - If there isn't a window with the ID, the request will be rejected with `INVALID_DATA`. - - - - - - - true if successful; false, if failed. - - - - Provides additional human readable info regarding the result. - - - - See Result - - - - - - - - - - - - - - - - Deletes previously created window of the SDL application. - - - - A unique ID to identify the window. The value of '0' will always be the default main window on the main display and cannot be deleted. - See PredefinedWindows enum. - - - - - - - true if successful; false, if failed. - - - - Provides additional human readable info regarding the result. - - - - See Result - - - - - - - - - - - - - - - Allows setting global properties. - - Location of the user's seat. Default is driver's seat location if it is not set yet. - - - - The help prompt. - An array of text chunks of type TTSChunk. See TTSChunk. - The array must have at least one item. - - - - - - Help text for a wait timeout. - An array of text chunks of type TTSChunk. See TTSChunk. - The array must have at least one item. - - - - - - VR Help Title text. - If omitted on supported displays, the default module help title shall be used. - If omitted and one or more vrHelp items are provided, the request will be rejected. - - - - - - VR Help Items. - If omitted on supported displays, the default SmartDeviceLink VR help / What Can I Say? screen shall be used. - If the list of VR Help Items contains nonsequential positions (e.g. [1,2,4]), the RPC shall be rejected. - If omitted and a vrHelpTitle is provided, the request will be rejected. - - - - Optional text to label an app menu button (for certain touchscreen platforms). - - - - Optional icon to draw on an app menu button (for certain touchscreen platforms). - - - - On-screen keyboard configuration (if available). - - - - Sets the layout of the main menu screen. If this is sent while a menu is already on-screen, the head unit will change the display to the new layout type. - - - - - - - true if successful; false, if failed - - - - See Result - - - - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - - - Allows resetting global properties. - - - Contains the names of all global properties (like timeoutPrompt) that should be unset. Resetting means, that they have the same value as at start up (default) - - - - - - - true if successful; false, if failed - - - - See Result - - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - - - Adds a command to the in application menu. - Either menuParams or vrCommands must be provided. - - - - unique ID of the command to add. - - - - Optional sub value containing menu parameters - - - - - An array of strings to be used as VR synonyms for this command. - If this array is provided, it may not be empty. - - - - - - Image struct determining whether static or dynamic icon. - If omitted on supported displays, no (or the default if applicable) icon shall be displayed. - - - - - - - - - true if successful; false, if failed - - - - See Result - - - - - - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - - - Deletes all commands from the in-application menu with the specified command id. - - - ID of the command(s) to delete. - - - - - - - true if successful; false, if failed - - - - See Result - - - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - - - Adds a sub menu to the in-application menu. - - - unique ID of the sub menu to add. - - - - - Position within the items that are are at top level of the in application menu. - 0 will insert at the front. - 1 will insert at the second position. - If position is greater or equal than the number of items on top level, the sub menu will be appended to the end. - Position of any submenu will always be located before the return and exit options - If this param was omitted the entry will be added at the end. - - - - - Text to show in the menu for this sub menu. - - - - The image field for AddSubMenu - - - - Sets the layout of the submenu screen. - - - - - - true if successful; false, if failed - - - - See Result - - - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - - Deletes a submenu from the in-application menu. - - - The "menuID" of the submenu to delete. (See addSubMenu.menuID) - - - - - - - - true if successful; false, if failed - - - - See Result - - - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - - - Shows the built in menu view - - - - If omitted the HMI opens the app's menu. - If set to a sub-menu ID the HMI opens the corresponding sub-menu previously added using `AddSubMenu`. - - - - - - - - - true if successful; false, if failed - - - - See Result - - - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - - - creates interaction choice set to be used later by performInteraction - - - Unique ID used for this interaction choice set. - - - - - - - - true if successful; false, if failed - - - - See Result - - - - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - - Triggers an interaction (e.g. "Permit GPS?" - Yes, no, Always Allow). - - - - Text to be displayed first. - - - - - - This is the initial prompt spoken to the user at the start of an interaction. - An array of text chunks of type TTSChunk. See TTSChunk. - The array must have at least one item. - - - - - See InteractionMode. - - - - List of interaction choice set IDs to use with an interaction. - - - - - Help text. This is the spoken string when a user speaks "help" when the interaction is occurring. - An array of text chunks of type TTSChunk. See TTSChunk. - The array must have at least one item. - - - - - - Timeout text. This text is spoken when a VR interaction times out. - An array of text chunks of type TTSChunk. See TTSChunk. - The array must have at least one item. - - - - - - Timeout in milliseconds. - If omitted a standard value of 10000 milliseconds is used. - Applies only to the menu portion of the interaction. The VR timeout will be handled by the platform. - - - - - - Ability to send suggested VR Help Items to display on-screen during Perform Interaction. - If omitted on supported displays, the default generated list of suggested choices shall be displayed. - - - - - See LayoutMode. - - - - - An ID for this specific PerformInteraction to allow cancellation through the `CancelInteraction` RPC. - - - - - - - - true if successful; false, if failed - - - - See Result - - - - - - - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - - ID of the choice that was selected in response to PerformInteraction. - Only is valid if general result is "success:true". - - - - - - Manually entered text selection, e.g. through keyboard - Can be returned in lieu of choiceID, depending on trigger source - - - - - - See TriggerSource - Only is valid if resultCode is SUCCESS. - - - - - - - Deletes interaction choice set that has been created with "CreateInteractionChoiceSet". - The interaction may only be deleted when not currently in use by a "performInteraction". - - - ID of the interaction choice set to delete. - - - - - - true if successful; false, if failed - - - - See Result - - - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - - Shows an alert which typically consists of text-to-speech message and text on the display. At least either alertText1, alertText2 or TTSChunks need to be provided. - - - The first line of the alert text field - - - - The second line of the alert text field - - - - The optional third line of the alert text field - - - - - An array of text chunks of type TTSChunk. See TTSChunk. - The array must have at least one item. - - - - - - Timeout in milliseconds. - Typical timeouts are 3-5 seconds. - If omitted, timeout is set to 5s. - - - - - - Defines if tone should be played. Tone is played before TTS. - If omitted, no tone is played. - - - - - - If supported on the given platform, the alert GUI will include some sort of animation indicating that loading of a feature is progressing. e.g. a spinning wheel or hourglass, etc. - - - - - - App defined SoftButtons. - If omitted on supported displays, the displayed alert shall not have any SoftButtons. - - - - - - Image struct determining whether static or dynamic icon. - If omitted on supported displays, no (or the default if applicable) icon should be displayed. - - - - - - An ID for this specific alert to allow cancellation through the `CancelInteraction` RPC. - - - - - - - - - true if successful; false, if failed - - - - See Result - - - - - - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - - Amount of time (in seconds) that an app must wait before resending an alert. - If provided, another system event or overlay currently has a higher priority than this alert. - An app must not send an alert without waiting at least the amount of time dictated. - - - - - - - Updates the persistent display. Supported fields depend on display capabilities. - - - - The text that should be displayed in a single or upper display line. - If this text is not set, the text of mainField1 stays unchanged. - If this text is empty "", the field will be cleared. - - - - - - The text that should be displayed on the second display line. - If this text is not set, the text of mainField2 stays unchanged. - If this text is empty "", the field will be cleared. - - - - - - The text that should be displayed on the second "page" first display line. - If this text is not set, the text of mainField3 stays unchanged. - If this text is empty "", the field will be cleared. - - - - - - The text that should be displayed on the second "page" second display line. - If this text is not set, the text of mainField4 stays unchanged. - If this text is empty "", the field will be cleared. - - - - - - Specifies how mainField1 and mainField2 texts should be aligned on display. - If omitted, texts will be centered. - - - - - Requires investigation regarding the nav display capabilities. Potentially lower lowerStatusBar, upperStatusBar, titleBar, etc. - - - - - Text value for MediaClock field. Has to be properly formatted by Mobile App according to the module's capabilities. - If this text is set, any automatic media clock updates previously set with SetMediaClockTimer will be stopped. - - - - - - The text that should be displayed in the track field. - If this text is not set, the text of mediaTrack stays unchanged. - If this text is empty "", the field will be cleared. - - - - - - Image struct determining whether static or dynamic image to display in app. - If omitted on supported displays, the displayed graphic shall not change. - - - - - - Image struct determining whether static or dynamic secondary image to display in app. - If omitted on supported displays, the displayed secondary graphic shall not change. - - - - - - App defined SoftButtons. - If omitted on supported displays, the currently displayed SoftButton values will not change. - - - - - - App labeled on-screen presets (i.e. on-screen media presets or dynamic search suggestions). - If omitted on supported displays, the presets will be shown as not defined. - - - - - - App defined metadata information. See MetadataStruct. Uses mainField1, mainField2, mainField3, mainField4. - If omitted on supported displays, the currently set metadata tags will not change. - If any text field contains no tags or the none tag, the metadata tag for that textfield should be removed. - - - - - - The title of the new template that will be displayed. - How this will be displayed is dependent on the OEM design and implementation of the template. - - - - - This is the unique ID assigned to the window that this RPC is intended. If this param is not included, - it will be assumed that this request is specifically for the main window on the main display. - See PredefinedWindows enum. - - - - - - Used to set an alternate template layout to a window. - - - - - - - - true if successful; false, if failed - - - - See Result - - - - - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - - Speaks a text. - - - - An array of text chunks of type TTSChunk. See TTSChunk. - The array must have at least one item. - - - - - - - - - true if successful; false, if failed - - - - See Result - - - - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - - - Sets the initial media clock value and automatic update method. - - - - See StartTime. - startTime must be provided for "COUNTUP" and "COUNTDOWN". - startTime will be ignored for "RESUME", and "CLEAR" - startTime can be sent for "PAUSE", in which case it will update the paused startTime - - - - - - See StartTime. - endTime can be provided for "COUNTUP" and "COUNTDOWN"; to be used to calculate any visual progress bar (if not provided, this feature is ignored) - If endTime is greater then startTime for COUNTDOWN or less than startTime for COUNTUP, then the request will return an INVALID_DATA. - endTime will be ignored for "RESUME", and "CLEAR" - endTime can be sent for "PAUSE", in which case it will update the paused endTime - - - - - - Enumeration to control the media clock. - In case of pause, resume, or clear, the start time value is ignored and shall be left out. For resume, the time continues with the same value as it was when paused. - - - - - - Enumeration for the indicator icon on a play/pause button. see AudioStreamingIndicator. - - - - - - - true if successful; false, if failed - - - - See Result - - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - - Starts audio pass thru session - - - The module will speak this prompt before opening the audio pass thru session. - An array of text chunks of type TTSChunk. See TTSChunk. - The array must have at least one item. - If omitted, then no initial prompt is spoken. - - - - First line of text displayed during audio capture. - - - Second line of text displayed during audio capture. - - - This value shall be allowed at 8 kHz or 16 or 22 or 44 kHz. - - - The maximum duration of audio recording in milliseconds. - - - Specifies the quality the audio is recorded. Currently 8 bit or 16 bit. - - - Specifies the type of audio data being requested. - - - - Defines if the current audio source should be muted during the APT session. If not, the audio source will play without interruption. - If omitted, the value is set to true. - - - - - - - true if successful; false, if failed - - - - See Result - - - - - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - - When this request is invoked, the audio capture stops. - - - - - true if successful; false, if failed - - - - See Result - - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - - - Subscribes to built-in HMI buttons. - The application will be notified by the OnButtonEvent and OnButtonPress. - To unsubscribe the notifications, use unsubscribeButton. - - - - Name of the button to subscribe. - - - - - - true if successful; false, if failed - - - - See Result - - - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - - Unsubscribes from built-in HMI buttons. - - - Name of the button to unsubscribe. - - - - - - true if successful; false, if failed - - - - See Result - - - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - - - Subscribes for specific published data items. - The data will be only sent if it has changed. - The application will be notified by the onVehicleData notification whenever new data is available. - To unsubscribe the notifications, use unsubscribe with the same subscriptionType. - - - - See GPSData - - - The vehicle speed in kilometers per hour - - - The number of revolutions per minute of the engine - - - The fuel level in the tank (percentage) - - - The fuel level state - - - The instantaneous fuel consumption in microlitres - - - The estimate range in KM the vehicle can travel based on fuel level and consumption - - - The external temperature in degrees celsius - - - See TurnSignal - - - See PRNDL - - - See TireStatus - - - Odometer in km - - - The status of the seat belts - - - The body information including power modes - - - The device status including signal and battery strength - - - The status of the brake pedal - - - The status of the wipers - - - Status of the head lamps - - - Torque value for engine (in Nm) on non-diesel variants - - - Accelerator pedal position (percentage depressed) - - - Current angle of the steering wheel (in deg) - - - The estimated percentage of remaining oil life of the engine. - - - The status of the park brake as provided by Electric Park Brake (EPB) system. - - - Parameter used by cloud apps to identify a head unit - - - Emergency Call notification and confirmation data - - - The status of the air bags - - - Information related to an emergency event (and if it occurred) - - - The status modes of the cluster - - - Information related to the MyKey feature - - - - - - - - true, if successful; false, if failed - - - - See Result - - - - - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - See GPSData - - - The vehicle speed in kilometers per hour - - - The number of revolutions per minute of the engine - - - The fuel level in the tank (percentage) - - - The fuel level state - - - The instantaneous fuel consumption in microlitres - - - The estimate range in KM the vehicle can travel based on fuel level and consumption - - - The external temperature in degrees celsius. - - - See TurnSignal - - - See PRNDL - - - See TireStatus - - - Odometer in km - - - The status of the seat belts - - - The body information including power modes - - - The device status including signal and battery strength - - - The status of the brake pedal - - - The status of the wipers - - - Status of the head lamps - - - Torque value for engine (in Nm) on non-diesel variants - - - Accelerator pedal position (percentage depressed) - - - Current angle of the steering wheel (in deg) - - - The estimated percentage of remaining oil life of the engine. - - - The status of the park brake as provided by Electric Park Brake (EPB) system. - - - Parameter used by cloud apps to identify a head unit - - - Emergency Call notification and confirmation data - - - The status of the air bags - - - Information related to an emergency event (and if it occurred) - - - The status modes of the cluster - - - Information related to the MyKey feature - - - - - This function is used to unsubscribe the notifications from the subscribeVehicleData function. - - - See GPSData - - - The vehicle speed in kilometers per hour - - - The number of revolutions per minute of the engine - - - The fuel level in the tank (percentage) - - - The fuel level state - - - The instantaneous fuel consumption in microlitres - - - The estimate range in KM the vehicle can travel based on fuel level and consumption - - - The external temperature in degrees celsius. - - - See TurnSignal - - - See PRNDL - - - See TireStatus - - - Odometer in km - - - The status of the seat belts - - - The body information including power modes - - - The device status including signal and battery strength - - - The status of the brake pedal - - - The status of the wipers - - - Status of the head lamps - - - Torque value for engine (in Nm) on non-diesel variants - - - Accelerator pedal position (percentage depressed) - - - Current angle of the steering wheel (in deg) - - - The estimated percentage of remaining oil life of the engine. - - - The status of the park brake as provided by Electric Park Brake (EPB) system. - - - Parameter used by cloud apps to identify a head unit - - - Emergency Call notification and confirmation data - - - The status of the air bags - - - Information related to an emergency event (and if it occurred) - - - The status modes of the cluster - - - Information related to the MyKey feature - - - - - - true, if successful; false, if failed - - - - See Result - - - - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - See GPSData - - - The vehicle speed in kilometers per hour - - - The number of revolutions per minute of the engine - - - The fuel level in the tank (percentage) - - - The fuel level state - - - The instantaneous fuel consumption in microlitres - - - The estimate range in KM the vehicle can travel based on fuel level and consumption - - - The external temperature in degrees celsius - - - See TurnSignal - - - See PRNDL - - - See TireStatus - - - Odometer in km - - - The status of the seat belts - - - The body information including power modes - - - The device status including signal and battery strength - - - The status of the brake pedal - - - The status of the wipers - - - Status of the head lamps - - - Torque value for engine (in Nm) on non-diesel variants - - - Accelerator pedal position (percentage depressed) - - - Current angle of the steering wheel (in deg) - - - The estimated percentage of remaining oil life of the engine. - - - The status of the park brake as provided by Electric Park Brake (EPB) system. - - - Parameter used by cloud apps to identify a head unit - - - Emergency Call notification and confirmation data - - - The status of the air bags - - - Information related to an emergency event (and if it occurred) - - - The status modes of the cluster - - - Information related to the MyKey feature - - - - - Non periodic vehicle data read request. - - - See GPSData - - - The vehicle speed in kilometers per hour - - - The number of revolutions per minute of the engine - - - The fuel level in the tank (percentage) - - - The fuel level state - - - The instantaneous fuel consumption in microlitres - - - The estimate range in KM the vehicle can travel based on fuel level and consumption - - - The external temperature in degrees celsius - - - See TurnSignal - - - Vehicle identification number - - - See PRNDL - - - See TireStatus - - - Odometer in km - - - The status of the seat belts - - - The body information including ignition status and internal temp - - - The device status including signal and battery strength - - - The status of the brake pedal - - - The status of the wipers - - - Status of the head lamps - - - Torque value for engine (in Nm) on non-diesel variants - - - Accelerator pedal position (percentage depressed) - - - Current angle of the steering wheel (in deg) - - - The estimated percentage of remaining oil life of the engine. - - - The status of the park brake as provided by Electric Park Brake (EPB) system. - - - Parameter used by cloud apps to identify a head unit - - - Emergency Call notification and confirmation data - - - The status of the air bags - - - Information related to an emergency event (and if it occurred) - - - The status modes of the cluster - - - Information related to the MyKey feature - - - - - - - true, if successful; false, if failed - - - - See Result - - - - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - See GPSData - - - The vehicle speed in kilometers per hour - - - The number of revolutions per minute of the engine - - - The fuel level in the tank (percentage) - - - The fuel level state - - - The instantaneous fuel consumption in microlitres - - - The estimate range in KM the vehicle can travel based on fuel level and consumption - - - The external temperature in degrees celsius - - - See TurnSignal - - - Vehicle identification number - - - See PRNDL - - - See TireStatus - - - Odometer in km - - - The status of the seat belts - - - The body information including power modes - - - The device status including signal and battery strength - - - The status of the brake pedal - - - The status of the wipers - - - Status of the head lamps - - - Torque value for engine (in Nm) on non-diesel variants - - - Accelerator pedal position (percentage depressed) - - - Current angle of the steering wheel (in deg) - - - The estimated percentage of remaining oil life of the engine. - - - The status of the park brake as provided by Electric Park Brake (EPB) system. - - - Parameter used by cloud apps to identify a head unit - - - Emergency Call notification and confirmation data - - - The status of the air bags - - - Information related to an emergency event (and if it occurred) - - - The status modes of the cluster - - - Information related to the MyKey feature - - - - - Non periodic vehicle data read request - - - Name of ECU. - - - Get raw data from vehicle data DID location(s) - - - - - - - true, if successful; false, if failed - - - - See Result - - - - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - Array of requested DID results (with data if available). - - - - - - Vehicle module diagnostic trouble code request. - - - Name of ECU. - - - - DTC Mask Byte to be sent in diagnostic request to module . - - - - - - - - true, if successful; false, if failed - - - - See Result - - - - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - 2 byte ECU Header for DTC response (as defined in VHR_Layout_Specification_DTCs.pdf) - - - - - Array of all reported DTCs on module (ecuHeader contains information if list is truncated). - Each DTC is represented by 4 bytes (3 bytes of data and 1 byte status as defined in VHR_Layout_Specification_DTCs.pdf). - - - - - - - Non periodic vehicle diagnostic request - - - Name of target ECU. - - - - Length of message (in bytes). - - - - - Array of bytes comprising CAN message. - - - - - - - - true, if successful; false, if failed - - - - See Result - - - - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - - Array of bytes comprising CAN message result. - - - - - - - Creates a full screen overlay containing a large block of formatted text that can be scrolled with up to 8 SoftButtons defined - - Body of text that can include newlines and tabs. - - - App defined timeout. Indicates how long of a timeout from the last action (i.e. scrolling message resets timeout). - - - - App defined SoftButtons. - If omitted on supported displays, only the system defined "Close" SoftButton will be displayed. - - - - - An ID for this specific ScrollableMessage to allow cancellation through the `CancelInteraction` RPC. - - - - - - - true, if successful; false, if failed - - - - See Result - - - - - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - - - Creates a full screen or pop-up overlay (depending on platform) with a single user controlled slider. - - Number of selectable items on a horizontal axis - - - Initial position of slider control (cannot exceed numTicks) - - - Text header to display - - - - Text footer to display (meant to display min/max threshold descriptors). - For a static text footer, only one footer string shall be provided in the array. - For a dynamic text footer, the number of footer text string in the array must match the numTicks value. - For a dynamic text footer, text array string should correlate with potential slider position index. - If omitted on supported displays, no footer text shall be displayed. - - - - - App defined timeout. Indicates how long of a timeout from the last action (i.e. sliding control resets timeout). - If omitted, the value is set to 10000. - - - - - An ID for this specific Slider to allow cancellation through the `CancelInteraction` RPC. - - - - - - - true, if successful; false, if failed - - - - See Result - - - - - - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - - Current slider value returned when saved or canceled (aborted) - This value is only returned for resultCodes "SAVED" or "ABORTED" - - - - - - - - - - - - - - - - - - - - - - Fraction of distance till next maneuver (starting from when AlertManeuver is triggered). - Used to calculate progress bar. - - - - - Distance till next maneuver (starting from) from previous maneuver. - Used to calculate progress bar. - - - - - If and when a maneuver has completed while an AlertManeuver is active, the app must send this value set to TRUE in order to clear the AlertManeuver overlay. - If omitted the value will be assumed as FALSE. - - - - - Three dynamic SoftButtons available (first SoftButton is fixed to "Turns"). - If omitted on supported displays, the currently displayed SoftButton values will not change. - - - - - - - true, if successful; false, if failed - - - See Result - - - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - - - An array of text chunks of type TTSChunk. See TTSChunk - - - If omitted on supported displays, only the system defined "Close" SoftButton shall be displayed. - - - - - - true, if successful; false, if failed - - - See Result - - - - - - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - - - - - If omitted on supported displays, app-defined SoftButton will be left blank. - - - - - - true, if successful; false, if failed - - - See Result - - - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - - - Requested voice engine (VR+TTS) language registration - - - Request display language registration - - - Request new app name registration - - - Request new ttsName registration - - - Request new app short name registration - - - Request new VR synonyms registration - - - - - - - - true, if successful - false, if failed - - - - - See Result - - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - - - - Generic Response is sent, when the name of a received msg cannot be retrieved. Only used in case of an error. - Currently, only resultCode INVALID_DATA is used. - - - true, if successful; false, if failed - - - - See Result - - - - - Provides additional human readable info regarding the result. - - - - - - Used to push a binary data onto the module from a mobile device, such as icons and album art - Not supported on first generation of SDL enabled modules. - Binary data is in binary part of hybrid msg. - - - - File reference name. - - - - Selected file type. - - - - - Indicates if the file is meant to persist between sessions / ignition cycles. - If set to TRUE, then the system will aim to persist this file through session / cycles. - While files with this designation will have priority over others, they are subject to deletion by the system at any time. - In the event of automatic deletion by the system, the app will receive a rejection and have to resend the file. - If omitted, the value will be set to false. - - - - - - Indicates if the file is meant to be passed thru core to elsewhere on the system. - If set to TRUE, then the system will instead pass the data thru as it arrives to a predetermined area outside of core. - If omitted, the value will be set to false. - - - - - Optional offset in bytes for resuming partial data chunks - - - - Optional length in bytes for resuming partial data chunks - If offset is set to 0, then length is the total length of the file to be downloaded - - - - Additional CRC32 checksum to protect data integrity up to 512 Mbits - - - - - Response is sent, when the file data was copied (success case). Or when an error occurred. - Not supported on first generation SDL enabled vehicles. - - true, if successful; false, if failed - - - - See Result - - - - - - - - - - - - - - Provides the total local space available in SDL Core for the registered app. - If the transfer has systemFile enabled, then the value will be set to 0 automatically. - - - - - - - - Provides additional human readable info regarding the result. - - - - - This request is sent to the module to retrieve a file - - File name that should be retrieved - - - ID of the service that should have uploaded the requested file. - - - Selected file type. - - - Optional offset in bytes for resuming partial data chunks - - - - Optional length in bytes for resuming partial data chunks - If offset is set to 0, then length is the total length of the file to be retrieved - - - - - - This response includes the data that is requested from the specific service - - true, if successful; false, if failed - - - See Result - - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - - Optional offset in bytes for resuming partial data chunks - - - - Optional length in bytes for resuming partial data chunks if offset is set to 0, then length is the total length of the file to be downloaded - - - - File type that is being sent in response. - - - - Additional CRC32 checksum to protect data integrity up to 512 Mbits - - - - - - Used to delete a file resident on the module in the app's local cache. - Not supported on first generation SDL enabled vehicles. - - - - File reference name. - - - - - - - Response is sent, when the file data was deleted (success case). Or when an error occurred. - Not supported on First generation SDL enabled vehicles. - - - true if successful; false, if failed - - - - See Result - - - - - - - - - - - - Provides the total local space available on the module for the registered app. - - - - - - - Provides additional human readable info regarding the result. - - - - - - Requests the current list of resident filenames for the registered app. - Not supported on first generation SDL enabled vehicles. - - - - - - Returns the current list of resident filenames for the registered app along with the current space available - Not supported on First generation SDL enabled vehicles. - - - true, if successful; false, if failed - - - - See Result - - - - - - - - - - - - - An array of all filenames resident on the module for the given registered app. - If omitted, then no files currently reside on the system. - - - - - Provides the total local space available on the module for the registered app. - - - - - - - Provides additional human readable info regarding the result. - - - - - - Used to set existing local file on the module as the app's icon - Not supported on first generation SDL enabled vehicles. - - - - File reference name. - - - - - - - Response is sent, when the file data was copied (success case). Or when an error occurred. - Not supported on First generation SDL enabled vehicles. - - - - true, if successful; false, if failed - - - - See Result - - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - - - - - - This RPC is deprecated. Use Show RPC to change layout. - - - Predefined or dynamically created screen layout. - Currently only predefined screen layouts are defined. - - - - - - - - - - - - - This RPC is deprecated. Use Show RPC to change layout. - - true, if successful; false, if failed - - - - See Result - - - - - - - - - - - - See DisplayCapabilities - - - - See ButtonCapabilities - - - - If returned, the platform supports on-screen SoftButtons; see SoftButtonCapabilities. - - - - If returned, the platform supports custom on-screen Presets; see PresetBankCapabilities. - - - - Provides additional human readable info regarding the result. - - - - - - An asynchronous request from the device; binary data can be included in hybrid part of message for some requests (such as HTTP, Proprietary, or Authentication requests) - - - The type of system request. - Note that Proprietary requests should forward the binary data to the known proprietary module on the system. - - - - - This parameter is filled for supporting OEM proprietary data exchanges. - - - - - Filename of HTTP data to store in predefined system staging area. - Mandatory if requestType is HTTP. - PROPRIETARY requestType should ignore this parameter. - - - - - - - true, if successful; false, if failed - - - - See Result - - - - - - - - - - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - - - - - - - - Name / title of intended location - - - - - Description intended location / establishment (if applicable) - - - - - Location address (if applicable) - - - - - Phone number of intended location / establishment (if applicable) - - - - - Image / icon of intended location (if applicable and supported) - - - - - - timestamp in ISO 8601 format - - - - - Address to be used for setting destination - - - Defines the mode of prompt for user - - - - - - true, if successful; false, if failed - - - - See Result - - - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - - Dials a phone number and switches to phone application. - - - - Phone number is a string, which can be up to 40 chars. - All characters shall be stripped from string except digits 0-9 and * # , ; + - - - - - - - true, if successful - false, if failed - - - - See Result - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - - - The module where the button should be pressed - - - Id of a module, published by System Capability. - - - The name of supported RC climate or radio button. - - - Indicates whether this is a LONG or SHORT button press event. - - - - - - See Result - - - - - - - - - - - - - - - true if successful; false, if failed - - - - - - - The type of a RC module to retrieve module data from the vehicle. - In the future, this should be the Identification of a module. - - - - Id of a module, published by System Capability. - - - - If subscribe is true, the head unit will register OnInteriorVehicleData notifications for the requested module (moduleId and moduleType). - If subscribe is false, the head unit will unregister OnInteriorVehicleData notifications for the requested module (moduleId and moduleType). - If subscribe is not included, the subscription status of the app for the requested module (moduleId and moduleType) will remain unchanged. - - - - - - - - - - - - See Result - - - - - - - - - - - - - - - - true if successful; false, if failed - - - - It is a conditional-mandatory parameter: must be returned in case "subscribe" parameter was present in the related request. - if "true" - the "moduleType" from request is successfully subscribed and the head unit will send onInteriorVehicleData notifications for the moduleType. - if "false" - the "moduleType" from request is either unsubscribed or failed to subscribe. - - - - - - - The module type that the app requests to control. - - - Ids of a module of same type, published by System Capability. - - - - - - true if successful; false, if failed - - - See Result - - - - - - - - - - - - - - - - - This array has the same size as "moduleIds" in the request and each element corresponds to one moduleId - If true, SDL grants the permission for the requested module - If false, SDL denies the permission for the requested module. - - - - - - - - - Id of a module, published by System Capability. - - - - - - true if successful; false, if failed - - - See Result - - - - - - - - - - - - - - - - - - The module data to set for the requested RC module. - - - - - Used to set the values of one remote control module - - - - See Result - - - - - - - - - - - - - - - - - - true if successful; false, if failed - - - - - To subscribe in getting changes for Waypoints/destinations - - - - - true, if successful; false, if failed - - - See Result - - - - - - - - - - Provides additional human readable info regarding the result. - - - - - Request for getting waypoint/destination data. - - To request for either the destination only or for all waypoints including destination - - - - - - true, if successful; false, if failed - - - See Result - - - - - - - - - - - - Provides additional human readable info regarding the result. - - - See LocationDetails - - - - - Request to unsubscribe from WayPoints and Destination - - - - - true, if successful; false, if failed - - - See Result - - - - - - - - - - Provides additional human readable info regarding the result. - - - See LocationDetails - - - - - Request for expanded information about a supported system/HMI capability - - The type of system capability to get more information on - - - Flag to subscribe to updates of the supplied service capability type. If true, the requester will be subscribed. If false, the requester will not be subscribed and be removed as a subscriber if it was previously subscribed. - - - - - - - - See Result - - - - - - - - - - - - The capability does not exist on the module - - - The capability should exist on the module but there was an error retrieving the data. - - - - Provides additional human readable info regarding the result. - - - true if successful; false, if failed - - - - - Send the spatial data gathered from SDLCarWindow or VirtualDisplayEncoder to the HMI. This data will be utilized by the HMI to determine how and when haptic events should occur - - Array of spatial data structures that represent the locations of all user controls present on the HMI. This data should be updated if/when the application presents a new screen. When a request is sent, if successful, it will replace all spatial data previously sent through RPC. If an empty array is sent, the existing spatial data will be cleared - - - - - - true if successful; false if failed - - - Provides additional human readable info regarding the result. - - - See Result - - - - - - - - RPC used to enable/disable a cloud application and set its cloud-related policy properties - - - The new cloud application properties - - - - - The response to SetCloudAppProperties - - true if successful; false if failed - - - See Result - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - - - RPC used to get the current properties of a cloud application - - - - - - The response to GetCloudAppProperties - - The requested cloud application properties - - - true if successful; false if failed - - - See Result - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - - - Registers a service offered by this app on the module. - Subsequent calls with the same service type will update the manifest for that service. - - - - - The manifest of the service that wishes to be published. - If already published, the updated manifest for this service. - - - - - - Response to the request to register a service offered by this app on the module - - - true, if successful; false, if failed - - - - See Result - - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - If the request was successful, this object will be the current status of the service record for the published service. This will include the Core supplied service ID. - - - - - Unpublish an existing service published by this application. - - - The ID of the service to be unpublished. - - - - - The response to UnpublishAppService - - true, if successful; false, if failed - - - - See Result - - - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - - This request asks the module for current data related to the specific service. It also includes an option to subscribe to that service for future updates - - - The type of service that is to be offered by this app. See AppServiceType for known enum equivalent types. Parameter is a string to allow for new service types to be used by apps on older versions of SDL Core. - - - - If true, the consumer is requesting to subscribe to all future updates from the service publisher. If false, the consumer doesn't wish to subscribe and should be unsubscribed if it was previously subscribed. - - - - - This response includes the data that was requested from the specific service - - - true, if successful; false, if failed - - - - See Result - - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - - - - - - Fully qualified URI based on a predetermined scheme provided by the app service. SDL makes no guarantee that this URI is correct. - - - - The service ID that the app consumer wishes to send this URI. - - - - This string is the appID of the app requesting the app service provider take the specific action. - - - - This flag signals the requesting consumer would like this service to become the active primary service of the destination's type. - - - - - - true, if successful; false, if failed - - - - See Result. All results will be available for this response. - - - - Provides additional human readable info regarding the result. - - - - The service can provide specific result strings to the consumer through this param. - - - - - - Close an active interaction on the HMI. - - - - - The ID of the specific interaction you want to dismiss. If not set, the most recent of the RPC type set in functionID will be dismissed. - - - - - - The ID of the type of interaction the developer wants to dismiss. Only values 10, (PerformInteractionID), 12 (AlertID), 25 (ScrollableMessageID), and 26 (SliderID) are permitted. - - - - - - - If no applicable request can be dismissed, the result will be IGNORED. - - - - true if successful; false, if failed - - - - See Result - - - - - - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - - Request from the application to exit the foreground and enter HMI_NONE. - - - - - true if successful; false, if failed - - - - See Result - - - - - - - - - Provides additional human readable info regarding the result. - - - - - - - - See HMILevel - - - - See AudioStreamingState - - - - See SystemContext - - - - - See VideoStreamingState. - If it is NOT_STREAMABLE, the app must stop streaming video to SDL Core(stop service). - - - - - This is the unique ID assigned to the window that this RPC is intended. If this param is not included, it will be assumed that this request is specifically for the main window on the main display. See PredefinedWindows enum. - - - - - - - See AppInterfaceUnregisteredReason - - - - - Notifies application of UP/DOWN events for buttons to which the application is subscribed. - - - Indicates whether this is an UP or DOWN event. - - - If ButtonName is "CUSTOM_BUTTON", this references the integer ID passed by a custom button. (e.g. softButton ID) - - - - - Notifies application of LONG/SHORT press events for buttons to which the application is subscribed. - - - Indicates whether this is a LONG or SHORT button press event. - - - If ButtonName is "CUSTOM_BUTTON", this references the integer ID passed by a custom button. (e.g. softButton ID) - - - - - Callback for the periodic and non periodic vehicle data read function. - - See GPSData - - - The vehicle speed in kilometers per hour - - - The number of revolutions per minute of the engine - - - The fuel level in the tank (percentage) - - - The fuel level state - - - The instantaneous fuel consumption in microlitres - - - The estimate range in KM the vehicle can travel based on fuel level and consumption - - - The external temperature in degrees celsius - - - See TurnSignal - - - Vehicle identification number. - - - See PRNDL - - - See TireStatus - - - Odometer in km - - - The status of the seat belts - - - The body information including power modes - - - The device status including signal and battery strength - - - The status of the brake pedal - - - The status of the wipers - - - Status of the head lamps - - - Torque value for engine (in Nm) on non-diesel variants - - - Accelerator pedal position (percentage depressed) - - - Current angle of the steering wheel (in deg) - - - The estimated percentage of remaining oil life of the engine. - - - The status of the park brake as provided by Electric Park Brake (EPB) system. - - - Parameter used by cloud apps to identify a head unit - - - Emergency Call notification and confirmation data - - - The status of the air bags - - - Information related to an emergency event (and if it occurred) - - - The status modes of the cluster - - - Information related to the MyKey feature - - - - - - - - Command ID, which is related to a specific menu entry - - - - See TriggerSource - - - - - Provides applications with notifications specific to the current TBT client status on the module - - Current State of TBT client - - - - - Provides driver distraction state to mobile applications - - Current State of Driver Distraction - - - - If enabled, the lock screen will be able to be dismissed while connected to SDL, allowing users - the ability to interact with the app. Dismissals should include a warning to the user and ensure - that they are not the driver. - - - - - Warning message to be displayed on the lock screen when dismissal is enabled. - This warning should be used to ensure that the user is not the driver of the vehicle, - ex. `Swipe down to dismiss, acknowledging that you are not the driver.`. - This parameter must be present if "lockScreenDismissalEnabled" is set to true. - - - - - - Provides update to app of which policy-table-enabled functions are available - - Change in permissions for a given set of RPCs - - - - - - Binary data is in binary part of hybrid msg - - - - - Current SDL voice engine (VR+TTS) language - - - Current display language - - - - - - On-screen keyboard event. - Can be full string or individual keypresses depending on keyboard mode. - - - On-screen keyboard input data. - - - - On-screen keyboard input data. - For dynamic keypress events, this will be the current compounded string of entry text. - For entry submission events, this will be the full text entry (this will always return regardless of the mode). - For entry cancelled and entry aborted events, this data param will be omitted. - - - - - - Notifies about touch events on the screen's prescribed area - - The type of touch event. - - - List of all individual touches involved in this event. - - - - - - An asynchronous request from the system for specific data from the device or the cloud or response to a request from the device or cloud - Binary data can be included in hybrid part of message for some requests (such as Authentication request responses) - - - The type of system request. - - - - This parameter is filled for supporting OEM proprietary data exchanges. - - - - - Optional URL for HTTP requests. - If blank, the binary data shall be forwarded to the app. - If not blank, the binary data shall be forwarded to the url with a provided timeout in seconds. - - - - - Optional timeout for HTTP requests - Required if a URL is provided - - - - Optional file type (meant for HTTP file requests). - - - Optional offset in bytes for resuming partial data chunks - - - Optional length in bytes for resuming partial data chunks - - - - - - Notification containing an updated hashID which can be used over connection cycles (i.e. loss of connection, ignition cycles, etc.). - Sent after initial registration and subsequently after any change in the calculated hash of all persisted app data. - - - Calculated hash ID to be referenced during RegisterAppInterface. - - - - - Notification which provides the entire LocationDetails when there is a change to any waypoints or destination. - - See LocationDetails - - - - - - - - - - Issued by SDL to notify the application about remote control status change on SDL - - If "true" - RC is allowed; if "false" - RC is disallowed. - - - Contains a list (zero or more) of module types that are allocated to the application. - - - Contains a list (zero or more) of module types that are free to access for the application. - - - - - This notification includes the data that is updated from the specific service - - - - - - A notification to inform the connected device that a specific system capability has changed. - - The system capability that has been updated - - - - - - - - - - Allows encoded data in the form of SyncP packets to be sent to the SYNC module. - Legacy / v1 Protocol implementation; use SyncPData instead. - *** DEPRECATED *** - - - - Contains base64 encoded string of SyncP packets. - What is the maxlength? - - - - - - true, if successful; false, if failed - - - - See Result - - - - - - - - - - - Provides additional human readable info regarding the result. - - - - - - - - Callback including encoded data of any SyncP packets that SYNC needs to send back to the mobile device. - Legacy / v1 Protocol implementation; responds to EncodedSyncPData. - *** DEPRECATED *** - - - Contains base64 encoded string of SyncP packets. - - - - If blank, the SyncP data shall be forwarded to the app. - If not blank, the SyncP data shall be forwarded to the provided URL. - - - - - If blank, the SyncP data shall be forwarded to the app. - If not blank, the SyncP data shall be forwarded with the provided timeout in seconds. - - - - - - - \ No newline at end of file diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/RPCConstructorsTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/RPCConstructorsTests.java deleted file mode 100644 index 64f22a673..000000000 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/RPCConstructorsTests.java +++ /dev/null @@ -1,339 +0,0 @@ -package com.smartdevicelink.test.rpc; - - -import androidx.test.ext.junit.runners.AndroidJUnit4; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; -import org.xmlpull.v1.XmlPullParserFactory; - -import java.io.IOException; -import java.io.InputStream; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; -import static junit.framework.TestCase.assertTrue; - -/** - * This is a unit test class for the SmartDeviceLink library project - * It makes sure that for each RPC, all mandatory parameters are set in a constructor - */ - -@RunWith(AndroidJUnit4.class) -public class RPCConstructorsTests { - - private final String XML_FILE_NAME = "xml/MOBILE_API.xml"; - private final String RPC_PACKAGE_PREFIX = "com.smartdevicelink.proxy.rpc."; - private Map> rpcMandatoryParamsMapFromXml; - - private class Parameter { - private String name; - private String type; - private boolean isArray; - - public Parameter(String name, String type, boolean isArray) { - this.name = name; - this.type = type; - this.isArray = isArray; - } - } - - @Before - public void setUp(){ - // Map that has keys correspond to the RPC names and values correspond to the - // mandatory params for that RPC. All info are loaded from the RPC spec xml file - rpcMandatoryParamsMapFromXml = getRPCMandatoryParamsMap(XML_FILE_NAME); - - } - - // This method parses the RPC spec xml file and returns a map that has - // keys correspond to the RPC names and values correspond to the mandatory params for that RPC - private Map> getRPCMandatoryParamsMap(String fileName) { - Map> rpcMandatoryParamsMap = new HashMap<>(); - try { - InputStream stream = getInstrumentation().getTargetContext().getAssets().open(fileName); - XmlPullParserFactory xmlFactoryObject = XmlPullParserFactory.newInstance(); - XmlPullParser myParser = xmlFactoryObject.newPullParser(); - myParser.setInput(stream, null); - int event = myParser.getEventType(); - String rpcName = null; - boolean ignoreRPC = false; - while (event != XmlPullParser.END_DOCUMENT) { - String name = myParser.getName(); - switch (event){ - case XmlPullParser.START_TAG: - // Store the RPC name in the map - if(name.equals("function") || name.equals("struct")){ - rpcName = myParser.getAttributeValue(null,"name"); - ignoreRPC = false; - if (name.equals("function") && myParser.getAttributeValue(null, "messagetype").equals("response") && !rpcName.contains("Response")){ - rpcName += "Response"; - } - - // -------------- Exceptional cases because of mismatch between the RPC spec and the Android code -------------- - if(rpcName.equals("SyncMsgVersion")){ - rpcName = "SdlMsgVersion"; - } else if(rpcName.equals("ShowConstantTBTResponse")){ - rpcName = "ShowConstantTbtResponse"; - } else if(rpcName.equals("OASISAddress")) { - rpcName = "OasisAddress"; - } else if(rpcName.equals("ShowConstantTBT")) { - rpcName = "ShowConstantTbt"; - } else if (rpcName.equals("EncodedSyncPData") || rpcName.equals("OnEncodedSyncPData") || rpcName.equals("EncodedSyncPDataResponse")){ - ignoreRPC = true; - } - // ------------------------------------------------------------------------------------------------------------- - - if (!ignoreRPC) { - rpcMandatoryParamsMap.put(rpcName, new ArrayList()); - } - } - // Store the mandatory params for the current RPC in the map - if(name.equals("param") && myParser.getAttributeValue(null, "until") == null && !ignoreRPC){ - boolean mandatory = Boolean.valueOf(myParser.getAttributeValue(null,"mandatory")); - if (mandatory) { - String paramName = myParser.getAttributeValue(null, "name"); - String paramType = myParser.getAttributeValue(null, "type"); - boolean paramIsArray = Boolean.valueOf(myParser.getAttributeValue(null, "array")); - - // -------------- Exceptional cases because of mismatch between the RPC spec and the Android code -------------- - if (paramType.equals("SyncMsgVersion")){ - paramType = "SdlMsgVersion"; - } else if (rpcName.equals("GPSData") && paramType.equals("Float")){ - paramType = "Double"; - } else if (rpcName.equals("TouchEvent") && paramType.equals("Integer") && paramIsArray){ - paramType = "Long"; - } - - if (paramName.equals("syncFileName")){ - paramName = "sdlFileName"; - } else if (paramName.equals("syncMsgVersion")){ - paramName = "sdlMsgVersion"; - } else if (paramName.equals("hmiPermissions")){ - paramName = "hMIPermissions"; - } else if (paramName.equals("resolution")){ - paramName = "imageResolution"; - } else if (paramName.equals("pressureTelltale")){ - paramName = "pressureTellTale"; - } - // ------------------------------------------------------------------------------------------------------------- - - Parameter param = new Parameter(paramName, paramType, paramIsArray); - rpcMandatoryParamsMap.get(rpcName).add(param); - } - } - break; - } - event = myParser.next(); - } - stream.close(); - } catch (IOException | XmlPullParserException e) { - e.printStackTrace(); - } - return rpcMandatoryParamsMap; - } - - // This method makes sure that for every RPC, there is a constructor that has all the mandatory params - // It also checks if there are RPC in the XML file that don't exist in the code - @Test - public void testMandatoryParamsMatch() { - // List of RPC names that don't have a constructor that has all mandatory params - List rpcsWithInvalidConstructor = new ArrayList<>(); - - // List of the RPC names that couldn't be found in code - // potentially because of a mismatch between name in the RPC spec xml file and name in code - List rpcsFromXmlNotFoundInCode = new ArrayList<>(); - - // Loop through all RPCs that were loaded from RPC spec XML file - // and make sure that every RPC has a constructor that has all mandatory params - for (String rpcName : rpcMandatoryParamsMapFromXml.keySet()) { - Class aClass; - try { - aClass = Class.forName(RPC_PACKAGE_PREFIX + rpcName); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - rpcsFromXmlNotFoundInCode.add(rpcName); - continue; - } - List mandatoryParamsListFromXML = new ArrayList<>(); - for (Parameter param : rpcMandatoryParamsMapFromXml.get(rpcName)) { - String type = param.type; - // If the param is a list of objects, the type should be like "List" - if (param.isArray){ - type = String.format("List<%s>", type); - } - mandatoryParamsListFromXML.add(type); - } - List mandatoryParamsListFromCode = new ArrayList<>(); - boolean rpcHasValidConstructor = false; - for (Constructor constructor : aClass.getConstructors()){ - mandatoryParamsListFromCode.clear(); - for (Type paramType : constructor.getGenericParameterTypes()){ - String paramFullType = paramType.toString(); - String paramSimpleType; - - // If the param is a list of objects, the type should be like "List" - if (paramFullType.matches("java.util.List<.+>")) { - paramSimpleType = String.format("List<%s>", paramFullType.substring(paramFullType.lastIndexOf('.') + 1, paramFullType.length() - 1)); - } - // If the param is a simple object for example "java.lang.String", the type should be the last part "String" - else if (!paramFullType.contains(">")){ - paramSimpleType = paramFullType.substring(paramFullType.lastIndexOf('.') + 1, paramFullType.length()); - } - else { - paramSimpleType = paramFullType; - } - mandatoryParamsListFromCode.add(paramSimpleType); - } - if (mandatoryParamsListFromCode.containsAll(mandatoryParamsListFromXML) && mandatoryParamsListFromXML.containsAll(mandatoryParamsListFromCode)){ - rpcHasValidConstructor = true; - break; - } - } - if (!rpcHasValidConstructor){ - rpcsWithInvalidConstructor.add(rpcName); - } - } - assertTrue("The following RPCs were not found in the code: " + rpcsFromXmlNotFoundInCode, rpcsFromXmlNotFoundInCode.isEmpty()); - assertTrue("The following RPCs don't have a constructor that has all the mandatory params: " + rpcsWithInvalidConstructor, rpcsWithInvalidConstructor.isEmpty()); - } - - // This method makes sure that for every RPC, the constructor that has the mandatory params is setting the values correctly - @Test - public void testMandatoryParamsValues() { - // List of RPC names that have a constructor which is not settings the values for the mandatory params correctly - List rpcsWithInvalidConstructor = new ArrayList<>(); - - // List of types that exist in java.lang.* - List javaLangBuiltInTypes = Arrays.asList("String", "Integer", "Float", "Double", "Boolean"); - - // Loop through all RPCs that were loaded from RPC spec XML file - // and make sure that the constructor that has the mandatory params is setting the values correctly - for (String rpcName : rpcMandatoryParamsMapFromXml.keySet()) { - Class aClass; - try { - aClass = Class.forName(RPC_PACKAGE_PREFIX + rpcName); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - continue; - } - - List parameters = rpcMandatoryParamsMapFromXml.get(rpcName); - List> mandatoryParamsTypes = new ArrayList<>(); - List mandatoryParamsValues = new ArrayList<>(); - - // Loop through all mandatory params for the current RPC - // and try to find the full Java type for each param - // also assign a value for each param from com.smartdevicelink.test.Test class - for (Parameter param : parameters) { - String typeString = null; - Class type = null; - String valueString = null; - Object value = null; - - // Find the full Java type for the current param - try { - if (param.isArray) { - type = List.class; - } else { - if (javaLangBuiltInTypes.contains(param.type)){ - typeString = "java.lang." + param.type; - } else { - typeString = RPC_PACKAGE_PREFIX + param.type; - } - type = Class.forName(typeString); - } - - } catch (ClassNotFoundException e) { - // If the class was not found in the com.smartdevicelink.proxy.rpc package - // try to see if it can be found in com.smartdevicelink.proxy.rpc.enums package - typeString = RPC_PACKAGE_PREFIX + "enums." + param.type; - try { - type = Class.forName(typeString); - } catch (ClassNotFoundException e1) { - e1.printStackTrace(); - assertTrue("Type: " + typeString + " cannot be found for RPC: " + rpcName , false); - } - } - - - // Assign a value for the current param from com.smartdevicelink.test.Test based of the param type - try { - // --------------------------------------------- Exceptional cases --------------------------------------------- - // This case is exceptional because the setter changes the input if it is not all digits - if (rpcName.equals("DialNumber") && param.type.equals("String")){ - value = "5558675309"; - } - // ------------------------------------------------------------------------------------------------------------- - - if (value == null) { - valueString = "GENERAL_" + param.type.toUpperCase(); - if (param.isArray){ - valueString += "_LIST"; - } - value = Class.forName("com.smartdevicelink.test.TestValues").getDeclaredField(valueString).get(null); - } - - } catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) { - e.printStackTrace(); - assertTrue("Value: " + valueString + " cannot be found for RPC: " + rpcName + ". Make sure that you declared that value in com.smartdevicelink.test.Test" , false); - } - - mandatoryParamsTypes.add(type); - mandatoryParamsValues.add(value); - } - - - // Create an instance of the RPC object using the constructor that has all the mandatory params - Object instance = null; - try { - Constructor constructor = aClass.getConstructor(mandatoryParamsTypes.toArray(new Class[mandatoryParamsTypes.size()])); - instance = constructor.newInstance(mandatoryParamsValues.toArray(new Object[mandatoryParamsValues.size()])); - } catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) { - e.printStackTrace(); - assertTrue("Constructor for RPC " + rpcName + " cannot be invoked. Make sure that the constructor parameters order and types are identical to the RPC specs", false); - } - - - // Loop through all getter methods for the instance and make sure that they are returning the expected values - if (instance != null) { - for (int i = 0; i < parameters.size(); i++) { - // Find the getter method name by taking the param name, capitalize the first letter, then add thw word "get" to the beginning - // for example if the param name is "buttonName" the method name will be "getButtonName" - String getterMethodName = "get" + parameters.get(i).name.substring(0, 1).toUpperCase() + parameters.get(i).name.substring(1); - - // --------------------------------------------- Exceptional cases --------------------------------------------- - if (rpcName.equals("CancelInteraction") && getterMethodName.equals("getFunctionID")){ - getterMethodName = "getInteractionFunctionID"; - } - // ------------------------------------------------------------------------------------------------------------- - - try { - Method getterMethod = aClass.getMethod(getterMethodName); - Object val = getterMethod.invoke(instance); - if (val == null || !val.equals(mandatoryParamsValues.get(i))) { - rpcsWithInvalidConstructor.add(rpcName); - break; - } - } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { - e.printStackTrace(); - assertTrue("Method: " + getterMethodName + " cannot be found for RPC: " + rpcName + ". Make sure that the method exists and that the parameters order and types are identical to the RPC specs", false); - - } - } - } - } - - assertTrue("The following RPCs have a constructor that is not setting the mandatory params correctly: " + rpcsWithInvalidConstructor, rpcsWithInvalidConstructor.isEmpty()); - } -} diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/RPCGenericTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/RPCGenericTests.java new file mode 100644 index 000000000..88dfeb1c6 --- /dev/null +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/RPCGenericTests.java @@ -0,0 +1,662 @@ +package com.smartdevicelink.test.rpc; + + +import androidx.test.ext.junit.runners.AndroidJUnit4; + +import com.smartdevicelink.proxy.rpc.enums.SystemCapabilityType; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; +import org.xmlpull.v1.XmlPullParserFactory; + +import java.io.IOException; +import java.io.InputStream; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; +import static junit.framework.TestCase.assertNotNull; +import static junit.framework.TestCase.assertTrue; +import static junit.framework.TestCase.fail; + +@RunWith(AndroidJUnit4.class) +public class RPCGenericTests { + + private final String XML_FILE_NAME = "MOBILE_API.xml"; + private final String RPC_PACKAGE_PREFIX = "com.smartdevicelink.proxy.rpc."; + private final String TEST_VALUES_CLASS = "com.smartdevicelink.test.TestValues"; + private Map> rpcMandatoryParamsMapFromXml; + private Map> rpcAllParamsMapFromXml; + + private class Parameter { + private String rpcName; + private String name; + private String type; + private Class javaType; + private boolean isArray; + private boolean isMandatory; + private String setterName; + private String getterName1; + private String getterName2; + private Object value; + private boolean skip; + + + public Parameter setRPCName(String rpcName) { + this.rpcName = rpcName; + return this; + } + + public Parameter setName(String name) { + this.name = name; + return this; + } + + public Parameter setType(String type) { + this.type = type; + return this; + } + + public Parameter setJavaType(Class javaType) { + this.javaType = javaType; + return this; + } + + public Parameter setArray(boolean array) { + isArray = array; + return this; + } + + public Parameter setMandatory(boolean mandatory) { + isMandatory = mandatory; + return this; + } + + public Parameter setSetterName(String setterName) { + this.setterName = setterName; + return this; + } + + public Parameter setGetterName1(String getterName1) { + this.getterName1 = getterName1; + return this; + } + + public Parameter setGetterName2(String getterName2) { + this.getterName2 = getterName2; + return this; + } + + public void setValue(Object value) { + this.value = value; + } + + public Parameter setSkip(boolean skip) { + this.skip = skip; + return this; + } + } + + @Before + public void setUp(){ + // Map that has keys correspond to the RPC names and values correspond to the params for that RPC. + rpcMandatoryParamsMapFromXml = getRPCParamsMap(XML_FILE_NAME, true); + rpcAllParamsMapFromXml = getRPCParamsMap(XML_FILE_NAME, false); + } + + // This method parses the RPC spec xml file and returns a map that has + // keys correspond to the RPC names and values correspond to the params for that RPC + private Map> getRPCParamsMap(String fileName, boolean includeMandatoryOnly) { + Map> rpcParamsMap = new HashMap<>(); + try { + InputStream stream = getInstrumentation().getTargetContext().getAssets().open(fileName); + XmlPullParserFactory xmlFactoryObject = XmlPullParserFactory.newInstance(); + XmlPullParser myParser = xmlFactoryObject.newPullParser(); + myParser.setInput(stream, null); + int event = myParser.getEventType(); + String rpcName = null; + boolean ignoreRPC = false; + String setterMethodName; + String getterMethodName1; + String getterMethodName2; + Class javaParamType; + boolean skipParam; + while (event != XmlPullParser.END_DOCUMENT) { + String name = myParser.getName(); + switch (event){ + case XmlPullParser.START_TAG: + // Store the RPC name in the map + if(name.equals("function") || name.equals("struct")){ + rpcName = myParser.getAttributeValue(null,"name"); + ignoreRPC = false; + if (name.equals("function") && myParser.getAttributeValue(null, "messagetype").equals("response") && !rpcName.contains("Response")){ + rpcName += "Response"; + } + + // -------------- Exceptional cases because of mismatch between the RPC spec and the Android code -------------- + if(rpcName.equals("SyncMsgVersion")){ + rpcName = "SdlMsgVersion"; + } else if(rpcName.equals("ShowConstantTBTResponse")){ + rpcName = "ShowConstantTbtResponse"; + } else if(rpcName.equals("OASISAddress")) { + rpcName = "OasisAddress"; + } else if(rpcName.equals("ShowConstantTBT")) { + rpcName = "ShowConstantTbt"; + } else if (rpcName.equals("EncodedSyncPData") || rpcName.equals("OnEncodedSyncPData") || rpcName.equals("EncodedSyncPDataResponse")){ + ignoreRPC = true; + } + // ------------------------------------------------------------------------------------------------------------- + + if (!ignoreRPC) { + rpcParamsMap.put(rpcName, new ArrayList()); + } + } + // Store the params for the current RPC in the map + if(name.equals("param") && myParser.getAttributeValue(null, "until") == null && !ignoreRPC){ + setterMethodName = null; + getterMethodName1 = null; + getterMethodName2 = null; + javaParamType = null; + skipParam = false; + boolean isMandatory = Boolean.valueOf(myParser.getAttributeValue(null,"mandatory")); + if (isMandatory || !includeMandatoryOnly) { + String paramName = myParser.getAttributeValue(null, "name"); + String paramType = myParser.getAttributeValue(null, "type"); + boolean isArray = Boolean.valueOf(myParser.getAttributeValue(null, "array")); + + // -------------- Exceptional cases because of mismatch between the RPC spec and the Android code -------------- + if (paramName.equals("syncFileName")){ + paramName = "sdlFileName"; + } else if (paramName.equals("syncMsgVersion")){ + paramName = "sdlMsgVersion"; + } else if (paramName.equals("hmiPermissions")){ + paramName = "hMIPermissions"; + } else if (paramName.equals("resolution")){ + paramName = "imageResolution"; + } else if (paramName.equals("pressureTelltale")){ + paramName = "pressureTellTale"; + } + + setterMethodName = "set" + paramName.substring(0, 1).toUpperCase() + paramName.substring(1); + + if (paramType.equals("SyncMsgVersion")){ + paramType = "SdlMsgVersion"; + } else if (rpcName.equals("GPSData") && paramType.equals("Float")){ + paramType = "Double"; + } else if (rpcName.equals("TouchEvent") && paramType.equals("Integer") && isArray){ + paramType = "Long"; + } else if (paramType.equals("OASISAddress")) { + paramType = "OasisAddress"; + } else if (rpcName.equals("VideoStreamingCapability") && paramType.equals("Float")) { + paramType = "Double"; + } else if (rpcName.equals("UnsubscribeVehicleData") && setterMethodName.equals("setCloudAppVehicleID")) { + paramType = "boolean"; + } else if (rpcName.equals("CancelInteraction") && setterMethodName.equals("setFunctionID")) { + setterMethodName = "setInteractionFunctionID"; + } else if (rpcName.equals("NavigationCapability") && setterMethodName.equals("setGetWayPointsEnabled")) { + setterMethodName = "setWayPointsEnabled"; + } else if (rpcName.equals("UnsubscribeWayPointsResponse") && setterMethodName.equals("setGetWayPointsEnabled")) { + setterMethodName = "setWayPointsEnabled"; + } else if (rpcName.equals("HMICapabilities") && setterMethodName.equals("setNavigation")) { + setterMethodName = "setNavigationAvilable"; + } else if (rpcName.equals("HMICapabilities") && setterMethodName.equals("setPhoneCall")) { + setterMethodName = "setPhoneCallAvilable"; + } else if (rpcName.equals("HMICapabilities") && setterMethodName.equals("setDisplays")) { + setterMethodName = "setDisplaysCapabilityAvailable"; + } else if (rpcName.equals("HMICapabilities")) { + setterMethodName += "Available"; + } else if (rpcName.equals("VideoStreamingCapability") && setterMethodName.equals("setHapticSpatialDataSupported")) { + setterMethodName = "setIsHapticSpatialDataSupported"; + } else if (rpcName.equals("OnDriverDistraction") && setterMethodName.equals("setLockScreenDismissalEnabled")) { + setterMethodName = "setLockscreenDismissibility"; + paramType = "boolean"; + } else if (rpcName.equals("OnDriverDistraction") && setterMethodName.equals("setLockScreenDismissalWarning")) { + setterMethodName = "setLockscreenWarningMessage"; + } else if (rpcName.equals("PublishAppServiceResponse") && setterMethodName.equals("setAppServiceRecord")) { + setterMethodName = "setServiceRecord"; + } else if (setterMethodName.equals("setFuelLevel_State")) { + setterMethodName = "setFuelLevelState"; + } else if (rpcName.equals("LightCapabilities") && setterMethodName.equals("setRgbColorSpaceAvailable")) { + setterMethodName = "setRGBColorSpaceAvailable"; + } else if (rpcName.equals("CloudAppProperties") && setterMethodName.equals("setEnabled")) { + paramType = "boolean"; + } else if (rpcName.equals("DateTime") && setterMethodName.equals("setMillisecond")) { + setterMethodName = "setMilliSecond"; + } else if (rpcName.equals("DateTime") && setterMethodName.equals("setTz_hour")) { + setterMethodName = "setTzHour"; + } else if (rpcName.equals("DateTime") && setterMethodName.equals("setTz_minute")) { + setterMethodName = "setTzMinute"; + } else if (rpcName.equals("PutFile") && setterMethodName.equals("setCrc")) { + setterMethodName = "setCRC"; + paramType = "Long"; + } else if (rpcName.equals("AppServiceManifest") && setterMethodName.equals("setHandledRPCs")) { + setterMethodName = "setHandledRpcs"; + } else if (rpcName.equals("LocationDetails") && setterMethodName.equals("setHandledRPCs")) { + setterMethodName = "setHandledRpcs"; + } else if (rpcName.equals("SendLocation") && setterMethodName.equals("setLongitudeDegrees")) { + paramType = "Double"; + } else if (rpcName.equals("SendLocation") && setterMethodName.equals("setLatitudeDegrees")) { + paramType = "Double"; + } else if (rpcName.equals("Grid") && setterMethodName.equals("setColspan")) { + setterMethodName = "setColSpan"; + } else if (rpcName.equals("Grid") && setterMethodName.equals("setRowspan")) { + setterMethodName = "setRowSpan"; + } else if (rpcName.equals("Grid") && setterMethodName.equals("setLevelspan")) { + setterMethodName = "setLevelSpan"; + } else if (rpcName.equals("HeadLampStatus") && setterMethodName.equals("setAmbientLightSensorStatus")) { + setterMethodName = "setAmbientLightStatus"; + } else if (rpcName.equals("GetVehicleData") && setterMethodName.equals("setCloudAppVehicleID")) { + paramType = "boolean"; + } else if (rpcName.equals("GetVehicleDataResponse") && Arrays.asList("setInstantFuelConsumption", "setFuelLevel", "setSpeed", "setExternalTemperature", "setEngineTorque", "setAccPedalPosition", "setSteeringWheelAngle").contains(setterMethodName)) { + paramType = "Double"; + } else if (rpcName.equals("RdsData") && setterMethodName.equals("setPS")) { + setterMethodName = "setProgramService"; + } else if (rpcName.equals("RdsData") && setterMethodName.equals("setCT")) { + setterMethodName = "setClockText"; + } else if (rpcName.equals("RdsData") && setterMethodName.equals("setRT")) { + setterMethodName = "setRadioText"; + } else if (rpcName.equals("RdsData") && setterMethodName.equals("setPI")) { + setterMethodName = "setProgramIdentification"; + } else if (rpcName.equals("RdsData") && setterMethodName.equals("setPTY")) { + setterMethodName = "setProgramType"; + } else if (rpcName.equals("RdsData") && setterMethodName.equals("setTP")) { + setterMethodName = "setTrafficProgram"; + } else if (rpcName.equals("RdsData") && setterMethodName.equals("setTA")) { + setterMethodName = "setTrafficAnnouncement"; + } else if (rpcName.equals("RdsData") && setterMethodName.equals("setREG")) { + setterMethodName = "setRegion"; + } else if (rpcName.equals("RadioControlCapabilities") && setterMethodName.equals("setSiriusxmRadioAvailable")) { + setterMethodName = "setSiriusXMRadioAvailable"; + } else if (rpcName.equals("GetCloudAppPropertiesResponse") && setterMethodName.equals("setProperties")) { + setterMethodName = "setCloudAppProperties"; + } else if (rpcName.equals("GetFileResponse") && setterMethodName.equals("setCrc")) { + setterMethodName = "setCRC"; + } else if (rpcName.equals("RegisterAppInterfaceResponse") && setterMethodName.equals("setPcmStreamCapabilities")) { + setterMethodName = "setPcmStreamingCapabilities"; + } else if (rpcName.equals("SubscribeVehicleData") && setterMethodName.equals("setElectronicParkBrakeStatus")) { + paramType = "boolean"; + } else if (rpcName.equals("SubscribeVehicleData") && setterMethodName.equals("setCloudAppVehicleID")) { + paramType = "boolean"; + } else if (rpcName.equals("ModuleInfo") && setterMethodName.equals("setLocation")) { + setterMethodName = "setModuleLocation"; + } else if (rpcName.equals("ModuleInfo") && setterMethodName.equals("setServiceArea")) { + setterMethodName = "setModuleServiceArea"; + } else if (rpcName.equals("ModuleInfo") && setterMethodName.equals("setAllowMultipleAccess")) { + setterMethodName = "setMultipleAccessAllowance"; + } else if (rpcName.equals("OnVehicleData") && setterMethodName.equals("setSpeed")) { + paramType = "Double"; + } else if (rpcName.equals("OnVehicleData") && setterMethodName.equals("setFuelLevel")) { + paramType = "Double"; + } else if (rpcName.equals("OnVehicleData") && setterMethodName.equals("setInstantFuelConsumption")) { + paramType = "Double"; + } else if (rpcName.equals("OnVehicleData") && setterMethodName.equals("setExternalTemperature")) { + paramType = "Double"; + } else if (rpcName.equals("OnVehicleData") && setterMethodName.equals("setEngineTorque")) { + paramType = "Double"; + } else if (rpcName.equals("OnVehicleData") && setterMethodName.equals("setAccPedalPosition")) { + paramType = "Double"; + } else if (rpcName.equals("OnVehicleData") && setterMethodName.equals("setSteeringWheelAngle")) { + paramType = "Double"; + } else if (rpcName.equals("GetInteriorVehicleDataConsentResponse") && setterMethodName.equals("setAllowed")) { + setterMethodName = "setAllowances"; + } else if (rpcName.equals("SeatLocationCapability") && setterMethodName.equals("setColumns")) { + setterMethodName = "setCols"; + } else if (rpcName.equals("ShowConstantTbt") && setterMethodName.equals("setDistanceToManeuver")) { + paramType = "Double"; + } else if (rpcName.equals("ShowConstantTbt") && setterMethodName.equals("setDistanceToManeuverScale")) { + paramType = "Double"; + } else if (rpcName.equals("SingleTireStatus") && setterMethodName.equals("setTpms")) { + setterMethodName = "setTPMS"; + } else if (rpcName.equals("VehicleDataResult") && setterMethodName.equals("setOemCustomDataType")) { + setterMethodName = "setOEMCustomVehicleDataType"; + } else if (rpcName.equals("SystemCapability") && !setterMethodName.equals("setSystemCapabilityType")) { + setterMethodName = "setCapabilityForType"; + paramType = "SystemCapabilityType"; + } else if (rpcName.equals("UnsubscribeWayPointsResponse") && paramName.equals("wayPoints")) { + skipParam = true; + } else if (rpcName.equals("UnsubscribeVehicleDataResponse") && paramName.equals("clusterModes")) { + skipParam = true; + } else if (rpcName.equals("ClimateControlCapabilities") && paramName.equals("currentTemperatureAvailable")) { + skipParam = true; + } else if (rpcName.equals("SubscribeVehicleDataResponse") && paramName.equals("clusterModes")) { + skipParam = true; + } + + // ------------------------------------------------------------------------------------------------------------- + + javaParamType = findJavaTypeForParam(paramType, isArray); + getterMethodName1 = "get" + setterMethodName.substring(3); + if (paramType.equalsIgnoreCase("boolean")) { + getterMethodName2 = "is" + setterMethodName.substring(3); + } + + Parameter param = new Parameter() + .setRPCName(rpcName) + .setName(paramName) + .setType(paramType) + .setJavaType(javaParamType) + .setArray(isArray) + .setMandatory(isMandatory) + .setSkip(skipParam) + .setSetterName(setterMethodName) + .setGetterName1(getterMethodName1) + .setGetterName2(getterMethodName2) + ; + + rpcParamsMap.get(rpcName).add(param); + } + } + break; + } + event = myParser.next(); + } + stream.close(); + } catch (IOException | XmlPullParserException e) { + fail("Cannot parse mobile APIs XML file: " + e.getMessage()); + } + return rpcParamsMap; + } + + // This method makes sure that for every RPC, there is a constructor that has all the mandatory params + // It also checks if there are RPC in the XML file that don't exist in the code + @Test + public void testMandatoryParamsMatch() { + // List of RPC names that don't have a constructor that has all mandatory params + List rpcsWithInvalidConstructor = new ArrayList<>(); + + // List of the RPC names that couldn't be found in code + // potentially because of a mismatch between name in the RPC spec xml file and name in code + List rpcsFromXmlNotFoundInCode = new ArrayList<>(); + + // Loop through all RPCs that were loaded from RPC spec XML file + // and make sure that every RPC has a constructor that has all mandatory params + for (String rpcName : rpcMandatoryParamsMapFromXml.keySet()) { + Class aClass; + try { + aClass = Class.forName(RPC_PACKAGE_PREFIX + rpcName); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + rpcsFromXmlNotFoundInCode.add(rpcName); + continue; + } + List mandatoryParamsListFromXML = new ArrayList<>(); + for (Parameter param : rpcMandatoryParamsMapFromXml.get(rpcName)) { + String type = param.type; + // If the param is a list of objects, the type should be like "List" + if (param.isArray){ + type = String.format("List<%s>", type); + } + mandatoryParamsListFromXML.add(type); + } + List mandatoryParamsListFromCode = new ArrayList<>(); + boolean rpcHasValidConstructor = false; + for (Constructor constructor : aClass.getConstructors()){ + mandatoryParamsListFromCode.clear(); + for (Type paramType : constructor.getGenericParameterTypes()){ + String paramFullType = paramType.toString(); + String paramSimpleType; + + // If the param is a list of objects, the type should be like "List" + if (paramFullType.matches("java.util.List<.+>")) { + paramSimpleType = String.format("List<%s>", paramFullType.substring(paramFullType.lastIndexOf('.') + 1, paramFullType.length() - 1)); + } + // If the param is a simple object for example "java.lang.String", the type should be the last part "String" + else if (!paramFullType.contains(">")){ + paramSimpleType = paramFullType.substring(paramFullType.lastIndexOf('.') + 1, paramFullType.length()); + } + else { + paramSimpleType = paramFullType; + } + mandatoryParamsListFromCode.add(paramSimpleType); + } + if (mandatoryParamsListFromCode.containsAll(mandatoryParamsListFromXML) && mandatoryParamsListFromXML.containsAll(mandatoryParamsListFromCode)){ + rpcHasValidConstructor = true; + break; + } + } + if (!rpcHasValidConstructor){ + rpcsWithInvalidConstructor.add(rpcName); + } + } + assertTrue("The following RPCs were not found in the code: " + rpcsFromXmlNotFoundInCode, rpcsFromXmlNotFoundInCode.isEmpty()); + assertTrue("The following RPCs don't have a constructor that has all the mandatory params: " + rpcsWithInvalidConstructor, rpcsWithInvalidConstructor.isEmpty()); + } + + // This method returns the correct java reflection method in a specific class + private Method getMethod(Class aClass, Parameter parameter, String methodName, boolean isGetter) throws NoSuchMethodException { + Method method = null; + if (methodName == null) { + throw new NoSuchMethodException(); + } + if (isGetter) { + if (parameter.rpcName.equals("SystemCapability") && !methodName.contains("SystemCapabilityType")) { + method = aClass.getMethod(methodName, SystemCapabilityType.class); + } else { + method = aClass.getMethod(methodName); + } + } else { + if (parameter.rpcName.equals("SystemCapability") && !methodName.contains("SystemCapabilityType")) { + method = aClass.getMethod(methodName, SystemCapabilityType.class, Object.class); + } else { + method = aClass.getMethod(methodName, parameter.javaType); + } + } + return method; + } + + // This method returns the full Java type for a param + private Class findJavaTypeForParam(String type, boolean isArray) { + String typeString = null; + Class javaType = null; + + // List of types that exist in java.lang.* + List javaLangBuiltInTypes = Arrays.asList("String", "Integer", "Long", "Float", "Double", "Boolean"); + + // List of primitive types in java + List javaLangPrimitiveTypes = Arrays.asList("int", "long", "float", "double", "boolean"); + + // Find the full Java type for the current param + try { + if (isArray) { + javaType = List.class; + } else if (javaLangPrimitiveTypes.contains(type)) { + if (type.equals("int")) { + javaType = int.class; + } else if (type.equals("long")) { + javaType = long.class; + } else if (type.equals("float")) { + javaType = float.class; + } else if (type.equals("double")) { + javaType = double.class; + } else if (type.equals("boolean")) { + javaType = boolean.class; + } + } else { + if (javaLangBuiltInTypes.contains(type)) { + typeString = "java.lang." + type; + } else { + typeString = RPC_PACKAGE_PREFIX + type; + } + javaType = Class.forName(typeString); + } + + } catch (ClassNotFoundException e) { + // If the class was not found in the rpc package + // try to see if it can be found in enums package + typeString = RPC_PACKAGE_PREFIX + "enums." + type; + try { + javaType = Class.forName(typeString); + } catch (ClassNotFoundException e1) { + e1.printStackTrace(); + } + } + assertNotNull("Java type cannot be found for: " + type, javaType); + return javaType; + } + + // This method makes sure that for every RPC, the constructor that has the mandatory params is setting the values correctly + @Test + public void testMandatoryParamsValues() { + // List of RPC names that have a constructor which is not settings the values for the mandatory params correctly + List rpcsWithInvalidConstructor = new ArrayList<>(); + + // Loop through all RPCs that were loaded from RPC spec XML file + // and make sure that the constructor that has the mandatory params is setting the values correctly + for (String rpcName : rpcMandatoryParamsMapFromXml.keySet()) { + Class aClass; + try { + aClass = Class.forName(RPC_PACKAGE_PREFIX + rpcName); + } catch (ClassNotFoundException e) { + fail(e.getMessage()); + continue; + } + + List parameters = rpcMandatoryParamsMapFromXml.get(rpcName); + List> mandatoryParamsTypes = new ArrayList<>(); + List mandatoryParamsValues = new ArrayList<>(); + + // Loop through all mandatory params for the current RPC + // and try to find the full Java type for each param + // also assign a value for each param from TestValues class + for (Parameter param : parameters) { + String valueString = null; + Object value = null; + + // Assign a value for the current param from TestValues based of the param type + try { + // --------------------------------------------- Exceptional cases --------------------------------------------- + // This case is exceptional because the setter changes the input if it is not all digits + if (rpcName.equals("DialNumber") && param.type.equals("String")){ + value = "5558675309"; + } + // ------------------------------------------------------------------------------------------------------------- + + if (value == null) { + valueString = "GENERAL_" + param.type.toUpperCase(); + if (param.isArray){ + valueString += "_LIST"; + } + value = Class.forName(TEST_VALUES_CLASS).getDeclaredField(valueString).get(null); + } + + } catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) { + e.printStackTrace(); + fail("Value: " + valueString + " cannot be found for RPC: " + rpcName + ". Make sure that you declared that value in " + TEST_VALUES_CLASS); + } + + mandatoryParamsTypes.add(param.javaType); + mandatoryParamsValues.add(value); + } + + + // Create an instance of the RPC object using the constructor that has all the mandatory params + Object instance = null; + try { + Constructor constructor = aClass.getConstructor(mandatoryParamsTypes.toArray(new Class[mandatoryParamsTypes.size()])); + instance = constructor.newInstance(mandatoryParamsValues.toArray(new Object[mandatoryParamsValues.size()])); + } catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) { + e.printStackTrace(); + fail("Constructor for RPC " + rpcName + " cannot be invoked. Make sure that the constructor parameters order and types are identical to the RPC specs"); + } + + + // Loop through all getter methods for the instance and make sure that they are returning the expected values + if (instance != null) { + for (int i = 0; i < parameters.size(); i++) { + try { + Method getterMethod = getMethod(aClass, parameters.get(i), parameters.get(i).getterName1, true); + Object val = getterMethod.invoke(instance); + if (val == null || !val.equals(mandatoryParamsValues.get(i))) { + rpcsWithInvalidConstructor.add(rpcName); + break; + } + } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + fail("Method: " + parameters.get(i).getterName1 + " cannot be found for RPC: " + rpcName + ". Make sure that the method exists and that the parameters order and types are identical to the RPC specs"); + } + } + } + } + + assertTrue("The following RPCs have a constructor that is not setting the mandatory params correctly: " + rpcsWithInvalidConstructor, rpcsWithInvalidConstructor.isEmpty()); + } + + /** + * This method makes sure that for every param in every RPC: + * - A setter exists and its name matches the RPC spec + * - The setter return type matches the RPC type (to make RPCs chainable) + * - A getter exists and its name matches the RPC spec + */ + @Test + public void testParamsSettersAndGetters() { + List errors = new ArrayList<>(); + + // Loop through all RPCs that were loaded from RPC spec XML file + for (String rpcName : rpcAllParamsMapFromXml.keySet()) { + Class aClass; + try { + aClass = Class.forName(RPC_PACKAGE_PREFIX + rpcName); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + errors.add("Class not found for rpc: "+ rpcName + ". \n"); + continue; + } + + // Loop through all params for the current RPC and make sure everyone has a a setter and a getter + List parameters = rpcAllParamsMapFromXml.get(rpcName); + for (int i = 0; i < parameters.size(); i++) { + Parameter parameter = parameters.get(i); + if (parameter.skip) { + continue; + } + + // Confirm that the setter is correct + try { + Method setterMethod = getMethod(aClass, parameter, parameter.setterName, false); + List expectedReturnTypes = Arrays.asList(aClass.getName(), aClass.getSuperclass().getName()); + String actualReturnType = setterMethod.getReturnType().getName(); + if (!expectedReturnTypes.contains(actualReturnType)) { + String errMsg = rpcName + "." + parameter.setterName + "() is expected to return one of these types: " + expectedReturnTypes + " but it returns: " + actualReturnType + ". \n"; + errors.add(errMsg); + } + } catch (NoSuchMethodException e) { + String errMsg = rpcName + "." + parameter.setterName + "(" + parameter.type + ")" + " cannot be found. Make sure that the method exists. \n"; + errors.add(errMsg); + } + + // Confirm that the getter is correct + Method getterMethod = null; + try { + // --------------------------------------------- Exceptional cases --------------------------------------------- + if (parameter.getterName1.contains("Avilable")) { + continue; + } else if (parameter.getterName1.equals("getSeats")) { + parameter.getterName1 = "getSeatLocations"; + } + // ------------------------------------------------------------------------------------------------------------- + getterMethod = getMethod(aClass, parameter, parameter.getterName1, true); + } catch (NoSuchMethodException e) { + try { + getterMethod = getMethod(aClass, parameter, parameter.getterName2, true); + } catch (NoSuchMethodException ex) { + ex.printStackTrace(); + String errMsg = String.format(rpcName + "." + parameter.getterName1 + "()" + "%s" + " cannot be found. Make sure that the method exists. \n", parameter.type.equalsIgnoreCase("boolean")? "/" + parameter.getterName2 + "()" : ""); + errors.add(errMsg); + } + } + } + } + + assertTrue("There are " + errors.size() + " errors: \n" + errors, errors.isEmpty()); + } +} diff --git a/base/src/main/java/com/smartdevicelink/proxy/RPCMessage.java b/base/src/main/java/com/smartdevicelink/proxy/RPCMessage.java index ac0d11506..427379842 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/RPCMessage.java +++ b/base/src/main/java/com/smartdevicelink/proxy/RPCMessage.java @@ -100,8 +100,9 @@ public class RPCMessage extends RPCStruct { return (String)function.get(KEY_FUNCTION_NAME); } - protected void setFunctionName(String functionName) { + protected RPCMessage setFunctionName(String functionName) { function.put(KEY_FUNCTION_NAME, functionName); + return this; } public String getMessageType() { @@ -115,12 +116,13 @@ public class RPCMessage extends RPCStruct { // Generalized Getters and Setters - public void setParameters(String key, Object value) { + public RPCMessage setParameters(String key, Object value) { if (value != null) { parameters.put(key, value); } else { parameters.remove(key); } + return this; } public Object getParameters(String key) { diff --git a/base/src/main/java/com/smartdevicelink/proxy/RPCRequest.java b/base/src/main/java/com/smartdevicelink/proxy/RPCRequest.java index 22ce1c2a5..7dc9de1d3 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/RPCRequest.java +++ b/base/src/main/java/com/smartdevicelink/proxy/RPCRequest.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy; import com.smartdevicelink.proxy.rpc.listeners.OnRPCResponseListener; @@ -64,15 +64,17 @@ public class RPCRequest extends RPCMessage { return (Integer)function.get(RPCMessage.KEY_CORRELATION_ID); } - public void setCorrelationID(Integer correlationID) { + public RPCRequest setCorrelationID(Integer correlationID) { if (correlationID != null) { function.put(RPCMessage.KEY_CORRELATION_ID, correlationID ); } else { function.remove(RPCMessage.KEY_CORRELATION_ID); } + return this; } - public void setOnRPCResponseListener(OnRPCResponseListener listener){ + public RPCRequest setOnRPCResponseListener(OnRPCResponseListener listener){ onResponseListener = listener; + return this; } public OnRPCResponseListener getOnRPCResponseListener(){ diff --git a/base/src/main/java/com/smartdevicelink/proxy/RPCResponse.java b/base/src/main/java/com/smartdevicelink/proxy/RPCResponse.java index 771ccfe7c..b0a3549dc 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/RPCResponse.java +++ b/base/src/main/java/com/smartdevicelink/proxy/RPCResponse.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy; import androidx.annotation.NonNull; @@ -126,12 +126,13 @@ public class RPCResponse extends RPCMessage { * @param correlationID * the ID of the response */ - public void setCorrelationID(Integer correlationID) { + public RPCResponse setCorrelationID(Integer correlationID) { if (correlationID != null) { function.put(RPCMessage.KEY_CORRELATION_ID, correlationID ); } else { function.remove(RPCMessage.KEY_CORRELATION_ID); } + return this; } /** *

@@ -151,10 +152,11 @@ public class RPCResponse extends RPCMessage { * @param success * whether the request is successfully processed */ - public void setSuccess( @NonNull Boolean success ) { + public RPCResponse setSuccess( @NonNull Boolean success ) { if (success != null) { parameters.put(RPCResponse.KEY_SUCCESS, success ); } + return this; } /** *

@@ -180,10 +182,11 @@ public class RPCResponse extends RPCMessage { * @param resultCode * whether the request is successfully processed */ - public void setResultCode( @NonNull Result resultCode ) { + public RPCResponse setResultCode( @NonNull Result resultCode ) { if (resultCode != null) { parameters.put(RPCResponse.KEY_RESULT_CODE, resultCode ); } + return this; } /** *

@@ -203,9 +206,10 @@ public class RPCResponse extends RPCMessage { * @param info * a string of text representing additional information returned from SDL */ - public void setInfo( String info ) { + public RPCResponse setInfo( String info ) { if (info != null) { parameters.put(RPCResponse.KEY_INFO, info ); } + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/RPCStruct.java b/base/src/main/java/com/smartdevicelink/proxy/RPCStruct.java index cebe43a60..e54694526 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/RPCStruct.java +++ b/base/src/main/java/com/smartdevicelink/proxy/RPCStruct.java @@ -172,7 +172,7 @@ public class RPCStruct { return this._bulkData; } - public void setBulkData(byte[] bulkData) { + public RPCStruct setBulkData(byte[] bulkData) { if (bulkData != null) { this._bulkData = new byte[bulkData.length]; System.arraycopy(bulkData, 0, _bulkData, 0, bulkData.length); @@ -180,10 +180,12 @@ public class RPCStruct { else{ this._bulkData = null; } + return this; } - public void setPayloadProtected(Boolean bVal) { + public RPCStruct setPayloadProtected(Boolean bVal) { protectedPayload = bVal; + return this; } public Boolean isPayloadProtected() { @@ -217,12 +219,13 @@ public class RPCStruct { // Generalized Getters and Setters - public void setValue(String key, Object value){ + public RPCStruct setValue(String key, Object value){ if (value != null) { store.put(key, value); } else { store.remove(key); } + return this; } public Object getValue(String key) { diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/AddCommand.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/AddCommand.java index c46fb4a7a..57d0719a5 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/AddCommand.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/AddCommand.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -165,15 +165,16 @@ public class AddCommand extends RPCRequest { *

Sets an Unique Command ID that identifies the command. Is returned in an * {@linkplain OnCommand} notification to identify the command * selected by the user

- * - * + * + * * @param cmdID * an integer object representing a Command ID *

* Notes: Min Value: 0; Max Value: 2000000000

*/ - public void setCmdID(@NonNull Integer cmdID) { - setParameters(KEY_CMD_ID, cmdID); + public AddCommand setCmdID(@NonNull Integer cmdID) { + setParameters(KEY_CMD_ID, cmdID); + return this; } /** *

@@ -195,12 +196,13 @@ public class AddCommand extends RPCRequest { * Command Menu

* If null, commands will not be accessible through the HMI application menu *

- * + * * @param menuParams * a menuParams object - */ - public void setMenuParams(MenuParams menuParams) { + */ + public AddCommand setMenuParams( MenuParams menuParams) { setParameters(KEY_MENU_PARAMS, menuParams); + return this; } /** *

@@ -222,7 +224,7 @@ public class AddCommand extends RPCRequest { *

If null, commands will not be accessible by voice commands (when the user * hits push-to-talk) *

- * + * * @param vrCommands * List indicating one or more VR phrases *

@@ -230,8 +232,9 @@ public class AddCommand extends RPCRequest { * provided, array must contain at least one non-empty (not null, * not zero-length, not whitespace only) element

*/ - public void setVrCommands( List vrCommands ) { - setParameters(KEY_VR_COMMANDS, vrCommands); + public AddCommand setVrCommands( List vrCommands) { + setParameters(KEY_VR_COMMANDS, vrCommands); + return this; } /** @@ -256,7 +259,8 @@ public class AddCommand extends RPCRequest { * default if applicable) icon will be displayed

* @since SmartDeviceLink 2.0 */ - public void setCmdIcon(Image cmdIcon) { + public AddCommand setCmdIcon( Image cmdIcon) { setParameters(KEY_CMD_ICON, cmdIcon); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/AddSubMenu.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/AddSubMenu.java index 3751134e0..e2453a727 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/AddSubMenu.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/AddSubMenu.java @@ -166,15 +166,16 @@ public class AddSubMenu extends RPCRequest { *

Sets a Menu ID that identifies a sub menu.

This value is used in * {@linkplain AddCommand} to which SubMenu is the parent of the command * being added

- * - * + * + * * @param menuID * an integer object representing a Menu ID - * + * *

Notes: Min Value: 0; Max Value: 2000000000

- */ - public void setMenuID( @NonNull Integer menuID ) { - setParameters(KEY_MENU_ID, menuID); + */ + public AddSubMenu setMenuID(@NonNull Integer menuID) { + setParameters(KEY_MENU_ID, menuID); + return this; } /** *

Returns an Integer object representing the position of menu

@@ -187,7 +188,7 @@ public class AddSubMenu extends RPCRequest { } /** * Sets a position of menu - * + * * @param position *

An Integer object representing the position within the items * of the top level Command Menu. 0 will insert at the front, 1 @@ -204,9 +205,10 @@ public class AddSubMenu extends RPCRequest { *

  • If this parameter is omitted, the entry will be added at * the end of the list
  • * - */ - public void setPosition( Integer position ) { - setParameters(KEY_POSITION, position); + */ + public AddSubMenu setPosition( Integer position) { + setParameters(KEY_POSITION, position); + return this; } /** * Returns String which is displayed representing this submenu item @@ -218,12 +220,13 @@ public class AddSubMenu extends RPCRequest { } /** * Sets a menuName which is displayed representing this submenu item - * + * * @param menuName * String which will be displayed representing this submenu item - */ - public void setMenuName( @NonNull String menuName ) { - setParameters(KEY_MENU_NAME, menuName); + */ + public AddSubMenu setMenuName(@NonNull String menuName) { + setParameters(KEY_MENU_NAME, menuName); + return this; } /** * Returns Image to be be shown along with the submenu item @@ -239,17 +242,19 @@ public class AddSubMenu extends RPCRequest { * @param menuIcon * Image to be be shown along with the submenu item */ - public void setMenuIcon(Image menuIcon) { - setParameters(KEY_MENU_ICON, menuIcon); - } + public AddSubMenu setMenuIcon( Image menuIcon) { + setParameters(KEY_MENU_ICON, menuIcon); + return this; + } /** * Sets the layout of the submenu screen. * @param menuLayout - the menuLayout */ - public void setMenuLayout(MenuLayout menuLayout) { - setParameters(KEY_MENU_LAYOUT, menuLayout); - } + public AddSubMenu setMenuLayout( MenuLayout menuLayout) { + setParameters(KEY_MENU_LAYOUT, menuLayout); + return this; + } /** * Gets the layout of the submenu screen. @@ -267,9 +272,10 @@ public class AddSubMenu extends RPCRequest { * provided to the top level of the in application menu. * @since SmartDeviceLink 7.0.0 */ - public void setParentID(Integer parentID) { - setParameters(KEY_PARENT_ID, parentID); - } + public AddSubMenu setParentID( Integer parentID) { + setParameters(KEY_PARENT_ID, parentID); + return this; + } /** * Gets the parentID. diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/AirbagStatus.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/AirbagStatus.java index 49fdf959e..55498160a 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/AirbagStatus.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/AirbagStatus.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -149,50 +149,58 @@ public class AirbagStatus extends RPCStruct { setPassengerKneeAirbagDeployed(passengerKneeAirbagDeployed); } - public void setDriverAirbagDeployed(@NonNull VehicleDataEventStatus driverAirbagDeployed) { + public AirbagStatus setDriverAirbagDeployed(@NonNull VehicleDataEventStatus driverAirbagDeployed) { setValue(KEY_DRIVER_AIRBAG_DEPLOYED, driverAirbagDeployed); + return this; } public VehicleDataEventStatus getDriverAirbagDeployed() { return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_DRIVER_AIRBAG_DEPLOYED); } - public void setDriverSideAirbagDeployed(@NonNull VehicleDataEventStatus driverSideAirbagDeployed) { + public AirbagStatus setDriverSideAirbagDeployed(@NonNull VehicleDataEventStatus driverSideAirbagDeployed) { setValue(KEY_DRIVER_SIDE_AIRBAG_DEPLOYED, driverSideAirbagDeployed); + return this; } public VehicleDataEventStatus getDriverSideAirbagDeployed() { return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_DRIVER_SIDE_AIRBAG_DEPLOYED); } - public void setDriverCurtainAirbagDeployed(@NonNull VehicleDataEventStatus driverCurtainAirbagDeployed) { + public AirbagStatus setDriverCurtainAirbagDeployed(@NonNull VehicleDataEventStatus driverCurtainAirbagDeployed) { setValue(KEY_DRIVER_CURTAIN_AIRBAG_DEPLOYED, driverCurtainAirbagDeployed); + return this; } public VehicleDataEventStatus getDriverCurtainAirbagDeployed() { return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_DRIVER_CURTAIN_AIRBAG_DEPLOYED); } - public void setPassengerAirbagDeployed(@NonNull VehicleDataEventStatus passengerAirbagDeployed) { + public AirbagStatus setPassengerAirbagDeployed(@NonNull VehicleDataEventStatus passengerAirbagDeployed) { setValue(KEY_PASSENGER_AIRBAG_DEPLOYED, passengerAirbagDeployed); + return this; } public VehicleDataEventStatus getPassengerAirbagDeployed() { return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_PASSENGER_AIRBAG_DEPLOYED); } - public void setPassengerCurtainAirbagDeployed(@NonNull VehicleDataEventStatus passengerCurtainAirbagDeployed) { + public AirbagStatus setPassengerCurtainAirbagDeployed(@NonNull VehicleDataEventStatus passengerCurtainAirbagDeployed) { setValue(KEY_PASSENGER_CURTAIN_AIRBAG_DEPLOYED, passengerCurtainAirbagDeployed); + return this; } public VehicleDataEventStatus getPassengerCurtainAirbagDeployed() { return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_PASSENGER_CURTAIN_AIRBAG_DEPLOYED); } - public void setDriverKneeAirbagDeployed(@NonNull VehicleDataEventStatus driverKneeAirbagDeployed) { + public AirbagStatus setDriverKneeAirbagDeployed(@NonNull VehicleDataEventStatus driverKneeAirbagDeployed) { setValue(KEY_DRIVER_KNEE_AIRBAG_DEPLOYED, driverKneeAirbagDeployed); + return this; } public VehicleDataEventStatus getDriverKneeAirbagDeployed() { return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_DRIVER_KNEE_AIRBAG_DEPLOYED); } - public void setPassengerSideAirbagDeployed(@NonNull VehicleDataEventStatus passengerSideAirbagDeployed) { + public AirbagStatus setPassengerSideAirbagDeployed(@NonNull VehicleDataEventStatus passengerSideAirbagDeployed) { setValue(KEY_PASSENGER_SIDE_AIRBAG_DEPLOYED, passengerSideAirbagDeployed); + return this; } public VehicleDataEventStatus getPassengerSideAirbagDeployed() { return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_PASSENGER_SIDE_AIRBAG_DEPLOYED); } - public void setPassengerKneeAirbagDeployed(@NonNull VehicleDataEventStatus passengerKneeAirbagDeployed) { + public AirbagStatus setPassengerKneeAirbagDeployed(@NonNull VehicleDataEventStatus passengerKneeAirbagDeployed) { setValue(KEY_PASSENGER_KNEE_AIRBAG_DEPLOYED, passengerKneeAirbagDeployed); + return this; } public VehicleDataEventStatus getPassengerKneeAirbagDeployed() { return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_PASSENGER_KNEE_AIRBAG_DEPLOYED); diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/Alert.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/Alert.java index a67484131..dbb16c073 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/Alert.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/Alert.java @@ -204,10 +204,10 @@ public class Alert extends RPCRequest { /** * Sets the String to be displayed in the first field of the display during * the Alert - * + * * @param alertText1 * String Value - * + * *

    Notes:

    *
      *
    • Length is limited to what is indicated in @@ -215,9 +215,10 @@ public class Alert extends RPCRequest { *
    • If omitted, top display line will be cleared
    • *
    • Text is always centered
    • *
    - */ - public void setAlertText1(String alertText1) { - setParameters(KEY_ALERT_TEXT_1, alertText1); + */ + public Alert setAlertText1( String alertText1) { + setParameters(KEY_ALERT_TEXT_1, alertText1); + return this; } /** * Gets the text which is displayed in the second field of the display @@ -232,10 +233,10 @@ public class Alert extends RPCRequest { /** * Sets the String to be displayed in the second field of the display during * the Alert - * + * * @param alertText2 * String Value - * + * *

    Notes:

    *
      *
    • Only permitted if HMI supports a second display line
    • @@ -244,9 +245,10 @@ public class Alert extends RPCRequest { *
    • If omitted, second display line will be cleared
    • *
    • Text is always centered
    • *
    - */ - public void setAlertText2(String alertText2) { - setParameters(KEY_ALERT_TEXT_2, alertText2); + */ + public Alert setAlertText2( String alertText2) { + setParameters(KEY_ALERT_TEXT_2, alertText2); + return this; } /** @@ -265,10 +267,10 @@ public class Alert extends RPCRequest { /** * Sets the String to be displayed in the third field of the display during * the Alert - * + * * @param alertText3 * String Value - * + * *

    Notes:

    *
      *
    • Only permitted if HMI supports a third display line
    • @@ -277,11 +279,12 @@ public class Alert extends RPCRequest { *
    • If omitted, third display line will be cleared
    • *
    • Text is always centered
    • *
    - * + * * @since SmartDeviceLink 2.0 */ - public void setAlertText3(String alertText3) { - setParameters(KEY_ALERT_TEXT_3, alertText3); + public Alert setAlertText3( String alertText3) { + setParameters(KEY_ALERT_TEXT_3, alertText3); + return this; } /** * Gets TTSChunk[], the Array of type TTSChunk which, taken together, @@ -297,13 +300,14 @@ public class Alert extends RPCRequest { /** * Sets array of type TTSChunk which, taken together, specify what is to be * spoken to the user - * + * * @param ttsChunks - * + * *

    Notes: Array must have a least one element

    - */ - public void setTtsChunks(List ttsChunks) { - setParameters(KEY_TTS_CHUNKS, ttsChunks); + */ + public Alert setTtsChunks( List ttsChunks) { + setParameters(KEY_TTS_CHUNKS, ttsChunks); + return this; } /** * Gets the duration of the displayed portion of the alert, in milliseconds @@ -319,8 +323,8 @@ public class Alert extends RPCRequest { * After this amount of time has passed, the display fields alertText1 and * alertText2 will revert to what was displayed in those fields before the * alert began

    - * - * + * + * * @param duration * the Integer values representing the duration time, in * milliseconds @@ -330,9 +334,10 @@ public class Alert extends RPCRequest { *
  • Min Value: 3000; Max Value: 10000
  • *
  • If omitted, the default is 5000 milliseconds
  • * - */ - public void setDuration(Integer duration) { - setParameters(KEY_DURATION, duration); + */ + public Alert setDuration( Integer duration) { + setParameters(KEY_DURATION, duration); + return this; } /** * Gets a Boolean value representing the alert tone @@ -346,15 +351,16 @@ public class Alert extends RPCRequest { /** * Sets whether the alert tone should be played before the TTS (if any) is * spoken - * + * * @param playTone * a Boolean value which specifies whether the alert tone should * be played before the TTS (if any) is spoken - * + * *

    Notes: If omitted, default is true

    - */ - public void setPlayTone(Boolean playTone) { - setParameters(KEY_PLAY_TONE, playTone); + */ + public Alert setPlayTone( Boolean playTone) { + setParameters(KEY_PLAY_TONE, playTone); + return this; } /** @@ -371,7 +377,7 @@ public class Alert extends RPCRequest { /** * Sets the SoftButtons - * + * * @param softButtons * a List value *

    @@ -384,8 +390,9 @@ public class Alert extends RPCRequest { * * @since SmartDeviceLink 2.0 */ - public void setSoftButtons(List softButtons) { - setParameters(KEY_SOFT_BUTTONS, softButtons); + public Alert setSoftButtons( List softButtons) { + setParameters(KEY_SOFT_BUTTONS, softButtons); + return this; } /** @@ -406,8 +413,9 @@ public class Alert extends RPCRequest { * * @since SmartDeviceLink 3.0 */ - public void setProgressIndicator(Boolean progressIndicator) { + public Alert setProgressIndicator( Boolean progressIndicator) { setParameters(KEY_PROGRESS_INDICATOR, progressIndicator); + return this; } /** @@ -428,9 +436,10 @@ public class Alert extends RPCRequest { * * @since SmartDeviceLink 6.0 */ - public void setCancelID(Integer cancelID) { - setParameters(KEY_CANCEL_ID, cancelID); - }; + public Alert setCancelID( Integer cancelID) { + setParameters(KEY_CANCEL_ID, cancelID); + return this; + }; /** *

    Sets the Image @@ -441,9 +450,10 @@ public class Alert extends RPCRequest { * Notes: If omitted on supported displays, no (or the * default if applicable) icon will be displayed

    */ - public void setAlertIcon(Image alertIcon) { - setParameters(KEY_ALERT_ICON, alertIcon); - } + public Alert setAlertIcon( Image alertIcon) { + setParameters(KEY_ALERT_ICON, alertIcon); + return this; + } /** *

    Gets the image to be shown along with the alert

    diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/AlertManeuver.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/AlertManeuver.java index 37b6c2da3..9e5fb32b7 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/AlertManeuver.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/AlertManeuver.java @@ -86,7 +86,7 @@ public class AlertManeuver extends RPCRequest{ /** * Sets the SoftButtons - * + * * @param softButtons * a List value *

    @@ -99,8 +99,9 @@ public class AlertManeuver extends RPCRequest{ * @since SmartDeviceLink 2.0 */ - public void setSoftButtons(List softButtons){ + public AlertManeuver setSoftButtons( List softButtons) { setParameters(KEY_SOFT_BUTTONS, softButtons); + return this; } /** @@ -115,13 +116,14 @@ public class AlertManeuver extends RPCRequest{ /** * Sets array of type TTSChunk which, taken together, specify what is to be spoken to the user - * + * * @param ttsChunks *

    * Notes:

    Array must have a least one element */ - public void setTtsChunks(List ttsChunks){ + public AlertManeuver setTtsChunks( List ttsChunks) { setParameters(KEY_TTS_CHUNKS, ttsChunks); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/AlertResponse.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/AlertResponse.java index a2fae73be..3ad14972b 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/AlertResponse.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/AlertResponse.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -78,7 +78,8 @@ public class AlertResponse extends RPCResponse { public Integer getTryAgainTime() { return getInteger(KEY_TRY_AGAIN_TIME); } - public void setTryAgainTime(Integer tryAgainTime) { + public AlertResponse setTryAgainTime( Integer tryAgainTime) { setParameters(KEY_TRY_AGAIN_TIME, tryAgainTime); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/AppInfo.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/AppInfo.java index a71d7b6e2..b07e918d1 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/AppInfo.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/AppInfo.java @@ -73,9 +73,10 @@ public class AppInfo extends RPCStruct { /** Sets the name displayed for the mobile application on the mobile device (can differ from the app name set in the initial RAI request). * @param appDisplayName - name displayed for the mobile application on the mobile device. */ - public void setAppDisplayName(@NonNull String appDisplayName) { - setValue(KEY_APP_DISPLAY_NAME, appDisplayName); - } + public AppInfo setAppDisplayName(@NonNull String appDisplayName) { + setValue(KEY_APP_DISPLAY_NAME, appDisplayName); + return this; + } /** Gets the name displayed for the mobile application on the mobile device (can differ from the app name set in the initial RAI request). * @return appDisplayName - name displayed for the mobile application on the mobile device. @@ -87,9 +88,10 @@ public class AppInfo extends RPCStruct { /** Sets package name of the Android application. This supports App Launch strategies for each platform. * @param appBundleID - package name of the application */ - public void setAppBundleID(@NonNull String appBundleID) { - setValue(KEY_APP_BUNDLE_ID, appBundleID); - } + public AppInfo setAppBundleID(@NonNull String appBundleID) { + setValue(KEY_APP_BUNDLE_ID, appBundleID); + return this; + } /** Gets package name of the Android application. This supports App Launch strategies for each platform. * @return appBundleID - package name of the application. @@ -101,9 +103,10 @@ public class AppInfo extends RPCStruct { /** Sets build version number of this particular mobile app. * @param appVersion - build version number of this particular mobile app. */ - public void setAppVersion(@NonNull String appVersion) { - setValue(KEY_APP_VERSION, appVersion); - } + public AppInfo setAppVersion(@NonNull String appVersion) { + setValue(KEY_APP_VERSION, appVersion); + return this; + } /** Gets build version number of this particular mobile app. * @return appVersion - build version number of this particular mobile app. @@ -115,9 +118,10 @@ public class AppInfo extends RPCStruct { /** Sets file reference to the icon utilized by this app (simplifies the process of setting an app icon during app registration). * @param appIcon - file reference to the icon utilized by this app */ - public void setAppIcon(String appIcon) { - setValue(KEY_APP_ICON, appIcon); - } + public AppInfo setAppIcon( String appIcon) { + setValue(KEY_APP_ICON, appIcon); + return this; + } /** Gets build version number of this particular mobile app. * @return appIcon - build version number of this particular mobile app. diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/AppServiceCapability.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/AppServiceCapability.java index 780ac13ed..3f46cbb7a 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/AppServiceCapability.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/AppServiceCapability.java @@ -69,9 +69,10 @@ public class AppServiceCapability extends RPCStruct { * Only included in OnSystemCapabilityUpdated. Update reason for this service record. * @param updateReason - */ - public void setUpdateReason(ServiceUpdateReason updateReason){ - setValue(KEY_UPDATE_REASON, updateReason); - } + public AppServiceCapability setUpdateReason( ServiceUpdateReason updateReason) { + setValue(KEY_UPDATE_REASON, updateReason); + return this; + } /** * Only included in OnSystemCapabilityUpdated. Update reason for this service record. @@ -85,9 +86,10 @@ public class AppServiceCapability extends RPCStruct { * Only included in OnSystemCapabilityUpdated. Update reason for this service record. * @param updatedAppServiceRecord - */ - public void setUpdatedAppServiceRecord(AppServiceRecord updatedAppServiceRecord){ - setValue(KEY_UPDATED_APP_SERVICE_RECORD, updatedAppServiceRecord); - } + public AppServiceCapability setUpdatedAppServiceRecord( AppServiceRecord updatedAppServiceRecord) { + setValue(KEY_UPDATED_APP_SERVICE_RECORD, updatedAppServiceRecord); + return this; + } /** * Only included in OnSystemCapabilityUpdated. Update reason for this service record. diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/AppServiceData.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/AppServiceData.java index 1a441a7fa..529815cfc 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/AppServiceData.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/AppServiceData.java @@ -68,9 +68,10 @@ public class AppServiceData extends RPCStruct { /** * @param serviceType - */ - public void setServiceType(@NonNull String serviceType) { - setValue(KEY_SERVICE_TYPE, serviceType); - } + public AppServiceData setServiceType(@NonNull String serviceType) { + setValue(KEY_SERVICE_TYPE, serviceType); + return this; + } /** * @return serviceType - @@ -82,9 +83,10 @@ public class AppServiceData extends RPCStruct { /** * @param serviceId - */ - public void setServiceID(@NonNull String serviceId) { - setValue(KEY_SERVICE_ID, serviceId); - } + public AppServiceData setServiceID(@NonNull String serviceId) { + setValue(KEY_SERVICE_ID, serviceId); + return this; + } /** * @return serviceId - @@ -96,9 +98,10 @@ public class AppServiceData extends RPCStruct { /** * @param mediaServiceData - */ - public void setMediaServiceData(MediaServiceData mediaServiceData) { - setValue(KEY_MEDIA_SERVICE_DATA, mediaServiceData); - } + public AppServiceData setMediaServiceData( MediaServiceData mediaServiceData) { + setValue(KEY_MEDIA_SERVICE_DATA, mediaServiceData); + return this; + } /** * @return mediaServiceData - @@ -110,9 +113,10 @@ public class AppServiceData extends RPCStruct { /** * @param weatherServiceData - */ - public void setWeatherServiceData(WeatherServiceData weatherServiceData) { - setValue(KEY_WEATHER_SERVICE_DATA, weatherServiceData); - } + public AppServiceData setWeatherServiceData( WeatherServiceData weatherServiceData) { + setValue(KEY_WEATHER_SERVICE_DATA, weatherServiceData); + return this; + } /** * @return weatherServiceData - @@ -124,9 +128,10 @@ public class AppServiceData extends RPCStruct { /** * @param navigationServiceData - */ - public void setNavigationServiceData(NavigationServiceData navigationServiceData) { - setValue(KEY_NAVIGATION_SERVICE_DATA, navigationServiceData); - } + public AppServiceData setNavigationServiceData( NavigationServiceData navigationServiceData) { + setValue(KEY_NAVIGATION_SERVICE_DATA, navigationServiceData); + return this; + } /** * @return navigationServiceData - diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/AppServiceManifest.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/AppServiceManifest.java index 9f2e4e2f6..9de0201b9 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/AppServiceManifest.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/AppServiceManifest.java @@ -88,9 +88,10 @@ public class AppServiceManifest extends RPCStruct { * Unique name of this service * @param serviceName - the service name */ - public void setServiceName(String serviceName){ - setValue(KEY_SERVICE_NAME, serviceName); - } + public AppServiceManifest setServiceName( String serviceName) { + setValue(KEY_SERVICE_NAME, serviceName); + return this; + } /** * Unique name of this service @@ -102,12 +103,13 @@ public class AppServiceManifest extends RPCStruct { /** * The type of service that is to be offered by this app - * @param serviceType - the serviceType use {@link com.smartdevicelink.proxy.rpc.enums.AppServiceType} - * @see com.smartdevicelink.proxy.rpc.enums.AppServiceType + * @param serviceType - the serviceType use {@link AppServiceType} + * @see AppServiceType */ - public void setServiceType(@NonNull String serviceType){ - setValue(KEY_SERVICE_TYPE, serviceType); - } + public AppServiceManifest setServiceType(@NonNull String serviceType) { + setValue(KEY_SERVICE_TYPE, serviceType); + return this; + } /** * The type of service that is to be offered by this app @@ -122,9 +124,10 @@ public class AppServiceManifest extends RPCStruct { * The icon to be associated with this service Most likely the same as the appIcon. * @param serviceIcon - The Service Icon Image */ - public void setServiceIcon(Image serviceIcon){ - setValue(KEY_SERVICE_ICON, serviceIcon); - } + public AppServiceManifest setServiceIcon( Image serviceIcon) { + setValue(KEY_SERVICE_ICON, serviceIcon); + return this; + } /** * The icon to be associated with this service Most likely the same as the appIcon. @@ -139,9 +142,10 @@ public class AppServiceManifest extends RPCStruct { * only the IVI system will be able consume the service. If not provided, it is assumed to be false. * @param allowAppConsumers - boolean */ - public void setAllowAppConsumers(Boolean allowAppConsumers){ - setValue(KEY_ALLOW_APP_CONSUMERS, allowAppConsumers); - } + public AppServiceManifest setAllowAppConsumers( Boolean allowAppConsumers) { + setValue(KEY_ALLOW_APP_CONSUMERS, allowAppConsumers); + return this; + } /** * If true, app service consumers beyond the IVI system will be able to access this service. If false, @@ -157,9 +161,10 @@ public class AppServiceManifest extends RPCStruct { * If not included, it is assumed the max version of the module is acceptable. * @param rpcSpecVersion - The rpcSpecVersion */ - public void setRpcSpecVersion(SdlMsgVersion rpcSpecVersion){ - setValue(KEY_RPC_SPEC_VERSION, rpcSpecVersion); - } + public AppServiceManifest setRpcSpecVersion( SdlMsgVersion rpcSpecVersion) { + setValue(KEY_RPC_SPEC_VERSION, rpcSpecVersion); + return this; + } /** * This is the max RPC Spec version the app service understands. This is important during the RPC pass through functionality. @@ -174,20 +179,21 @@ public class AppServiceManifest extends RPCStruct { * This field contains the Function IDs for the RPCs that this service intends to handle correctly. * This means the service will provide meaningful responses. * @param handledRPCs - The List of Handled RPCs using their ID value from the FunctionID enum - * @see com.smartdevicelink.protocol.enums.FunctionID - * @see #setHandledRpcsUsingFunctionIDs(List) + * @see FunctionID + * @see #setHandledRpcsUsingFunctionIDs( List ) */ - public void setHandledRpcs(List handledRPCs){ - setValue(KEY_HANDLED_RPCS, handledRPCs); - } + public AppServiceManifest setHandledRpcs( List handledRPCs) { + setValue(KEY_HANDLED_RPCS, handledRPCs); + return this; + } /** * This field contains the Function IDs for the RPCs that this service intends to handle correctly. * This means the service will provide meaningful responses. * @param handledRPCs - The List of Handled RPCs using the FunctionID enum - * @see #setHandledRpcs(List) + * @see #setHandledRpcs( List ) */ - public void setHandledRpcsUsingFunctionIDs(List handledRPCs){ - if(handledRPCs != null){ + public AppServiceManifest setHandledRpcsUsingFunctionIDs( List handledRPCs) { + if(handledRPCs != null){ List rpcIds = new ArrayList<>(); for(FunctionID functionID : handledRPCs){ rpcIds.add(functionID.getId()); @@ -196,7 +202,8 @@ public class AppServiceManifest extends RPCStruct { }else{ setValue(KEY_HANDLED_RPCS, null); } - } + return this; + } /** * This field contains the FunctionID integer ID values for the RPCs that this service intends to handle correctly. @@ -213,9 +220,10 @@ public class AppServiceManifest extends RPCStruct { * The MediaServiceManifest * @param mediaServiceManifest - The mediaServiceManifest */ - public void setMediaServiceManifest(MediaServiceManifest mediaServiceManifest){ - setValue(KEY_MEDIA_SERVICE_MANIFEST, mediaServiceManifest); - } + public AppServiceManifest setMediaServiceManifest( MediaServiceManifest mediaServiceManifest) { + setValue(KEY_MEDIA_SERVICE_MANIFEST, mediaServiceManifest); + return this; + } /** * The MediaServiceManifest @@ -229,9 +237,10 @@ public class AppServiceManifest extends RPCStruct { * The WeatherServiceManifest * @param weatherServiceManifest - The weatherServiceManifest */ - public void setWeatherServiceManifest(WeatherServiceManifest weatherServiceManifest){ - setValue(KEY_WEATHER_SERVICE_MANIFEST, weatherServiceManifest); - } + public AppServiceManifest setWeatherServiceManifest( WeatherServiceManifest weatherServiceManifest) { + setValue(KEY_WEATHER_SERVICE_MANIFEST, weatherServiceManifest); + return this; + } /** * The WeatherServiceManifest @@ -245,9 +254,10 @@ public class AppServiceManifest extends RPCStruct { * The NavigationServiceManifest * @param navigationServiceManifest - The navigationServiceManifest */ - public void setNavigationServiceManifest(NavigationServiceManifest navigationServiceManifest){ - setValue(KEY_NAVIGATION_SERVICE_MANIFEST, navigationServiceManifest); - } + public AppServiceManifest setNavigationServiceManifest( NavigationServiceManifest navigationServiceManifest) { + setValue(KEY_NAVIGATION_SERVICE_MANIFEST, navigationServiceManifest); + return this; + } /** * The NavigationServiceManifest diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/AppServiceRecord.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/AppServiceRecord.java index 198be4e26..d59cb8fe0 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/AppServiceRecord.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/AppServiceRecord.java @@ -70,9 +70,10 @@ public class AppServiceRecord extends RPCStruct { * ID of this service * @param serviceID - the service ID */ - public void setServiceID(@NonNull String serviceID){ - setValue(KEY_SERVICE_ID, serviceID); - } + public AppServiceRecord setServiceID(@NonNull String serviceID) { + setValue(KEY_SERVICE_ID, serviceID); + return this; + } /** * ID of this service @@ -86,9 +87,10 @@ public class AppServiceRecord extends RPCStruct { * the App Service Manifest * @param serviceManifest - the App Service Manifest */ - public void setServiceManifest(@NonNull AppServiceManifest serviceManifest){ - setValue(KEY_SERVICE_MANIFEST, serviceManifest); - } + public AppServiceRecord setServiceManifest(@NonNull AppServiceManifest serviceManifest) { + setValue(KEY_SERVICE_MANIFEST, serviceManifest); + return this; + } /** * the App Service Manifest @@ -103,9 +105,10 @@ public class AppServiceRecord extends RPCStruct { * unpublished, and should be considered unavailable. * @param servicePublished - boolean */ - public void setServicePublished(@NonNull Boolean servicePublished){ - setValue(KEY_SERVICE_PUBLISHED, servicePublished); - } + public AppServiceRecord setServicePublished(@NonNull Boolean servicePublished) { + setValue(KEY_SERVICE_PUBLISHED, servicePublished); + return this; + } /** * If true, the service is published and available. If false, the service has likely just been @@ -122,9 +125,10 @@ public class AppServiceRecord extends RPCStruct { * service of the supplied type. See servicePublished for its availability. * @param serviceActive - boolean */ - public void setServiceActive(@NonNull Boolean serviceActive){ - setValue(KEY_SERVICE_ACTIVE, serviceActive); - } + public AppServiceRecord setServiceActive(@NonNull Boolean serviceActive) { + setValue(KEY_SERVICE_ACTIVE, serviceActive); + return this; + } /** * If true, the service is the active primary service of the supplied service type. It will receive diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/AppServicesCapabilities.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/AppServicesCapabilities.java index 63d3dd6a5..30cac40fa 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/AppServicesCapabilities.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/AppServicesCapabilities.java @@ -72,9 +72,10 @@ public class AppServicesCapabilities extends RPCStruct { * capability the affected services will include an update reason in that item * @param appServices - */ - public void setAppServices(List appServices){ - setValue(KEY_APP_SERVICES, appServices); - } + public AppServicesCapabilities setAppServices( List appServices) { + setValue(KEY_APP_SERVICES, appServices); + return this; + } /** * An array of currently available services. If this is an update to the diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/AudioControlCapabilities.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/AudioControlCapabilities.java index 7ee26175e..ecb6daef8 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/AudioControlCapabilities.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/AudioControlCapabilities.java @@ -76,9 +76,10 @@ public class AudioControlCapabilities extends RPCStruct { * * @param moduleName The short friendly name of the light control module. It should not be used to identify a module by mobile application. */ - public void setModuleName(@NonNull String moduleName) { - setValue(KEY_MODULE_NAME, moduleName); - } + public AudioControlCapabilities setModuleName(@NonNull String moduleName) { + setValue(KEY_MODULE_NAME, moduleName); + return this; + } /** * Gets the moduleName portion of the AudioControlCapabilities class @@ -94,9 +95,10 @@ public class AudioControlCapabilities extends RPCStruct { * * @param keepContextAvailable Availability of the keepContext parameter. */ - public void setKeepContextAvailable(Boolean keepContextAvailable) { - setValue(KEY_KEEP_CONTEXT_AVAILABLE, keepContextAvailable); - } + public AudioControlCapabilities setKeepContextAvailable( Boolean keepContextAvailable) { + setValue(KEY_KEEP_CONTEXT_AVAILABLE, keepContextAvailable); + return this; + } /** * Gets the keepContextAvailable portion of the AudioControlCapabilities class @@ -112,9 +114,10 @@ public class AudioControlCapabilities extends RPCStruct { * * @param sourceAvailable Availability of the control of audio source. */ - public void setSourceAvailable(Boolean sourceAvailable) { - setValue(KEY_SOURCE_AVAILABLE, sourceAvailable); - } + public AudioControlCapabilities setSourceAvailable( Boolean sourceAvailable) { + setValue(KEY_SOURCE_AVAILABLE, sourceAvailable); + return this; + } /** * Gets the sourceAvailable portion of the AudioControlCapabilities class @@ -130,9 +133,10 @@ public class AudioControlCapabilities extends RPCStruct { * * @param volumeAvailable Availability of the control of audio volume. */ - public void setVolumeAvailable(Boolean volumeAvailable) { - setValue(KEY_VOLUME_AVAILABLE, volumeAvailable); - } + public AudioControlCapabilities setVolumeAvailable( Boolean volumeAvailable) { + setValue(KEY_VOLUME_AVAILABLE, volumeAvailable); + return this; + } /** * Gets the volumeAvailable portion of the AudioControlCapabilities class @@ -148,9 +152,10 @@ public class AudioControlCapabilities extends RPCStruct { * * @param equalizerAvailable Availability of the control of Equalizer Settings. */ - public void setEqualizerAvailable(Boolean equalizerAvailable) { - setValue(KEY_EQUALIZER_AVAILABLE, equalizerAvailable); - } + public AudioControlCapabilities setEqualizerAvailable( Boolean equalizerAvailable) { + setValue(KEY_EQUALIZER_AVAILABLE, equalizerAvailable); + return this; + } /** * Gets the equalizerAvailable portion of the AudioControlCapabilities class @@ -166,9 +171,10 @@ public class AudioControlCapabilities extends RPCStruct { * * @param equalizerMaxChannelId Must be included if equalizerAvailable=true, and assume all IDs starting from 1 to this value are valid. */ - public void setEqualizerMaxChannelId(Integer equalizerMaxChannelId) { - setValue(KEY_EQUALIZER_MAX_CHANNEL_ID, equalizerMaxChannelId); - } + public AudioControlCapabilities setEqualizerMaxChannelId( Integer equalizerMaxChannelId) { + setValue(KEY_EQUALIZER_MAX_CHANNEL_ID, equalizerMaxChannelId); + return this; + } /** * Gets the equalizerMaxChannelId portion of the AudioControlCapabilities class @@ -183,9 +189,10 @@ public class AudioControlCapabilities extends RPCStruct { * Sets ModuleInfo for this capability * @param info the ModuleInfo to be set */ - public void setModuleInfo(ModuleInfo info) { - setValue(KEY_MODULE_INFO, info); - } + public AudioControlCapabilities setModuleInfo( ModuleInfo info) { + setValue(KEY_MODULE_INFO, info); + return this; + } /** * Gets a ModuleInfo of this capability diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/AudioControlData.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/AudioControlData.java index ff95186d5..2de646ff6 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/AudioControlData.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/AudioControlData.java @@ -65,9 +65,10 @@ public class AudioControlData extends RPCStruct { * In a setter request, it is the target audio source that the system shall switch to. * If the value is MOBILE_APP, the system shall switch to the mobile media app that issues the setter RPC. */ - public void setSource(PrimaryAudioSource source) { - setValue(KEY_SOURCE, source); - } + public AudioControlData setSource( PrimaryAudioSource source) { + setValue(KEY_SOURCE, source); + return this; + } /** * Gets the source portion of the AudioControlData class @@ -89,9 +90,10 @@ public class AudioControlData extends RPCStruct { * system UI associated with the audio source to foreground. * If it is true, the system only changes the audio source, but keeps the current application in foreground. */ - public void setKeepContext(Boolean keepContext) { - setValue(KEY_KEEP_CONTEXT, keepContext); - } + public AudioControlData setKeepContext( Boolean keepContext) { + setValue(KEY_KEEP_CONTEXT, keepContext); + return this; + } /** * Gets the keepContext portion of the AudioControlData class @@ -111,9 +113,10 @@ public class AudioControlData extends RPCStruct { * * @param volume Reflects the volume of audio, from 0%-100%. */ - public void setVolume(Integer volume) { - setValue(KEY_VOLUME, volume); - } + public AudioControlData setVolume( Integer volume) { + setValue(KEY_VOLUME, volume); + return this; + } /** * Gets the volume portion of the AudioControlData class @@ -139,8 +142,9 @@ public class AudioControlData extends RPCStruct { * * @param equalizerSettings Defines the list of supported channels (band) and their current/desired settings on HMI. */ - public void setEqualizerSettings(List equalizerSettings) { - setValue(KEY_EQUALIZER_SETTINGS, equalizerSettings); - } + public AudioControlData setEqualizerSettings( List equalizerSettings) { + setValue(KEY_EQUALIZER_SETTINGS, equalizerSettings); + return this; + } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/AudioPassThruCapabilities.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/AudioPassThruCapabilities.java index 38f2f80bb..769813bad 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/AudioPassThruCapabilities.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/AudioPassThruCapabilities.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -110,8 +110,9 @@ public class AudioPassThruCapabilities extends RPCStruct { * set the sampling rate for AudioPassThru * @param samplingRate the sampling rate for AudioPassThru */ - public void setSamplingRate(@NonNull SamplingRate samplingRate) { - setValue(KEY_SAMPLING_RATE, samplingRate); + public AudioPassThruCapabilities setSamplingRate(@NonNull SamplingRate samplingRate) { + setValue(KEY_SAMPLING_RATE, samplingRate); + return this; } /** @@ -126,8 +127,9 @@ public class AudioPassThruCapabilities extends RPCStruct { * set the sample depth in bit for AudioPassThru * @param bitsPerSample the sample depth in bit for AudioPassThru */ - public void setBitsPerSample(@NonNull BitsPerSample bitsPerSample) { - setValue(KEY_BITS_PER_SAMPLE, bitsPerSample); + public AudioPassThruCapabilities setBitsPerSample(@NonNull BitsPerSample bitsPerSample) { + setValue(KEY_BITS_PER_SAMPLE, bitsPerSample); + return this; } /** @@ -142,8 +144,9 @@ public class AudioPassThruCapabilities extends RPCStruct { * set the audiotype for AudioPassThru * @param audioType the audiotype for AudioPassThru */ - public void setAudioType(@NonNull AudioType audioType) { - setValue(KEY_AUDIO_TYPE, audioType); + public AudioPassThruCapabilities setAudioType(@NonNull AudioType audioType) { + setValue(KEY_AUDIO_TYPE, audioType); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/BeltStatus.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/BeltStatus.java index ff01b72e4..faa10d607 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/BeltStatus.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/BeltStatus.java @@ -200,92 +200,107 @@ public class BeltStatus extends RPCStruct { setMiddleRow1BuckleBelted(middleRow1BuckleBelted); } - public void setDriverBeltDeployed(@NonNull VehicleDataEventStatus driverBeltDeployed) { + public BeltStatus setDriverBeltDeployed(@NonNull VehicleDataEventStatus driverBeltDeployed) { setValue(KEY_DRIVER_BELT_DEPLOYED, driverBeltDeployed); + return this; } public VehicleDataEventStatus getDriverBeltDeployed() { return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_DRIVER_BELT_DEPLOYED); } - public void setPassengerBeltDeployed(@NonNull VehicleDataEventStatus passengerBeltDeployed) { + public BeltStatus setPassengerBeltDeployed(@NonNull VehicleDataEventStatus passengerBeltDeployed) { setValue(KEY_PASSENGER_BELT_DEPLOYED, passengerBeltDeployed); + return this; } public VehicleDataEventStatus getPassengerBeltDeployed() { return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_PASSENGER_BELT_DEPLOYED); } - public void setPassengerBuckleBelted(@NonNull VehicleDataEventStatus passengerBuckleBelted) { + public BeltStatus setPassengerBuckleBelted(@NonNull VehicleDataEventStatus passengerBuckleBelted) { setValue(KEY_PASSENGER_BUCKLE_BELTED, passengerBuckleBelted); + return this; } public VehicleDataEventStatus getPassengerBuckleBelted() { return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_PASSENGER_BUCKLE_BELTED); } - public void setDriverBuckleBelted(VehicleDataEventStatus driverBuckleBelted) { + public BeltStatus setDriverBuckleBelted( VehicleDataEventStatus driverBuckleBelted) { setValue(KEY_DRIVER_BUCKLE_BELTED, driverBuckleBelted); + return this; } public VehicleDataEventStatus getDriverBuckleBelted() { return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_DRIVER_BUCKLE_BELTED); } - public void setLeftRow2BuckleBelted(VehicleDataEventStatus leftRow2BuckleBelted) { + public BeltStatus setLeftRow2BuckleBelted( VehicleDataEventStatus leftRow2BuckleBelted) { setValue(KEY_LEFT_ROW_2_BUCKLE_BELTED, leftRow2BuckleBelted); + return this; } public VehicleDataEventStatus getLeftRow2BuckleBelted() { return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_LEFT_ROW_2_BUCKLE_BELTED); } - public void setPassengerChildDetected(@NonNull VehicleDataEventStatus passengerChildDetected) { + public BeltStatus setPassengerChildDetected(@NonNull VehicleDataEventStatus passengerChildDetected) { setValue(KEY_PASSENGER_CHILD_DETECTED, passengerChildDetected); + return this; } public VehicleDataEventStatus getPassengerChildDetected() { return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_PASSENGER_CHILD_DETECTED); } - public void setRightRow2BuckleBelted(@NonNull VehicleDataEventStatus rightRow2BuckleBelted) { + public BeltStatus setRightRow2BuckleBelted(@NonNull VehicleDataEventStatus rightRow2BuckleBelted) { setValue(KEY_RIGHT_ROW_2_BUCKLE_BELTED, rightRow2BuckleBelted); + return this; } public VehicleDataEventStatus getRightRow2BuckleBelted() { return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_RIGHT_ROW_2_BUCKLE_BELTED); } - public void setMiddleRow2BuckleBelted(@NonNull VehicleDataEventStatus middleRow2BuckleBelted) { + public BeltStatus setMiddleRow2BuckleBelted(@NonNull VehicleDataEventStatus middleRow2BuckleBelted) { setValue(KEY_MIDDLE_ROW_2_BUCKLE_BELTED, middleRow2BuckleBelted); + return this; } public VehicleDataEventStatus getMiddleRow2BuckleBelted() { return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_MIDDLE_ROW_2_BUCKLE_BELTED); } - public void setMiddleRow3BuckleBelted(@NonNull VehicleDataEventStatus middleRow3BuckleBelted) { + public BeltStatus setMiddleRow3BuckleBelted(@NonNull VehicleDataEventStatus middleRow3BuckleBelted) { setValue(KEY_MIDDLE_ROW_3_BUCKLE_BELTED, middleRow3BuckleBelted); + return this; } public VehicleDataEventStatus getMiddleRow3BuckleBelted() { return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_MIDDLE_ROW_3_BUCKLE_BELTED); } - public void setLeftRow3BuckleBelted(@NonNull VehicleDataEventStatus leftRow3BuckleBelted) { + public BeltStatus setLeftRow3BuckleBelted(@NonNull VehicleDataEventStatus leftRow3BuckleBelted) { setValue(KEY_LEFT_ROW_3_BUCKLE_BELTED, leftRow3BuckleBelted); + return this; } public VehicleDataEventStatus getLeftRow3BuckleBelted() { return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_LEFT_ROW_3_BUCKLE_BELTED); } - public void setRightRow3BuckleBelted(@NonNull VehicleDataEventStatus rightRow3BuckleBelted) { + public BeltStatus setRightRow3BuckleBelted(@NonNull VehicleDataEventStatus rightRow3BuckleBelted) { setValue(KEY_RIGHT_ROW_3_BUCKLE_BELTED, rightRow3BuckleBelted); + return this; } public VehicleDataEventStatus getRightRow3BuckleBelted() { return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_RIGHT_ROW_3_BUCKLE_BELTED); } - public void setLeftRearInflatableBelted(@NonNull VehicleDataEventStatus rearInflatableBelted) { + public BeltStatus setLeftRearInflatableBelted(@NonNull VehicleDataEventStatus rearInflatableBelted) { setValue(KEY_LEFT_REAR_INFLATABLE_BELTED, rearInflatableBelted); + return this; } public VehicleDataEventStatus getLeftRearInflatableBelted() { return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_LEFT_REAR_INFLATABLE_BELTED); } - public void setRightRearInflatableBelted(@NonNull VehicleDataEventStatus rightRearInflatableBelted) { + public BeltStatus setRightRearInflatableBelted(@NonNull VehicleDataEventStatus rightRearInflatableBelted) { setValue(KEY_RIGHT_REAR_INFLATABLE_BELTED, rightRearInflatableBelted); + return this; } public VehicleDataEventStatus getRightRearInflatableBelted() { return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_RIGHT_REAR_INFLATABLE_BELTED); } - public void setMiddleRow1BeltDeployed(@NonNull VehicleDataEventStatus middleRow1BeltDeployed) { + public BeltStatus setMiddleRow1BeltDeployed(@NonNull VehicleDataEventStatus middleRow1BeltDeployed) { setValue(KEY_MIDDLE_ROW_1_BELT_DEPLOYED, middleRow1BeltDeployed); + return this; } public VehicleDataEventStatus getMiddleRow1BeltDeployed() { return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_MIDDLE_ROW_1_BELT_DEPLOYED); } - public void setMiddleRow1BuckleBelted(@NonNull VehicleDataEventStatus middleRow1BuckleBelted) { + public BeltStatus setMiddleRow1BuckleBelted(@NonNull VehicleDataEventStatus middleRow1BuckleBelted) { setValue(KEY_MIDDLE_ROW_1_BUCKLE_BELTED, middleRow1BuckleBelted); + return this; } public VehicleDataEventStatus getMiddleRow1BuckleBelted() { return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_MIDDLE_ROW_1_BUCKLE_BELTED); diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/BodyInformation.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/BodyInformation.java index a502e1df6..61379d9dc 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/BodyInformation.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/BodyInformation.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -142,50 +142,57 @@ public class BodyInformation extends RPCStruct { setIgnitionStableStatus(ignitionStableStatus); setIgnitionStatus(ignitionStatus); } - public void setParkBrakeActive(@NonNull Boolean parkBrakeActive) { + public BodyInformation setParkBrakeActive(@NonNull Boolean parkBrakeActive) { setValue(KEY_PARK_BRAKE_ACTIVE, parkBrakeActive); + return this; } public Boolean getParkBrakeActive() { return getBoolean(KEY_PARK_BRAKE_ACTIVE); } - public void setIgnitionStableStatus(@NonNull IgnitionStableStatus ignitionStableStatus) { + public BodyInformation setIgnitionStableStatus(@NonNull IgnitionStableStatus ignitionStableStatus) { setValue(KEY_IGNITION_STABLE_STATUS, ignitionStableStatus); + return this; } public IgnitionStableStatus getIgnitionStableStatus() { return (IgnitionStableStatus) getObject(IgnitionStableStatus.class, KEY_IGNITION_STABLE_STATUS); } - public void setIgnitionStatus(@NonNull IgnitionStatus ignitionStatus) { + public BodyInformation setIgnitionStatus(@NonNull IgnitionStatus ignitionStatus) { setValue(KEY_IGNITION_STATUS, ignitionStatus); + return this; } public IgnitionStatus getIgnitionStatus() { return (IgnitionStatus) getObject(IgnitionStatus.class, KEY_IGNITION_STATUS); } - public void setDriverDoorAjar(Boolean driverDoorAjar) { + public BodyInformation setDriverDoorAjar( Boolean driverDoorAjar) { setValue(KEY_DRIVER_DOOR_AJAR, driverDoorAjar); - } + return this; + } public Boolean getDriverDoorAjar() { return getBoolean(KEY_DRIVER_DOOR_AJAR); } - public void setPassengerDoorAjar(Boolean passengerDoorAjar) { + public BodyInformation setPassengerDoorAjar( Boolean passengerDoorAjar) { setValue(KEY_PASSENGER_DOOR_AJAR, passengerDoorAjar); - } + return this; + } public Boolean getPassengerDoorAjar() { return getBoolean(KEY_PASSENGER_DOOR_AJAR); } - public void setRearLeftDoorAjar(Boolean rearLeftDoorAjar) { + public BodyInformation setRearLeftDoorAjar( Boolean rearLeftDoorAjar) { setValue(KEY_REAR_LEFT_DOOR_AJAR, rearLeftDoorAjar); - } + return this; + } public Boolean getRearLeftDoorAjar() { return getBoolean(KEY_REAR_LEFT_DOOR_AJAR); } - public void setRearRightDoorAjar(Boolean rearRightDoorAjar) { + public BodyInformation setRearRightDoorAjar( Boolean rearRightDoorAjar) { setValue(KEY_REAR_RIGHT_DOOR_AJAR, rearRightDoorAjar); - } + return this; + } public Boolean getRearRightDoorAjar() { return getBoolean(KEY_REAR_RIGHT_DOOR_AJAR); } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/ButtonCapabilities.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/ButtonCapabilities.java index 1a8cb4df9..d2d5246be 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/ButtonCapabilities.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/ButtonCapabilities.java @@ -133,9 +133,10 @@ public class ButtonCapabilities extends RPCStruct { /** * Set the name of theSDL HMI button. * @param name the name of button - */ - public void setName( @NonNull ButtonName name ) { + */ + public ButtonCapabilities setName(@NonNull ButtonName name) { setValue(KEY_NAME, name); + return this; } /** * Whether the button supports a SHORT press. See {@linkplain com.smartdevicelink.proxy.rpc.enums.ButtonPressMode} for more information. @@ -147,9 +148,10 @@ public class ButtonCapabilities extends RPCStruct { /** * Set the button supports a SHORT press. See {@linkplain com.smartdevicelink.proxy.rpc.enums.ButtonPressMode} for more information. * @param shortPressAvailable True if support otherwise False. - */ - public void setShortPressAvailable( @NonNull Boolean shortPressAvailable ) { + */ + public ButtonCapabilities setShortPressAvailable(@NonNull Boolean shortPressAvailable) { setValue(KEY_SHORT_PRESS_AVAILABLE, shortPressAvailable); + return this; } /** * Whether the button supports a LONG press. See {@linkplain com.smartdevicelink.proxy.rpc.enums.ButtonPressMode} for more information. @@ -161,9 +163,10 @@ public class ButtonCapabilities extends RPCStruct { /** * Set the button supports a LONG press. See {@linkplain com.smartdevicelink.proxy.rpc.enums.ButtonPressMode} for more information. * @param longPressAvailable True if support otherwise False. - */ - public void setLongPressAvailable( @NonNull Boolean longPressAvailable ) { + */ + public ButtonCapabilities setLongPressAvailable(@NonNull Boolean longPressAvailable) { setValue(KEY_LONG_PRESS_AVAILABLE, longPressAvailable); + return this; } /** * Whether the button supports "button down" and "button up". When the button is depressed, the {@linkplain OnButtonEvent} notification will be invoked with a value of BUTTONDOWN. @@ -175,17 +178,19 @@ public class ButtonCapabilities extends RPCStruct { /** * Set the button supports "button down" and "button up". When the button is depressed, the {@linkplain OnButtonEvent} notification will be invoked with a value of BUTTONDOWN. * @param upDownAvailable True if support otherwise False. - */ - public void setUpDownAvailable( @NonNull Boolean upDownAvailable ) { + */ + public ButtonCapabilities setUpDownAvailable(@NonNull Boolean upDownAvailable) { setValue(KEY_UP_DOWN_AVAILABLE, upDownAvailable); + return this; } /** * Sets ModuleInfo for this capability * @param info the ModuleInfo to be set */ - public void setModuleInfo(ModuleInfo info) { + public ButtonCapabilities setModuleInfo( ModuleInfo info) { setValue(KEY_MODULE_INFO, info); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/ButtonPress.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/ButtonPress.java index 645ae336d..ecdac7b95 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/ButtonPress.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/ButtonPress.java @@ -96,8 +96,9 @@ public class ButtonPress extends RPCRequest { * @param moduleType * Represents module where the button should be pressed */ - public void setModuleType(@NonNull ModuleType moduleType) { + public ButtonPress setModuleType(@NonNull ModuleType moduleType) { setParameters(KEY_MODULE_TYPE, moduleType); + return this; } /** @@ -115,8 +116,9 @@ public class ButtonPress extends RPCRequest { * @param buttonName * Represents name of supported RC climate or radio button */ - public void setButtonName(@NonNull ButtonName buttonName) { + public ButtonPress setButtonName(@NonNull ButtonName buttonName) { setParameters(KEY_BUTTON_NAME, buttonName); + return this; } /** @@ -134,16 +136,18 @@ public class ButtonPress extends RPCRequest { * @param buttonPressMode * Indicates whether this is a LONG or SHORT button press event. */ - public void setButtonPressMode(@NonNull ButtonPressMode buttonPressMode) { + public ButtonPress setButtonPressMode(@NonNull ButtonPressMode buttonPressMode) { setParameters(KEY_BUTTON_PRESS_MODE, buttonPressMode); + return this; } /** * Sets the module id for this object * @param id the id to be set */ - public void setModuleId(String id) { + public ButtonPress setModuleId( String id) { setParameters(KEY_MODULE_ID, id); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/CancelInteraction.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/CancelInteraction.java index 9016458a6..16de2d9f7 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/CancelInteraction.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/CancelInteraction.java @@ -104,8 +104,9 @@ public class CancelInteraction extends RPCRequest { * Only values 10 (PerformInteractionID), 12 (AlertID), 25 (ScrollableMessageID), 26 (SliderID), and 64 (SubtleAlertID) are permitted. * @param functionID - the functionID */ - public void setInteractionFunctionID(@NonNull Integer functionID) { + public CancelInteraction setInteractionFunctionID(@NonNull Integer functionID) { setParameters(KEY_FUNCTION_ID, functionID); + return this; } /** @@ -120,7 +121,8 @@ public class CancelInteraction extends RPCRequest { * The ID of the specific interaction to dismiss. If not set, the most recent of the RPC type set in functionID will be dismissed. * @param cancelID - the cancelID */ - public void setCancelID(Integer cancelID) { + public CancelInteraction setCancelID( Integer cancelID) { setParameters(KEY_CANCEL_ID, cancelID); + return this; } } \ No newline at end of file diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/ChangeRegistration.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/ChangeRegistration.java index 2087ea886..41dbe6f78 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/ChangeRegistration.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/ChangeRegistration.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -170,12 +170,13 @@ public class ChangeRegistration extends RPCRequest { /** * Sets language - * + * * @param language * a language value */ - public void setLanguage(@NonNull Language language) { + public ChangeRegistration setLanguage(@NonNull Language language) { setParameters(KEY_LANGUAGE, language); + return this; } /** @@ -189,12 +190,13 @@ public class ChangeRegistration extends RPCRequest { /** * Sets HMI display language - * + * * @param hmiDisplayLanguage * a Language value */ - public void setHmiDisplayLanguage(@NonNull Language hmiDisplayLanguage) { + public ChangeRegistration setHmiDisplayLanguage(@NonNull Language hmiDisplayLanguage) { setParameters(KEY_HMI_DISPLAY_LANGUAGE, hmiDisplayLanguage); + return this; } /** @@ -208,11 +210,12 @@ public class ChangeRegistration extends RPCRequest { /** * Sets app name - * + * * @param appName App name to set */ - public void setAppName(String appName){ + public ChangeRegistration setAppName( String appName) { setParameters(KEY_APP_NAME, appName); + return this; } /** @@ -226,11 +229,12 @@ public class ChangeRegistration extends RPCRequest { /** * Sets NGN media screen app name - * + * * @param ngnAppName The NGN app name */ - public void setNgnMediaScreenAppName(String ngnAppName){ + public ChangeRegistration setNgnMediaScreenAppName( String ngnAppName) { setParameters(KEY_NGN_MEDIA_SCREEN_NAME, ngnAppName); + return this; } /** @@ -244,11 +248,12 @@ public class ChangeRegistration extends RPCRequest { /** * Sets the TTS name - * + * * @param ttsName The TTS name to set */ - public void setTtsName(List ttsName){ + public ChangeRegistration setTtsName( List ttsName) { setParameters(KEY_TTS_NAME, ttsName); + return this; } /** @@ -277,7 +282,7 @@ public class ChangeRegistration extends RPCRequest { /** * Sets a vrSynonyms representing the an array of 1-100 elements, each * element containing a voice-recognition synonym - * + * * @param vrSynonyms * a List value representing the an array of 1-100 * elements @@ -290,8 +295,9 @@ public class ChangeRegistration extends RPCRequest { * the name or any synonym of any currently-registered * application * - */ - public void setVrSynonyms(List vrSynonyms) { + */ + public ChangeRegistration setVrSynonyms( List vrSynonyms) { setParameters(KEY_VR_SYNONYMS, vrSynonyms); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/Choice.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/Choice.java index 72fb49a91..aca5f86d5 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/Choice.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/Choice.java @@ -171,9 +171,10 @@ public class Choice extends RPCStruct { /** * Set the application-scoped identifier that uniquely identifies this choice. * @param choiceID Min: 0 Max: 65535 - */ - public void setChoiceID(@NonNull Integer choiceID) { + */ + public Choice setChoiceID(@NonNull Integer choiceID) { setValue(KEY_CHOICE_ID, choiceID); + return this; } /** * Text which appears in menu, representing this choice. @@ -189,9 +190,10 @@ public class Choice extends RPCStruct { * Min: 1; * Max: 100 * @param menuName the menu name - */ - public void setMenuName(@NonNull String menuName) { + */ + public Choice setMenuName(@NonNull String menuName) { setValue(KEY_MENU_NAME, menuName); + return this; } /** * Get an array of strings to be used as VR synonyms for this choice. If this array is provided, it must have at least one non-empty element @@ -206,16 +208,18 @@ public class Choice extends RPCStruct { * Set an array of strings to be used as VR synonyms for this choice. If this array is provided, it must have at least one non-empty element * @param vrCommands the List of vrCommands * @since SmartDeviceLink 2.0 - */ - public void setVrCommands(List vrCommands) { + */ + public Choice setVrCommands( List vrCommands) { setValue(KEY_VR_COMMANDS, vrCommands); + return this; } /** * Set the image * @param image the image of the choice - */ - public void setImage(Image image) { + */ + public Choice setImage( Image image) { setValue(KEY_IMAGE, image); + return this; } /** * Get the image @@ -230,20 +234,23 @@ public class Choice extends RPCStruct { return getString(KEY_SECONDARY_TEXT); } - public void setSecondaryText(String secondaryText) { + public Choice setSecondaryText( String secondaryText) { setValue(KEY_SECONDARY_TEXT, secondaryText); + return this; } public String getTertiaryText() { return getString(KEY_TERTIARY_TEXT); } - public void setTertiaryText(String tertiaryText) { + public Choice setTertiaryText( String tertiaryText) { setValue(KEY_TERTIARY_TEXT, tertiaryText); + return this; } - public void setSecondaryImage(Image image) { + public Choice setSecondaryImage( Image image) { setValue(KEY_SECONDARY_IMAGE, image); + return this; } @SuppressWarnings("unchecked") @@ -255,7 +262,8 @@ public class Choice extends RPCStruct { * This prevents the @{link Choice#format} method from adding VR commands if set to true * @param ignoreAddingVRItems - whether or not to let the format method add vr commands */ - public void setIgnoreAddingVRItems(boolean ignoreAddingVRItems){ + public Choice setIgnoreAddingVRItems( boolean ignoreAddingVRItems) { this.ignoreAddingVRItems = ignoreAddingVRItems; + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/ClimateControlCapabilities.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/ClimateControlCapabilities.java index 856087fda..1c3140d6f 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/ClimateControlCapabilities.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/ClimateControlCapabilities.java @@ -86,8 +86,9 @@ public class ClimateControlCapabilities extends RPCStruct{ * * @param moduleName The short friendly name of the climate control module. It should not be used to identify a module by mobile application. */ - public void setModuleName(@NonNull String moduleName) { + public ClimateControlCapabilities setModuleName(@NonNull String moduleName) { setValue(KEY_MODULE_NAME, moduleName); + return this; } /** @@ -106,8 +107,9 @@ public class ClimateControlCapabilities extends RPCStruct{ * Availability of the control of fan speed. * True: Available, False: Not Available, Not present: Not Available. */ - public void setFanSpeedAvailable(Boolean fanSpeedAvailable) { + public ClimateControlCapabilities setFanSpeedAvailable( Boolean fanSpeedAvailable) { setValue(KEY_FAN_SPEED_AVAILABLE, fanSpeedAvailable); + return this; } /** @@ -127,8 +129,9 @@ public class ClimateControlCapabilities extends RPCStruct{ * Availability of the control of desired temperature. * True: Available, False: Not Available, Not present: Not Available. */ - public void setDesiredTemperatureAvailable(Boolean desiredTemperatureAvailable) { + public ClimateControlCapabilities setDesiredTemperatureAvailable( Boolean desiredTemperatureAvailable) { setValue(KEY_DESIRED_TEMPERATURE_AVAILABLE, desiredTemperatureAvailable); + return this; } /** @@ -148,8 +151,9 @@ public class ClimateControlCapabilities extends RPCStruct{ * Availability of the control of turn on/off AC. * True: Available, False: Not Available, Not present: Not Available. */ - public void setAcEnableAvailable(Boolean acEnableAvailable) { + public ClimateControlCapabilities setAcEnableAvailable( Boolean acEnableAvailable) { setValue(KEY_AC_ENABLE_AVAILABLE, acEnableAvailable); + return this; } /** @@ -169,8 +173,9 @@ public class ClimateControlCapabilities extends RPCStruct{ * Availability of the control of enable/disable air conditioning is ON on the maximum level. * True: Available, False: Not Available, Not present: Not Available. */ - public void setAcMaxEnableAvailable(Boolean acMaxEnableAvailable) { + public ClimateControlCapabilities setAcMaxEnableAvailable( Boolean acMaxEnableAvailable) { setValue(KEY_AC_MAX_ENABLE_AVAILABLE, acMaxEnableAvailable); + return this; } /** @@ -190,8 +195,9 @@ public class ClimateControlCapabilities extends RPCStruct{ * Availability of the control of enable/disable circulate Air mode. * True: Available, False: Not Available, Not present: Not Available. */ - public void setCirculateAirEnableAvailable(Boolean circulateAirEnableAvailable) { + public ClimateControlCapabilities setCirculateAirEnableAvailable( Boolean circulateAirEnableAvailable) { setValue(KEY_CIRCULATE_AIR_ENABLE_AVAILABLE, circulateAirEnableAvailable); + return this; } /** @@ -211,8 +217,9 @@ public class ClimateControlCapabilities extends RPCStruct{ * Availability of the control of enable/disable auto mode. * True: Available, False: Not Available, Not present: Not Available. */ - public void setAutoModeEnableAvailable(Boolean autoModeEnableAvailable) { + public ClimateControlCapabilities setAutoModeEnableAvailable( Boolean autoModeEnableAvailable) { setValue(KEY_AUTO_MODE_ENABLE_AVAILABLE, autoModeEnableAvailable); + return this; } /** @@ -232,8 +239,9 @@ public class ClimateControlCapabilities extends RPCStruct{ * Availability of the control of enable/disable dual mode. * True: Available, False: Not Available, Not present: Not Available. */ - public void setDualModeEnableAvailable(Boolean dualModeEnableAvailable) { + public ClimateControlCapabilities setDualModeEnableAvailable( Boolean dualModeEnableAvailable) { setValue(KEY_DUAL_MODE_ENABLE_AVAILABLE, dualModeEnableAvailable); + return this; } /** @@ -253,8 +261,9 @@ public class ClimateControlCapabilities extends RPCStruct{ * Availability of the control of defrost zones. * True: Available, False: Not Available, Not present: Not Available. */ - public void setDefrostZoneAvailable(Boolean defrostZoneAvailable) { + public ClimateControlCapabilities setDefrostZoneAvailable( Boolean defrostZoneAvailable) { setValue(KEY_DEFROST_ZONE_AVAILABLE, defrostZoneAvailable); + return this; } /** @@ -282,8 +291,9 @@ public class ClimateControlCapabilities extends RPCStruct{ * @param defrostZone * A set of all defrost zones that are controllable. */ - public void setDefrostZone(List defrostZone) { + public ClimateControlCapabilities setDefrostZone( List defrostZone) { setValue(KEY_DEFROST_ZONE, defrostZone); + return this; } /** @@ -293,8 +303,9 @@ public class ClimateControlCapabilities extends RPCStruct{ * Availability of the control of air ventilation mode. * True: Available, False: Not Available, Not present: Not Available. */ - public void setVentilationModeAvailable(Boolean ventilationModeAvailable) { + public ClimateControlCapabilities setVentilationModeAvailable( Boolean ventilationModeAvailable) { setValue(KEY_VENTILATION_MODE_AVAILABLE, ventilationModeAvailable); + return this; } /** @@ -322,8 +333,9 @@ public class ClimateControlCapabilities extends RPCStruct{ * @param ventilationMode * A set of all ventilation modes that are controllable. */ - public void setVentilationMode(List ventilationMode) { + public ClimateControlCapabilities setVentilationMode( List ventilationMode) { setValue(KEY_VENTILATION_MODE, ventilationMode); + return this; } /** @@ -332,8 +344,9 @@ public class ClimateControlCapabilities extends RPCStruct{ * @param heatedSteeringWheelAvailable Availability of the control (enable/disable) of heated Steering Wheel. * True: Available, False: Not Available, Not present: Not Available. */ - public void setHeatedSteeringWheelAvailable(Boolean heatedSteeringWheelAvailable) { + public ClimateControlCapabilities setHeatedSteeringWheelAvailable( Boolean heatedSteeringWheelAvailable) { setValue(KEY_HEATED_STEERING_WHEEL_AVAILABLE, heatedSteeringWheelAvailable); + return this; } /** @@ -352,8 +365,9 @@ public class ClimateControlCapabilities extends RPCStruct{ * @param heatedWindshieldAvailable Availability of the control (enable/disable) of heated Windshield. * True: Available, False: Not Available, Not present: Not Available. */ - public void setHeatedWindshieldAvailable(Boolean heatedWindshieldAvailable) { + public ClimateControlCapabilities setHeatedWindshieldAvailable( Boolean heatedWindshieldAvailable) { setValue(KEY_HEATED_WIND_SHIELD_AVAILABLE, heatedWindshieldAvailable); + return this; } /** @@ -372,8 +386,9 @@ public class ClimateControlCapabilities extends RPCStruct{ * @param heatedRearWindowAvailable Availability of the control (enable/disable) of heated Rear Window. * True: Available, False: Not Available, Not present: Not Available. */ - public void setHeatedRearWindowAvailable(Boolean heatedRearWindowAvailable) { + public ClimateControlCapabilities setHeatedRearWindowAvailable( Boolean heatedRearWindowAvailable) { setValue(KEY_HEATED_REAR_WINDOW_AVAILABLE, heatedRearWindowAvailable); + return this; } /** @@ -392,8 +407,9 @@ public class ClimateControlCapabilities extends RPCStruct{ * @param heatedMirrorsAvailable Availability of the control (enable/disable) of heated Mirrors. * True: Available, False: Not Available, Not present: Not Available. */ - public void setHeatedMirrorsAvailable(Boolean heatedMirrorsAvailable) { + public ClimateControlCapabilities setHeatedMirrorsAvailable( Boolean heatedMirrorsAvailable) { setValue(KEY_HEATED_MIRRORS_AVAILABLE, heatedMirrorsAvailable); + return this; } /** @@ -410,8 +426,9 @@ public class ClimateControlCapabilities extends RPCStruct{ * Sets ModuleInfo for this capability * @param info the ModuleInfo to be set */ - public void setModuleInfo(ModuleInfo info) { + public ClimateControlCapabilities setModuleInfo( ModuleInfo info) { setValue(KEY_MODULE_INFO, info); + return this; } /** @@ -427,8 +444,9 @@ public class ClimateControlCapabilities extends RPCStruct{ * @param climateEnableAvailable Availability of the control of enable/disable climate control. * True: Available, False: Not Available, Not present: Not Available. */ - public void setClimateEnableAvailable(Boolean climateEnableAvailable) { + public ClimateControlCapabilities setClimateEnableAvailable( Boolean climateEnableAvailable) { setValue(KEY_CLIMATE_ENABLE_AVAILABLE, climateEnableAvailable); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/ClimateControlData.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/ClimateControlData.java index 365a74044..de243bc8d 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/ClimateControlData.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/ClimateControlData.java @@ -61,80 +61,90 @@ public class ClimateControlData extends RPCStruct{ super(hash); } - public void setFanSpeed(Integer fanSpeed) { + public ClimateControlData setFanSpeed( Integer fanSpeed) { setValue(KEY_FAN_SPEED, fanSpeed); + return this; } public Integer getFanSpeed() { return getInteger(KEY_FAN_SPEED); } - public void setCurrentTemperature(Temperature currentTemperature) { + public ClimateControlData setCurrentTemperature( Temperature currentTemperature) { setValue(KEY_CURRENT_TEMPERATURE, currentTemperature); + return this; } public Temperature getCurrentTemperature() { return (Temperature) getObject(Temperature.class, KEY_CURRENT_TEMPERATURE); } - public void setDesiredTemperature(Temperature desiredTemperature) { + public ClimateControlData setDesiredTemperature( Temperature desiredTemperature) { setValue(KEY_DESIRED_TEMPERATURE, desiredTemperature); + return this; } public Temperature getDesiredTemperature() { return (Temperature) getObject(Temperature.class, KEY_DESIRED_TEMPERATURE); } - public void setAcEnable(Boolean acEnable) { + public ClimateControlData setAcEnable( Boolean acEnable) { setValue(KEY_AC_ENABLE, acEnable); + return this; } public Boolean getAcEnable() { return getBoolean(KEY_AC_ENABLE); } - public void setCirculateAirEnable(Boolean circulateAirEnable) { + public ClimateControlData setCirculateAirEnable( Boolean circulateAirEnable) { setValue(KEY_CIRCULATE_AIR_ENABLE, circulateAirEnable); + return this; } public Boolean getCirculateAirEnable() { return getBoolean(KEY_CIRCULATE_AIR_ENABLE); } - public void setAutoModeEnable(Boolean autoModeEnable) { + public ClimateControlData setAutoModeEnable( Boolean autoModeEnable) { setValue(KEY_AUTO_MODE_ENABLE, autoModeEnable); + return this; } public Boolean getAutoModeEnable() { return getBoolean(KEY_AUTO_MODE_ENABLE); } - public void setDefrostZone(DefrostZone defrostZone) { + public ClimateControlData setDefrostZone( DefrostZone defrostZone) { setValue(KEY_DEFROST_ZONE, defrostZone); + return this; } public DefrostZone getDefrostZone() { return (DefrostZone) getObject(DefrostZone.class, KEY_DEFROST_ZONE); } - public void setDualModeEnable(Boolean dualModeEnable) { + public ClimateControlData setDualModeEnable( Boolean dualModeEnable) { setValue(KEY_DUAL_MODE_ENABLE, dualModeEnable); + return this; } public Boolean getDualModeEnable() { return getBoolean(KEY_DUAL_MODE_ENABLE); } - public void setAcMaxEnable(Boolean acMaxEnable) { + public ClimateControlData setAcMaxEnable( Boolean acMaxEnable) { setValue(KEY_AC_MAX_ENABLE, acMaxEnable); + return this; } public Boolean getAcMaxEnable() { return getBoolean(KEY_AC_MAX_ENABLE); } - public void setVentilationMode(VentilationMode ventilationMode) { + public ClimateControlData setVentilationMode( VentilationMode ventilationMode) { setValue(KEY_VENTILATION_MODE, ventilationMode); + return this; } public VentilationMode getVentilationMode() { @@ -146,8 +156,9 @@ public class ClimateControlData extends RPCStruct{ * * @param heatedSteeringWheelEnable Value false means disabled/turn off, value true means enabled/turn on. */ - public void setHeatedSteeringWheelEnable(Boolean heatedSteeringWheelEnable) { + public ClimateControlData setHeatedSteeringWheelEnable( Boolean heatedSteeringWheelEnable) { setValue(KEY_HEATED_STEERING_WHEEL_ENABLE, heatedSteeringWheelEnable); + return this; } /** @@ -164,8 +175,9 @@ public class ClimateControlData extends RPCStruct{ * * @param heatedWindshieldEnable Value false means disabled, value true means enabled. */ - public void setHeatedWindshieldEnable(Boolean heatedWindshieldEnable) { + public ClimateControlData setHeatedWindshieldEnable( Boolean heatedWindshieldEnable) { setValue(KEY_HEATED_WIND_SHIELD_ENABLE, heatedWindshieldEnable); + return this; } /** @@ -182,8 +194,9 @@ public class ClimateControlData extends RPCStruct{ * * @param heatedRearWindowEnable Value false means disabled, value true means enabled. */ - public void setHeatedRearWindowEnable(Boolean heatedRearWindowEnable) { + public ClimateControlData setHeatedRearWindowEnable( Boolean heatedRearWindowEnable) { setValue(KEY_HEATED_REAR_WINDOW_ENABLE, heatedRearWindowEnable); + return this; } /** @@ -200,8 +213,9 @@ public class ClimateControlData extends RPCStruct{ * * @param heatedMirrorsEnable Value false means disabled, value true means enabled. */ - public void setHeatedMirrorsEnable(Boolean heatedMirrorsEnable) { + public ClimateControlData setHeatedMirrorsEnable( Boolean heatedMirrorsEnable) { setValue(KEY_HEATED_MIRRORS_ENABLE, heatedMirrorsEnable); + return this; } /** @@ -218,8 +232,9 @@ public class ClimateControlData extends RPCStruct{ * * @param climateEnable Value false means disabled, value true means enabled. */ - public void setClimateEnable(Boolean climateEnable) { + public ClimateControlData setClimateEnable( Boolean climateEnable) { setValue(KEY_CLIMATE_ENABLE, climateEnable); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/CloudAppProperties.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/CloudAppProperties.java index 1c81ce95b..59035fc27 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/CloudAppProperties.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/CloudAppProperties.java @@ -63,8 +63,9 @@ public class CloudAppProperties extends RPCStruct { setValue(KEY_APP_ID, appID); } - public void setNicknames(List nicknames){ + public CloudAppProperties setNicknames( List nicknames) { setValue(KEY_NICKNAMES, nicknames); + return this; } @SuppressWarnings("unchecked") @@ -72,8 +73,9 @@ public class CloudAppProperties extends RPCStruct { return (List) getObject(String.class, KEY_NICKNAMES); } - public void setAppID(@NonNull String appID){ + public CloudAppProperties setAppID(@NonNull String appID) { setValue(KEY_APP_ID, appID); + return this; } public String getAppID(){ @@ -84,8 +86,9 @@ public class CloudAppProperties extends RPCStruct { * If true, this cloud app entry will designate it should appear in the HMI * @param enabled if the app should be */ - public void setEnabled(boolean enabled){ + public CloudAppProperties setEnabled( boolean enabled) { setValue(KEY_ENABLED, enabled); + return this; } /** @@ -95,24 +98,27 @@ public class CloudAppProperties extends RPCStruct { return getBoolean(KEY_ENABLED); } - public void setAuthToken(String token){ + public CloudAppProperties setAuthToken( String token) { setValue(KEY_AUTH_TOKEN, token); + return this; } public String getAuthToken(){ return getString(KEY_AUTH_TOKEN); } - public void setCloudTransportType(String transportType){ + public CloudAppProperties setCloudTransportType( String transportType) { setValue(KEY_CLOUD_TRANSPORT_TYPE, transportType); + return this; } public String getCloudTransportType(){ return getString(KEY_CLOUD_TRANSPORT_TYPE); } - public void setHybridAppPreference(HybridAppPreference hybridAppPreference){ + public CloudAppProperties setHybridAppPreference( HybridAppPreference hybridAppPreference) { setValue(KEY_HYBRID_APP_PREFERENCE, hybridAppPreference); + return this; } public HybridAppPreference getHybridAppPreference(){ @@ -122,8 +128,9 @@ public class CloudAppProperties extends RPCStruct { /** * @param token - max length ="65535" */ - public void setEndpoint(String token){ + public CloudAppProperties setEndpoint( String token) { setValue(KEY_ENDPOINT, token); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/ClusterModeStatus.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/ClusterModeStatus.java index 98aa2a060..94b3aed05 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/ClusterModeStatus.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/ClusterModeStatus.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -109,27 +109,31 @@ public class ClusterModeStatus extends RPCStruct { setPowerModeStatus(powerModeStatus); } - public void setPowerModeActive(@NonNull Boolean powerModeActive) { - setValue(KEY_POWER_MODE_ACTIVE, powerModeActive); - } + public ClusterModeStatus setPowerModeActive(@NonNull Boolean powerModeActive) { + setValue(KEY_POWER_MODE_ACTIVE, powerModeActive); + return this; + } public Boolean getPowerModeActive() { return getBoolean(KEY_POWER_MODE_ACTIVE); } - public void setPowerModeQualificationStatus(@NonNull PowerModeQualificationStatus powerModeQualificationStatus) { - setValue(KEY_POWER_MODE_QUALIFICATION_STATUS, powerModeQualificationStatus); - } + public ClusterModeStatus setPowerModeQualificationStatus(@NonNull PowerModeQualificationStatus powerModeQualificationStatus) { + setValue(KEY_POWER_MODE_QUALIFICATION_STATUS, powerModeQualificationStatus); + return this; + } public PowerModeQualificationStatus getPowerModeQualificationStatus() { return (PowerModeQualificationStatus) getObject(PowerModeQualificationStatus.class, KEY_POWER_MODE_QUALIFICATION_STATUS); } - public void setCarModeStatus(@NonNull CarModeStatus carModeStatus) { - setValue(KEY_CAR_MODE_STATUS, carModeStatus); - } + public ClusterModeStatus setCarModeStatus(@NonNull CarModeStatus carModeStatus) { + setValue(KEY_CAR_MODE_STATUS, carModeStatus); + return this; + } public CarModeStatus getCarModeStatus() { return (CarModeStatus) getObject(CarModeStatus.class, KEY_CAR_MODE_STATUS); } - public void setPowerModeStatus(@NonNull PowerModeStatus powerModeStatus) { - setValue(KEY_POWER_MODE_STATUS, powerModeStatus); - } + public ClusterModeStatus setPowerModeStatus(@NonNull PowerModeStatus powerModeStatus) { + setValue(KEY_POWER_MODE_STATUS, powerModeStatus); + return this; + } public PowerModeStatus getPowerModeStatus() { return (PowerModeStatus) getObject(PowerModeStatus.class, KEY_POWER_MODE_STATUS); } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/Coordinate.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/Coordinate.java index 970692dab..bc41103d5 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/Coordinate.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/Coordinate.java @@ -60,8 +60,9 @@ public class Coordinate extends RPCStruct{ return SdlDataTypeConverter.objectToFloat(value); } - public void setLatitudeDegrees(@NonNull Float latitudeDegrees) { + public Coordinate setLatitudeDegrees(@NonNull Float latitudeDegrees) { setValue(KEY_LATITUDE_DEGREES, latitudeDegrees); + return this; } public Float getLongitudeDegrees() { @@ -69,7 +70,8 @@ public class Coordinate extends RPCStruct{ return SdlDataTypeConverter.objectToFloat(value); } - public void setLongitudeDegrees(@NonNull Float longitudeDegrees) { + public Coordinate setLongitudeDegrees(@NonNull Float longitudeDegrees) { setValue(KEY_LONGITUDE_DEGREES, longitudeDegrees); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/CreateInteractionChoiceSet.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/CreateInteractionChoiceSet.java index be638065b..32e09dde3 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/CreateInteractionChoiceSet.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/CreateInteractionChoiceSet.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -148,14 +148,15 @@ public class CreateInteractionChoiceSet extends RPCRequest { } /** * Sets a unique ID that identifies the Choice Set - * + * * @param interactionChoiceSetID * an Integer value representing the Choice Set ID - * + * * Notes: Min Value: 0; Max Value: 2000000000 - */ - public void setInteractionChoiceSetID( @NonNull Integer interactionChoiceSetID ) { - setParameters(KEY_INTERACTION_CHOICE_SET_ID, interactionChoiceSetID); + */ + public CreateInteractionChoiceSet setInteractionChoiceSetID(@NonNull Integer interactionChoiceSetID) { + setParameters(KEY_INTERACTION_CHOICE_SET_ID, interactionChoiceSetID); + return this; } /** * Gets Choice Set Array of one or more elements @@ -169,14 +170,15 @@ public class CreateInteractionChoiceSet extends RPCRequest { } /** * Sets a Choice Set that is an Array of one or more elements - * + * * @param choiceSet * a List representing the array of one or more * elements - * + * * Notes: Min Value: 1; Max Value: 100 - */ - public void setChoiceSet( @NonNull List choiceSet ) { - setParameters(KEY_CHOICE_SET, choiceSet); + */ + public CreateInteractionChoiceSet setChoiceSet(@NonNull List choiceSet) { + setParameters(KEY_CHOICE_SET, choiceSet); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/CreateWindow.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/CreateWindow.java index 6184bb059..976d00f9e 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/CreateWindow.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/CreateWindow.java @@ -60,8 +60,9 @@ public class CreateWindow extends RPCRequest { * * @param windowID A unique ID to identify the window. The value of '0' will always be the default main window on the main display and should not be used in this context as it will already be created for the app. See PredefinedWindows enum. Creating a window with an ID that is already in use will be rejected with `INVALID_ID`. */ - public void setWindowID(@NonNull Integer windowID) { + public CreateWindow setWindowID(@NonNull Integer windowID) { setParameters(KEY_WINDOW_ID, windowID); + return this; } /** @@ -83,8 +84,9 @@ public class CreateWindow extends RPCRequest { * Multiple apps can share the same window name except for the default main window. * {@code windowName.length() <= 100} */ - public void setWindowName(@NonNull String windowName) { + public CreateWindow setWindowName(@NonNull String windowName) { setParameters(KEY_WINDOW_NAME, windowName); + return this; } /** @@ -101,8 +103,9 @@ public class CreateWindow extends RPCRequest { * * @param type The type of the window to be created. Main window or widget. */ - public void setType(@NonNull WindowType type) { + public CreateWindow setType(@NonNull WindowType type) { setParameters(KEY_TYPE, type); + return this; } /** @@ -127,8 +130,9 @@ public class CreateWindow extends RPCRequest { * @param associatedServiceType Allows an app to create a widget related to a specific service type. * As an example if a `MEDIA` app becomes active, this app becomes audible and is allowed to play audio. */ - public void setAssociatedServiceType(String associatedServiceType) { + public CreateWindow setAssociatedServiceType( String associatedServiceType) { setParameters(KEY_ASSOCIATED_SERVICE_TYPE, associatedServiceType); + return this; } /** @@ -148,8 +152,9 @@ public class CreateWindow extends RPCRequest { * * @param duplicateUpdatesFromWindowID Specify whether the content sent to an existing window should be duplicated to the created window. */ - public void setDuplicateUpdatesFromWindowID(Integer duplicateUpdatesFromWindowID) { + public CreateWindow setDuplicateUpdatesFromWindowID( Integer duplicateUpdatesFromWindowID) { setParameters(KEY_DUPLICATE_UPDATES_FROM_WINDOW_ID, duplicateUpdatesFromWindowID); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/DIDResult.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/DIDResult.java index 8cd8e9c18..73d45282d 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/DIDResult.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/DIDResult.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -96,20 +96,23 @@ public class DIDResult extends RPCStruct { setResultCode(resultCode); setDidLocation(didLocation); } - public void setResultCode(@NonNull VehicleDataResultCode resultCode) { - setValue(KEY_RESULT_CODE, resultCode); + public DIDResult setResultCode(@NonNull VehicleDataResultCode resultCode) { + setValue(KEY_RESULT_CODE, resultCode); + return this; } public VehicleDataResultCode getResultCode() { return (VehicleDataResultCode) getObject(VehicleDataResultCode.class, KEY_RESULT_CODE); } - public void setDidLocation(@NonNull Integer didLocation) { - setValue(KEY_DID_LOCATION, didLocation); + public DIDResult setDidLocation(@NonNull Integer didLocation) { + setValue(KEY_DID_LOCATION, didLocation); + return this; } public Integer getDidLocation() { return getInteger(KEY_DID_LOCATION); } - public void setData(String data) { - setValue(KEY_DATA, data); + public DIDResult setData( String data) { + setValue(KEY_DATA, data); + return this; } public String getData() { return getString(KEY_DATA); diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/DTC.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/DTC.java index 697514a08..9b7623129 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/DTC.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/DTC.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import com.smartdevicelink.proxy.RPCStruct; @@ -78,8 +78,9 @@ public class DTC extends RPCStruct { * set identifier * @param identifier the hexadecimal id of the DTC */ - public void setIdentifier(String identifier) { - setValue(KEY_IDENTIFIER, identifier); + public DTC setIdentifier( String identifier) { + setValue(KEY_IDENTIFIER, identifier); + return this; } /** @@ -94,8 +95,9 @@ public class DTC extends RPCStruct { * set Hexadecimal byte string * @param statusByte Hexadecimal byte string */ - public void setStatusByte(String statusByte) { - setValue(KEY_STATUS_BYTE, statusByte); + public DTC setStatusByte( String statusByte) { + setValue(KEY_STATUS_BYTE, statusByte); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/DateTime.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/DateTime.java index 2335743d0..ab3f61140 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/DateTime.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/DateTime.java @@ -66,13 +66,14 @@ public class DateTime extends RPCStruct{ /** * Sets the Milliseconds portion of the DateTime class - * + * * @param milliSecond * The milliseconds associated with this DateTime class - * - */ - public void setMilliSecond(Integer milliSecond) { + * + */ + public DateTime setMilliSecond( Integer milliSecond) { setValue(KEY_MILLISECOND, milliSecond); + return this; } @@ -88,13 +89,14 @@ public class DateTime extends RPCStruct{ /** * Sets the Seconds portion of the DateTime class - * + * * @param second * The Seconds associated with this DateTime class - * + * */ - public void setSecond(Integer second) { + public DateTime setSecond( Integer second) { setValue(KEY_SECOND, second); + return this; } @@ -110,13 +112,14 @@ public class DateTime extends RPCStruct{ /** * Sets the Minutes portion of the DateTime class - * + * * @param minute * The Minutes associated with this DateTime class - * - */ - public void setMinute(Integer minute) { + * + */ + public DateTime setMinute( Integer minute) { setValue(KEY_MINUTE, minute); + return this; } /** @@ -130,14 +133,15 @@ public class DateTime extends RPCStruct{ } /** - * Sets the Hours portion of the DateTime class. - * + * Sets the Hours portion of the DateTime class. + * * @param hour * The Hours associated with this DateTime class. This structure is used to store hours in a 24 hour format. - * - */ - public void setHour(Integer hour) { + * + */ + public DateTime setHour( Integer hour) { setValue(KEY_HOUR, hour); + return this; } /** @@ -152,13 +156,14 @@ public class DateTime extends RPCStruct{ /** * Sets the Day portion of the DateTime class - * + * * @param day * The Day of the month associated with this DateTime class - * - */ - public void setDay(Integer day) { + * + */ + public DateTime setDay( Integer day) { setValue(KEY_DAY, day); + return this; } /** @@ -173,13 +178,14 @@ public class DateTime extends RPCStruct{ /** * Sets the Month portion of the DateTime class - * + * * @param month * The Month of the year associate with this DateTime class - * - */ - public void setMonth(Integer month) { + * + */ + public DateTime setMonth( Integer month) { setValue(KEY_MONTH, month); + return this; } /** @@ -194,13 +200,14 @@ public class DateTime extends RPCStruct{ /** * Sets the Year portion of the DateTime class - * + * * @param year * The Year in YYYY format associated with this DateTime class - * - */ - public void setYear(Integer year) { + * + */ + public DateTime setYear( Integer year) { setValue(KEY_YEAR, year); + return this; } /** @@ -215,13 +222,14 @@ public class DateTime extends RPCStruct{ /** * Sets the Time Zone Hours portion of the DateTime class - * + * * @param tzHour * The time zone offset in Hours with regard to UTC time associated with this DateTime class - * - */ - public void setTzHour(Integer tzHour) { + * + */ + public DateTime setTzHour( Integer tzHour) { setValue(KEY_TZ_HOUR, tzHour); + return this; } /** @@ -236,11 +244,12 @@ public class DateTime extends RPCStruct{ /** * Sets the Time Zone Minutes portion of the DateTime class - * + * * @param tzMinute * The time zone offset in Minutes with regard to UTC associated with this DateTime class - */ - public void setTzMinute(Integer tzMinute) { + */ + public DateTime setTzMinute( Integer tzMinute) { setValue(KEY_TZ_MINUTE, tzMinute); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/DeleteCommand.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/DeleteCommand.java index e102e9427..35b96387f 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/DeleteCommand.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/DeleteCommand.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -125,13 +125,14 @@ public class DeleteCommand extends RPCRequest { } /** * Sets the Command ID that identifies the Command to be deleted from Command Menu - * + * * @param cmdID * an Integer value representing Command ID - * + * *

    Notes: Min Value: 0; Max Value: 2000000000

    - */ - public void setCmdID( @NonNull Integer cmdID ) { - setParameters(KEY_CMD_ID, cmdID); + */ + public DeleteCommand setCmdID(@NonNull Integer cmdID) { + setParameters(KEY_CMD_ID, cmdID); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/DeleteFile.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/DeleteFile.java index 177171027..b855f1bbf 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/DeleteFile.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/DeleteFile.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -105,12 +105,13 @@ public class DeleteFile extends RPCRequest { /** * Sets a file reference name - * + * * @param sdlFileName * a String value representing a file reference name */ - public void setSdlFileName(@NonNull String sdlFileName) { - setParameters(KEY_SDL_FILE_NAME, sdlFileName); + public DeleteFile setSdlFileName(@NonNull String sdlFileName) { + setParameters(KEY_SDL_FILE_NAME, sdlFileName); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/DeleteFileResponse.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/DeleteFileResponse.java index e1076935b..bea9a1b65 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/DeleteFileResponse.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/DeleteFileResponse.java @@ -90,8 +90,9 @@ public class DeleteFileResponse extends RPCResponse { super.format(rpcVersion, formatParams); } - public void setSpaceAvailable(Integer spaceAvailable) { + public DeleteFileResponse setSpaceAvailable( Integer spaceAvailable) { setParameters(KEY_SPACE_AVAILABLE, spaceAvailable); + return this; } public Integer getSpaceAvailable() { diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/DeleteInteractionChoiceSet.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/DeleteInteractionChoiceSet.java index e3d0d5c86..3bfc56e72 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/DeleteInteractionChoiceSet.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/DeleteInteractionChoiceSet.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -131,8 +131,9 @@ public class DeleteInteractionChoiceSet extends RPCRequest { * Sets a unique ID that identifies the Choice Set * @param interactionChoiceSetID a unique ID that identifies the Choice Set *

    Notes: Min Value: 0; Max Value: 2000000000

    - */ - public void setInteractionChoiceSetID( @NonNull Integer interactionChoiceSetID ) { - setParameters(KEY_INTERACTION_CHOICE_SET_ID, interactionChoiceSetID); + */ + public DeleteInteractionChoiceSet setInteractionChoiceSetID(@NonNull Integer interactionChoiceSetID) { + setParameters(KEY_INTERACTION_CHOICE_SET_ID, interactionChoiceSetID); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/DeleteSubMenu.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/DeleteSubMenu.java index e526013c8..22306a668 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/DeleteSubMenu.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/DeleteSubMenu.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -118,12 +118,13 @@ public class DeleteSubMenu extends RPCRequest { return getInteger( KEY_MENU_ID ); } /** - * Sets the MenuID that identifies the SubMenu to be delete + * Sets the MenuID that identifies the SubMenu to be delete * @param menuID an Integer value representing menuID that identifies the SubMenu to be delete - * + * *

    Notes: Min Value: 0; Max Value: 2000000000

    - */ - public void setMenuID( @NonNull Integer menuID ) { + */ + public DeleteSubMenu setMenuID(@NonNull Integer menuID) { setParameters(KEY_MENU_ID, menuID); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/DeleteWindow.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/DeleteWindow.java index 4e78b95a7..06c00736a 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/DeleteWindow.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/DeleteWindow.java @@ -50,8 +50,9 @@ public class DeleteWindow extends RPCRequest { * * @param windowID A unique ID to identify the window. The value of '0' will always be the default main window on the main display and should not be used in this context as it will already be created for the app. See PredefinedWindows enum. Creating a window with an ID that is already in use will be rejected with `INVALID_ID`. */ - public void setWindowID(@NonNull Integer windowID) { + public DeleteWindow setWindowID(@NonNull Integer windowID) { setParameters(KEY_WINDOW_ID, windowID); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/DeviceInfo.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/DeviceInfo.java index c19068eb0..7c98b1e84 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/DeviceInfo.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/DeviceInfo.java @@ -119,41 +119,46 @@ public class DeviceInfo extends RPCStruct{ super(hash); } - public void setHardware(String hardware) { + public DeviceInfo setHardware( String hardware) { setValue(KEY_HARDWARE, hardware); - } + return this; + } public String getHardware() { return getString(KEY_HARDWARE); } - public void setFirmwareRev(String firmwareRev) { - setValue(KEY_FIRMWARE_REV, firmwareRev); - } + public DeviceInfo setFirmwareRev( String firmwareRev) { + setValue(KEY_FIRMWARE_REV, firmwareRev); + return this; + } public String getFirmwareRev() { return getString(KEY_FIRMWARE_REV); } - public void setOs(String os) { - setValue(KEY_OS, os); - } + public DeviceInfo setOs( String os) { + setValue(KEY_OS, os); + return this; + } public String getOs() { return getString(KEY_OS); } - public void setOsVersion(String osVersion) { - setValue(KEY_OS_VERSION, osVersion); -} + public DeviceInfo setOsVersion( String osVersion) { + setValue(KEY_OS_VERSION, osVersion); + return this; + } public String getOsVersion() { return getString(KEY_OS_VERSION); } -public void setCarrier(String carrier) { - setValue(KEY_CARRIER, carrier); -} +public DeviceInfo setCarrier( String carrier) { + setValue(KEY_CARRIER, carrier); + return this; + } public String getCarrier() { return getString(KEY_CARRIER); @@ -163,8 +168,9 @@ public Integer getMaxNumberRFCOMMPorts() { return getInteger( KEY_MAX_NUMBER_RFCOMM_PORTS ); } -public void setMaxNumberRFCOMMPorts( Integer maxNumberRFCOMMPorts ) { - setValue(KEY_MAX_NUMBER_RFCOMM_PORTS, maxNumberRFCOMMPorts); -} +public DeviceInfo setMaxNumberRFCOMMPorts( Integer maxNumberRFCOMMPorts) { + setValue(KEY_MAX_NUMBER_RFCOMM_PORTS, maxNumberRFCOMMPorts); + return this; + } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/DeviceStatus.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/DeviceStatus.java index 8748014f2..78ff3a91b 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/DeviceStatus.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/DeviceStatus.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -194,8 +194,9 @@ public class DeviceStatus extends RPCStruct { * set the voice recognition on or off * @param voiceRecOn */ - public void setVoiceRecOn(@NonNull Boolean voiceRecOn) { + public DeviceStatus setVoiceRecOn(@NonNull Boolean voiceRecOn) { setValue(KEY_VOICE_REC_ON, voiceRecOn); + return this; } /** @@ -210,8 +211,9 @@ public class DeviceStatus extends RPCStruct { * set the bluetooth connection established * @param btIconOn the bluetooth connection established */ - public void setBtIconOn(@NonNull Boolean btIconOn) { + public DeviceStatus setBtIconOn(@NonNull Boolean btIconOn) { setValue(KEY_BT_ICON_ON, btIconOn); + return this; } /** @@ -226,8 +228,9 @@ public class DeviceStatus extends RPCStruct { * set a call is being active * @param callActive a call is being active */ - public void setCallActive(@NonNull Boolean callActive) { + public DeviceStatus setCallActive(@NonNull Boolean callActive) { setValue(KEY_CALL_ACTIVE, callActive); + return this; } /** @@ -242,8 +245,9 @@ public class DeviceStatus extends RPCStruct { * set the phone is in roaming mode * @param phoneRoaming the phone is in roaming mode */ - public void setPhoneRoaming(@NonNull Boolean phoneRoaming) { + public DeviceStatus setPhoneRoaming(@NonNull Boolean phoneRoaming) { setValue(KEY_PHONE_ROAMING, phoneRoaming); + return this; } /** @@ -253,8 +257,9 @@ public class DeviceStatus extends RPCStruct { public Boolean getPhoneRoaming() { return getBoolean(KEY_PHONE_ROAMING); } - public void setTextMsgAvailable(@NonNull Boolean textMsgAvailable) { + public DeviceStatus setTextMsgAvailable(@NonNull Boolean textMsgAvailable) { setValue(KEY_TEXT_MSG_AVAILABLE, textMsgAvailable); + return this; } /** @@ -269,8 +274,9 @@ public class DeviceStatus extends RPCStruct { * set battery level status * @param battLevelStatus battery level status */ - public void setBattLevelStatus(@NonNull DeviceLevelStatus battLevelStatus) { + public DeviceStatus setBattLevelStatus(@NonNull DeviceLevelStatus battLevelStatus) { setValue(KEY_BATT_LEVEL_STATUS, battLevelStatus); + return this; } /** @@ -285,8 +291,9 @@ public class DeviceStatus extends RPCStruct { * set the status of the stereo audio output channel * @param stereoAudioOutputMuted the status of the stereo audio output channel */ - public void setStereoAudioOutputMuted(@NonNull Boolean stereoAudioOutputMuted) { + public DeviceStatus setStereoAudioOutputMuted(@NonNull Boolean stereoAudioOutputMuted) { setValue(KEY_STEREO_AUDIO_OUTPUT_MUTED, stereoAudioOutputMuted); + return this; } /** @@ -301,8 +308,9 @@ public class DeviceStatus extends RPCStruct { * set the status of the mono audio output channel * @param monoAudioOutputMuted the status of the mono audio output channel */ - public void setMonoAudioOutputMuted(@NonNull Boolean monoAudioOutputMuted) { + public DeviceStatus setMonoAudioOutputMuted(@NonNull Boolean monoAudioOutputMuted) { setValue(KEY_MONO_AUDIO_OUTPUT_MUTED, monoAudioOutputMuted); + return this; } /** @@ -317,8 +325,9 @@ public class DeviceStatus extends RPCStruct { * set signal level status * @param signalLevelStatus signal level status */ - public void setSignalLevelStatus(@NonNull DeviceLevelStatus signalLevelStatus) { + public DeviceStatus setSignalLevelStatus(@NonNull DeviceLevelStatus signalLevelStatus) { setValue(KEY_SIGNAL_LEVEL_STATUS, signalLevelStatus); + return this; } /** @@ -333,8 +342,9 @@ public class DeviceStatus extends RPCStruct { * set the current primary audio source of SDL (if selected). * @param primaryAudioSource the current primary audio source of SDL (if selected). */ - public void setPrimaryAudioSource(@NonNull PrimaryAudioSource primaryAudioSource) { + public DeviceStatus setPrimaryAudioSource(@NonNull PrimaryAudioSource primaryAudioSource) { setValue(KEY_PRIMARY_AUDIO_SOURCE, primaryAudioSource); + return this; } /** @@ -344,8 +354,9 @@ public class DeviceStatus extends RPCStruct { public PrimaryAudioSource getPrimaryAudioSource() { return (PrimaryAudioSource) getObject(PrimaryAudioSource.class, KEY_PRIMARY_AUDIO_SOURCE); } - public void setECallEventActive(@NonNull Boolean eCallEventActive) { + public DeviceStatus setECallEventActive(@NonNull Boolean eCallEventActive) { setValue(KEY_E_CALL_EVENT_ACTIVE, eCallEventActive); + return this; } public Boolean getECallEventActive() { return getBoolean(KEY_E_CALL_EVENT_ACTIVE); diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/DiagnosticMessage.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/DiagnosticMessage.java index effba93a9..ddfcccf7c 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/DiagnosticMessage.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/DiagnosticMessage.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -123,8 +123,9 @@ public class DiagnosticMessage extends RPCRequest { * * @param targetID the target for this Diagnostic Message */ - public void setTargetID(@NonNull Integer targetID) { - setParameters(KEY_TARGET_ID, targetID); + public DiagnosticMessage setTargetID(@NonNull Integer targetID) { + setParameters(KEY_TARGET_ID, targetID); + return this; } /** @@ -138,8 +139,9 @@ public class DiagnosticMessage extends RPCRequest { return getInteger(KEY_TARGET_ID); } - public void setMessageLength(@NonNull Integer messageLength) { - setParameters(KEY_MESSAGE_LENGTH, messageLength); + public DiagnosticMessage setMessageLength(@NonNull Integer messageLength) { + setParameters(KEY_MESSAGE_LENGTH, messageLength); + return this; } public Integer getMessageLength() { return getInteger(KEY_MESSAGE_LENGTH); @@ -150,7 +152,8 @@ public class DiagnosticMessage extends RPCRequest { return (List) getObject(Integer.class, KEY_MESSAGE_DATA); } - public void setMessageData(@NonNull List messageData) { - setParameters(KEY_MESSAGE_DATA, messageData); - } + public DiagnosticMessage setMessageData(@NonNull List messageData) { + setParameters(KEY_MESSAGE_DATA, messageData); + return this; + } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/DiagnosticMessageResponse.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/DiagnosticMessageResponse.java index c1a1cf5cb..38aee38b0 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/DiagnosticMessageResponse.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/DiagnosticMessageResponse.java @@ -74,8 +74,9 @@ public class DiagnosticMessageResponse extends RPCResponse { return (List) getObject(Integer.class, KEY_MESSAGE_DATA_RESULT); } - public void setMessageDataResult(List messageDataResult) { + public DiagnosticMessageResponse setMessageDataResult( List messageDataResult) { setParameters(KEY_MESSAGE_DATA_RESULT, messageDataResult); + return this; } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/DialNumber.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/DialNumber.java index 989617456..472bca08d 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/DialNumber.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/DialNumber.java @@ -68,11 +68,12 @@ public class DialNumber extends RPCRequest { * Notes: Maxlength=40

    * All characters shall be stripped from string except digits 0-9 and * # , ; + */ - public void setNumber(@NonNull String number) { + public DialNumber setNumber(@NonNull String number) { if (number != null) { number = number.replaceAll("[^0-9*#,;+]", ""); //This will sanitize the input } setParameters(KEY_NUMBER, number); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/DisplayCapabilities.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/DisplayCapabilities.java index 43b4b408e..15d9c5f39 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/DisplayCapabilities.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/DisplayCapabilities.java @@ -167,8 +167,9 @@ public class DisplayCapabilities extends RPCStruct { * @param displayType the display type */ @Deprecated - public void setDisplayType( @NonNull DisplayType displayType ) { + public DisplayCapabilities setDisplayType(@NonNull DisplayType displayType) { setValue(KEY_DISPLAY_TYPE, displayType); + return this; } /** Get the name of the display * @return the name of the display @@ -180,8 +181,9 @@ public class DisplayCapabilities extends RPCStruct { * Set the name of the display * @param displayName the name of the display */ - public void setDisplayName( String displayName ) { + public DisplayCapabilities setDisplayName( String displayName) { setValue(KEY_DISPLAY_NAME, displayName); + return this; } /** *Get an array of TextField structures, each of which describes a field in the HMI which the application can write to using operations such as {@linkplain Show}, {@linkplain SetMediaClockTimer}, etc. @@ -193,12 +195,13 @@ public class DisplayCapabilities extends RPCStruct { return (List) getObject(TextField.class, KEY_TEXT_FIELDS); } /** - * Set an array of TextField structures, each of which describes a field in the HMI which the application can write to using operations such as {@linkplain Show}, {@linkplain SetMediaClockTimer}, etc. + * Set an array of TextField structures, each of which describes a field in the HMI which the application can write to using operations such as {@linkplain Show}, {@linkplain SetMediaClockTimer}, etc. * This array of TextField structures identify all the text fields to which the application can write on the current display (identified by DisplayType ). * @param textFields the List of textFields - */ - public void setTextFields( @NonNull List textFields ) { + */ + public DisplayCapabilities setTextFields(@NonNull List textFields) { setValue(KEY_TEXT_FIELDS, textFields); + return this; } @@ -208,16 +211,18 @@ public class DisplayCapabilities extends RPCStruct { return (List) getObject(ImageField.class, KEY_IMAGE_FIELDS); } - public void setImageFields( List imageFields ) { + public DisplayCapabilities setImageFields( List imageFields) { setValue(KEY_IMAGE_FIELDS, imageFields); - } + return this; + } public Integer getNumCustomPresetsAvailable() { return getInteger(KEY_NUM_CUSTOM_PRESETS_AVAILABLE); } - public void setNumCustomPresetsAvailable(Integer numCustomPresetsAvailable) { + public DisplayCapabilities setNumCustomPresetsAvailable( Integer numCustomPresetsAvailable) { setValue(KEY_NUM_CUSTOM_PRESETS_AVAILABLE, numCustomPresetsAvailable); + return this; } /** @@ -231,9 +236,10 @@ public class DisplayCapabilities extends RPCStruct { /** * Set an array of MediaClockFormat elements, defining the valid string formats used in specifying the contents of the media clock field * @param mediaClockFormats the List of MediaClockFormat - */ - public void setMediaClockFormats( @NonNull List mediaClockFormats ) { + */ + public DisplayCapabilities setMediaClockFormats(@NonNull List mediaClockFormats) { setValue(KEY_MEDIA_CLOCK_FORMATS, mediaClockFormats); + return this; } /** @@ -241,8 +247,9 @@ public class DisplayCapabilities extends RPCStruct { * @param graphicSupported true if the display supports graphics, false if it does not * @since SmartDeviceLink 2.0 */ - public void setGraphicSupported(@NonNull Boolean graphicSupported) { - setValue(KEY_GRAPHIC_SUPPORTED, graphicSupported); + public DisplayCapabilities setGraphicSupported(@NonNull Boolean graphicSupported) { + setValue(KEY_GRAPHIC_SUPPORTED, graphicSupported); + return this; } /** @@ -259,12 +266,14 @@ public class DisplayCapabilities extends RPCStruct { return (List) getObject(String.class, KEY_TEMPLATES_AVAILABLE); } - public void setTemplatesAvailable(List templatesAvailable) { + public DisplayCapabilities setTemplatesAvailable( List templatesAvailable) { setValue(KEY_TEMPLATES_AVAILABLE, templatesAvailable); + return this; } - public void setScreenParams(ScreenParams screenParams) { + public DisplayCapabilities setScreenParams( ScreenParams screenParams) { setValue(KEY_SCREEN_PARAMS, screenParams); + return this; } @SuppressWarnings("unchecked") diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/DisplayCapability.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/DisplayCapability.java index 992083689..a071d915f 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/DisplayCapability.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/DisplayCapability.java @@ -36,8 +36,9 @@ public class DisplayCapability extends RPCStruct { * * @param displayName the name of the display */ - public void setDisplayName(String displayName) { + public DisplayCapability setDisplayName( String displayName) { setValue(KEY_DISPLAY_NAME, displayName); + return this; } /** @@ -46,8 +47,9 @@ public class DisplayCapability extends RPCStruct { * * @param windowTypeSupported It informs the application how many windows the app is allowed to create per type. */ - public void setWindowTypeSupported(List windowTypeSupported) { + public DisplayCapability setWindowTypeSupported( List windowTypeSupported) { setValue(KEY_WINDOW_TYPE_SUPPORTED, windowTypeSupported); + return this; } /** @@ -72,8 +74,9 @@ public class DisplayCapability extends RPCStruct { * 1. App creates a new window. After the window is created, a system capability notification will be sent related only to the created window. * 2. App sets a new template to the window. The new template changes window capabilties. The notification will reflect those changes to the single window. */ - public void setWindowCapabilities(List windowCapabilities) { + public DisplayCapability setWindowCapabilities( List windowCapabilities) { setValue(KEY_WINDOW_CAPABILITIES, windowCapabilities); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/DriverDistractionCapability.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/DriverDistractionCapability.java index c09a77f46..67d9bb434 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/DriverDistractionCapability.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/DriverDistractionCapability.java @@ -87,8 +87,9 @@ public class DriverDistractionCapability extends RPCStruct { * * @param menuLength The number of items allowed in a Choice Set or Command menu while the driver is distracted */ - public void setMenuLength(Integer menuLength) { + public DriverDistractionCapability setMenuLength( Integer menuLength) { setValue(KEY_MENU_LENGTH, menuLength); + return this; } /** @@ -106,8 +107,9 @@ public class DriverDistractionCapability extends RPCStruct { * @param subMenuDepth The depth of submenus allowed when the driver is distracted. e.g. 3 == top level menu -> * submenu -> submenu; 1 == top level menu only */ - public void setSubMenuDepth(Integer subMenuDepth) { + public DriverDistractionCapability setSubMenuDepth( Integer subMenuDepth) { setValue(KEY_SUB_MENU_DEPTH, subMenuDepth); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/DynamicUpdateCapabilities.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/DynamicUpdateCapabilities.java index f8b16ce29..d70523356 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/DynamicUpdateCapabilities.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/DynamicUpdateCapabilities.java @@ -93,8 +93,9 @@ public class DynamicUpdateCapabilities extends RPCStruct { * you upload the data with PutFile at a later point when the HMI needs it. The HMI will then * display the image in the appropriate field. If not sent, assume false. */ - public void setSupportedDynamicImageFieldNames(List supportedDynamicImageFieldNames) { + public DynamicUpdateCapabilities setSupportedDynamicImageFieldNames( List supportedDynamicImageFieldNames) { setValue(KEY_SUPPORTED_DYNAMIC_IMAGE_FIELD_NAMES, supportedDynamicImageFieldNames); + return this; } /** @@ -119,8 +120,9 @@ public class DynamicUpdateCapabilities extends RPCStruct { * AddSubMenu until OnUpdateSubMenu is received with the menuID. At that point, you should * send all AddCommands with a parentID that match the menuID. If not set, assume false. */ - public void setSupportsDynamicSubMenus(Boolean supportsDynamicSubMenus) { + public DynamicUpdateCapabilities setSupportsDynamicSubMenus( Boolean supportsDynamicSubMenus) { setValue(KEY_SUPPORTS_DYNAMIC_SUB_MENUS, supportsDynamicSubMenus); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/ECallInfo.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/ECallInfo.java index 03c69af0a..c1bd8d476 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/ECallInfo.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/ECallInfo.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -107,20 +107,23 @@ public class ECallInfo extends RPCStruct { setECallConfirmationStatus(eCallConfirmationStatus); } - public void setECallNotificationStatus(@NonNull VehicleDataNotificationStatus eCallNotificationStatus) { + public ECallInfo setECallNotificationStatus(@NonNull VehicleDataNotificationStatus eCallNotificationStatus) { setValue(KEY_E_CALL_NOTIFICATION_STATUS, eCallNotificationStatus); + return this; } public VehicleDataNotificationStatus getECallNotificationStatus() { return (VehicleDataNotificationStatus) getObject(VehicleDataNotificationStatus.class, KEY_E_CALL_NOTIFICATION_STATUS); } - public void setAuxECallNotificationStatus(@NonNull VehicleDataNotificationStatus auxECallNotificationStatus) { + public ECallInfo setAuxECallNotificationStatus(@NonNull VehicleDataNotificationStatus auxECallNotificationStatus) { setValue(KEY_AUX_E_CALL_NOTIFICATION_STATUS, auxECallNotificationStatus); + return this; } public VehicleDataNotificationStatus getAuxECallNotificationStatus() { return (VehicleDataNotificationStatus) getObject(VehicleDataNotificationStatus.class, KEY_AUX_E_CALL_NOTIFICATION_STATUS); } - public void setECallConfirmationStatus(@NonNull ECallConfirmationStatus eCallConfirmationStatus) { + public ECallInfo setECallConfirmationStatus(@NonNull ECallConfirmationStatus eCallConfirmationStatus) { setValue(KEY_E_CALL_CONFIRMATION_STATUS, eCallConfirmationStatus); + return this; } public ECallConfirmationStatus getECallConfirmationStatus() { return (ECallConfirmationStatus) getObject(ECallConfirmationStatus.class, KEY_E_CALL_CONFIRMATION_STATUS); diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/EmergencyEvent.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/EmergencyEvent.java index 6c22dc83d..923ad39fd 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/EmergencyEvent.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/EmergencyEvent.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -132,32 +132,37 @@ public class EmergencyEvent extends RPCStruct { setMultipleEvents(multipleEvents); } - public void setEmergencyEventType(@NonNull EmergencyEventType emergencyEventType) { + public EmergencyEvent setEmergencyEventType(@NonNull EmergencyEventType emergencyEventType) { setValue(KEY_EMERGENCY_EVENT_TYPE, emergencyEventType); + return this; } public EmergencyEventType getEmergencyEventType() { return (EmergencyEventType) getObject(EmergencyEventType.class, KEY_EMERGENCY_EVENT_TYPE); } - public void setFuelCutoffStatus(@NonNull FuelCutoffStatus fuelCutoffStatus) { + public EmergencyEvent setFuelCutoffStatus(@NonNull FuelCutoffStatus fuelCutoffStatus) { setValue(KEY_FUEL_CUTOFF_STATUS, fuelCutoffStatus); + return this; } public FuelCutoffStatus getFuelCutoffStatus() { return (FuelCutoffStatus) getObject(FuelCutoffStatus.class, KEY_FUEL_CUTOFF_STATUS); } - public void setRolloverEvent(@NonNull VehicleDataEventStatus rolloverEvent) { + public EmergencyEvent setRolloverEvent(@NonNull VehicleDataEventStatus rolloverEvent) { setValue(KEY_ROLLOVER_EVENT, rolloverEvent); + return this; } public VehicleDataEventStatus getRolloverEvent() { return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_ROLLOVER_EVENT); } - public void setMaximumChangeVelocity(@NonNull Integer maximumChangeVelocity) { + public EmergencyEvent setMaximumChangeVelocity(@NonNull Integer maximumChangeVelocity) { setValue(KEY_MAXIMUM_CHANGE_VELOCITY, maximumChangeVelocity); + return this; } public Integer getMaximumChangeVelocity() { return getInteger(KEY_MAXIMUM_CHANGE_VELOCITY); } - public void setMultipleEvents(@NonNull VehicleDataEventStatus multipleEvents) { + public EmergencyEvent setMultipleEvents(@NonNull VehicleDataEventStatus multipleEvents) { setValue(KEY_MULTIPLE_EVENTS, multipleEvents); + return this; } public VehicleDataEventStatus getMultipleEvents() { return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_MULTIPLE_EVENTS); diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/EqualizerSettings.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/EqualizerSettings.java index 81c7f100c..509545143 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/EqualizerSettings.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/EqualizerSettings.java @@ -77,9 +77,10 @@ public class EqualizerSettings extends RPCStruct { * * @param channelId ID that represents the channel these settings should be applied */ - public void setChannelId(@NonNull Integer channelId) { - setValue(KEY_CHANNEL_ID, channelId); - } + public EqualizerSettings setChannelId(@NonNull Integer channelId) { + setValue(KEY_CHANNEL_ID, channelId); + return this; + } /** * Gets the channelId portion of the EqualizerSettings class @@ -95,9 +96,10 @@ public class EqualizerSettings extends RPCStruct { * * @param channelName Read-only channel / frequency name (e.i. "Treble, Midrange, Bass" or "125 Hz"). */ - public void setChannelName(String channelName) { - setValue(KEY_CHANNEL_NAME, channelName); - } + public EqualizerSettings setChannelName( String channelName) { + setValue(KEY_CHANNEL_NAME, channelName); + return this; + } /** * Gets the channelName portion of the EqualizerSettings class @@ -113,9 +115,10 @@ public class EqualizerSettings extends RPCStruct { * * @param channelSetting Reflects the setting, from 0%-100%. */ - public void setChannelSetting(@NonNull Integer channelSetting) { - setValue(KEY_CHANNEL_SETTING, channelSetting); - } + public EqualizerSettings setChannelSetting(@NonNull Integer channelSetting) { + setValue(KEY_CHANNEL_SETTING, channelSetting); + return this; + } /** * Gets the channelSetting portion of the EqualizerSettings class diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/FuelRange.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/FuelRange.java index 334f6eb4e..549ce6862 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/FuelRange.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/FuelRange.java @@ -132,10 +132,11 @@ public class FuelRange extends RPCStruct { * * @param fuelType the type of fuel related to this FuelRange object. * - * @see com.smartdevicelink.proxy.rpc.enums.FuelType + * @see FuelType */ - public void setType(FuelType fuelType) { + public FuelRange setType( FuelType fuelType) { setValue(KEY_TYPE, fuelType); + return this; } /** @@ -163,8 +164,9 @@ public class FuelRange extends RPCStruct { * @param range * The estimate range in KM the vehicle can travel based on fuel level and consumption. */ - public void setRange(Float range) { + public FuelRange setRange( Float range) { setValue(KEY_RANGE, range); + return this; } /** @@ -174,8 +176,9 @@ public class FuelRange extends RPCStruct { * {"num_min_value": -6.0, "num_max_value": 1000000.0} * @since SmartDeviceLink 7.0.0 */ - public void setLevel(Float level) { + public FuelRange setLevel( Float level) { setValue(KEY_LEVEL, level); + return this; } /** @@ -196,8 +199,9 @@ public class FuelRange extends RPCStruct { * @param levelState The fuel level state * @since SmartDeviceLink 7.0.0 */ - public void setLevelState(ComponentVolumeStatus levelState) { + public FuelRange setLevelState( ComponentVolumeStatus levelState) { setValue(KEY_LEVEL_STATE, levelState); + return this; } /** @@ -217,8 +221,9 @@ public class FuelRange extends RPCStruct { * {"num_min_value": 0.0, "num_max_value": 1000000.0} * @since SmartDeviceLink 7.0.0 */ - public void setCapacity(Float capacity) { + public FuelRange setCapacity( Float capacity) { setValue(KEY_CAPACITY, capacity); + return this; } /** @@ -240,8 +245,9 @@ public class FuelRange extends RPCStruct { * batteries. * @since SmartDeviceLink 7.0.0 */ - public void setCapacityUnit(CapacityUnit capacityUnit) { + public FuelRange setCapacityUnit( CapacityUnit capacityUnit) { setValue(KEY_CAPACITY_UNIT, capacityUnit); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/GPSData.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/GPSData.java index f36cd6127..98d85a739 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/GPSData.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/GPSData.java @@ -222,8 +222,9 @@ public class GPSData extends RPCStruct { * set longitude degrees * @param longitudeDegrees degrees of the longitudinal position */ - public void setLongitudeDegrees(@NonNull Double longitudeDegrees) { - setValue(KEY_LONGITUDE_DEGREES, longitudeDegrees); + public GPSData setLongitudeDegrees(@NonNull Double longitudeDegrees) { + setValue(KEY_LONGITUDE_DEGREES, longitudeDegrees); + return this; } /** @@ -239,8 +240,9 @@ public class GPSData extends RPCStruct { * set latitude degrees * @param latitudeDegrees degrees of the latitudinal position */ - public void setLatitudeDegrees(@NonNull Double latitudeDegrees) { - setValue(KEY_LATITUDE_DEGREES, latitudeDegrees); + public GPSData setLatitudeDegrees(@NonNull Double latitudeDegrees) { + setValue(KEY_LATITUDE_DEGREES, latitudeDegrees); + return this; } /** @@ -256,8 +258,9 @@ public class GPSData extends RPCStruct { * set utc year * @param utcYear utc year */ - public void setUtcYear(Integer utcYear) { - setValue(KEY_UTC_YEAR, utcYear); + public GPSData setUtcYear( Integer utcYear) { + setValue(KEY_UTC_YEAR, utcYear); + return this; } /** @@ -272,8 +275,9 @@ public class GPSData extends RPCStruct { * set utc month * @param utcMonth utc month */ - public void setUtcMonth(Integer utcMonth) { - setValue(KEY_UTC_MONTH, utcMonth); + public GPSData setUtcMonth( Integer utcMonth) { + setValue(KEY_UTC_MONTH, utcMonth); + return this; } /** @@ -288,8 +292,9 @@ public class GPSData extends RPCStruct { * set utc day * @param utcDay utc day */ - public void setUtcDay(Integer utcDay) { - setValue(KEY_UTC_DAY, utcDay); + public GPSData setUtcDay( Integer utcDay) { + setValue(KEY_UTC_DAY, utcDay); + return this; } /** @@ -304,8 +309,9 @@ public class GPSData extends RPCStruct { * set utc hours * @param utcHours utc hours */ - public void setUtcHours(Integer utcHours) { - setValue(KEY_UTC_HOURS, utcHours); + public GPSData setUtcHours( Integer utcHours) { + setValue(KEY_UTC_HOURS, utcHours); + return this; } /** @@ -320,8 +326,9 @@ public class GPSData extends RPCStruct { * set utc minutes * @param utcMinutes utc minutes */ - public void setUtcMinutes(Integer utcMinutes) { - setValue(KEY_UTC_MINUTES, utcMinutes); + public GPSData setUtcMinutes( Integer utcMinutes) { + setValue(KEY_UTC_MINUTES, utcMinutes); + return this; } /** @@ -336,8 +343,9 @@ public class GPSData extends RPCStruct { * set utc seconds * @param utcSeconds utc seconds */ - public void setUtcSeconds(Integer utcSeconds) { - setValue(KEY_UTC_SECONDS, utcSeconds); + public GPSData setUtcSeconds( Integer utcSeconds) { + setValue(KEY_UTC_SECONDS, utcSeconds); + return this; } /** @@ -347,8 +355,9 @@ public class GPSData extends RPCStruct { public Integer getUtcSeconds() { return getInteger(KEY_UTC_SECONDS); } - public void setCompassDirection(CompassDirection compassDirection) { - setValue(KEY_COMPASS_DIRECTION, compassDirection); + public GPSData setCompassDirection( CompassDirection compassDirection) { + setValue(KEY_COMPASS_DIRECTION, compassDirection); + return this; } public CompassDirection getCompassDirection() { return (CompassDirection) getObject(CompassDirection.class, KEY_COMPASS_DIRECTION); @@ -358,8 +367,9 @@ public class GPSData extends RPCStruct { * set the positional dilution of precision * @param pdop the positional dilution of precision */ - public void setPdop(Double pdop) { - setValue(KEY_PDOP, pdop); + public GPSData setPdop( Double pdop) { + setValue(KEY_PDOP, pdop); + return this; } /** @@ -374,8 +384,9 @@ public class GPSData extends RPCStruct { * set the horizontal dilution of precision * @param hdop the horizontal dilution of precision */ - public void setHdop(Double hdop) { - setValue(KEY_HDOP, hdop); + public GPSData setHdop( Double hdop) { + setValue(KEY_HDOP, hdop); + return this; } /** @@ -391,8 +402,9 @@ public class GPSData extends RPCStruct { * set the vertical dilution of precision * @param vdop the vertical dilution of precision */ - public void setVdop(Double vdop) { - setValue(KEY_VDOP, vdop); + public GPSData setVdop( Double vdop) { + setValue(KEY_VDOP, vdop); + return this; } /** @@ -405,11 +417,12 @@ public class GPSData extends RPCStruct { } /** - * set what coordinates based on + * set what coordinates based on * @param actual True, if coordinates are based on satellites.False, if based on dead reckoning */ - public void setActual(Boolean actual) { - setValue(KEY_ACTUAL, actual); + public GPSData setActual( Boolean actual) { + setValue(KEY_ACTUAL, actual); + return this; } /** @@ -424,8 +437,9 @@ public class GPSData extends RPCStruct { * set the number of satellites in view * @param satellites the number of satellites in view */ - public void setSatellites(Integer satellites) { - setValue(KEY_SATELLITES, satellites); + public GPSData setSatellites( Integer satellites) { + setValue(KEY_SATELLITES, satellites); + return this; } /** @@ -435,8 +449,9 @@ public class GPSData extends RPCStruct { public Integer getSatellites() { return getInteger(KEY_SATELLITES); } - public void setDimension(Dimension dimension) { - setValue(KEY_DIMENSION, dimension); + public GPSData setDimension( Dimension dimension) { + setValue(KEY_DIMENSION, dimension); + return this; } public Dimension getDimension() { return (Dimension) getObject(Dimension.class, KEY_DIMENSION); @@ -446,8 +461,9 @@ public class GPSData extends RPCStruct { * set altitude in meters * @param altitude altitude in meters */ - public void setAltitude(Double altitude) { - setValue(KEY_ALTITUDE, altitude); + public GPSData setAltitude( Double altitude) { + setValue(KEY_ALTITUDE, altitude); + return this; } /** @@ -461,10 +477,11 @@ public class GPSData extends RPCStruct { /** * set the heading.North is 0, East is 90, etc. - * @param heading the heading. + * @param heading the heading. */ - public void setHeading(Double heading) { - setValue(KEY_HEADING, heading); + public GPSData setHeading( Double heading) { + setValue(KEY_HEADING, heading); + return this; } /** @@ -479,8 +496,9 @@ public class GPSData extends RPCStruct { * set speed in KPH * @param speed the speed */ - public void setSpeed(Double speed) { - setValue(KEY_SPEED, speed); + public GPSData setSpeed( Double speed) { + setValue(KEY_SPEED, speed); + return this; } /** @@ -491,22 +509,23 @@ public class GPSData extends RPCStruct { Object object = getValue(KEY_SPEED); return SdlDataTypeConverter.objectToDouble(object); } - - /** - * Sets the shifted param for GPSData. - * @param shifted True, if GPS lat/long, time, and altitude have been purposefully shifted (requires a proprietary algorithm to unshift). - * False, if the GPS data is raw and un-shifted. - * If not provided, then value is assumed False. - */ - public void setShifted(Boolean shifted) { - setValue(KEY_SHIFTED, shifted); - } - - /** - * Gets the shifted param for GPSData. - * @return Boolean - True, if GPS lat/long, time, and altitude have been purposefully shifted (requires a proprietary algorithm to unshift). - */ - public Boolean getShifted() { - return getBoolean(KEY_SHIFTED); - } -} + + /** + * Sets the shifted param for GPSData. + * @param shifted True, if GPS lat/long, time, and altitude have been purposefully shifted (requires a proprietary algorithm to unshift). + * False, if the GPS data is raw and un-shifted. + * If not provided, then value is assumed False. + */ + public GPSData setShifted( Boolean shifted) { + setValue(KEY_SHIFTED, shifted); + return this; + } + + /** + * Gets the shifted param for GPSData. + * @return Boolean - True, if GPS lat/long, time, and altitude have been purposefully shifted (requires a proprietary algorithm to unshift). + */ + public Boolean getShifted() { + return getBoolean(KEY_SHIFTED); + } +} diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/GearStatus.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/GearStatus.java index 131e7f831..dbae57a2a 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/GearStatus.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/GearStatus.java @@ -97,8 +97,9 @@ public class GearStatus extends RPCStruct { * * @param userSelectedGear Gear position selected by the user i.e. Park, Drive, Reverse */ - public void setUserSelectedGear(PRNDL selectedGear){ + public GearStatus setUserSelectedGear( PRNDL selectedGear) { setValue(KEY_USER_SELECTED_GEAR, selectedGear); + return this; } /** @@ -116,8 +117,9 @@ public class GearStatus extends RPCStruct { * * @param actualGear Actual Gear in use by the transmission */ - public void setActualGear(PRNDL actualGear){ + public GearStatus setActualGear( PRNDL actualGear) { setValue(KEY_ACTUAL_GEAR, actualGear); + return this; } /** @@ -135,8 +137,9 @@ public class GearStatus extends RPCStruct { * * @param transmissionType Tells the transmission type */ - public void setTransmissionType(TransmissionType transmissionType){ + public GearStatus setTransmissionType( TransmissionType transmissionType) { setValue(KEY_TRANSMISSION_TYPE, transmissionType); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetAppServiceData.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetAppServiceData.java index 9946de27a..77a423af9 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetAppServiceData.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetAppServiceData.java @@ -78,9 +78,10 @@ public class GetAppServiceData extends RPCRequest { /** * @param appServiceType - the appServiceType */ - public void setServiceType(@NonNull String appServiceType){ - setParameters(KEY_SERVICE_TYPE, appServiceType); - } + public GetAppServiceData setServiceType(@NonNull String appServiceType) { + setParameters(KEY_SERVICE_TYPE, appServiceType); + return this; + } /** * @return appServiceType @@ -95,9 +96,10 @@ public class GetAppServiceData extends RPCRequest { * if it was previously subscribed. * @param subscribe - */ - public void setSubscribe(Boolean subscribe){ - setParameters(KEY_SUBSCRIBE, subscribe); - } + public GetAppServiceData setSubscribe( Boolean subscribe) { + setParameters(KEY_SUBSCRIBE, subscribe); + return this; + } /** * If true, the consumer is requesting to subscribe to all future updates from the service diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetAppServiceDataResponse.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetAppServiceDataResponse.java index 253626e9b..0739e9e58 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetAppServiceDataResponse.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetAppServiceDataResponse.java @@ -67,9 +67,10 @@ public class GetAppServiceDataResponse extends RPCResponse { /** * @param serviceData - */ - public void setServiceData(AppServiceData serviceData){ - setParameters(KEY_SERVICE_DATA, serviceData); - } + public GetAppServiceDataResponse setServiceData( AppServiceData serviceData) { + setParameters(KEY_SERVICE_DATA, serviceData); + return this; + } /** * @return serviceData diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetCloudAppProperties.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetCloudAppProperties.java index 3348d4cb1..11913954b 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetCloudAppProperties.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetCloudAppProperties.java @@ -55,8 +55,9 @@ public class GetCloudAppProperties extends RPCRequest { setParameters(KEY_APP_ID, appID); } - public void setAppID(String appId){ + public GetCloudAppProperties setAppID( String appId) { setParameters(KEY_APP_ID, appId); + return this; } public String getAppID(){ diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetCloudAppPropertiesResponse.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetCloudAppPropertiesResponse.java index 2c4eddeda..04e576353 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetCloudAppPropertiesResponse.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetCloudAppPropertiesResponse.java @@ -62,8 +62,9 @@ public class GetCloudAppPropertiesResponse extends RPCResponse { setResultCode(resultCode); } - public void setCloudAppProperties(CloudAppProperties cloudAppProperties){ + public GetCloudAppPropertiesResponse setCloudAppProperties( CloudAppProperties cloudAppProperties) { setParameters(KEY_PROPERTIES, cloudAppProperties); + return this; } public CloudAppProperties getCloudAppProperties(){ diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetDTCs.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetDTCs.java index 939e1cdb6..63b0d716b 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetDTCs.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetDTCs.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -120,15 +120,16 @@ public class GetDTCs extends RPCRequest { /** * Sets a name of the module to receive the DTC form - * + * * @param ecuName * an Integer value representing a name of the module to receive * the DTC form *

    * Notes:

    Minvalue:0; Maxvalue:65535 */ - public void setEcuName(@NonNull Integer ecuName) { - setParameters(KEY_ECU_NAME, ecuName); + public GetDTCs setEcuName(@NonNull Integer ecuName) { + setParameters(KEY_ECU_NAME, ecuName); + return this; } /** @@ -140,8 +141,9 @@ public class GetDTCs extends RPCRequest { public Integer getEcuName() { return getInteger(KEY_ECU_NAME); } - public void setDtcMask(Integer dtcMask) { - setParameters(KEY_DTC_MASK, dtcMask); + public GetDTCs setDtcMask( Integer dtcMask) { + setParameters(KEY_DTC_MASK, dtcMask); + return this; } public Integer getDtcMask() { return getInteger(KEY_DTC_MASK); diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetDTCsResponse.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetDTCsResponse.java index e7c54c02b..87ae47ab8 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetDTCsResponse.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetDTCsResponse.java @@ -74,16 +74,18 @@ public class GetDTCsResponse extends RPCResponse{ return (List) getObject(String.class, KEY_DTC); } - public void setDtc(List dtc){ + public GetDTCsResponse setDtc( List dtc) { setParameters(KEY_DTC, dtc); + return this; } public Integer getEcuHeader(){ return getInteger(KEY_ECU_HEADER); } - public void setEcuHeader(Integer ecuHeader){ + public GetDTCsResponse setEcuHeader( Integer ecuHeader) { setParameters(KEY_ECU_HEADER, ecuHeader); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetFile.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetFile.java index d1453ded1..ea8d41c04 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetFile.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetFile.java @@ -72,9 +72,10 @@ public class GetFile extends RPCRequest { * maxlength="255" * @param fileName - */ - public void setFileName(@NonNull String fileName){ - setParameters(KEY_FILE_NAME, fileName); - } + public GetFile setFileName(@NonNull String fileName) { + setParameters(KEY_FILE_NAME, fileName); + return this; + } /** * File name that should be retrieved. @@ -89,9 +90,10 @@ public class GetFile extends RPCRequest { * ID of the service that should have uploaded the requested file * @param appServiceId - */ - public void setAppServiceId(String appServiceId){ - setParameters(KEY_APP_SERVICE_ID, appServiceId); - } + public GetFile setAppServiceId( String appServiceId) { + setParameters(KEY_APP_SERVICE_ID, appServiceId); + return this; + } /** * ID of the service that should have uploaded the requested file @@ -105,9 +107,10 @@ public class GetFile extends RPCRequest { * Selected file type. * @param fileType - */ - public void setFileType(FileType fileType){ - setParameters(KEY_FILE_TYPE, fileType); - } + public GetFile setFileType( FileType fileType) { + setParameters(KEY_FILE_TYPE, fileType); + return this; + } /** * Selected file type. @@ -122,9 +125,10 @@ public class GetFile extends RPCRequest { * minvalue="0" maxvalue="2000000000" * @param offset - */ - public void setOffset(Integer offset){ - setParameters(KEY_OFFSET, offset); - } + public GetFile setOffset( Integer offset) { + setParameters(KEY_OFFSET, offset); + return this; + } /** * Optional offset in bytes for resuming partial data chunks @@ -141,9 +145,10 @@ public class GetFile extends RPCRequest { * minvalue="0" maxvalue="2000000000" * @param length - */ - public void setLength(Integer length){ - setParameters(KEY_LENGTH, length); - } + public GetFile setLength( Integer length) { + setParameters(KEY_LENGTH, length); + return this; + } /** * Optional length in bytes for resuming partial data chunks if offset is set to 0, then length diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetFileResponse.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetFileResponse.java index 711de294c..17b5473c4 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetFileResponse.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetFileResponse.java @@ -73,9 +73,10 @@ public class GetFileResponse extends RPCResponse { * File type that is being sent in response * @param fileType - */ - public void setFileType(FileType fileType){ - setParameters(KEY_FILE_TYPE, fileType); - } + public GetFileResponse setFileType( FileType fileType) { + setParameters(KEY_FILE_TYPE, fileType); + return this; + } /** * File type that is being sent in response @@ -90,9 +91,10 @@ public class GetFileResponse extends RPCResponse { * minvalue="0" maxvalue="2000000000" * @param offset - */ - public void setOffset(Integer offset){ - setParameters(KEY_OFFSET, offset); - } + public GetFileResponse setOffset( Integer offset) { + setParameters(KEY_OFFSET, offset); + return this; + } /** * Optional offset in bytes for resuming partial data chunks @@ -109,9 +111,10 @@ public class GetFileResponse extends RPCResponse { * minvalue="0" maxvalue="2000000000" * @param length - */ - public void setLength(Integer length){ - setParameters(KEY_LENGTH, length); - } + public GetFileResponse setLength( Integer length) { + setParameters(KEY_LENGTH, length); + return this; + } /** * Optional length in bytes for resuming partial data chunks if offset is set to 0, then length @@ -128,9 +131,10 @@ public class GetFileResponse extends RPCResponse { * minvalue="0" maxvalue="4294967295" * @param crc - */ - public void setCRC(Integer crc){ - setParameters(KEY_CRC, crc); - } + public GetFileResponse setCRC( Integer crc) { + setParameters(KEY_CRC, crc); + return this; + } /** * Additional CRC32 checksum to protect data integrity up to 512 Mbits diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetInteriorVehicleData.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetInteriorVehicleData.java index a6a323646..3b2a5098b 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetInteriorVehicleData.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetInteriorVehicleData.java @@ -95,8 +95,9 @@ public class GetInteriorVehicleData extends RPCRequest { * The type of a RC module to retrieve module data from the vehicle. * In the future, this should be the Identification of a module. */ - public void setModuleType(@NonNull ModuleType moduleType) { + public GetInteriorVehicleData setModuleType(@NonNull ModuleType moduleType) { setParameters(KEY_MODULE_TYPE, moduleType); + return this; } /** @@ -106,8 +107,9 @@ public class GetInteriorVehicleData extends RPCRequest { * If subscribe is true, the head unit will register onInteriorVehicleData notifications for the requested moduelType. * If subscribe is false, the head unit will unregister onInteriorVehicleData notifications for the requested moduelType. */ - public void setSubscribe(Boolean subscribe) { + public GetInteriorVehicleData setSubscribe( Boolean subscribe) { setParameters(KEY_SUBSCRIBE, subscribe); + return this; } /** @@ -124,8 +126,9 @@ public class GetInteriorVehicleData extends RPCRequest { * Sets the Module ID for this class * @param id the id to be set */ - public void setModuleId(String id) { + public GetInteriorVehicleData setModuleId( String id) { setParameters(KEY_MODULE_ID, id); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetInteriorVehicleDataConsent.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetInteriorVehicleDataConsent.java index b4d3e02f3..46a40b5dd 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetInteriorVehicleDataConsent.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetInteriorVehicleDataConsent.java @@ -35,8 +35,9 @@ public class GetInteriorVehicleDataConsent extends RPCRequest { * Sets the Module Type for this class * @param type the Module Type to be set */ - public void setModuleType(@NonNull ModuleType type) { + public GetInteriorVehicleDataConsent setModuleType(@NonNull ModuleType type) { setParameters(KEY_MODULE_TYPE, type); + return this; } /** @@ -51,8 +52,9 @@ public class GetInteriorVehicleDataConsent extends RPCRequest { * Sets the Module Ids for this class * @param ids the ids to be set */ - public void setModuleIds(@NonNull List ids) { + public GetInteriorVehicleDataConsent setModuleIds(@NonNull List ids) { setParameters(KEY_MODULE_ID, ids); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetInteriorVehicleDataConsentResponse.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetInteriorVehicleDataConsentResponse.java index 5c2b5c7e9..91df49d4a 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetInteriorVehicleDataConsentResponse.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetInteriorVehicleDataConsentResponse.java @@ -31,8 +31,9 @@ public class GetInteriorVehicleDataConsentResponse extends RPCResponse { * Sets the list of allowances for this class * @param allowances the allowances to be set */ - public void setAllowances(@NonNull List allowances) { + public GetInteriorVehicleDataConsentResponse setAllowances(@NonNull List allowances) { setParameters(KEY_ALLOWED, allowances); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetInteriorVehicleDataResponse.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetInteriorVehicleDataResponse.java index ccf1e7913..7fb081f30 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetInteriorVehicleDataResponse.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetInteriorVehicleDataResponse.java @@ -87,9 +87,10 @@ public class GetInteriorVehicleDataResponse extends RPCResponse { * * @param moduleData specific data for the module that was requested */ - public void setModuleData(ModuleData moduleData) { - setParameters(KEY_MODULE_DATA, moduleData); - } + public GetInteriorVehicleDataResponse setModuleData( ModuleData moduleData) { + setParameters(KEY_MODULE_DATA, moduleData); + return this; + } /** * Sets isSubscribed parameter @@ -99,9 +100,10 @@ public class GetInteriorVehicleDataResponse extends RPCResponse { * If "true" - the "moduleType" from request is successfully subscribed and the head unit will send onInteriorVehicleData notifications for the moduleType. * If "false" - the "moduleType" from request is either unsubscribed or failed to subscribe. * */ - public void setIsSubscribed(Boolean isSubscribed) { - setParameters(KEY_IS_SUBSCRIBED, isSubscribed); - } + public GetInteriorVehicleDataResponse setIsSubscribed( Boolean isSubscribed) { + setParameters(KEY_IS_SUBSCRIBED, isSubscribed); + return this; + } /** * Gets isSubscribed parameter diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetSystemCapability.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetSystemCapability.java index 8cb70d7aa..173360d64 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetSystemCapability.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetSystemCapability.java @@ -84,8 +84,9 @@ public class GetSystemCapability extends RPCRequest { * Used to set the SystemCapabilityType being requested * @param value SystemCapabilityType being requested */ - public void setSystemCapabilityType(@NonNull SystemCapabilityType value){ + public GetSystemCapability setSystemCapabilityType(@NonNull SystemCapabilityType value) { setParameters(KEY_SYSTEM_CAPABILITY_TYPE, value); + return this; } /** @@ -104,7 +105,8 @@ public class GetSystemCapability extends RPCRequest { * subscriber if it was previously subscribed. * @param subscribe to changes in the SystemCapabilityType */ - public void setSubscribe(Boolean subscribe){ + public GetSystemCapability setSubscribe( Boolean subscribe) { setParameters(KEY_SUBSCRIBE, subscribe); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetSystemCapabilityResponse.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetSystemCapabilityResponse.java index 29803499e..f48e095e7 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetSystemCapabilityResponse.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetSystemCapabilityResponse.java @@ -87,7 +87,8 @@ public class GetSystemCapabilityResponse extends RPCResponse { * Set a SystemCapability object in the response * @param value SystemCapability object */ - public void setSystemCapability(SystemCapability value){ + public GetSystemCapabilityResponse setSystemCapability( SystemCapability value) { setParameters(KEY_SYSTEM_CAPABILITY, value); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleData.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleData.java index d1400d8f3..e5480b584 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleData.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleData.java @@ -357,20 +357,23 @@ public class GetVehicleData extends RPCRequest { public GetVehicleData(Hashtable hash) { super(hash); } - public void setGps(Boolean gps) { + public GetVehicleData setGps( Boolean gps) { setParameters(KEY_GPS, gps); + return this; } public Boolean getGps() { return getBoolean(KEY_GPS); } - public void setSpeed(Boolean speed) { + public GetVehicleData setSpeed( Boolean speed) { setParameters(KEY_SPEED, speed); + return this; } public Boolean getSpeed() { return getBoolean(KEY_SPEED); } - public void setRpm(Boolean rpm) { + public GetVehicleData setRpm( Boolean rpm) { setParameters(KEY_RPM, rpm); + return this; } public Boolean getRpm() { return getBoolean(KEY_RPM); @@ -383,8 +386,9 @@ public class GetVehicleData extends RPCRequest { * 7.0, please see fuelRange. */ @Deprecated - public void setFuelLevel(Boolean fuelLevel) { + public GetVehicleData setFuelLevel( Boolean fuelLevel) { setParameters(KEY_FUEL_LEVEL, fuelLevel); + return this; } /** @@ -399,38 +403,43 @@ public class GetVehicleData extends RPCRequest { } @Deprecated - public void setFuelLevelState(Boolean fuelLevelState) { + public GetVehicleData setFuelLevelState( Boolean fuelLevelState) { setParameters(KEY_FUEL_LEVEL_STATE, fuelLevelState); + return this; } @Deprecated public Boolean getFuelLevelState() { return getBoolean(KEY_FUEL_LEVEL_STATE); } - public void setInstantFuelConsumption(Boolean instantFuelConsumption) { + public GetVehicleData setInstantFuelConsumption( Boolean instantFuelConsumption) { setParameters(KEY_INSTANT_FUEL_CONSUMPTION, instantFuelConsumption); + return this; } public Boolean getInstantFuelConsumption() { return getBoolean(KEY_INSTANT_FUEL_CONSUMPTION); } - public void setFuelRange(Boolean fuelRange) { + public GetVehicleData setFuelRange( Boolean fuelRange) { setParameters(KEY_FUEL_RANGE, fuelRange); + return this; } public Boolean getFuelRange() { return getBoolean(KEY_FUEL_RANGE); } - public void setExternalTemperature(Boolean externalTemperature) { + public GetVehicleData setExternalTemperature( Boolean externalTemperature) { setParameters(KEY_EXTERNAL_TEMPERATURE, externalTemperature); + return this; } public Boolean getExternalTemperature() { return getBoolean(KEY_EXTERNAL_TEMPERATURE); } - public void setVin(Boolean vin) { + public GetVehicleData setVin( Boolean vin) { setParameters(KEY_VIN, vin); + return this; } public Boolean getVin() { return getBoolean(KEY_VIN); @@ -443,8 +452,9 @@ public class GetVehicleData extends RPCRequest { * @deprecated in SmartDeviceLink 7.0.0 */ @Deprecated - public void setPrndl(Boolean prndl) { + public GetVehicleData setPrndl( Boolean prndl) { setParameters(KEY_PRNDL, prndl); + return this; } /** @@ -457,107 +467,124 @@ public class GetVehicleData extends RPCRequest { public Boolean getPrndl() { return getBoolean(KEY_PRNDL); } - public void setTirePressure(Boolean tirePressure) { + public GetVehicleData setTirePressure( Boolean tirePressure) { setParameters(KEY_TIRE_PRESSURE, tirePressure); + return this; } public Boolean getTirePressure() { return getBoolean(KEY_TIRE_PRESSURE); } - public void setOdometer(Boolean odometer) { + public GetVehicleData setOdometer( Boolean odometer) { setParameters(KEY_ODOMETER, odometer); + return this; } public Boolean getOdometer() { return getBoolean(KEY_ODOMETER); } - public void setBeltStatus(Boolean beltStatus) { + public GetVehicleData setBeltStatus( Boolean beltStatus) { setParameters(KEY_BELT_STATUS, beltStatus); + return this; } public Boolean getBeltStatus() { return getBoolean(KEY_BELT_STATUS); } - public void setBodyInformation(Boolean bodyInformation) { + public GetVehicleData setBodyInformation( Boolean bodyInformation) { setParameters(KEY_BODY_INFORMATION, bodyInformation); + return this; } public Boolean getBodyInformation() { return getBoolean(KEY_BODY_INFORMATION); } - public void setDeviceStatus(Boolean deviceStatus) { + public GetVehicleData setDeviceStatus( Boolean deviceStatus) { setParameters(KEY_DEVICE_STATUS, deviceStatus); + return this; } public Boolean getDeviceStatus() { return getBoolean(KEY_DEVICE_STATUS); } - public void setDriverBraking(Boolean driverBraking) { + public GetVehicleData setDriverBraking( Boolean driverBraking) { setParameters(KEY_DRIVER_BRAKING, driverBraking); + return this; } public Boolean getDriverBraking() { return getBoolean(KEY_DRIVER_BRAKING); } - public void setWiperStatus(Boolean wiperStatus) { + public GetVehicleData setWiperStatus( Boolean wiperStatus) { setParameters(KEY_WIPER_STATUS, wiperStatus); + return this; } public Boolean getWiperStatus() { return getBoolean(KEY_WIPER_STATUS); } - public void setHeadLampStatus(Boolean headLampStatus) { + public GetVehicleData setHeadLampStatus( Boolean headLampStatus) { setParameters(KEY_HEAD_LAMP_STATUS, headLampStatus); + return this; } public Boolean getHeadLampStatus() { return getBoolean(KEY_HEAD_LAMP_STATUS); } - public void setEngineTorque(Boolean engineTorque) { + public GetVehicleData setEngineTorque( Boolean engineTorque) { setParameters(KEY_ENGINE_TORQUE, engineTorque); + return this; } public Boolean getEngineTorque() { return getBoolean(KEY_ENGINE_TORQUE); } - public void setEngineOilLife(Boolean engineOilLife) { + public GetVehicleData setEngineOilLife( Boolean engineOilLife) { setParameters(KEY_ENGINE_OIL_LIFE, engineOilLife); + return this; } public Boolean getEngineOilLife() { return getBoolean(KEY_ENGINE_OIL_LIFE); } - public void setAccPedalPosition(Boolean accPedalPosition) { + public GetVehicleData setAccPedalPosition( Boolean accPedalPosition) { setParameters(KEY_ACC_PEDAL_POSITION, accPedalPosition); + return this; } public Boolean getAccPedalPosition() { return getBoolean(KEY_ACC_PEDAL_POSITION); } - public void setSteeringWheelAngle(Boolean steeringWheelAngle) { + public GetVehicleData setSteeringWheelAngle( Boolean steeringWheelAngle) { setParameters(KEY_STEERING_WHEEL_ANGLE, steeringWheelAngle); + return this; } public Boolean getSteeringWheelAngle() { return getBoolean(KEY_STEERING_WHEEL_ANGLE); } - public void setECallInfo(Boolean eCallInfo) { + public GetVehicleData setECallInfo( Boolean eCallInfo) { setParameters(KEY_E_CALL_INFO, eCallInfo); + return this; } public Boolean getECallInfo() { return getBoolean(KEY_E_CALL_INFO); } - public void setAirbagStatus(Boolean airbagStatus) { + public GetVehicleData setAirbagStatus( Boolean airbagStatus) { setParameters(KEY_AIRBAG_STATUS, airbagStatus); + return this; } public Boolean getAirbagStatus() { return getBoolean(KEY_AIRBAG_STATUS); } - public void setEmergencyEvent(Boolean emergencyEvent) { + public GetVehicleData setEmergencyEvent( Boolean emergencyEvent) { setParameters(KEY_EMERGENCY_EVENT, emergencyEvent); + return this; } public Boolean getEmergencyEvent() { return getBoolean(KEY_EMERGENCY_EVENT); } - public void setClusterModeStatus(Boolean clusterModeStatus) { + public GetVehicleData setClusterModeStatus( Boolean clusterModeStatus) { setParameters(KEY_CLUSTER_MODE_STATUS, clusterModeStatus); + return this; } public Boolean getClusterModeStatus() { return getBoolean(KEY_CLUSTER_MODE_STATUS); } - public void setMyKey(Boolean myKey) { + public GetVehicleData setMyKey( Boolean myKey) { setParameters(KEY_MY_KEY, myKey); + return this; } public Boolean getMyKey() { return getBoolean(KEY_MY_KEY); @@ -567,7 +594,10 @@ public class GetVehicleData extends RPCRequest { * Sets a boolean value. If true, subscribes turnSignal data * @param turnSignal a boolean value */ - public void setTurnSignal(Boolean turnSignal) { setParameters(KEY_TURN_SIGNAL, turnSignal); } + public GetVehicleData setTurnSignal( Boolean turnSignal) { + setParameters(KEY_TURN_SIGNAL, turnSignal); + return this; + } /** * Gets a boolean value. If true, means the turnSignal data has been subscribed. @@ -579,8 +609,9 @@ public class GetVehicleData extends RPCRequest { * Sets a boolean value. If true, subscribes electronicParkBrakeStatus data * @param electronicParkBrakeStatus a boolean value */ - public void setElectronicParkBrakeStatus(Boolean electronicParkBrakeStatus){ + public GetVehicleData setElectronicParkBrakeStatus( Boolean electronicParkBrakeStatus) { setParameters(KEY_ELECTRONIC_PARK_BRAKE_STATUS, electronicParkBrakeStatus); + return this; } /** @@ -595,8 +626,9 @@ public class GetVehicleData extends RPCRequest { * Sets a boolean value. If true, gets the cloudAppVehicleID data * @param cloudAppVehicleID a boolean value */ - public void setCloudAppVehicleID(boolean cloudAppVehicleID){ + public GetVehicleData setCloudAppVehicleID( boolean cloudAppVehicleID) { setParameters(KEY_CLOUD_APP_VEHICLE_ID, cloudAppVehicleID); + return this; } /** @@ -612,8 +644,9 @@ public class GetVehicleData extends RPCRequest { * @param vehicleDataName a String value * @param vehicleDataState a boolean value */ - public void setOEMCustomVehicleData(String vehicleDataName, Boolean vehicleDataState){ + public GetVehicleData setOEMCustomVehicleData( String vehicleDataName, Boolean vehicleDataState) { setParameters(vehicleDataName, vehicleDataState); + return this; } /** @@ -630,8 +663,9 @@ public class GetVehicleData extends RPCRequest { * @param windowStatus See WindowStatus * @since SmartDeviceLink 7.0.0 */ - public void setWindowStatus(Boolean windowStatus) { + public GetVehicleData setWindowStatus( Boolean windowStatus) { setParameters(KEY_WINDOW_STATUS, windowStatus); + return this; } /** @@ -650,8 +684,9 @@ public class GetVehicleData extends RPCRequest { * @param handsOffSteering To indicate whether driver hands are off the steering wheel * @since SmartDeviceLink 7.0.0 */ - public void setHandsOffSteering(Boolean handsOffSteering) { + public GetVehicleData setHandsOffSteering( Boolean handsOffSteering) { setParameters(KEY_HANDS_OFF_STEERING, handsOffSteering); + return this; } /** @@ -670,8 +705,9 @@ public class GetVehicleData extends RPCRequest { * @param gearStatus See GearStatus * @since SmartDeviceLink 7.0.0 */ - public void setGearStatus(Boolean gearStatus) { + public GetVehicleData setGearStatus( Boolean gearStatus) { setParameters(KEY_GEAR_STATUS, gearStatus); + return this; } /** @@ -690,8 +726,9 @@ public class GetVehicleData extends RPCRequest { * @param stabilityControlsStatus See StabilityControlsStatus * @since SmartDeviceLink 7.0.0 */ - public void setStabilityControlsStatus(Boolean stabilityControlsStatus) { + public GetVehicleData setStabilityControlsStatus( Boolean stabilityControlsStatus) { setParameters(KEY_STABILITY_CONTROLS_STATUS, stabilityControlsStatus); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleDataResponse.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleDataResponse.java index 2e7df80a9..fd1636edb 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleDataResponse.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleDataResponse.java @@ -117,22 +117,25 @@ public class GetVehicleDataResponse extends RPCResponse { setSuccess(success); setResultCode(resultCode); } - public void setGps(GPSData gps) { + public GetVehicleDataResponse setGps( GPSData gps) { setParameters(KEY_GPS, gps); + return this; } @SuppressWarnings("unchecked") public GPSData getGps() { return (GPSData) getObject(GPSData.class, KEY_GPS); } - public void setSpeed(Double speed) { + public GetVehicleDataResponse setSpeed( Double speed) { setParameters(KEY_SPEED, speed); + return this; } public Double getSpeed() { Object object = getParameters(KEY_SPEED); return SdlDataTypeConverter.objectToDouble(object); } - public void setRpm(Integer rpm) { + public GetVehicleDataResponse setRpm( Integer rpm) { setParameters(KEY_RPM, rpm); + return this; } public Integer getRpm() { return getInteger(KEY_RPM); @@ -143,8 +146,9 @@ public class GetVehicleDataResponse extends RPCResponse { * @param fuelLevelState a ComponentVolumeStatus related to FuelLevel State */ @Deprecated - public void setFuelLevelState(ComponentVolumeStatus fuelLevelState) { + public GetVehicleDataResponse setFuelLevelState( ComponentVolumeStatus fuelLevelState) { setParameters(KEY_FUEL_LEVEL_STATE, fuelLevelState); + return this; } /** * Gets Fuel Level State @@ -164,8 +168,9 @@ public class GetVehicleDataResponse extends RPCResponse { * @since SmartDeviceLink 7.0.0 */ @Deprecated - public void setFuelLevel(Double fuelLevel) { + public GetVehicleDataResponse setFuelLevel( Double fuelLevel) { setParameters(KEY_FUEL_LEVEL, fuelLevel); + return this; } /** @@ -180,22 +185,25 @@ public class GetVehicleDataResponse extends RPCResponse { Object object = getParameters(KEY_FUEL_LEVEL); return SdlDataTypeConverter.objectToDouble(object); } - public void setInstantFuelConsumption(Double instantFuelConsumption) { + public GetVehicleDataResponse setInstantFuelConsumption( Double instantFuelConsumption) { setParameters(KEY_INSTANT_FUEL_CONSUMPTION, instantFuelConsumption); + return this; } public Double getInstantFuelConsumption() { Object object = getParameters(KEY_INSTANT_FUEL_CONSUMPTION); return SdlDataTypeConverter.objectToDouble(object); } - public void setExternalTemperature(Double externalTemperature) { + public GetVehicleDataResponse setExternalTemperature( Double externalTemperature) { setParameters(KEY_EXTERNAL_TEMPERATURE, externalTemperature); + return this; } public Double getExternalTemperature() { Object object = getParameters(KEY_EXTERNAL_TEMPERATURE); return SdlDataTypeConverter.objectToDouble(object); } - public void setVin(String vin) { + public GetVehicleDataResponse setVin( String vin) { setParameters(KEY_VIN, vin); + return this; } public String getVin() { return getString(KEY_VIN); @@ -208,8 +216,9 @@ public class GetVehicleDataResponse extends RPCResponse { * @deprecated in SmartDeviceLink 7.0.0 */ @Deprecated - public void setPrndl(PRNDL prndl) { + public GetVehicleDataResponse setPrndl( PRNDL prndl) { setParameters(KEY_PRNDL, prndl); + return this; } /** @@ -222,123 +231,140 @@ public class GetVehicleDataResponse extends RPCResponse { public PRNDL getPrndl() { return (PRNDL) getObject(PRNDL.class, KEY_PRNDL); } - public void setTirePressure(TireStatus tirePressure) { + public GetVehicleDataResponse setTirePressure( TireStatus tirePressure) { setParameters(KEY_TIRE_PRESSURE, tirePressure); + return this; } @SuppressWarnings("unchecked") public TireStatus getTirePressure() { return (TireStatus) getObject(TireStatus.class, KEY_TIRE_PRESSURE); } - public void setOdometer(Integer odometer) { + public GetVehicleDataResponse setOdometer( Integer odometer) { setParameters(KEY_ODOMETER, odometer); + return this; } public Integer getOdometer() { return getInteger(KEY_ODOMETER); } - public void setBeltStatus(BeltStatus beltStatus) { + public GetVehicleDataResponse setBeltStatus( BeltStatus beltStatus) { setParameters(KEY_BELT_STATUS, beltStatus); + return this; } @SuppressWarnings("unchecked") public BeltStatus getBeltStatus() { return (BeltStatus) getObject(BeltStatus.class, KEY_BELT_STATUS); } - public void setBodyInformation(BodyInformation bodyInformation) { + public GetVehicleDataResponse setBodyInformation( BodyInformation bodyInformation) { setParameters(KEY_BODY_INFORMATION, bodyInformation); + return this; } @SuppressWarnings("unchecked") public BodyInformation getBodyInformation() { return (BodyInformation) getObject(BodyInformation.class, KEY_BODY_INFORMATION); } - public void setDeviceStatus(DeviceStatus deviceStatus) { + public GetVehicleDataResponse setDeviceStatus( DeviceStatus deviceStatus) { setParameters(KEY_DEVICE_STATUS, deviceStatus); + return this; } @SuppressWarnings("unchecked") public DeviceStatus getDeviceStatus() { return (DeviceStatus) getObject(DeviceStatus.class, KEY_DEVICE_STATUS); } - public void setDriverBraking(VehicleDataEventStatus driverBraking) { + public GetVehicleDataResponse setDriverBraking( VehicleDataEventStatus driverBraking) { setParameters(KEY_DRIVER_BRAKING, driverBraking); + return this; } public VehicleDataEventStatus getDriverBraking() { return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_DRIVER_BRAKING); } - public void setWiperStatus(WiperStatus wiperStatus) { + public GetVehicleDataResponse setWiperStatus( WiperStatus wiperStatus) { setParameters(KEY_WIPER_STATUS, wiperStatus); + return this; } public WiperStatus getWiperStatus() { return (WiperStatus) getObject(WiperStatus.class, KEY_WIPER_STATUS); } - public void setHeadLampStatus(HeadLampStatus headLampStatus) { + public GetVehicleDataResponse setHeadLampStatus( HeadLampStatus headLampStatus) { setParameters(KEY_HEAD_LAMP_STATUS, headLampStatus); + return this; } @SuppressWarnings("unchecked") public HeadLampStatus getHeadLampStatus() { return (HeadLampStatus) getObject(HeadLampStatus.class, KEY_HEAD_LAMP_STATUS); } - public void setEngineTorque(Double engineTorque) { + public GetVehicleDataResponse setEngineTorque( Double engineTorque) { setParameters(KEY_ENGINE_TORQUE, engineTorque); + return this; } public Double getEngineTorque() { Object object = getParameters(KEY_ENGINE_TORQUE); return SdlDataTypeConverter.objectToDouble(object); } - public void setEngineOilLife(Float engineOilLife) { + public GetVehicleDataResponse setEngineOilLife( Float engineOilLife) { setParameters(KEY_ENGINE_OIL_LIFE, engineOilLife); + return this; } public Float getEngineOilLife() { Object object = getParameters(KEY_ENGINE_OIL_LIFE); return SdlDataTypeConverter.objectToFloat(object); } - public void setAccPedalPosition(Double accPedalPosition) { + public GetVehicleDataResponse setAccPedalPosition( Double accPedalPosition) { setParameters(KEY_ACC_PEDAL_POSITION, accPedalPosition); + return this; } public Double getAccPedalPosition() { Object object = getParameters(KEY_ACC_PEDAL_POSITION); return SdlDataTypeConverter.objectToDouble(object); } - public void setSteeringWheelAngle(Double steeringWheelAngle) { + public GetVehicleDataResponse setSteeringWheelAngle( Double steeringWheelAngle) { setParameters(KEY_STEERING_WHEEL_ANGLE, steeringWheelAngle); + return this; } public Double getSteeringWheelAngle() { Object object = getParameters(KEY_STEERING_WHEEL_ANGLE); return SdlDataTypeConverter.objectToDouble(object); } - public void setECallInfo(ECallInfo eCallInfo) { + public GetVehicleDataResponse setECallInfo( ECallInfo eCallInfo) { setParameters(KEY_E_CALL_INFO, eCallInfo); + return this; } @SuppressWarnings("unchecked") public ECallInfo getECallInfo() { return (ECallInfo) getObject(ECallInfo.class, KEY_E_CALL_INFO); } - public void setAirbagStatus(AirbagStatus airbagStatus) { + public GetVehicleDataResponse setAirbagStatus( AirbagStatus airbagStatus) { setParameters(KEY_AIRBAG_STATUS, airbagStatus); + return this; } @SuppressWarnings("unchecked") public AirbagStatus getAirbagStatus() { return (AirbagStatus) getObject(AirbagStatus.class, KEY_AIRBAG_STATUS); } - public void setEmergencyEvent(EmergencyEvent emergencyEvent) { + public GetVehicleDataResponse setEmergencyEvent( EmergencyEvent emergencyEvent) { setParameters(KEY_EMERGENCY_EVENT, emergencyEvent); + return this; } @SuppressWarnings("unchecked") public EmergencyEvent getEmergencyEvent() { return (EmergencyEvent) getObject(EmergencyEvent.class, KEY_EMERGENCY_EVENT); } - public void setClusterModeStatus(ClusterModeStatus clusterModeStatus) { + public GetVehicleDataResponse setClusterModeStatus( ClusterModeStatus clusterModeStatus) { setParameters(KEY_CLUSTER_MODE_STATUS, clusterModeStatus); + return this; } @SuppressWarnings("unchecked") public ClusterModeStatus getClusterModeStatus() { return (ClusterModeStatus) getObject(ClusterModeStatus.class, KEY_CLUSTER_MODE_STATUS); } - public void setMyKey(MyKey myKey) { + public GetVehicleDataResponse setMyKey( MyKey myKey) { setParameters(KEY_MY_KEY, myKey); + return this; } @SuppressWarnings("unchecked") public MyKey getMyKey() { @@ -349,11 +375,12 @@ public class GetVehicleDataResponse extends RPCResponse { * Sets Fuel Range List. Fuel Range - The estimate range in KM the vehicle can travel based on fuel level and consumption. * @param fuelRange the range in KM left as well as fuel type * - * @see com.smartdevicelink.proxy.rpc.FuelRange + * @see FuelRange * @see com.smartdevicelink.proxy.rpc.enums.FuelType */ - public void setFuelRange(List fuelRange) { + public GetVehicleDataResponse setFuelRange( List fuelRange) { setParameters(KEY_FUEL_RANGE, fuelRange); + return this; } /** @@ -370,10 +397,11 @@ public class GetVehicleDataResponse extends RPCResponse { * Sets turnSignal * @param turnSignal status of the turn signals * - * @see com.smartdevicelink.proxy.rpc.enums.TurnSignal + * @see TurnSignal */ - public void setTurnSignal(TurnSignal turnSignal) { + public GetVehicleDataResponse setTurnSignal( TurnSignal turnSignal) { setParameters(KEY_TURN_SIGNAL, turnSignal); + return this; } /** @@ -391,10 +419,11 @@ public class GetVehicleDataResponse extends RPCResponse { * Sets electronicParkBrakeStatus * @param electronicParkBrakeStatus status of the electronic park brake of the connected vehicle * - * @see com.smartdevicelink.proxy.rpc.enums.ElectronicParkBrakeStatus + * @see ElectronicParkBrakeStatus */ - public void setElectronicParkBrakeStatus(ElectronicParkBrakeStatus electronicParkBrakeStatus){ + public GetVehicleDataResponse setElectronicParkBrakeStatus( ElectronicParkBrakeStatus electronicParkBrakeStatus) { setParameters(KEY_ELECTRONIC_PARK_BRAKE_STATUS, electronicParkBrakeStatus); + return this; } /** @@ -411,8 +440,9 @@ public class GetVehicleDataResponse extends RPCResponse { * Sets a string value for the cloud app vehicle ID * @param cloudAppVehicleID a string value */ - public void setCloudAppVehicleID(String cloudAppVehicleID){ + public GetVehicleDataResponse setCloudAppVehicleID( String cloudAppVehicleID) { setParameters(KEY_CLOUD_APP_VEHICLE_ID, cloudAppVehicleID); + return this; } /** @@ -429,8 +459,9 @@ public class GetVehicleDataResponse extends RPCResponse { * @param vehicleDataName a String value * @param vehicleDataState a VehicleDataResult value */ - public void setOEMCustomVehicleData(String vehicleDataName, Object vehicleDataState){ + public GetVehicleDataResponse setOEMCustomVehicleData( String vehicleDataName, Object vehicleDataState) { setParameters(vehicleDataName, vehicleDataState); + return this; } /** @@ -447,8 +478,9 @@ public class GetVehicleDataResponse extends RPCResponse { * @param windowStatus See WindowStatus * @since SmartDeviceLink 7.0.0 */ - public void setWindowStatus(List windowStatus) { + public GetVehicleDataResponse setWindowStatus( List windowStatus) { setParameters(KEY_WINDOW_STATUS, windowStatus); + return this; } /** @@ -468,8 +500,9 @@ public class GetVehicleDataResponse extends RPCResponse { * @param handsOffSteering To indicate whether driver hands are off the steering wheel * @since SmartDeviceLink 7.0.0 */ - public void setHandsOffSteering(Boolean handsOffSteering) { + public GetVehicleDataResponse setHandsOffSteering( Boolean handsOffSteering) { setParameters(KEY_HANDS_OFF_STEERING, handsOffSteering); + return this; } /** @@ -488,8 +521,9 @@ public class GetVehicleDataResponse extends RPCResponse { * @param gearStatus See GearStatus * @since SmartDeviceLink 7.0.0 */ - public void setGearStatus(GearStatus gearStatus) { + public GetVehicleDataResponse setGearStatus( GearStatus gearStatus) { setParameters(KEY_GEAR_STATUS, gearStatus); + return this; } /** @@ -518,7 +552,8 @@ public class GetVehicleDataResponse extends RPCResponse { * @param stabilityControlsStatus See StabilityControlsStatus * @since SmartDeviceLink 7.0.0 */ - public void setStabilityControlsStatus(StabilityControlsStatus stabilityControlsStatus) { + public GetVehicleDataResponse setStabilityControlsStatus( StabilityControlsStatus stabilityControlsStatus) { setParameters(KEY_STABILITY_CONTROLS_STATUS, stabilityControlsStatus); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetWayPoints.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetWayPoints.java index 2146e3933..6ad9518e9 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetWayPoints.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetWayPoints.java @@ -59,7 +59,8 @@ public class GetWayPoints extends RPCRequest { return (WayPointType) getObject(WayPointType.class, KEY_WAY_POINT_TYPE); } - public void setWayPointType(@NonNull WayPointType wayPointType) { + public GetWayPoints setWayPointType(@NonNull WayPointType wayPointType) { setParameters(KEY_WAY_POINT_TYPE, wayPointType); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetWayPointsResponse.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetWayPointsResponse.java index 7a4924dea..cb7b99be3 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetWayPointsResponse.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetWayPointsResponse.java @@ -59,8 +59,9 @@ public class GetWayPointsResponse extends RPCResponse { setSuccess(success); setResultCode(resultCode); } - public void setWayPoints(List wayPoints) { - setParameters(KEY_WAY_POINTS, wayPoints); + public GetWayPointsResponse setWayPoints( List wayPoints) { + setParameters(KEY_WAY_POINTS, wayPoints); + return this; } @SuppressWarnings("unchecked") public List getWayPoints() { diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/Grid.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/Grid.java index e0c93369d..861c1a433 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/Grid.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/Grid.java @@ -39,8 +39,9 @@ public class Grid extends RPCStruct { * Sets the column of this Grid * @param col the column to be set */ - public void setCol(@NonNull Integer col) { + public Grid setCol(@NonNull Integer col) { setValue(KEY_COL, col); + return this; } /** @@ -55,8 +56,9 @@ public class Grid extends RPCStruct { * Sets the row's value of this Grid * @param row the row to be set */ - public void setRow(@NonNull Integer row) { + public Grid setRow(@NonNull Integer row) { setValue(KEY_ROW, row); + return this; } /** @@ -71,8 +73,9 @@ public class Grid extends RPCStruct { * Sets the level value of this Grid * @param level the level to be set */ - public void setLevel(Integer level) { + public Grid setLevel( Integer level) { setValue(KEY_LEVEL, level); + return this; } /** @@ -87,8 +90,9 @@ public class Grid extends RPCStruct { * Sets the column span of this Grid * @param span the span to be set */ - public void setColSpan(Integer span) { + public Grid setColSpan( Integer span) { setValue(KEY_COL_SPAN, span); + return this; } /** @@ -103,8 +107,9 @@ public class Grid extends RPCStruct { * Sets the row span of this Grid * @param span the span to be set */ - public void setRowSpan(Integer span) { + public Grid setRowSpan( Integer span) { setValue(KEY_ROW_SPAN, span); + return this; } /** @@ -119,8 +124,9 @@ public class Grid extends RPCStruct { * Sets the level span of this Grid * @param span the span to be set */ - public void setLevelSpan(Integer span) { + public Grid setLevelSpan( Integer span) { setValue(KEY_LEVEL_SPAN, span); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/HMICapabilities.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/HMICapabilities.java index f1b3c4821..0762b42ed 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/HMICapabilities.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/HMICapabilities.java @@ -59,9 +59,10 @@ public class HMICapabilities extends RPCStruct{ return (Boolean)available; } - public void setNavigationAvilable(Boolean available){ - setValue(KEY_NAVIGATION, available); - } + public HMICapabilities setNavigationAvilable( Boolean available) { + setValue(KEY_NAVIGATION, available); + return this; + } public boolean isPhoneCallAvailable(){ Object available = getValue(KEY_PHONE_CALL); @@ -71,9 +72,10 @@ public class HMICapabilities extends RPCStruct{ return (Boolean)available; } - public void setPhoneCallAvilable(Boolean available){ - setValue(KEY_PHONE_CALL, available); - } + public HMICapabilities setPhoneCallAvilable( Boolean available) { + setValue(KEY_PHONE_CALL, available); + return this; + } public boolean isVideoStreamingAvailable(){ Object available = getValue(KEY_VIDEO_STREAMING); @@ -83,9 +85,10 @@ public class HMICapabilities extends RPCStruct{ return (Boolean)available; } - public void setVideoStreamingAvailable(Boolean available){ - setValue(KEY_VIDEO_STREAMING, available); - } + public HMICapabilities setVideoStreamingAvailable( Boolean available) { + setValue(KEY_VIDEO_STREAMING, available); + return this; + } public boolean isRemoteControlAvailable(){ Object available = getValue(KEY_REMOTE_CONTROL); @@ -95,9 +98,10 @@ public class HMICapabilities extends RPCStruct{ return (Boolean)available; } - public void setRemoteControlAvailable(Boolean available){ - setValue(KEY_REMOTE_CONTROL, available); - } + public HMICapabilities setRemoteControlAvailable( Boolean available) { + setValue(KEY_REMOTE_CONTROL, available); + return this; + } public boolean isAppServicesAvailable(){ Object available = getValue(KEY_APP_SERVICES); @@ -107,9 +111,10 @@ public class HMICapabilities extends RPCStruct{ return (Boolean)available; } - public void setAppServicesAvailable(Boolean available){ - setValue(KEY_APP_SERVICES, available); - } + public HMICapabilities setAppServicesAvailable( Boolean available) { + setValue(KEY_APP_SERVICES, available); + return this; + } public boolean isDisplaysCapabilityAvailable(){ Object available = getValue(KEY_DISPLAYS); @@ -119,9 +124,10 @@ public class HMICapabilities extends RPCStruct{ return (Boolean)available; } - public void setDisplaysCapabilityAvailable(Boolean available){ - setValue(KEY_DISPLAYS, available); - } + public HMICapabilities setDisplaysCapabilityAvailable( Boolean available) { + setValue(KEY_DISPLAYS, available); + return this; + } public boolean isSeatLocationAvailable(){ Object available = getValue(KEY_SEAT_LOCATION); @@ -131,9 +137,10 @@ public class HMICapabilities extends RPCStruct{ return (Boolean)available; } - public void setSeatLocationAvailable(Boolean available){ - setValue(KEY_SEAT_LOCATION, available); - } + public HMICapabilities setSeatLocationAvailable( Boolean available) { + setValue(KEY_SEAT_LOCATION, available); + return this; + } /** * Sets the driverDistraction. @@ -141,8 +148,9 @@ public class HMICapabilities extends RPCStruct{ * @param driverDistraction Availability of driver distraction capability. True: Available, False: Not Available * @since SmartDeviceLink 7.0.0 */ - public void setDriverDistraction(Boolean driverDistraction) { + public HMICapabilities setDriverDistraction( Boolean driverDistraction) { setValue(KEY_DRIVER_DISTRACTION, driverDistraction); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/HMIPermissions.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/HMIPermissions.java index 68a84d451..5d5237b12 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/HMIPermissions.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/HMIPermissions.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -112,8 +112,9 @@ public class HMIPermissions extends RPCStruct { * set HMI level that is permitted for this given RPC. * @param allowed HMI level that is permitted for this given RPC */ - public void setAllowed(@NonNull List allowed) { - setValue(KEY_ALLOWED, allowed); + public HMIPermissions setAllowed(@NonNull List allowed) { + setValue(KEY_ALLOWED, allowed); + return this; } /** @@ -129,7 +130,8 @@ public class HMIPermissions extends RPCStruct { * set a set of all HMI levels that are prohibited for this given RPC * @param userDisallowed HMI level that is prohibited for this given RPC */ - public void setUserDisallowed(@NonNull List userDisallowed) { - setValue(KEY_USER_DISALLOWED, userDisallowed); + public HMIPermissions setUserDisallowed(@NonNull List userDisallowed) { + setValue(KEY_USER_DISALLOWED, userDisallowed); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/HMISettingsControlCapabilities.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/HMISettingsControlCapabilities.java index d62b646ba..36ef9c12c 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/HMISettingsControlCapabilities.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/HMISettingsControlCapabilities.java @@ -70,9 +70,10 @@ public class HMISettingsControlCapabilities extends RPCStruct { * * @param moduleName The short friendly name of the hmi setting module. It should not be used to identify a module by mobile application. */ - public void setModuleName(@NonNull String moduleName) { - setValue(KEY_MODULE_NAME, moduleName); - } + public HMISettingsControlCapabilities setModuleName(@NonNull String moduleName) { + setValue(KEY_MODULE_NAME, moduleName); + return this; + } /** * Gets the moduleName portion of the HMISettingsControlCapabilities class @@ -88,9 +89,10 @@ public class HMISettingsControlCapabilities extends RPCStruct { * * @param distanceUnitAvailable Availability of the control of distance unit. */ - public void setDistanceUnitAvailable(Boolean distanceUnitAvailable) { - setValue(KEY_DISTANCE_UNIT_AVAILABLE, distanceUnitAvailable); - } + public HMISettingsControlCapabilities setDistanceUnitAvailable( Boolean distanceUnitAvailable) { + setValue(KEY_DISTANCE_UNIT_AVAILABLE, distanceUnitAvailable); + return this; + } /** * Gets the distanceUnitAvailable portion of the HMISettingsControlCapabilities class @@ -106,9 +108,10 @@ public class HMISettingsControlCapabilities extends RPCStruct { * * @param temperatureUnitAvailable Availability of the control of temperature unit. */ - public void setTemperatureUnitAvailable(Boolean temperatureUnitAvailable) { - setValue(KEY_TEMPERATURE_UNIT_AVAILABLE, temperatureUnitAvailable); - } + public HMISettingsControlCapabilities setTemperatureUnitAvailable( Boolean temperatureUnitAvailable) { + setValue(KEY_TEMPERATURE_UNIT_AVAILABLE, temperatureUnitAvailable); + return this; + } /** * Gets the temperatureUnitAvailable portion of the HMISettingsControlCapabilities class @@ -124,9 +127,10 @@ public class HMISettingsControlCapabilities extends RPCStruct { * * @param displayModeUnitAvailable Availability of the control of HMI display mode. */ - public void setDisplayModeUnitAvailable(Boolean displayModeUnitAvailable) { - setValue(KEY_DISPLAY_MODE_UNIT_AVAILABLE, displayModeUnitAvailable); - } + public HMISettingsControlCapabilities setDisplayModeUnitAvailable( Boolean displayModeUnitAvailable) { + setValue(KEY_DISPLAY_MODE_UNIT_AVAILABLE, displayModeUnitAvailable); + return this; + } /** * Gets the displayModeUnitAvailable portion of the HMISettingsControlCapabilities class @@ -141,9 +145,10 @@ public class HMISettingsControlCapabilities extends RPCStruct { * Sets ModuleInfo for this capability * @param info the ModuleInfo to be set */ - public void setModuleInfo(ModuleInfo info) { - setValue(KEY_MODULE_INFO, info); - } + public HMISettingsControlCapabilities setModuleInfo( ModuleInfo info) { + setValue(KEY_MODULE_INFO, info); + return this; + } /** * Gets a ModuleInfo of this capability diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/HMISettingsControlData.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/HMISettingsControlData.java index 6030e712a..05dda0de2 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/HMISettingsControlData.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/HMISettingsControlData.java @@ -59,11 +59,12 @@ public class HMISettingsControlData extends RPCStruct { * * @param displayMode the display mode (DAY, NIGHT, AUTO) of screen on the respective module * - * @see com.smartdevicelink.proxy.rpc.enums.DisplayMode + * @see DisplayMode */ - public void setDisplayMode(DisplayMode displayMode) { - setValue(KEY_DISPLAY_MODE, displayMode); - } + public HMISettingsControlData setDisplayMode( DisplayMode displayMode) { + setValue(KEY_DISPLAY_MODE, displayMode); + return this; + } /** * Gets the displayMode portion of the HMISettingsControlData class @@ -81,11 +82,12 @@ public class HMISettingsControlData extends RPCStruct { * * @param temperatureUnit enum value of temperature unit associated with the display of the current module * - * @see com.smartdevicelink.proxy.rpc.enums.TemperatureUnit + * @see TemperatureUnit */ - public void setTemperatureUnit(TemperatureUnit temperatureUnit) { - setValue(KEY_TEMPERATURE_UNIT, temperatureUnit); - } + public HMISettingsControlData setTemperatureUnit( TemperatureUnit temperatureUnit) { + setValue(KEY_TEMPERATURE_UNIT, temperatureUnit); + return this; + } /** * Gets the temperatureUnit portion of the HMISettingsControlData class @@ -103,11 +105,12 @@ public class HMISettingsControlData extends RPCStruct { * * @param distanceUnit enum value of distance unit associated with the display of the current module * - * @see com.smartdevicelink.proxy.rpc.enums.DistanceUnit + * @see DistanceUnit */ - public void setDistanceUnit(DistanceUnit distanceUnit) { - setValue(KEY_DISTANCE_UNIT, distanceUnit); - } + public HMISettingsControlData setDistanceUnit( DistanceUnit distanceUnit) { + setValue(KEY_DISTANCE_UNIT, distanceUnit); + return this; + } /** * Gets the distanceUnit portion of the HMISettingsControlData class diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/HapticRect.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/HapticRect.java index c4458e547..a50c2d37b 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/HapticRect.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/HapticRect.java @@ -62,9 +62,10 @@ public class HapticRect extends RPCStruct { /** * Set a user control spatial identifier that references the supplied spatial data */ - public void setId(@NonNull Integer id) { - setValue(KEY_ID, id); - } + public HapticRect setId(@NonNull Integer id) { + setValue(KEY_ID, id); + return this; + } /** * @return a user control spatial identifier that references the supplied spatial data @@ -76,9 +77,10 @@ public class HapticRect extends RPCStruct { /** * Set the position of the haptic rectangle to be highlighted. The center of this rectangle will be "touched" when a press occurs. */ - public void setRect(@NonNull Rectangle rect) { - setValue(KEY_RECT, rect); - } + public HapticRect setRect(@NonNull Rectangle rect) { + setValue(KEY_RECT, rect); + return this; + } /** * @return the position of the haptic rectangle to be highlighted. The center of this rectangle will be "touched" when a press occurs. diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/HeadLampStatus.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/HeadLampStatus.java index abd0f10e0..693219fe0 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/HeadLampStatus.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/HeadLampStatus.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -98,20 +98,23 @@ public class HeadLampStatus extends RPCStruct { setLowBeamsOn(lowBeamsOn); setHighBeamsOn(highBeamsOn); } - public void setAmbientLightStatus(AmbientLightStatus ambientLightSensorStatus) { + public HeadLampStatus setAmbientLightStatus( AmbientLightStatus ambientLightSensorStatus) { setValue(KEY_AMBIENT_LIGHT_SENSOR_STATUS, ambientLightSensorStatus); + return this; } public AmbientLightStatus getAmbientLightStatus() { return (AmbientLightStatus) getObject(AmbientLightStatus.class, KEY_AMBIENT_LIGHT_SENSOR_STATUS); } - public void setHighBeamsOn(@NonNull Boolean highBeamsOn) { + public HeadLampStatus setHighBeamsOn(@NonNull Boolean highBeamsOn) { setValue(KEY_HIGH_BEAMS_ON, highBeamsOn); + return this; } public Boolean getHighBeamsOn() { return getBoolean(KEY_HIGH_BEAMS_ON); } - public void setLowBeamsOn(@NonNull Boolean lowBeamsOn) { + public HeadLampStatus setLowBeamsOn(@NonNull Boolean lowBeamsOn) { setValue(KEY_LOW_BEAMS_ON, lowBeamsOn); + return this; } public Boolean getLowBeamsOn() { return getBoolean(KEY_LOW_BEAMS_ON); diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/Headers.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/Headers.java index 845f4649f..6226dc991 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/Headers.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/Headers.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import com.smartdevicelink.proxy.RPCStruct; @@ -67,48 +67,54 @@ public class Headers extends RPCStruct { super(hash); } - public void setContentType(String contenttype) { + public Headers setContentType( String contenttype) { setValue(KEY_CONTENT_TYPE, contenttype); + return this; } public String getContentType() { return getString(KEY_CONTENT_TYPE); } - public void setConnectTimeout(Integer connectiontimeout) { + public Headers setConnectTimeout( Integer connectiontimeout) { setValue(KEY_CONNECT_TIMEOUT, connectiontimeout); + return this; } public Integer getConnectTimeout() { return getInteger(KEY_CONNECT_TIMEOUT); } - public void setDoOutput(Boolean dooutput) { + public Headers setDoOutput( Boolean dooutput) { setValue(KEY_DO_OUTPUT, dooutput); + return this; } public Boolean getDoOutput() { return getBoolean(KEY_DO_OUTPUT); } - public void setDoInput(Boolean doinput) { + public Headers setDoInput( Boolean doinput) { setValue(KEY_DO_INPUT, doinput); + return this; } public Boolean getDoInput() { return getBoolean(KEY_DO_INPUT); } - public void setUseCaches(Boolean usescaches) { + public Headers setUseCaches( Boolean usescaches) { setValue(KEY_USE_CACHES, usescaches); + return this; } public Boolean getUseCaches() { return getBoolean(KEY_USE_CACHES); } - public void setRequestMethod(String requestmethod) { + public Headers setRequestMethod( String requestmethod) { setValue(KEY_REQUEST_METHOD, requestmethod); + return this; } public String getRequestMethod() { @@ -116,32 +122,36 @@ public class Headers extends RPCStruct { } - public void setReadTimeout(Integer readtimeout) { + public Headers setReadTimeout( Integer readtimeout) { setValue(KEY_READ_TIMEOUT, readtimeout); + return this; } public Integer getReadTimeout() { return getInteger(KEY_READ_TIMEOUT); } - public void setInstanceFollowRedirects(Boolean instancefollowredirects) { + public Headers setInstanceFollowRedirects( Boolean instancefollowredirects) { setValue(KEY_INSTANCE_FOLLOW_REDIRECTS, instancefollowredirects); + return this; } public Boolean getInstanceFollowRedirects() { return getBoolean(KEY_INSTANCE_FOLLOW_REDIRECTS); } - public void setCharset(String charset) { + public Headers setCharset( String charset) { setValue(KEY_CHARSET, charset); + return this; } public String getCharset() { return getString(KEY_CHARSET); } - public void setContentLength(Integer contentlength) { + public Headers setContentLength( Integer contentlength) { setValue(KEY_CONTENT_LENGTH, contentlength); + return this; } public Integer getContentLength() { diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/Image.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/Image.java index ba9f25f5c..1d5b57e26 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/Image.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/Image.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -101,8 +101,9 @@ public class Image extends RPCStruct { * Set either the static hex icon value or the binary image file name identifier (sent by PutFile) * @param value either the static hex icon value or the binary image file name identifier (sent by PutFile) */ - public void setValue(@NonNull String value) { + public Image setValue(@NonNull String value) { setValue(KEY_VALUE, value); + return this; } /** @@ -117,8 +118,9 @@ public class Image extends RPCStruct { * Set the image type (static or dynamic image) * @param imageType whether it is a static or dynamic image */ - public void setImageType(@NonNull ImageType imageType) { + public Image setImageType(@NonNull ImageType imageType) { setValue(KEY_IMAGE_TYPE, imageType); + return this; } /** @@ -133,8 +135,9 @@ public class Image extends RPCStruct { * Set whether this Image is a template image whose coloring should be decided by the HMI * @param isTemplate boolean that tells whether this Image is a template image */ - public void setIsTemplate(Boolean isTemplate){ + public Image setIsTemplate( Boolean isTemplate) { setValue(KEY_IS_TEMPLATE, isTemplate); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/ImageField.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/ImageField.java index de052a6f7..0e4748072 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/ImageField.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/ImageField.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -108,21 +108,24 @@ public class ImageField extends RPCStruct { public ImageFieldName getName() { return (ImageFieldName) getObject(ImageFieldName.class, KEY_NAME); } - public void setName(@NonNull ImageFieldName name ) { + public ImageField setName(@NonNull ImageFieldName name) { setValue(KEY_NAME, name); - } + return this; + } @SuppressWarnings("unchecked") public List getImageTypeSupported() { return (List) getObject(FileType.class, KEY_IMAGE_TYPE_SUPPORTED); } - public void setImageTypeSupported(@NonNull List imageTypeSupported ) { + public ImageField setImageTypeSupported(@NonNull List imageTypeSupported) { setValue(KEY_IMAGE_TYPE_SUPPORTED, imageTypeSupported); + return this; } @SuppressWarnings("unchecked") public ImageResolution getImageResolution() { return (ImageResolution) getObject(ImageResolution.class, KEY_IMAGE_RESOLUTION); } - public void setImageResolution( ImageResolution imageResolution ) { + public ImageField setImageResolution( ImageResolution imageResolution) { setValue(KEY_IMAGE_RESOLUTION, imageResolution); - } + return this; + } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/ImageResolution.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/ImageResolution.java index 66841c773..151075bab 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/ImageResolution.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/ImageResolution.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -101,11 +101,12 @@ public class ImageResolution extends RPCStruct { * the Android H264 decoder, as a workaround the odd value is * converted to a pair value. */ - public void setResolutionWidth(@NonNull Integer resolutionWidth) { - if(resolutionWidth != null && resolutionWidth % 2 != 0) { - resolutionWidth++; - } + public ImageResolution setResolutionWidth(@NonNull Integer resolutionWidth) { + if(resolutionWidth != null && resolutionWidth % 2 != 0) { + resolutionWidth++; + } setValue(KEY_RESOLUTION_WIDTH, resolutionWidth); + return this; } public Integer getResolutionWidth() { @@ -117,11 +118,12 @@ public class ImageResolution extends RPCStruct { * the Android H264 decoder, as a workaround the odd value is * converted to a pair value. */ - public void setResolutionHeight(@NonNull Integer resolutionHeight) { - if(resolutionHeight != null && resolutionHeight % 2 != 0) { - resolutionHeight++; - } + public ImageResolution setResolutionHeight(@NonNull Integer resolutionHeight) { + if(resolutionHeight != null && resolutionHeight % 2 != 0) { + resolutionHeight++; + } setValue(KEY_RESOLUTION_HEIGHT, resolutionHeight); + return this; } public Integer getResolutionHeight() { diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/KeyboardProperties.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/KeyboardProperties.java index cd721fec8..3687cd05e 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/KeyboardProperties.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/KeyboardProperties.java @@ -131,16 +131,18 @@ public class KeyboardProperties extends RPCStruct { return (Language) getObject(Language.class, KEY_LANGUAGE); } - public void setLanguage(Language language) { + public KeyboardProperties setLanguage( Language language) { setValue(KEY_LANGUAGE, language); + return this; } public KeyboardLayout getKeyboardLayout() { return (KeyboardLayout) getObject(KeyboardLayout.class, KEY_KEYBOARD_LAYOUT); } - public void setKeyboardLayout(KeyboardLayout keyboardLayout) { + public KeyboardProperties setKeyboardLayout( KeyboardLayout keyboardLayout) { setValue(KEY_KEYBOARD_LAYOUT, keyboardLayout); + return this; } public KeypressMode getKeypressMode() { @@ -151,12 +153,13 @@ public class KeyboardProperties extends RPCStruct { return kp; } - public void setKeypressMode(KeypressMode keypressMode) { + public KeyboardProperties setKeypressMode( KeypressMode keypressMode) { if (keypressMode != null) { setValue(KEY_KEYPRESS_MODE, keypressMode); } else { setValue(KEY_KEYPRESS_MODE, KEYPRESS_MODE_DEFAULT); } + return this; } @SuppressWarnings("unchecked") @@ -164,8 +167,9 @@ public class KeyboardProperties extends RPCStruct { return (List) getObject(String.class, KEY_LIMITED_CHARACTER_LIST); } - public void setLimitedCharacterList(List limitedCharacterList) { + public KeyboardProperties setLimitedCharacterList( List limitedCharacterList) { setValue(KEY_LIMITED_CHARACTER_LIST, limitedCharacterList); + return this; } /** @@ -180,11 +184,11 @@ public class KeyboardProperties extends RPCStruct { /** * Sets the text that allows an app to prepopulate the text field with a suggested entry as the user types * @param autoCompleteText String representing the suggestions text - * @deprecated use {@link #setAutoCompleteList(List)} instead + * @deprecated use {@link #setAutoCompleteList( List )} instead */ - @Deprecated // Note: removing autoCompleteText setter will leave no way to provide auto complete suggestions on old head units that don't support autoCompleteList - public void setAutoCompleteText(String autoCompleteText) { + @Deprecated public KeyboardProperties setAutoCompleteText( String autoCompleteText) { setValue(KEY_AUTO_COMPLETE_TEXT, autoCompleteText); + return this; } /** @@ -201,7 +205,8 @@ public class KeyboardProperties extends RPCStruct { * completed entries as the user types. Set to an empty array to remove the auto-complete list from the screen * @param autoCompleteList List representing the suggestions list */ - public void setAutoCompleteList(List autoCompleteList) { + public KeyboardProperties setAutoCompleteList( List autoCompleteList) { setValue(KEY_AUTO_COMPLETE_LIST, autoCompleteList); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/LightCapabilities.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/LightCapabilities.java index 6ecfca5c6..365e71543 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/LightCapabilities.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/LightCapabilities.java @@ -75,11 +75,12 @@ public class LightCapabilities extends RPCStruct { * * @param name enum value of type LightName that describes the specific light * - * @see com.smartdevicelink.proxy.rpc.enums.LightName + * @see LightName */ - public void setName(@NonNull LightName name) { - setValue(KEY_NAME, name); - } + public LightCapabilities setName(@NonNull LightName name) { + setValue(KEY_NAME, name); + return this; + } /** * Gets the name portion of the LightCapabilities class @@ -97,9 +98,10 @@ public class LightCapabilities extends RPCStruct { * * @param densityAvailable Indicates if the light's density can be set remotely (similar to a dimmer). */ - public void setDensityAvailable(Boolean densityAvailable) { - setValue(KEY_DENSITY_AVAILABLE, densityAvailable); - } + public LightCapabilities setDensityAvailable( Boolean densityAvailable) { + setValue(KEY_DENSITY_AVAILABLE, densityAvailable); + return this; + } /** * Gets the densityAvailable portion of the LightCapabilities class @@ -115,9 +117,10 @@ public class LightCapabilities extends RPCStruct { * * @param RGBColorSpaceAvailable Indicates if the light's color can be set remotely by using the RGB color space. */ - public void setRGBColorSpaceAvailable(Boolean RGBColorSpaceAvailable) { - setValue(KEY_RGB_COLOR_SPACE_AVAILABLE, RGBColorSpaceAvailable); - } + public LightCapabilities setRGBColorSpaceAvailable( Boolean RGBColorSpaceAvailable) { + setValue(KEY_RGB_COLOR_SPACE_AVAILABLE, RGBColorSpaceAvailable); + return this; + } /** * Gets the RGBColorSpaceAvailable portion of the LightCapabilities class @@ -133,9 +136,10 @@ public class LightCapabilities extends RPCStruct { * * @param statusAvailable Indicates if the status (ON/OFF) can be set remotely. App shall not use read-only values (RAMP_UP/RAMP_DOWN/UNKNOWN/INVALID) in a setInteriorVehicleData request. */ - public void setStatusAvailable(Boolean statusAvailable) { - setValue(KEY_STATUS_AVAILABLE, statusAvailable); - } + public LightCapabilities setStatusAvailable( Boolean statusAvailable) { + setValue(KEY_STATUS_AVAILABLE, statusAvailable); + return this; + } /** * Gets the statusAvailable portion of the LightCapabilities class diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/LightControlCapabilities.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/LightControlCapabilities.java index 3cc66e67e..979b0a0cf 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/LightControlCapabilities.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/LightControlCapabilities.java @@ -76,9 +76,10 @@ public class LightControlCapabilities extends RPCStruct { * * @param moduleName The short friendly name of the light control module. It should not be used to identify a module by mobile application. */ - public void setModuleName(@NonNull String moduleName) { - setValue(KEY_MODULE_NAME, moduleName); - } + public LightControlCapabilities setModuleName(@NonNull String moduleName) { + setValue(KEY_MODULE_NAME, moduleName); + return this; + } /** * Gets the moduleName portion of the LightControlCapabilities class @@ -104,17 +105,19 @@ public class LightControlCapabilities extends RPCStruct { * * @param supportedLights An array of available LightCapabilities that are controllable. */ - public void setSupportedLights(@NonNull List supportedLights) { - setValue(KEY_SUPPORTED_LIGHTS, supportedLights); - } + public LightControlCapabilities setSupportedLights(@NonNull List supportedLights) { + setValue(KEY_SUPPORTED_LIGHTS, supportedLights); + return this; + } /** * Sets ModuleInfo for this capability * @param info the ModuleInfo to be set */ - public void setModuleInfo(ModuleInfo info) { - setValue(KEY_MODULE_INFO, info); - } + public LightControlCapabilities setModuleInfo( ModuleInfo info) { + setValue(KEY_MODULE_INFO, info); + return this; + } /** * Gets a ModuleInfo of this capability diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/LightControlData.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/LightControlData.java index 05bcb5fec..e40fd8c68 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/LightControlData.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/LightControlData.java @@ -83,7 +83,8 @@ public class LightControlData extends RPCStruct { * * @param lightState An array of LightNames and their current or desired status. Status of the LightNames that are not listed in the array shall remain unchanged. */ - public void setLightState(@NonNull List lightState) { - setValue(KEY_LIGHT_STATE, lightState); - } + public LightControlData setLightState(@NonNull List lightState) { + setValue(KEY_LIGHT_STATE, lightState); + return this; + } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/LightState.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/LightState.java index 0676b50da..749d43039 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/LightState.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/LightState.java @@ -79,9 +79,10 @@ public class LightState extends RPCStruct { * * @param id The name of a light or a group of lights. */ - public void setId(@NonNull LightName id) { - setValue(KEY_ID, id); - } + public LightState setId(@NonNull LightName id) { + setValue(KEY_ID, id); + return this; + } /** * Gets the id portion of the LightState class @@ -97,11 +98,12 @@ public class LightState extends RPCStruct { * * @param status enum value of type LightStatus that describes the specific lights state * - * @see com.smartdevicelink.proxy.rpc.enums.LightStatus + * @see LightStatus */ - public void setStatus(@NonNull LightStatus status) { - setValue(KEY_STATUS, status); - } + public LightState setStatus(@NonNull LightStatus status) { + setValue(KEY_STATUS, status); + return this; + } /** * Gets the status portion of the LightState class @@ -129,9 +131,10 @@ public class LightState extends RPCStruct { * * @param density a float representation of the density of the specific light state */ - public void setDensity(Float density) { - setValue(KEY_DENSITY, density); - } + public LightState setDensity( Float density) { + setValue(KEY_DENSITY, density); + return this; + } /** * Gets the color portion of the LightState class @@ -150,9 +153,10 @@ public class LightState extends RPCStruct { * * @param color an RGBColor representation of the color of this specific light state * - * @see com.smartdevicelink.proxy.rpc.RGBColor + * @see RGBColor */ - public void setColor(RGBColor color) { - setValue(KEY_COLOR, color); - } + public LightState setColor( RGBColor color) { + setValue(KEY_COLOR, color); + return this; + } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/ListFilesResponse.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/ListFilesResponse.java index e69e0a900..b60d79522 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/ListFilesResponse.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/ListFilesResponse.java @@ -91,8 +91,9 @@ public class ListFilesResponse extends RPCResponse { super.format(rpcVersion, formatParams); } - public void setFilenames(List filenames) { + public ListFilesResponse setFilenames( List filenames) { setParameters(KEY_FILENAMES, filenames); + return this; } @SuppressWarnings("unchecked") @@ -100,8 +101,9 @@ public class ListFilesResponse extends RPCResponse { return (List) getObject(String.class, KEY_FILENAMES); } - public void setSpaceAvailable(Integer spaceAvailable) { + public ListFilesResponse setSpaceAvailable( Integer spaceAvailable) { setParameters(KEY_SPACE_AVAILABLE, spaceAvailable); + return this; } public Integer getSpaceAvailable() { diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/LocationDetails.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/LocationDetails.java index f548336f2..574d16912 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/LocationDetails.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/LocationDetails.java @@ -56,16 +56,18 @@ public class LocationDetails extends RPCStruct{ public Coordinate getCoordinate() { return (Coordinate) getObject(Coordinate.class, KEY_COORDINATE); } - public void setCoordinate(Coordinate coordinate) { + public LocationDetails setCoordinate( Coordinate coordinate) { setValue(KEY_COORDINATE, coordinate); + return this; } public String getLocationName() { return getString(KEY_LOCATION_NAME); } - public void setLocationName(String locationName) { + public LocationDetails setLocationName( String locationName) { setValue(KEY_LOCATION_NAME, locationName); + return this; } @SuppressWarnings("unchecked") @@ -73,24 +75,27 @@ public class LocationDetails extends RPCStruct{ return (List) getObject(String.class, KEY_ADDRESS_LINES); } - public void setAddressLines(List addressLines) { + public LocationDetails setAddressLines( List addressLines) { setValue(KEY_ADDRESS_LINES, addressLines); + return this; } public String getLocationDescription() { return getString(KEY_LOCATION_DESCRIPTION); } - public void setLocationDescription(String locationDescription) { + public LocationDetails setLocationDescription( String locationDescription) { setValue(KEY_LOCATION_DESCRIPTION, locationDescription); + return this; } public String getPhoneNumber() { return getString(KEY_PHONE_NUMBER); } - public void setPhoneNumber(String phoneNumber) { + public LocationDetails setPhoneNumber( String phoneNumber) { setValue(KEY_PHONE_NUMBER, phoneNumber); + return this; } @SuppressWarnings("unchecked") @@ -98,15 +103,17 @@ public class LocationDetails extends RPCStruct{ return (Image) getObject(Image.class, KEY_LOCATION_IMAGE); } - public void setLocationImage(Image locationImage) { + public LocationDetails setLocationImage( Image locationImage) { setValue(KEY_LOCATION_IMAGE, locationImage); + return this; } @SuppressWarnings("unchecked") public OasisAddress getSearchAddress() { return (OasisAddress) getObject(OasisAddress.class, KEY_SEARCH_ADDRESS); } - public void setSearchAddress(OasisAddress searchAddress) { + public LocationDetails setSearchAddress( OasisAddress searchAddress) { setValue(KEY_SEARCH_ADDRESS, searchAddress); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/MassageCushionFirmness.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/MassageCushionFirmness.java index 6a4694a22..5d6219e14 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/MassageCushionFirmness.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/MassageCushionFirmness.java @@ -77,9 +77,10 @@ public class MassageCushionFirmness extends RPCStruct { * * @param cushion type of MassageCushion for multi-contour massage seat */ - public void setCushion(@NonNull MassageCushion cushion) { - setValue(KEY_CUSHION, cushion); - } + public MassageCushionFirmness setCushion(@NonNull MassageCushion cushion) { + setValue(KEY_CUSHION, cushion); + return this; + } /** * Gets the type of MassageCushion for multi-contour massage seat @@ -95,9 +96,10 @@ public class MassageCushionFirmness extends RPCStruct { * * @param firmness firmness of the supplied MassageCushion (Min: 0 Max: 100) */ - public void setFirmness(@NonNull Integer firmness) { - setValue(KEY_FIRMNESS, firmness); - } + public MassageCushionFirmness setFirmness(@NonNull Integer firmness) { + setValue(KEY_FIRMNESS, firmness); + return this; + } /** * Gets the firmness associated with the supplied MassageCushion diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/MassageModeData.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/MassageModeData.java index 1802c18c3..fee40d30d 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/MassageModeData.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/MassageModeData.java @@ -78,9 +78,10 @@ public class MassageModeData extends RPCStruct { * * @param massageZone the zone of a multi-contour massage seat */ - public void setMassageZone(@NonNull MassageZone massageZone) { - setValue(KEY_MASSAGE_ZONE, massageZone); - } + public MassageModeData setMassageZone(@NonNull MassageZone massageZone) { + setValue(KEY_MASSAGE_ZONE, massageZone); + return this; + } /** * Gets the massageZone that will be associated with the supplied massage mode @@ -105,7 +106,8 @@ public class MassageModeData extends RPCStruct { * * @param massageMode mode of massage to be used (OFF, LOW, HIGH) */ - public void setMassageMode(@NonNull MassageMode massageMode) { - setValue(KEY_MASSAGE_MODE, massageMode); - } + public MassageModeData setMassageMode(@NonNull MassageMode massageMode) { + setValue(KEY_MASSAGE_MODE, massageMode); + return this; + } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/MediaServiceData.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/MediaServiceData.java index 16065f669..a4722adb9 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/MediaServiceData.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/MediaServiceData.java @@ -68,9 +68,10 @@ public class MediaServiceData extends RPCStruct { /** * @param mediaType - The type of the currently playing or paused track. */ - public void setMediaType(MediaType mediaType) { - setValue(KEY_MEDIA_TYPE, mediaType); - } + public MediaServiceData setMediaType( MediaType mediaType) { + setValue(KEY_MEDIA_TYPE, mediaType); + return this; + } /** * @return mediaType - The type of the currently playing or paused track. @@ -85,9 +86,10 @@ public class MediaServiceData extends RPCStruct { * Audiobook: The name of the current chapter * @param mediaTitle - */ - public void setMediaTitle(String mediaTitle) { - setValue(KEY_MEDIA_TITLE, mediaTitle); - } + public MediaServiceData setMediaTitle( String mediaTitle) { + setValue(KEY_MEDIA_TITLE, mediaTitle); + return this; + } /** * Music: The name of the current track @@ -105,9 +107,10 @@ public class MediaServiceData extends RPCStruct { * Audiobook: The book author's name * @param mediaArtist - */ - public void setMediaArtist(String mediaArtist) { - setValue(KEY_MEDIA_ARTIST, mediaArtist); - } + public MediaServiceData setMediaArtist( String mediaArtist) { + setValue(KEY_MEDIA_ARTIST, mediaArtist); + return this; + } /** * Music: The name of the current album artist @@ -125,9 +128,10 @@ public class MediaServiceData extends RPCStruct { * Audiobook: The name of the current book * @param mediaAlbum - */ - public void setMediaAlbum(String mediaAlbum) { - setValue(KEY_MEDIA_ALBUM, mediaAlbum); - } + public MediaServiceData setMediaAlbum( String mediaAlbum) { + setValue(KEY_MEDIA_ALBUM, mediaAlbum); + return this; + } /** * Music: The name of the current album @@ -146,9 +150,10 @@ public class MediaServiceData extends RPCStruct { * Audiobook: The book or chapter artwork of the current audiobook * @param mediaImage */ - public void setMediaImage(Image mediaImage){ - setValue(KEY_MEDIA_IMAGE, mediaImage); - } + public MediaServiceData setMediaImage( Image mediaImage) { + setValue(KEY_MEDIA_IMAGE, mediaImage); + return this; + } /** * Returns the media image associated with the currently playing media @@ -166,9 +171,10 @@ public class MediaServiceData extends RPCStruct { * Audiobook: Likely not applicable, possibly a collection or "playlist" of books * @param playlistName - */ - public void setPlaylistName(String playlistName) { - setValue(KEY_PLAYLIST_NAME, playlistName); - } + public MediaServiceData setPlaylistName( String playlistName) { + setValue(KEY_PLAYLIST_NAME, playlistName); + return this; + } /** * Music: The name of the playlist or radio station, if the user is playing from a playlist, otherwise, Null @@ -183,9 +189,10 @@ public class MediaServiceData extends RPCStruct { /** * @param isExplicit - Whether or not the content currently playing (e.g. the track, episode, or book) contains explicit content */ - public void setIsExplicit(Boolean isExplicit) { - setValue(KEY_IS_EXPLICIT, isExplicit); - } + public MediaServiceData setIsExplicit( Boolean isExplicit) { + setValue(KEY_IS_EXPLICIT, isExplicit); + return this; + } /** * @return isExplicit - Whether or not the content currently playing (e.g. the track, episode, or book) contains explicit content @@ -200,9 +207,10 @@ public class MediaServiceData extends RPCStruct { * Audiobook: The current progress of the current segment (e.g. the chapter) in seconds * @param trackPlaybackProgress - */ - public void setTrackPlaybackProgress(Integer trackPlaybackProgress) { - setValue(KEY_TRACK_PLAYBACK_PROGRESS, trackPlaybackProgress); - } + public MediaServiceData setTrackPlaybackProgress( Integer trackPlaybackProgress) { + setValue(KEY_TRACK_PLAYBACK_PROGRESS, trackPlaybackProgress); + return this; + } /** * Music: The current progress of the track in seconds @@ -220,9 +228,10 @@ public class MediaServiceData extends RPCStruct { * Audiobook: The total duration of the current segment (e.g. the chapter) in seconds * @param trackPlaybackDuration - */ - public void setTrackPlaybackDuration(Integer trackPlaybackDuration) { - setValue(KEY_TRACK_PLAYBACK_DURATION, trackPlaybackDuration); - } + public MediaServiceData setTrackPlaybackDuration( Integer trackPlaybackDuration) { + setValue(KEY_TRACK_PLAYBACK_DURATION, trackPlaybackDuration); + return this; + } /** * Music: The total duration of the track in seconds @@ -240,9 +249,10 @@ public class MediaServiceData extends RPCStruct { * Audiobook: The current progress of the playback queue (e.g. the book) in seconds * @param queuePlaybackProgress - */ - public void setQueuePlaybackProgress(Integer queuePlaybackProgress) { - setValue(KEY_QUEUE_PLAYBACK_PROGRESS, queuePlaybackProgress); - } + public MediaServiceData setQueuePlaybackProgress( Integer queuePlaybackProgress) { + setValue(KEY_QUEUE_PLAYBACK_PROGRESS, queuePlaybackProgress); + return this; + } /** * Music: The current progress of the playback queue in seconds @@ -260,9 +270,10 @@ public class MediaServiceData extends RPCStruct { * Audiobook: The total duration of the playback queue (e.g. the book) in seconds * @param queuePlaybackDuration - */ - public void setQueuePlaybackDuration(Integer queuePlaybackDuration) { - setValue(KEY_QUEUE_PLAYBACK_DURATION, queuePlaybackDuration); - } + public MediaServiceData setQueuePlaybackDuration( Integer queuePlaybackDuration) { + setValue(KEY_QUEUE_PLAYBACK_DURATION, queuePlaybackDuration); + return this; + } /** * Music: The total duration of the playback queue in seconds @@ -280,9 +291,10 @@ public class MediaServiceData extends RPCStruct { * Audiobook: The current number (1 based) of the episode in the playback queue (e.g. the chapter number in the book) * @param queueCurrentTrackNumber - */ - public void setQueueCurrentTrackNumber(Integer queueCurrentTrackNumber) { - setValue(KEY_QUEUE_CURRENT_TRACK_NUMBER, queueCurrentTrackNumber); - } + public MediaServiceData setQueueCurrentTrackNumber( Integer queueCurrentTrackNumber) { + setValue(KEY_QUEUE_CURRENT_TRACK_NUMBER, queueCurrentTrackNumber); + return this; + } /** * Music: The current number (1 based) of the track in the playback queue @@ -300,9 +312,10 @@ public class MediaServiceData extends RPCStruct { * Audiobook: The total number of sections in the playback queue (e.g. the number of chapters in the book) * @param queueTotalTrackCount - */ - public void setQueueTotalTrackCount(Integer queueTotalTrackCount) { - setValue(KEY_QUEUE_TOTAL_TRACK_COUNT, queueTotalTrackCount); - } + public MediaServiceData setQueueTotalTrackCount( Integer queueTotalTrackCount) { + setValue(KEY_QUEUE_TOTAL_TRACK_COUNT, queueTotalTrackCount); + return this; + } /** * Music: The total number of tracks in the playback queue diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/MenuParams.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/MenuParams.java index 3ed8db072..408c36f71 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/MenuParams.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/MenuParams.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -123,9 +123,10 @@ public class MenuParams extends RPCStruct { * Set the unique ID of an existing submenu to which a command will be added. * If this element is not provided, the command will be added to the top level of the Command Menu. * @param parentID Min: 0; Max: 2000000000 - */ - public void setParentID( Integer parentID ) { + */ + public MenuParams setParentID( Integer parentID) { setValue(KEY_PARENT_ID, parentID); + return this; } /** * Get the position within the items of the parent Command Menu. 0 will insert at the front, 1 will insert after the first existing element, etc. @@ -142,7 +143,7 @@ public class MenuParams extends RPCStruct { return getInteger( KEY_POSITION ); } /** - * Set the position within the items of the parent Command Menu. 0 will insert at the front, 1 will insert after the first existing element, etc. + * Set the position within the items of the parent Command Menu. 0 will insert at the front, 1 will insert after the first existing element, etc. * Position of any submenu will always be located before the return and exit options. *
      *
    • Min Value: 0
    • @@ -151,9 +152,10 @@ public class MenuParams extends RPCStruct { *
    • If this element is omitted, the entry will be added at the end of the parent menu.
    • *
    * @param position Mix: 0 Max: 1000 - */ - public void setPosition( Integer position ) { + */ + public MenuParams setPosition( Integer position) { setValue(KEY_POSITION, position); + return this; } /** * Get the text which appears in menu, representing this command. @@ -175,8 +177,9 @@ public class MenuParams extends RPCStruct { * * @param menuName the menu name */ - - public void setMenuName( @NonNull String menuName ) { + + public MenuParams setMenuName(@NonNull String menuName) { setValue(KEY_MENU_NAME, menuName); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/MetadataTags.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/MetadataTags.java index 49afcd86b..6894109fa 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/MetadataTags.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/MetadataTags.java @@ -59,16 +59,18 @@ public class MetadataTags extends RPCStruct { /** * Set the metadata types of data contained in the "mainField1" text field */ - public void setMainField1( List metadataTypes ) { - setValue(KEY_MAIN_FIELD_1_TYPE, metadataTypes); - } + public MetadataTags setMainField1( List metadataTypes) { + setValue(KEY_MAIN_FIELD_1_TYPE, metadataTypes); + return this; + } /** * Set the metadata type of data contained in the "mainField1" text field */ - public void setMainField1(MetadataType metadataType) { - setValue(KEY_MAIN_FIELD_1_TYPE, Collections.singletonList(metadataType)); - } + public MetadataTags setMainField1( MetadataType metadataType) { + setValue(KEY_MAIN_FIELD_1_TYPE, Collections.singletonList(metadataType)); + return this; + } /** * @return The type of data contained in the "mainField1" text field @@ -81,16 +83,18 @@ public class MetadataTags extends RPCStruct { /** * Set the metadata types of data contained in the "mainField2" text field */ - public void setMainField2( List metadataTypes ) { - setValue(KEY_MAIN_FIELD_2_TYPE, metadataTypes); - } + public MetadataTags setMainField2( List metadataTypes) { + setValue(KEY_MAIN_FIELD_2_TYPE, metadataTypes); + return this; + } /** * Set the metadata type of data contained in the "mainField2" text field */ - public void setMainField2(MetadataType metadataType) { - setValue(KEY_MAIN_FIELD_2_TYPE, Collections.singletonList(metadataType)); - } + public MetadataTags setMainField2( MetadataType metadataType) { + setValue(KEY_MAIN_FIELD_2_TYPE, Collections.singletonList(metadataType)); + return this; + } /** * @return The type of data contained in the "mainField2" text field @@ -103,16 +107,18 @@ public class MetadataTags extends RPCStruct { /** * Set the metadata types of data contained in the "mainField3" text field */ - public void setMainField3( List metadataTypes ) { - setValue(KEY_MAIN_FIELD_3_TYPE, metadataTypes); - } + public MetadataTags setMainField3( List metadataTypes) { + setValue(KEY_MAIN_FIELD_3_TYPE, metadataTypes); + return this; + } /** * Set the metadata type of data contained in the "mainField3" text field */ - public void setMainField3(MetadataType metadataType) { - setValue(KEY_MAIN_FIELD_3_TYPE, Collections.singletonList(metadataType)); - } + public MetadataTags setMainField3( MetadataType metadataType) { + setValue(KEY_MAIN_FIELD_3_TYPE, Collections.singletonList(metadataType)); + return this; + } /** * @return The type of data contained in the "mainField3" text field @@ -125,16 +131,18 @@ public class MetadataTags extends RPCStruct { /** * Set the metadata types of data contained in the "mainField4" text field */ - public void setMainField4( List metadataTypes ) { - setValue(KEY_MAIN_FIELD_4_TYPE, metadataTypes); - } + public MetadataTags setMainField4( List metadataTypes) { + setValue(KEY_MAIN_FIELD_4_TYPE, metadataTypes); + return this; + } /** * Set the metadata type of data contained in the "mainField4" text field */ - public void setMainField4(MetadataType metadataType) { - setValue(KEY_MAIN_FIELD_4_TYPE, Collections.singletonList(metadataType)); - } + public MetadataTags setMainField4( MetadataType metadataType) { + setValue(KEY_MAIN_FIELD_4_TYPE, Collections.singletonList(metadataType)); + return this; + } /** * @return The type of data contained in the "mainField4" text field diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/ModuleData.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/ModuleData.java index 1c1333102..b20124551 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/ModuleData.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/ModuleData.java @@ -66,9 +66,10 @@ public class ModuleData extends RPCStruct { * @param moduleType The moduleType indicates which type of data should be changed and identifies which data object exists in this struct. * For example, if the moduleType is CLIMATE then a "climateControlData" should exist */ - public void setModuleType(@NonNull ModuleType moduleType) { - setValue(KEY_MODULE_TYPE, moduleType); - } + public ModuleData setModuleType(@NonNull ModuleType moduleType) { + setValue(KEY_MODULE_TYPE, moduleType); + return this; + } /** * Gets the moduleType portion of the ModuleData class @@ -85,9 +86,10 @@ public class ModuleData extends RPCStruct { * * @param radioControlData */ - public void setRadioControlData(RadioControlData radioControlData) { - setValue(KEY_RADIO_CONTROL_DATA, radioControlData); - } + public ModuleData setRadioControlData( RadioControlData radioControlData) { + setValue(KEY_RADIO_CONTROL_DATA, radioControlData); + return this; + } /** * Gets the radioControlData portion of the ModuleData class @@ -103,9 +105,10 @@ public class ModuleData extends RPCStruct { * * @param climateControlData */ - public void setClimateControlData(ClimateControlData climateControlData) { - setValue(KEY_CLIMATE_CONTROL_DATA, climateControlData); - } + public ModuleData setClimateControlData( ClimateControlData climateControlData) { + setValue(KEY_CLIMATE_CONTROL_DATA, climateControlData); + return this; + } /** * Gets the climateControlData portion of the ModuleData class @@ -121,9 +124,10 @@ public class ModuleData extends RPCStruct { * * @param seatControlData */ - public void setSeatControlData(SeatControlData seatControlData) { - setValue(KEY_SEAT_CONTROL_DATA, seatControlData); - } + public ModuleData setSeatControlData( SeatControlData seatControlData) { + setValue(KEY_SEAT_CONTROL_DATA, seatControlData); + return this; + } /** * Gets the seatControlData portion of the ModuleData class @@ -139,9 +143,10 @@ public class ModuleData extends RPCStruct { * * @param audioControlData */ - public void setAudioControlData(AudioControlData audioControlData) { - setValue(KEY_AUDIO_CONTROL_DATA, audioControlData); - } + public ModuleData setAudioControlData( AudioControlData audioControlData) { + setValue(KEY_AUDIO_CONTROL_DATA, audioControlData); + return this; + } /** * Gets the audioControlData portion of the ModuleData class @@ -157,9 +162,10 @@ public class ModuleData extends RPCStruct { * * @param lightControlData */ - public void setLightControlData(LightControlData lightControlData) { - setValue(KEY_LIGHT_CONTROL_DATA, lightControlData); - } + public ModuleData setLightControlData( LightControlData lightControlData) { + setValue(KEY_LIGHT_CONTROL_DATA, lightControlData); + return this; + } /** * Gets the lightControlData portion of the ModuleData class @@ -175,9 +181,10 @@ public class ModuleData extends RPCStruct { * * @param hmiSettingsControlData */ - public void setHmiSettingsControlData(HMISettingsControlData hmiSettingsControlData) { - setValue(KEY_HMI_SETTINGS_CONTROL_DATA, hmiSettingsControlData); - } + public ModuleData setHmiSettingsControlData( HMISettingsControlData hmiSettingsControlData) { + setValue(KEY_HMI_SETTINGS_CONTROL_DATA, hmiSettingsControlData); + return this; + } /** * Gets the hmiSettingsControlData portion of the ModuleData class @@ -192,9 +199,10 @@ public class ModuleData extends RPCStruct { * Sets the Module ID of the ModuleData class * @param id the id to be set */ - public void setModuleId(String id) { - setValue(KEY_MODULE_ID, id); - } + public ModuleData setModuleId( String id) { + setValue(KEY_MODULE_ID, id); + return this; + } /** * Gets the Module ID of the ModuleData class diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/ModuleInfo.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/ModuleInfo.java index 701fe6c09..65debe0cf 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/ModuleInfo.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/ModuleInfo.java @@ -34,8 +34,9 @@ public class ModuleInfo extends RPCStruct { * Sets the Module ID for this Module * @param id the id to be set */ - public void setModuleId(@NonNull String id) { + public ModuleInfo setModuleId(@NonNull String id) { setValue(KEY_MODULE_ID, id); + return this; } /** @@ -50,8 +51,9 @@ public class ModuleInfo extends RPCStruct { * Sets the location of this Module * @param location the location to be set */ - public void setModuleLocation(Grid location) { + public ModuleInfo setModuleLocation( Grid location) { setValue(KEY_MODULE_LOCATION, location); + return this; } /** @@ -66,8 +68,9 @@ public class ModuleInfo extends RPCStruct { * Sets the service area of this Module * @param serviceArea the service area of this Module */ - public void setModuleServiceArea(Grid serviceArea) { + public ModuleInfo setModuleServiceArea( Grid serviceArea) { setValue(KEY_MODULE_SERVICE_AREA, serviceArea); + return this; } /** @@ -82,8 +85,9 @@ public class ModuleInfo extends RPCStruct { * Sets the multiple access allowance for this Module * @param isMultipleAccess the access to be set */ - public void setMultipleAccessAllowance(Boolean isMultipleAccess) { + public ModuleInfo setMultipleAccessAllowance( Boolean isMultipleAccess) { setValue(KEY_MULTIPLE_ACCESS_ALLOWED, isMultipleAccess); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/MyKey.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/MyKey.java index c72b8a203..e73565677 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/MyKey.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/MyKey.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -84,8 +84,9 @@ public class MyKey extends RPCStruct { this(); setE911Override(e911Override); } - public void setE911Override(@NonNull VehicleDataStatus e911Override) { + public MyKey setE911Override(@NonNull VehicleDataStatus e911Override) { setValue(KEY_E_911_OVERRIDE, e911Override); + return this; } public VehicleDataStatus getE911Override() { return (VehicleDataStatus) getObject(VehicleDataStatus.class, KEY_E_911_OVERRIDE); diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/NavigationCapability.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/NavigationCapability.java index 486a3c2ea..c3d19c3b1 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/NavigationCapability.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/NavigationCapability.java @@ -52,15 +52,17 @@ public class NavigationCapability extends RPCStruct{ return getBoolean(KEY_LOCATION_ENABLED); } - public void setSendLocationEnabled(Boolean sendLocationEnabled){ - setValue(KEY_LOCATION_ENABLED, sendLocationEnabled); - } + public NavigationCapability setSendLocationEnabled( Boolean sendLocationEnabled) { + setValue(KEY_LOCATION_ENABLED, sendLocationEnabled); + return this; + } public Boolean getWayPointsEnabled(){ return getBoolean(KEY_GETWAYPOINTS_ENABLED); } - public void setWayPointsEnabled(Boolean getWayPointsEnabled){ - setValue(KEY_GETWAYPOINTS_ENABLED, getWayPointsEnabled); - } + public NavigationCapability setWayPointsEnabled( Boolean getWayPointsEnabled) { + setValue(KEY_GETWAYPOINTS_ENABLED, getWayPointsEnabled); + return this; + } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/NavigationInstruction.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/NavigationInstruction.java index bd7bbc0eb..e4c3136ab 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/NavigationInstruction.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/NavigationInstruction.java @@ -70,9 +70,10 @@ public class NavigationInstruction extends RPCStruct { /** * @param locationDetails - */ - public void setLocationDetails(@NonNull LocationDetails locationDetails){ - setValue(KEY_LOCATION_DETAILS, locationDetails); - } + public NavigationInstruction setLocationDetails(@NonNull LocationDetails locationDetails) { + setValue(KEY_LOCATION_DETAILS, locationDetails); + return this; + } /** * @return locationDetails @@ -84,9 +85,10 @@ public class NavigationInstruction extends RPCStruct { /** * @param action - */ - public void setAction(@NonNull NavigationAction action){ - setValue(KEY_ACTION, action); - } + public NavigationInstruction setAction(@NonNull NavigationAction action) { + setValue(KEY_ACTION, action); + return this; + } /** * @return action @@ -98,9 +100,10 @@ public class NavigationInstruction extends RPCStruct { /** * @param eta - */ - public void setEta(DateTime eta){ - setValue(KEY_ETA, eta); - } + public NavigationInstruction setEta( DateTime eta) { + setValue(KEY_ETA, eta); + return this; + } /** * @return eta @@ -115,9 +118,10 @@ public class NavigationInstruction extends RPCStruct { * a U-Turn, etc. * @param bearing - minValue="0" maxValue="359" */ - public void setBearing(Integer bearing){ - setValue(KEY_BEARING, bearing); - } + public NavigationInstruction setBearing( Integer bearing) { + setValue(KEY_BEARING, bearing); + return this; + } /** * The angle at which this instruction takes place. For example, 0 would mean straight, <=45 @@ -132,9 +136,10 @@ public class NavigationInstruction extends RPCStruct { /** * @param junctionType - */ - public void setJunctionType(NavigationJunction junctionType){ - setValue(KEY_JUNCTION_TYPE, junctionType); - } + public NavigationInstruction setJunctionType( NavigationJunction junctionType) { + setValue(KEY_JUNCTION_TYPE, junctionType); + return this; + } /** * @return junctionType @@ -148,9 +153,10 @@ public class NavigationInstruction extends RPCStruct { * will determine which direction the turn should take place. * @param drivingSide - Direction enum value that represents the driving side */ - public void setDrivingSide(Direction drivingSide){ - setValue(KEY_DRIVING_SIDE, drivingSide); - } + public NavigationInstruction setDrivingSide( Direction drivingSide) { + setValue(KEY_DRIVING_SIDE, drivingSide); + return this; + } /** * Used to infer which side of the road this instruction takes place. For a U-Turn (action=TURN, bearing=180) this @@ -167,9 +173,10 @@ public class NavigationInstruction extends RPCStruct { * NavigationServiceData for that. * @param details - */ - public void setDetails(String details){ - setValue(KEY_DETAILS, details); - } + public NavigationInstruction setDetails( String details) { + setValue(KEY_DETAILS, details); + return this; + } /** * This is a string representation of this instruction, used to display instructions to the @@ -185,9 +192,10 @@ public class NavigationInstruction extends RPCStruct { * An image representation of this instruction. * @param image - */ - public void setImage(Image image){ - setValue(KEY_IMAGE, image); - } + public NavigationInstruction setImage( Image image) { + setValue(KEY_IMAGE, image); + return this; + } /** * An image representation of this instruction. diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/NavigationServiceData.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/NavigationServiceData.java index ae566c6e8..dd4b9237f 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/NavigationServiceData.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/NavigationServiceData.java @@ -73,9 +73,10 @@ public class NavigationServiceData extends RPCStruct { * given in the data can accurately be adjusted if necessary. * @param timeStamp - */ - public void setTimeStamp(@NonNull DateTime timeStamp){ - setValue(KEY_TIMESTAMP, timeStamp); - } + public NavigationServiceData setTimeStamp(@NonNull DateTime timeStamp) { + setValue(KEY_TIMESTAMP, timeStamp); + return this; + } /** * This is the timeStamp of when the data was generated. This is to ensure any time or distance @@ -89,9 +90,10 @@ public class NavigationServiceData extends RPCStruct { /** * @param origin - */ - public void setOrigin(LocationDetails origin){ - setValue(KEY_ORIGIN, origin); - } + public NavigationServiceData setOrigin( LocationDetails origin) { + setValue(KEY_ORIGIN, origin); + return this; + } /** * @return origin @@ -103,9 +105,10 @@ public class NavigationServiceData extends RPCStruct { /** * @param destination - */ - public void setDestination(LocationDetails destination){ - setValue(KEY_DESTINATION, destination); - } + public NavigationServiceData setDestination( LocationDetails destination) { + setValue(KEY_DESTINATION, destination); + return this; + } /** * @return destination @@ -117,9 +120,10 @@ public class NavigationServiceData extends RPCStruct { /** * @param destinationETA - */ - public void setDestinationETA(DateTime destinationETA){ - setValue(KEY_DESTINATION_ETA, destinationETA); - } + public NavigationServiceData setDestinationETA( DateTime destinationETA) { + setValue(KEY_DESTINATION_ETA, destinationETA); + return this; + } /** * @return destinationETA @@ -133,9 +137,10 @@ public class NavigationServiceData extends RPCStruct { * always contain the next instruction. * @param instructions - */ - public void setInstructions(List instructions){ - setValue(KEY_INSTRUCTIONS, instructions); - } + public NavigationServiceData setInstructions( List instructions) { + setValue(KEY_INSTRUCTIONS, instructions); + return this; + } /** * This array should be ordered with all remaining instructions. The start of this array should @@ -150,9 +155,10 @@ public class NavigationServiceData extends RPCStruct { /** * @param nextInstructionETA - */ - public void setNextInstructionETA(DateTime nextInstructionETA){ - setValue(KEY_NEXT_INSTRUCTION_ETA, nextInstructionETA); - } + public NavigationServiceData setNextInstructionETA( DateTime nextInstructionETA) { + setValue(KEY_NEXT_INSTRUCTION_ETA, nextInstructionETA); + return this; + } /** * @return nextInstructionETA @@ -167,9 +173,10 @@ public class NavigationServiceData extends RPCStruct { * the next instruction. * @param nextInstructionDistance - */ - public void setNextInstructionDistance(Float nextInstructionDistance){ - setValue(KEY_NEXT_INSTRUCTION_DISTANCE, nextInstructionDistance); - } + public NavigationServiceData setNextInstructionDistance( Float nextInstructionDistance) { + setValue(KEY_NEXT_INSTRUCTION_DISTANCE, nextInstructionDistance); + return this; + } /** * The distance to this instruction from current location. This should only be updated every @@ -185,9 +192,10 @@ public class NavigationServiceData extends RPCStruct { * Distance till next maneuver (starting from) from previous maneuver. * @param nextInstructionDistanceScale - */ - public void setNextInstructionDistanceScale(Float nextInstructionDistanceScale){ - setValue(KEY_NEXT_INSTRUCTION_DISTANCE_SCALE, nextInstructionDistanceScale); - } + public NavigationServiceData setNextInstructionDistanceScale( Float nextInstructionDistanceScale) { + setValue(KEY_NEXT_INSTRUCTION_DISTANCE_SCALE, nextInstructionDistanceScale); + return this; + } /** * Distance till next maneuver (starting from) from previous maneuver. @@ -203,9 +211,10 @@ public class NavigationServiceData extends RPCStruct { * instruction, post instruction, alerts that affect the current navigation session, etc. * @param prompt - */ - public void setPrompt(String prompt){ - setValue(KEY_PROMPT, prompt); - } + public NavigationServiceData setPrompt( String prompt) { + setValue(KEY_PROMPT, prompt); + return this; + } /** * This is a prompt message that should be conveyed to the user through either display or voice diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/NavigationServiceManifest.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/NavigationServiceManifest.java index 78b392865..e355c7a1c 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/NavigationServiceManifest.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/NavigationServiceManifest.java @@ -53,9 +53,10 @@ public class NavigationServiceManifest extends RPCStruct { * Informs the subscriber if this service can actually accept way points. * @param acceptsWayPoints - */ - public void setAcceptsWayPoints(Boolean acceptsWayPoints){ - setValue(KEY_ACCEPTS_WAY_POINTS, acceptsWayPoints); - } + public NavigationServiceManifest setAcceptsWayPoints( Boolean acceptsWayPoints) { + setValue(KEY_ACCEPTS_WAY_POINTS, acceptsWayPoints); + return this; + } /** * Informs the subscriber if this service can actually accept way points. diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/OasisAddress.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/OasisAddress.java index 7b4d09478..775f50d2c 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/OasisAddress.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/OasisAddress.java @@ -71,13 +71,14 @@ public class OasisAddress extends RPCStruct{ /** * Sets the localized Name of the country associated with the OasisAddress class. - * + * * @param countryName * The localized Name of the country associated with the OasisAddress class. - * + * */ - public void setCountryName(String countryName) { + public OasisAddress setCountryName( String countryName) { setValue(KEY_COUNTRY_NAME, countryName); + return this; } /** @@ -92,13 +93,14 @@ public class OasisAddress extends RPCStruct{ /** * Sets the country code in ISO 3166-2 format associated with the OasisAddress class. - * + * * @param countryCode * The country code in ISO 3166-2 format associated with the OasisAddress class. - * - */ - public void setCountryCode(String countryCode) { + * + */ + public OasisAddress setCountryCode( String countryCode) { setValue(KEY_COUNTRY_CODE, countryCode); + return this; } /** @@ -113,13 +115,14 @@ public class OasisAddress extends RPCStruct{ /** * Sets the Postal Code associated with the OasisAddress class. - * + * * @param postalCode * The Postal Code associated with the OasisAddress class. - * - */ - public void setPostalCode(String postalCode) { + * + */ + public OasisAddress setPostalCode( String postalCode) { setValue(KEY_POSTAL_CODE, postalCode); + return this; } /** @@ -134,13 +137,14 @@ public class OasisAddress extends RPCStruct{ /** * Sets the Administrative Area associated with the OasisAddress class. A portion of the country - Administrative Area can include details of the top-level area division in the country, such as state, district, province, island, region, etc. - * + * * @param administrativeArea * The Administrative Area associated with the OasisAddress class. - * - */ - public void setAdministrativeArea(String administrativeArea) { + * + */ + public OasisAddress setAdministrativeArea( String administrativeArea) { setValue(KEY_ADMINISTRATIVE_AREA, administrativeArea); + return this; } /** @@ -155,13 +159,14 @@ public class OasisAddress extends RPCStruct{ /** * Sets the SubAdministrative Area associated with the OasisAddress class. A portion of the administrativeArea - The next level down division of the area. E.g. state / county, province / reservation. - * + * * @param subAdministrativeArea * The SubAdministrative Area associated with the OasisAddress class. - * - */ - public void setSubAdministrativeArea(String subAdministrativeArea) { + * + */ + public OasisAddress setSubAdministrativeArea( String subAdministrativeArea) { setValue(KEY_SUB_ADMINISTRATIVE_AREA, subAdministrativeArea); + return this; } /** @@ -176,13 +181,14 @@ public class OasisAddress extends RPCStruct{ /** * Sets the Locality associated with the OasisAddress class. - A hypernym for city/village. - * + * * @param locality * The Locality associated with the OasisAddress class. - * + * */ - public void setLocality(String locality) { + public OasisAddress setLocality( String locality) { setValue(KEY_LOCALITY, locality); + return this; } /** @@ -197,13 +203,14 @@ public class OasisAddress extends RPCStruct{ /** * Sets the Sub-Locality associated with the OasisAddress class. A hypernym for district. - * + * * @param subLocality * The Sub-Locality associated with the OasisAddress class. - * - */ - public void setSubLocality(String subLocality) { + * + */ + public OasisAddress setSubLocality( String subLocality) { setValue(KEY_SUB_LOCALITY, subLocality); + return this; } /** @@ -218,13 +225,14 @@ public class OasisAddress extends RPCStruct{ /** * Sets the Thoroughfare associated with the OasisAddress class. A hypernym for street, road etc. - * + * * @param thoroughFare * The Thoroughfare associated with the OasisAddress class. - * - */ - public void setThoroughfare(String thoroughFare) { + * + */ + public OasisAddress setThoroughfare( String thoroughFare) { setValue(KEY_THOROUGH_FARE, thoroughFare); + return this; } /** @@ -238,12 +246,13 @@ public class OasisAddress extends RPCStruct{ /** * Sets the Sub-Thoroughfare associated with the OasisAddress class. - A Portion of thoroughfare (e.g. house number). - * + * * @param subThoroughfare * The Sub-Thoroughfare associated with the OasisAddress class. - * - */ - public void setSubThoroughfare(String subThoroughfare) { + * + */ + public OasisAddress setSubThoroughfare( String subThoroughfare) { setValue(KEY_SUB_THOROUGH_FARE, subThoroughfare); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnAppInterfaceUnregistered.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnAppInterfaceUnregistered.java index 30fe4e755..33a896c2f 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnAppInterfaceUnregistered.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnAppInterfaceUnregistered.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -105,8 +105,9 @@ public class OnAppInterfaceUnregistered extends RPCNotification { /** *

    Set the reason application's interface was terminated

    * @param reason The reason application's interface registration was terminated - */ - public void setReason( @NonNull AppInterfaceUnregisteredReason reason ) { + */ + public OnAppInterfaceUnregistered setReason(@NonNull AppInterfaceUnregisteredReason reason) { setParameters(KEY_REASON, reason); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnAppServiceData.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnAppServiceData.java index e959b78f4..61b696809 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnAppServiceData.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnAppServiceData.java @@ -65,9 +65,10 @@ public class OnAppServiceData extends RPCNotification { /** * @param serviceData - */ - public void setServiceData(@NonNull AppServiceData serviceData){ - setParameters(KEY_SERVICE_DATA, serviceData); - } + public OnAppServiceData setServiceData(@NonNull AppServiceData serviceData) { + setParameters(KEY_SERVICE_DATA, serviceData); + return this; + } /** * @return serviceData diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnAudioPassThru.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnAudioPassThru.java index ab1ea3770..e5b9a5993 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnAudioPassThru.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnAudioPassThru.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import com.smartdevicelink.protocol.enums.FunctionID; @@ -84,8 +84,9 @@ public class OnAudioPassThru extends RPCNotification { public OnAudioPassThru(Hashtable hash) { super(hash); } - public void setAPTData(byte[] aptData) { + public OnAudioPassThru setAPTData( byte[] aptData) { setBulkData(aptData); + return this; } public byte[] getAPTData() { return getBulkData(); diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnButtonEvent.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnButtonEvent.java index d4e1b01b7..ca408c580 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnButtonEvent.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnButtonEvent.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -160,11 +160,12 @@ public class OnButtonEvent extends RPCNotification { } /** - *

    Set the button's name

    + *

    Set the button's name

    * @param buttonName name of the button - */ - public void setButtonName(@NonNull ButtonName buttonName) { + */ + public OnButtonEvent setButtonName(@NonNull ButtonName buttonName) { setParameters(KEY_BUTTON_NAME, buttonName); + return this; } /** @@ -179,13 +180,15 @@ public class OnButtonEvent extends RPCNotification { *

    Set the event mode of the button,pressed or released

    * @param buttonEventMode indicates the button is pressed or released * @see ButtonEventMode - */ - public void setButtonEventMode(@NonNull ButtonEventMode buttonEventMode) { + */ + public OnButtonEvent setButtonEventMode(@NonNull ButtonEventMode buttonEventMode) { setParameters(KEY_BUTTON_EVENT_MODE, buttonEventMode); + return this; } - public void setCustomButtonID(Integer customButtonID) { + public OnButtonEvent setCustomButtonID( Integer customButtonID) { setParameters(KEY_CUSTOM_BUTTON_ID, customButtonID); + return this; } public Integer getCustomButtonID() { return getInteger(KEY_CUSTOM_BUTTON_ID); diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnButtonPress.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnButtonPress.java index 8c0003db8..e214e8b96 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnButtonPress.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnButtonPress.java @@ -160,11 +160,12 @@ public class OnButtonPress extends RPCNotification { return (ButtonName) getObject(ButtonName.class, KEY_BUTTON_NAME); } /** - *

    Set the button's name

    + *

    Set the button's name

    * @param buttonName name of the button - */ - public void setButtonName( @NonNull ButtonName buttonName ) { + */ + public OnButtonPress setButtonName(@NonNull ButtonName buttonName) { setParameters(KEY_BUTTON_NAME, buttonName); + return this; } /**

    Returns {@linkplain ButtonPressMode}

    * @return ButtonPressMode whether this is a long or short button press event @@ -175,9 +176,10 @@ public class OnButtonPress extends RPCNotification { /** *

    Set the button press mode of the event

    * @param buttonPressMode indicates whether this is a short or long press - */ - public void setButtonPressMode( @NonNull ButtonPressMode buttonPressMode ) { + */ + public OnButtonPress setButtonPressMode(@NonNull ButtonPressMode buttonPressMode) { setParameters(KEY_BUTTON_PRESS_MODE, buttonPressMode); + return this; } /** @@ -185,8 +187,9 @@ public class OnButtonPress extends RPCNotification { * If ButtonName is "CUSTOM_BUTTON", this references the integer ID passed by a custom button. (e.g. softButton ID) * @param customButtonID CustomButtonID of the button */ - public void setCustomButtonID(Integer customButtonID) { + public OnButtonPress setCustomButtonID( Integer customButtonID) { setParameters(KEY_CUSTOM_BUTTON_ID, customButtonID); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnCommand.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnCommand.java index 1f474bd30..12695323d 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnCommand.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnCommand.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -118,11 +118,12 @@ public class OnCommand extends RPCNotification { return getInteger( KEY_CMD_ID ); } /** - *

    Sets a Command ID

    + *

    Sets a Command ID

    * @param cmdID an integer object representing a Command ID - */ - public void setCmdID( @NonNull Integer cmdID ) { + */ + public OnCommand setCmdID(@NonNull Integer cmdID) { setParameters(KEY_CMD_ID, cmdID); + return this; } /** *

    Returns a TriggerSource object which will be shown in the HMI

    @@ -133,10 +134,11 @@ public class OnCommand extends RPCNotification { } /** *

    Sets TriggerSource

    - *

    Indicates whether command was selected via VR or via a menu selection (using the OK button).

    + *

    Indicates whether command was selected via VR or via a menu selection (using the OK button).

    * @param triggerSource a TriggerSource object - */ - public void setTriggerSource( @NonNull TriggerSource triggerSource ) { + */ + public OnCommand setTriggerSource(@NonNull TriggerSource triggerSource) { setParameters(KEY_TRIGGER_SOURCE, triggerSource); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnDriverDistraction.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnDriverDistraction.java index dc0b1b5e7..d9c16e50d 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnDriverDistraction.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnDriverDistraction.java @@ -106,17 +106,19 @@ public class OnDriverDistraction extends RPCNotification { /** *

    Called to set the driver distraction state(i.e. whether driver distraction rules are in effect, or not)

    * @param state the current driver distraction state - */ - public void setState( @NonNull DriverDistractionState state ) { + */ + public OnDriverDistraction setState(@NonNull DriverDistractionState state) { setParameters(KEY_STATE, state); + return this; } /** *

    Called to set dismissible state of Lockscreen

    * @param isDismissible the Lockscreen's dismissibility */ - public void setLockscreenDismissibility(boolean isDismissible) { + public OnDriverDistraction setLockscreenDismissibility( boolean isDismissible) { setParameters(KEY_LOCKSCREEN_DISMISSIBLE, isDismissible); + return this; } /** @@ -131,8 +133,9 @@ public class OnDriverDistraction extends RPCNotification { * Called to set a warning message for the lockscreen * @param msg the message to be set */ - public void setLockscreenWarningMessage(String msg) { + public OnDriverDistraction setLockscreenWarningMessage( String msg) { setParameters(KEY_LOCKSCREEN_DISMISSIBLE_MSG, msg); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnHMIStatus.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnHMIStatus.java index ba2a5300b..52f3c4b84 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnHMIStatus.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnHMIStatus.java @@ -158,9 +158,10 @@ public class OnHMIStatus extends RPCNotification { /** *

    Set the HMILevel of OnHMIStatus

    * @param hmiLevel the HMILevel to set - */ - public void setHmiLevel( @NonNull HMILevel hmiLevel ) { + */ + public OnHMIStatus setHmiLevel(@NonNull HMILevel hmiLevel) { setParameters(KEY_HMI_LEVEL, hmiLevel); + return this; } /** *

    Get current state of audio streaming for the application

    @@ -172,9 +173,10 @@ public class OnHMIStatus extends RPCNotification { /** *

    Set the audio streaming state

    * @param audioStreamingState the state of audio streaming of the application - */ - public void setAudioStreamingState(@NonNull AudioStreamingState audioStreamingState ) { + */ + public OnHMIStatus setAudioStreamingState(@NonNull AudioStreamingState audioStreamingState) { setParameters(KEY_AUDIO_STREAMING_STATE, audioStreamingState); + return this; } /** *

    Get current state of video streaming for the application

    @@ -187,8 +189,9 @@ public class OnHMIStatus extends RPCNotification { *

    Set the video streaming state

    * @param videoStreamingState the state of video streaming of the application */ - public void setVideoStreamingState( VideoStreamingState videoStreamingState ) { + public OnHMIStatus setVideoStreamingState( VideoStreamingState videoStreamingState) { setParameters(KEY_VIDEO_STREAMING_STATE, videoStreamingState); + return this; } /** *

    Get the System Context

    @@ -199,11 +202,12 @@ public class OnHMIStatus extends RPCNotification { } /** *

    Set the System Context of OnHMIStatus

    - * @param systemContext Indicates that a user-initiated interaction is in-progress + * @param systemContext Indicates that a user-initiated interaction is in-progress * (VRSESSION or MENU), or not (MAIN) - */ - public void setSystemContext( @NonNull SystemContext systemContext ) { + */ + public OnHMIStatus setSystemContext(@NonNull SystemContext systemContext) { setParameters(KEY_SYSTEM_CONTEXT, systemContext); + return this; } /** *

    Query whether it's the first run

    @@ -215,9 +219,10 @@ public class OnHMIStatus extends RPCNotification { /** *

    Set the firstRun value

    * @param firstRun True if it is the first run, False or not - */ - public void setFirstRun(Boolean firstRun) { - this.firstRun = firstRun; + */ + public OnHMIStatus setFirstRun( Boolean firstRun) { + this.firstRun = firstRun; + return this; } /** *

    Set the windowID value

    @@ -226,8 +231,9 @@ public class OnHMIStatus extends RPCNotification { * See PredefinedWindows enum. * @since 6.0 */ - public void setWindowID(Integer windowID) { + public OnHMIStatus setWindowID( Integer windowID) { setParameters(KEY_WINDOW_ID, windowID); + return this; } /** *

    Get the windowID value

    diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnHashChange.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnHashChange.java index 0abe4c1a8..baea12ec3 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnHashChange.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnHashChange.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -99,8 +99,9 @@ public class OnHashChange extends RPCNotification { return getString(KEY_HASH_ID); } - public void setHashID(@NonNull String hashID) { + public OnHashChange setHashID(@NonNull String hashID) { setParameters(KEY_HASH_ID, hashID); - } + return this; + } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnInteriorVehicleData.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnInteriorVehicleData.java index 37c9d107c..a532421d9 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnInteriorVehicleData.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnInteriorVehicleData.java @@ -83,7 +83,8 @@ public class OnInteriorVehicleData extends RPCNotification { * * @param moduleData */ - public void setModuleData(@NonNull ModuleData moduleData) { + public OnInteriorVehicleData setModuleData(@NonNull ModuleData moduleData) { setParameters(KEY_MODULE_DATA, moduleData); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnKeyboardInput.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnKeyboardInput.java index d888c685b..3b2f71269 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnKeyboardInput.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnKeyboardInput.java @@ -107,12 +107,14 @@ public class OnKeyboardInput extends RPCNotification { return (KeyboardEvent) getObject(KeyboardEvent.class, KEY_EVENT); } - public void setEvent(@NonNull KeyboardEvent event) { + public OnKeyboardInput setEvent(@NonNull KeyboardEvent event) { setParameters(KEY_EVENT, event); + return this; } - public void setData(String data) { + public OnKeyboardInput setData( String data) { setParameters(KEY_DATA, data); + return this; } public String getData() { Object obj = getParameters(KEY_DATA); diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnLanguageChange.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnLanguageChange.java index bf72f5f19..cc58efaf6 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnLanguageChange.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnLanguageChange.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -116,11 +116,12 @@ public class OnLanguageChange extends RPCNotification { setHmiDisplayLanguage(hmiDisplayLanguage); } /** - *

    Sets language that current SDL voice engine(VR+TTS) use

    + *

    Sets language that current SDL voice engine(VR+TTS) use

    * @param language language that current SDL voice engine(VR+TTS) use - */ - public void setLanguage(@NonNull Language language) { + */ + public OnLanguageChange setLanguage(@NonNull Language language) { setParameters(KEY_LANGUAGE, language); + return this; } /** *

    Returns language that current SDL voice engine(VR+TTS) use

    @@ -130,11 +131,12 @@ public class OnLanguageChange extends RPCNotification { return (Language) getObject(Language.class, KEY_LANGUAGE); } /** - *

    Sets language that current display use

    + *

    Sets language that current display use

    * @param hmiDisplayLanguage language that current SDL voice engine(VR+TTS) use - */ - public void setHmiDisplayLanguage(@NonNull Language hmiDisplayLanguage) { + */ + public OnLanguageChange setHmiDisplayLanguage(@NonNull Language hmiDisplayLanguage) { setParameters(KEY_HMI_DISPLAY_LANGUAGE, hmiDisplayLanguage); + return this; } /** *

    Returns language that current display use

    diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnPermissionsChange.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnPermissionsChange.java index 41e003981..ebc95f699 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnPermissionsChange.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnPermissionsChange.java @@ -113,12 +113,13 @@ public class OnPermissionsChange extends RPCNotification { return (List) getObject(PermissionItem.class, KEY_PERMISSION_ITEM); } /** - *

    Sets PermissionItems describing change in permissions for a given set of RPCs

    + *

    Sets PermissionItems describing change in permissions for a given set of RPCs

    * @param permissionItem an List of PermissionItem describing change in permissions for a given set of RPCs - */ - public void setPermissionItem(@NonNull List permissionItem) { - setParameters(KEY_PERMISSION_ITEM, permissionItem); - } + */ + public OnPermissionsChange setPermissionItem(@NonNull List permissionItem) { + setParameters(KEY_PERMISSION_ITEM, permissionItem); + return this; + } /** * Returns the encryption requirement for this permission change @@ -132,7 +133,8 @@ public class OnPermissionsChange extends RPCNotification { * Sets the encryption requirement for this permission change * @param isRequired the boolean requirement to be set */ - public void setRequireEncryption(Boolean isRequired) { - setParameters(KEY_REQUIRE_ENCRYPTION, isRequired); - } + public OnPermissionsChange setRequireEncryption( Boolean isRequired) { + setParameters(KEY_REQUIRE_ENCRYPTION, isRequired); + return this; + } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnRCStatus.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnRCStatus.java index ffd7f03cc..e2f7831c9 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnRCStatus.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnRCStatus.java @@ -77,24 +77,27 @@ public class OnRCStatus extends RPCNotification { return (List) getObject(ModuleData.class, KEY_ALLOCATED_MODULES); } - public void setAllocatedModules(@NonNull List allocatedModules) { - setParameters(KEY_ALLOCATED_MODULES, allocatedModules); - } + public OnRCStatus setAllocatedModules(@NonNull List allocatedModules) { + setParameters(KEY_ALLOCATED_MODULES, allocatedModules); + return this; + } @SuppressWarnings("unchecked") public List getFreeModules() { return (List) getObject(ModuleData.class, KEY_FREE_MODULES); } - public void setFreeModules(@NonNull List freeModules) { - setParameters(KEY_FREE_MODULES, freeModules); - } + public OnRCStatus setFreeModules(@NonNull List freeModules) { + setParameters(KEY_FREE_MODULES, freeModules); + return this; + } public Boolean getAllowed() { return getBoolean(KEY_ALLOWED); } - public void setAllowed(Boolean allowed) { - setParameters(KEY_ALLOWED, allowed); - } + public OnRCStatus setAllowed( Boolean allowed) { + setParameters(KEY_ALLOWED, allowed); + return this; + } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnSystemCapabilityUpdated.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnSystemCapabilityUpdated.java index d01bf757d..98e9088c6 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnSystemCapabilityUpdated.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnSystemCapabilityUpdated.java @@ -65,9 +65,10 @@ public class OnSystemCapabilityUpdated extends RPCNotification { /** * @param systemCapability - The system capability that has been updated */ - public void setSystemCapability(@NonNull SystemCapability systemCapability){ - setParameters(KEY_SYSTEM_CAPABILITY, systemCapability); - } + public OnSystemCapabilityUpdated setSystemCapability(@NonNull SystemCapability systemCapability) { + setParameters(KEY_SYSTEM_CAPABILITY, systemCapability); + return this; + } /** * @return systemCapability - The system capability that has been updated diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnSystemRequest.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnSystemRequest.java index 5de6c922b..ff7f1b959 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnSystemRequest.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnSystemRequest.java @@ -231,9 +231,10 @@ public class OnSystemRequest extends RPCNotification { } @Override - public void setBulkData(byte[] bulkData){ + public OnSystemRequest setBulkData(byte[] bulkData){ super.setBulkData(bulkData); handleBulkData(bulkData); + return this; } @@ -246,12 +247,14 @@ public class OnSystemRequest extends RPCNotification { return this.body; } - public void setBody(String body) { + public OnSystemRequest setBody( String body) { this.body = body; + return this; } - public void setHeaders(Headers header) { + public OnSystemRequest setHeaders( Headers header) { this.headers = header; + return this; } public Headers getHeader() { @@ -262,16 +265,18 @@ public class OnSystemRequest extends RPCNotification { return (RequestType) getObject(RequestType.class, KEY_REQUEST_TYPE); } - public void setRequestType(@NonNull RequestType requestType) { + public OnSystemRequest setRequestType(@NonNull RequestType requestType) { setParameters(KEY_REQUEST_TYPE, requestType); + return this; } public String getRequestSubType() { return getString(KEY_REQUEST_SUB_TYPE); } - public void setRequestSubType(String requestSubType) { + public OnSystemRequest setRequestSubType( String requestSubType) { setParameters(KEY_REQUEST_SUB_TYPE, requestSubType); + return this; } public String getUrl() { @@ -290,28 +295,31 @@ public class OnSystemRequest extends RPCNotification { return null; } - public void setUrl(String url) { + public OnSystemRequest setUrl( String url) { setParameters(KEY_URL, url); + return this; } public FileType getFileType() { return (FileType) getObject(FileType.class, KEY_FILE_TYPE); } - public void setFileType(FileType fileType) { + public OnSystemRequest setFileType( FileType fileType) { setParameters(KEY_FILE_TYPE, fileType); + return this; } /** * @deprecated as of SmartDeviceLink 4.0 * @param offset of the data attached */ - public void setOffset(Integer offset) { - if(offset == null){ + public OnSystemRequest setOffset( Integer offset) { + if(offset == null){ setOffset((Long)null); }else{ setOffset(offset.longValue()); } + return this; } public Long getOffset() { @@ -329,8 +337,9 @@ public class OnSystemRequest extends RPCNotification { return null; } - public void setOffset(Long offset) { + public OnSystemRequest setOffset( Long offset) { setParameters(KEY_OFFSET, offset); + return this; } public Integer getTimeout() { @@ -347,9 +356,10 @@ public class OnSystemRequest extends RPCNotification { return null; } - public void setTimeout(Integer timeout) { + public OnSystemRequest setTimeout( Integer timeout) { setParameters(KEY_TIMEOUT, timeout); - } + return this; + } public Long getLength() { final Object o = getParameters(KEY_LENGTH); @@ -369,15 +379,17 @@ public class OnSystemRequest extends RPCNotification { * @deprecated as of SmartDeviceLink 4.0 * @param length of the data attached */ - public void setLength(Integer length) { - if(length == null){ + public OnSystemRequest setLength( Integer length) { + if(length == null){ setLength((Long)null); }else{ setLength(length.longValue()); } + return this; } - public void setLength(Long length) { + public OnSystemRequest setLength( Long length) { setParameters(KEY_LENGTH, length); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnTBTClientState.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnTBTClientState.java index c11eb1066..977e2afe9 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnTBTClientState.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnTBTClientState.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -104,8 +104,9 @@ public class OnTBTClientState extends RPCNotification { /** *

    Called to set the current state of TBT client

    * @param state current state of TBT client - */ - public void setState( TBTState state ) { + */ + public OnTBTClientState setState( TBTState state) { setParameters(KEY_STATE, state); + return this; } } // end-class diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnTouchEvent.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnTouchEvent.java index b898cc398..bdc83bfab 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnTouchEvent.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnTouchEvent.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -109,16 +109,18 @@ public class OnTouchEvent extends RPCNotification { setEvent(event); } - public void setType(@NonNull TouchType type) { - setParameters(KEY_TYPE, type); + public OnTouchEvent setType(@NonNull TouchType type) { + setParameters(KEY_TYPE, type); + return this; } public TouchType getType() { return (TouchType) getObject(TouchType.class, KEY_TYPE); } - public void setEvent(@NonNull List event) { - setParameters(KEY_EVENT, event); + public OnTouchEvent setEvent(@NonNull List event) { + setParameters(KEY_EVENT, event); + return this; } @SuppressWarnings("unchecked") diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnUpdateFile.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnUpdateFile.java index 2f1c63cf8..9a7b32c5c 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnUpdateFile.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnUpdateFile.java @@ -96,8 +96,9 @@ public class OnUpdateFile extends RPCNotification { * * @param fileName File reference name. */ - public void setFileName(@NonNull String fileName) { + public OnUpdateFile setFileName(@NonNull String fileName) { setParameters(KEY_FILE_NAME, fileName); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnUpdateSubMenu.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnUpdateSubMenu.java index e6fb05829..e430aa71d 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnUpdateSubMenu.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnUpdateSubMenu.java @@ -105,8 +105,9 @@ public class OnUpdateSubMenu extends RPCNotification { * * @param menuID This menuID must match a menuID in the current menu structure */ - public void setMenuID(@NonNull Integer menuID) { + public OnUpdateSubMenu setMenuID(@NonNull Integer menuID) { setParameters(KEY_MENU_ID, menuID); + return this; } /** @@ -125,8 +126,9 @@ public class OnUpdateSubMenu extends RPCNotification { * the menuID. These AddCommands will then be attached to the submenu and displayed if the * submenu is selected. */ - public void setUpdateSubCells(Boolean updateSubCells) { + public OnUpdateSubMenu setUpdateSubCells( Boolean updateSubCells) { setParameters(KEY_UPDATE_SUB_CELLS, updateSubCells); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnVehicleData.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnVehicleData.java index a5cbb162c..c134eba57 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnVehicleData.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnVehicleData.java @@ -386,22 +386,25 @@ public class OnVehicleData extends RPCNotification { public OnVehicleData(Hashtable hash) { super(hash); } - public void setGps(GPSData gps) { + public OnVehicleData setGps( GPSData gps) { setParameters(KEY_GPS, gps); + return this; } @SuppressWarnings("unchecked") public GPSData getGps() { return (GPSData) getObject(GPSData.class, KEY_GPS); } - public void setSpeed(Double speed) { + public OnVehicleData setSpeed( Double speed) { setParameters(KEY_SPEED, speed); + return this; } public Double getSpeed() { Object object = getParameters(KEY_SPEED); return SdlDataTypeConverter.objectToDouble(object); } - public void setRpm(Integer rpm) { + public OnVehicleData setRpm( Integer rpm) { setParameters(KEY_RPM, rpm); + return this; } public Integer getRpm() { return getInteger(KEY_RPM); @@ -414,8 +417,9 @@ public class OnVehicleData extends RPCNotification { * 7.0, please see fuelRange. */ @Deprecated - public void setFuelLevel(Double fuelLevel) { + public OnVehicleData setFuelLevel( Double fuelLevel) { setParameters(KEY_FUEL_LEVEL, fuelLevel); + return this; } /** @@ -430,29 +434,33 @@ public class OnVehicleData extends RPCNotification { return SdlDataTypeConverter.objectToDouble(object); } @Deprecated - public void setFuelLevelState(ComponentVolumeStatus fuelLevelState) { + public OnVehicleData setFuelLevelState( ComponentVolumeStatus fuelLevelState) { setParameters(KEY_FUEL_LEVEL_STATE, fuelLevelState); + return this; } @Deprecated public ComponentVolumeStatus getFuelLevelState() { return (ComponentVolumeStatus) getObject(ComponentVolumeStatus.class, KEY_FUEL_LEVEL_STATE); } - public void setInstantFuelConsumption(Double instantFuelConsumption) { + public OnVehicleData setInstantFuelConsumption( Double instantFuelConsumption) { setParameters(KEY_INSTANT_FUEL_CONSUMPTION, instantFuelConsumption); + return this; } public Double getInstantFuelConsumption() { Object object = getParameters(KEY_INSTANT_FUEL_CONSUMPTION); return SdlDataTypeConverter.objectToDouble(object); } - public void setExternalTemperature(Double externalTemperature) { + public OnVehicleData setExternalTemperature( Double externalTemperature) { setParameters(KEY_EXTERNAL_TEMPERATURE, externalTemperature); + return this; } public Double getExternalTemperature() { Object object = getParameters(KEY_EXTERNAL_TEMPERATURE); return SdlDataTypeConverter.objectToDouble(object); } - public void setVin(String vin) { + public OnVehicleData setVin( String vin) { setParameters(KEY_VIN, vin); + return this; } public String getVin() { return getString(KEY_VIN); @@ -465,8 +473,9 @@ public class OnVehicleData extends RPCNotification { * @deprecated in SmartDeviceLink 7.0.0 */ @Deprecated - public void setPrndl(PRNDL prndl) { + public OnVehicleData setPrndl( PRNDL prndl) { setParameters(KEY_PRNDL, prndl); + return this; } /** @@ -485,117 +494,134 @@ public class OnVehicleData extends RPCNotification { * * @param tirePressure See TireStatus */ - public void setTirePressure(TireStatus tirePressure) { + public OnVehicleData setTirePressure( TireStatus tirePressure) { setParameters(KEY_TIRE_PRESSURE, tirePressure); + return this; } @SuppressWarnings("unchecked") public TireStatus getTirePressure() { return (TireStatus) getObject(TireStatus.class, KEY_TIRE_PRESSURE); } - public void setOdometer(Integer odometer) { + public OnVehicleData setOdometer( Integer odometer) { setParameters(KEY_ODOMETER, odometer); + return this; } public Integer getOdometer() { return getInteger(KEY_ODOMETER); } - public void setBeltStatus(BeltStatus beltStatus) { + public OnVehicleData setBeltStatus( BeltStatus beltStatus) { setParameters(KEY_BELT_STATUS, beltStatus); + return this; } @SuppressWarnings("unchecked") public BeltStatus getBeltStatus() { return (BeltStatus) getObject(BeltStatus.class, KEY_BELT_STATUS); } - public void setBodyInformation(BodyInformation bodyInformation) { + public OnVehicleData setBodyInformation( BodyInformation bodyInformation) { setParameters(KEY_BODY_INFORMATION, bodyInformation); + return this; } @SuppressWarnings("unchecked") public BodyInformation getBodyInformation() { return (BodyInformation) getObject(BodyInformation.class, KEY_BODY_INFORMATION); } - public void setDeviceStatus(DeviceStatus deviceStatus) { + public OnVehicleData setDeviceStatus( DeviceStatus deviceStatus) { setParameters(KEY_DEVICE_STATUS, deviceStatus); + return this; } @SuppressWarnings("unchecked") public DeviceStatus getDeviceStatus() { return (DeviceStatus) getObject(DeviceStatus.class, KEY_DEVICE_STATUS); } - public void setDriverBraking(VehicleDataEventStatus driverBraking) { + public OnVehicleData setDriverBraking( VehicleDataEventStatus driverBraking) { setParameters(KEY_DRIVER_BRAKING, driverBraking); + return this; } public VehicleDataEventStatus getDriverBraking() { return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_DRIVER_BRAKING); } - public void setWiperStatus(WiperStatus wiperStatus) { + public OnVehicleData setWiperStatus( WiperStatus wiperStatus) { setParameters(KEY_WIPER_STATUS, wiperStatus); + return this; } public WiperStatus getWiperStatus() { return (WiperStatus) getObject(WiperStatus.class, KEY_WIPER_STATUS); } - public void setHeadLampStatus(HeadLampStatus headLampStatus) { + public OnVehicleData setHeadLampStatus( HeadLampStatus headLampStatus) { setParameters(KEY_HEAD_LAMP_STATUS, headLampStatus); + return this; } @SuppressWarnings("unchecked") public HeadLampStatus getHeadLampStatus() { return (HeadLampStatus) getObject(HeadLampStatus.class, KEY_HEAD_LAMP_STATUS); } - public void setEngineTorque(Double engineTorque) { + public OnVehicleData setEngineTorque( Double engineTorque) { setParameters(KEY_ENGINE_TORQUE, engineTorque); + return this; } public Double getEngineTorque() { Object object = getParameters(KEY_ENGINE_TORQUE); return SdlDataTypeConverter.objectToDouble(object); } - public void setEngineOilLife(Float engineOilLife) { + public OnVehicleData setEngineOilLife( Float engineOilLife) { setParameters(KEY_ENGINE_OIL_LIFE, engineOilLife); + return this; } public Float getEngineOilLife() { Object object = getParameters(KEY_ENGINE_OIL_LIFE); return SdlDataTypeConverter.objectToFloat(object); } - public void setAccPedalPosition(Double accPedalPosition) { + public OnVehicleData setAccPedalPosition( Double accPedalPosition) { setParameters(KEY_ACC_PEDAL_POSITION, accPedalPosition); + return this; } public Double getAccPedalPosition() { Object object = getParameters(KEY_ACC_PEDAL_POSITION); return SdlDataTypeConverter.objectToDouble(object); } - public void setSteeringWheelAngle(Double steeringWheelAngle) { + public OnVehicleData setSteeringWheelAngle( Double steeringWheelAngle) { setParameters(KEY_STEERING_WHEEL_ANGLE, steeringWheelAngle); + return this; } public Double getSteeringWheelAngle() { Object object = getParameters(KEY_STEERING_WHEEL_ANGLE); return SdlDataTypeConverter.objectToDouble(object); } - public void setECallInfo(ECallInfo eCallInfo) { + public OnVehicleData setECallInfo( ECallInfo eCallInfo) { setParameters(KEY_E_CALL_INFO, eCallInfo); + return this; } @SuppressWarnings("unchecked") public ECallInfo getECallInfo() { return (ECallInfo) getObject(ECallInfo.class, KEY_E_CALL_INFO); } - public void setAirbagStatus(AirbagStatus airbagStatus) { + public OnVehicleData setAirbagStatus( AirbagStatus airbagStatus) { setParameters(KEY_AIRBAG_STATUS, airbagStatus); + return this; } @SuppressWarnings("unchecked") public AirbagStatus getAirbagStatus() { return (AirbagStatus) getObject(AirbagStatus.class, KEY_AIRBAG_STATUS); } - public void setEmergencyEvent(EmergencyEvent emergencyEvent) { + public OnVehicleData setEmergencyEvent( EmergencyEvent emergencyEvent) { setParameters(KEY_EMERGENCY_EVENT, emergencyEvent); + return this; } @SuppressWarnings("unchecked") public EmergencyEvent getEmergencyEvent() { return (EmergencyEvent) getObject(EmergencyEvent.class, KEY_EMERGENCY_EVENT); } - public void setClusterModeStatus(ClusterModeStatus clusterModeStatus) { + public OnVehicleData setClusterModeStatus( ClusterModeStatus clusterModeStatus) { setParameters(KEY_CLUSTER_MODE_STATUS, clusterModeStatus); + return this; } @SuppressWarnings("unchecked") public ClusterModeStatus getClusterModeStatus() { return (ClusterModeStatus) getObject(ClusterModeStatus.class, KEY_CLUSTER_MODE_STATUS); } - public void setMyKey(MyKey myKey) { + public OnVehicleData setMyKey( MyKey myKey) { setParameters(KEY_MY_KEY, myKey); + return this; } @SuppressWarnings("unchecked") public MyKey getMyKey() { @@ -610,8 +636,9 @@ public class OnVehicleData extends RPCNotification { * {"array_min_size": 0, "array_max_size": 100} * @since SmartDeviceLink 5.0.0 */ - public void setFuelRange(List fuelRange) { + public OnVehicleData setFuelRange( List fuelRange) { setParameters(KEY_FUEL_RANGE, fuelRange); + return this; } /** @@ -632,8 +659,9 @@ public class OnVehicleData extends RPCNotification { * Sets turnSignal * @param turnSignal */ - public void setTurnSignal(TurnSignal turnSignal) { + public OnVehicleData setTurnSignal( TurnSignal turnSignal) { setParameters(KEY_TURN_SIGNAL, turnSignal); + return this; } /** @@ -649,8 +677,9 @@ public class OnVehicleData extends RPCNotification { * Sets electronicParkBrakeStatus * @param electronicParkBrakeStatus */ - public void setElectronicParkBrakeStatus(ElectronicParkBrakeStatus electronicParkBrakeStatus){ + public OnVehicleData setElectronicParkBrakeStatus( ElectronicParkBrakeStatus electronicParkBrakeStatus) { setParameters(KEY_ELECTRONIC_PARK_BRAKE_STATUS, electronicParkBrakeStatus); + return this; } /** @@ -665,8 +694,9 @@ public class OnVehicleData extends RPCNotification { * Sets a string value for the cloud app vehicle ID * @param cloudAppVehicleID a string value */ - public void setCloudAppVehicleID(String cloudAppVehicleID){ + public OnVehicleData setCloudAppVehicleID( String cloudAppVehicleID) { setParameters(KEY_CLOUD_APP_VEHICLE_ID, cloudAppVehicleID); + return this; } /** @@ -682,8 +712,9 @@ public class OnVehicleData extends RPCNotification { * @param vehicleDataName a String value * @param vehicleDataState a VehicleDataResult value */ - public void setOEMCustomVehicleData(String vehicleDataName, Object vehicleDataState){ + public OnVehicleData setOEMCustomVehicleData( String vehicleDataName, Object vehicleDataState) { setParameters(vehicleDataName, vehicleDataState); + return this; } /** @@ -700,8 +731,9 @@ public class OnVehicleData extends RPCNotification { * @param windowStatus See WindowStatus * @since SmartDeviceLink 7.0.0 */ - public void setWindowStatus(List windowStatus) { + public OnVehicleData setWindowStatus( List windowStatus) { setParameters(KEY_WINDOW_STATUS, windowStatus); + return this; } /** @@ -731,8 +763,9 @@ public class OnVehicleData extends RPCNotification { * @param stabilityControlsStatus See StabilityControlsStatus * @since SmartDeviceLink 7.0.0 */ - public void setStabilityControlsStatus(StabilityControlsStatus stabilityControlsStatus) { + public OnVehicleData setStabilityControlsStatus( StabilityControlsStatus stabilityControlsStatus) { setParameters(KEY_STABILITY_CONTROLS_STATUS, stabilityControlsStatus); + return this; } /** @@ -741,8 +774,9 @@ public class OnVehicleData extends RPCNotification { * @param handsOffSteering To indicate whether driver hands are off the steering wheel * @since SmartDeviceLink 7.0.0 */ - public void setHandsOffSteering(Boolean handsOffSteering) { + public OnVehicleData setHandsOffSteering( Boolean handsOffSteering) { setParameters(KEY_HANDS_OFF_STEERING, handsOffSteering); + return this; } /** @@ -760,8 +794,9 @@ public class OnVehicleData extends RPCNotification { * @param gearStatus See GearStatus * @since SmartDeviceLink 7.0.0 */ - public void setGearStatus(GearStatus gearStatus) { + public OnVehicleData setGearStatus( GearStatus gearStatus) { setParameters(KEY_GEAR_STATUS, gearStatus); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnWayPointChange.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnWayPointChange.java index f204b6998..27809115b 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnWayPointChange.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnWayPointChange.java @@ -60,7 +60,8 @@ public class OnWayPointChange extends RPCNotification { return (List) getObject(LocationDetails.class, KEY_WAY_POINTS); } - public void setWayPoints(@NonNull List wayPoints) { - setParameters(KEY_WAY_POINTS, wayPoints); - } + public OnWayPointChange setWayPoints(@NonNull List wayPoints) { + setParameters(KEY_WAY_POINTS, wayPoints); + return this; + } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/ParameterPermissions.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/ParameterPermissions.java index 4de4ad82c..e102f56c0 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/ParameterPermissions.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/ParameterPermissions.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -116,8 +116,9 @@ public class ParameterPermissions extends RPCStruct { * set a set of all parameters that are permitted for this given RPC. * @param allowed parameter that is permitted for this given RPC */ - public void setAllowed(@NonNull List allowed) { + public ParameterPermissions setAllowed(@NonNull List allowed) { setValue(KEY_ALLOWED, allowed); + return this; } /** @@ -133,7 +134,8 @@ public class ParameterPermissions extends RPCStruct { * set a set of all parameters that are prohibited for this given RPC. * @param userDisallowed paramter that is prohibited for this given RPC */ - public void setUserDisallowed(@NonNull List userDisallowed) { + public ParameterPermissions setUserDisallowed(@NonNull List userDisallowed) { setValue(KEY_USER_DISALLOWED, userDisallowed); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/PerformAppServiceInteraction.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/PerformAppServiceInteraction.java index a71f1b25a..af70ab1c0 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/PerformAppServiceInteraction.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/PerformAppServiceInteraction.java @@ -67,9 +67,10 @@ public class PerformAppServiceInteraction extends RPCRequest { * URI is correct. * @param serviceUri - */ - public void setServiceUri(@NonNull String serviceUri){ - setParameters(KEY_SERVICE_URI, serviceUri); - } + public PerformAppServiceInteraction setServiceUri(@NonNull String serviceUri) { + setParameters(KEY_SERVICE_URI, serviceUri); + return this; + } /** * Fully qualified URI based on a predetermined scheme provided by the app service. SDL makes no guarantee that this @@ -84,9 +85,10 @@ public class PerformAppServiceInteraction extends RPCRequest { * The service ID that the app consumer wishes to send this URI. * @param appServiceId - */ - public void setServiceID(@NonNull String appServiceId){ - setParameters(KEY_SERVICE_ID, appServiceId); - } + public PerformAppServiceInteraction setServiceID(@NonNull String appServiceId) { + setParameters(KEY_SERVICE_ID, appServiceId); + return this; + } /** * The service ID that the app consumer wishes to send this URI. @@ -100,9 +102,10 @@ public class PerformAppServiceInteraction extends RPCRequest { * This string is the appID of the app requesting the app service provider take the specific action. * @param originApp - */ - public void setOriginApp(@NonNull String originApp){ - setParameters(KEY_ORIGIN_APP, originApp); - } + public PerformAppServiceInteraction setOriginApp(@NonNull String originApp) { + setParameters(KEY_ORIGIN_APP, originApp); + return this; + } /** * This string is the appID of the app requesting the app service provider take the specific action. @@ -117,9 +120,10 @@ public class PerformAppServiceInteraction extends RPCRequest { * service of the destination's type. * @param requestServiceActive - */ - public void setRequestServiceActive(Boolean requestServiceActive){ - setParameters(KEY_REQUEST_SERVICE_ACTIVE, requestServiceActive); - } + public PerformAppServiceInteraction setRequestServiceActive( Boolean requestServiceActive) { + setParameters(KEY_REQUEST_SERVICE_ACTIVE, requestServiceActive); + return this; + } /** * This string is the appID of the app requesting the app service provider take the specific action. diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/PerformAppServiceInteractionResponse.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/PerformAppServiceInteractionResponse.java index cc6d5c5f4..481c91e17 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/PerformAppServiceInteractionResponse.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/PerformAppServiceInteractionResponse.java @@ -70,9 +70,10 @@ public class PerformAppServiceInteractionResponse extends RPCResponse { * The service can provide specific result strings to the consumer through this param. * @param serviceSpecificResult - */ - public void setServiceSpecificResult(String serviceSpecificResult){ - setParameters(KEY_SERVICE_SPECIFIC_RESULT, serviceSpecificResult); - } + public PerformAppServiceInteractionResponse setServiceSpecificResult( String serviceSpecificResult) { + setParameters(KEY_SERVICE_SPECIFIC_RESULT, serviceSpecificResult); + return this; + } /** * The service can provide specific result strings to the consumer through this param. diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/PerformAudioPassThru.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/PerformAudioPassThru.java index f9a4a29cb..0e125f8a7 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/PerformAudioPassThru.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/PerformAudioPassThru.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -170,7 +170,7 @@ public class PerformAudioPassThru extends RPCRequest { /** * Sets initial prompt which will be spoken before opening the audio pass * thru session by SDL - * + * * @param initialPrompt * a List value represents the initial prompt which * will be spoken before opening the audio pass thru session by @@ -185,8 +185,9 @@ public class PerformAudioPassThru extends RPCRequest { *
  • Array Maxsize: 100
  • * */ - public void setInitialPrompt(List initialPrompt) { - setParameters(KEY_INITIAL_PROMPT, initialPrompt); + public PerformAudioPassThru setInitialPrompt( List initialPrompt) { + setParameters(KEY_INITIAL_PROMPT, initialPrompt); + return this; } /** @@ -204,15 +205,16 @@ public class PerformAudioPassThru extends RPCRequest { /** * Sets a line of text displayed during audio capture - * + * * @param audioPassThruDisplayText1 *

    a String value representing the line of text displayed during * audio capture

    *

    * Notes: Maxlength=500 */ - public void setAudioPassThruDisplayText1(String audioPassThruDisplayText1) { - setParameters(KEY_AUDIO_PASS_THRU_DISPLAY_TEXT_1, audioPassThruDisplayText1); + public PerformAudioPassThru setAudioPassThruDisplayText1( String audioPassThruDisplayText1) { + setParameters(KEY_AUDIO_PASS_THRU_DISPLAY_TEXT_1, audioPassThruDisplayText1); + return this; } /** @@ -227,15 +229,16 @@ public class PerformAudioPassThru extends RPCRequest { /** * Sets a line of text displayed during audio capture - * + * * @param audioPassThruDisplayText2 *

    a String value representing the line of text displayed during * audio capture

    *

    * Notes: Maxlength=500 */ - public void setAudioPassThruDisplayText2(String audioPassThruDisplayText2) { - setParameters(KEY_AUDIO_PASS_THRU_DISPLAY_TEXT_2, audioPassThruDisplayText2); + public PerformAudioPassThru setAudioPassThruDisplayText2( String audioPassThruDisplayText2) { + setParameters(KEY_AUDIO_PASS_THRU_DISPLAY_TEXT_2, audioPassThruDisplayText2); + return this; } /** @@ -250,12 +253,13 @@ public class PerformAudioPassThru extends RPCRequest { /** * Sets a samplingRate - * + * * @param samplingRate * a SamplingRate value representing a 8 or 16 or 22 or 24 khz */ - public void setSamplingRate(@NonNull SamplingRate samplingRate) { - setParameters(KEY_SAMPLING_RATE, samplingRate); + public PerformAudioPassThru setSamplingRate(@NonNull SamplingRate samplingRate) { + setParameters(KEY_SAMPLING_RATE, samplingRate); + return this; } /** @@ -269,15 +273,16 @@ public class PerformAudioPassThru extends RPCRequest { /** * Sets the maximum duration of audio recording in milliseconds - * + * * @param maxDuration * an Integer value representing the maximum duration of audio * recording in millisecond *

    * Notes: Minvalue:1; Maxvalue:1000000 */ - public void setMaxDuration(@NonNull Integer maxDuration) { - setParameters(KEY_MAX_DURATION, maxDuration); + public PerformAudioPassThru setMaxDuration(@NonNull Integer maxDuration) { + setParameters(KEY_MAX_DURATION, maxDuration); + return this; } /** @@ -292,12 +297,13 @@ public class PerformAudioPassThru extends RPCRequest { /** * Sets the quality the audio is recorded - 8 bit or 16 bit - * + * * @param audioQuality * a BitsPerSample value representing 8 bit or 16 bit */ - public void setBitsPerSample(@NonNull BitsPerSample audioQuality) { - setParameters(KEY_BITS_PER_SAMPLE, audioQuality); + public PerformAudioPassThru setBitsPerSample(@NonNull BitsPerSample audioQuality) { + setParameters(KEY_BITS_PER_SAMPLE, audioQuality); + return this; } /** @@ -311,12 +317,13 @@ public class PerformAudioPassThru extends RPCRequest { /** * Sets an audioType - * + * * @param audioType * an audioType */ - public void setAudioType(@NonNull AudioType audioType) { - setParameters(KEY_AUDIO_TYPE, audioType); + public PerformAudioPassThru setAudioType(@NonNull AudioType audioType) { + setParameters(KEY_AUDIO_TYPE, audioType); + return this; } /** @@ -345,13 +352,14 @@ public class PerformAudioPassThru extends RPCRequest { * muted during the APT session * If not, the audio source will play without interruption. If omitted, the * value is set to true

    - * - * + * + * * @param muteAudio * a Boolean value representing if the current audio source * should be muted during the APT session */ - public void setMuteAudio(Boolean muteAudio) { - setParameters(KEY_MUTE_AUDIO, muteAudio); - } + public PerformAudioPassThru setMuteAudio( Boolean muteAudio) { + setParameters(KEY_MUTE_AUDIO, muteAudio); + return this; + } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/PerformInteraction.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/PerformInteraction.java index 129825f6c..99efbb2ef 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/PerformInteraction.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/PerformInteraction.java @@ -207,12 +207,13 @@ public class PerformInteraction extends RPCRequest { * be overlaid by the "Listening" prompt during the interaction. Text is * displayed on first line of multiline display, and is centered. If text * does not fit on line, it will be truncated - * + * * @param initialText * a String value that Displayed when the interaction begins - */ - public void setInitialText(@NonNull String initialText) { - setParameters(KEY_INITIAL_TEXT, initialText); + */ + public PerformInteraction setInitialText(@NonNull String initialText) { + setParameters(KEY_INITIAL_TEXT, initialText); + return this; } /** * Gets an An array of one or more TTSChunks that, taken together, specify @@ -228,13 +229,14 @@ public class PerformInteraction extends RPCRequest { /** * Sets An array of one or more TTSChunks that, taken together, specify what * is to be spoken to the user at the start of an interaction - * + * * @param initialPrompt * a List value, specify what is to be spoken to the * user at the start of an interaction - */ - public void setInitialPrompt(List initialPrompt) { - setParameters(KEY_INITIAL_PROMPT, initialPrompt); + */ + public PerformInteraction setInitialPrompt( List initialPrompt) { + setParameters(KEY_INITIAL_PROMPT, initialPrompt); + return this; } /** * Gets the Indicates mode that indicate how user selects interaction @@ -251,13 +253,14 @@ public class PerformInteraction extends RPCRequest { * Sets the Indicates mode that indicate how user selects interaction * choice. User can choose either by voice (VR_ONLY), by visual selection * from the menu (MANUAL_ONLY), or by either mode (BOTH) - * + * * @param interactionMode * indicate how user selects interaction choice (VR_ONLY, * MANUAL_ONLY or BOTH) - */ - public void setInteractionMode(@NonNull InteractionMode interactionMode) { - setParameters(KEY_INTERACTION_MODE, interactionMode); + */ + public PerformInteraction setInteractionMode(@NonNull InteractionMode interactionMode) { + setParameters(KEY_INTERACTION_MODE, interactionMode); + return this; } /** * Gets a List value representing an Array of one or more Choice @@ -274,16 +277,17 @@ public class PerformInteraction extends RPCRequest { /** * Sets a List representing an Array of one or more Choice Set * IDs. User can select any choice from any of the specified Choice Sets - * + * * @param interactionChoiceSetIDList * -a List representing an Array of one or more Choice * Set IDs. User can select any choice from any of the specified * Choice Sets *

    * Notes: Min Value: 0; Max Vlaue: 2000000000 - */ - public void setInteractionChoiceSetIDList(@NonNull List interactionChoiceSetIDList) { - setParameters(KEY_INTERACTION_CHOICE_SET_ID_LIST, interactionChoiceSetIDList); + */ + public PerformInteraction setInteractionChoiceSetIDList(@NonNull List interactionChoiceSetIDList) { + setParameters(KEY_INTERACTION_CHOICE_SET_ID_LIST, interactionChoiceSetIDList); + return this; } /** * Gets a List which taken together, specify the help phrase to @@ -307,14 +311,15 @@ public class PerformInteraction extends RPCRequest { *

    * Notes: The helpPrompt specified in * {@linkplain SetGlobalProperties} is not used by PerformInteraction - * + * * @param helpPrompt * a List which taken together, specify the help * phrase to be spoken when the user says "help" during the VR * session - */ - public void setHelpPrompt(List helpPrompt) { - setParameters(KEY_HELP_PROMPT, helpPrompt); + */ + public PerformInteraction setHelpPrompt( List helpPrompt) { + setParameters(KEY_HELP_PROMPT, helpPrompt); + return this; } /** * Gets An array of TTSChunks which, taken together, specify the phrase to @@ -333,13 +338,14 @@ public class PerformInteraction extends RPCRequest { *

    * Notes: The timeoutPrompt specified in * {@linkplain SetGlobalProperties} is not used by PerformInteraction - * + * * @param timeoutPrompt * a List specify the phrase to be spoken when the * listen times out during the VR session - */ - public void setTimeoutPrompt(List timeoutPrompt) { - setParameters(KEY_TIMEOUT_PROMPT, timeoutPrompt); + */ + public PerformInteraction setTimeoutPrompt( List timeoutPrompt) { + setParameters(KEY_TIMEOUT_PROMPT, timeoutPrompt); + return this; } /** * Gets a Integer value representing the amount of time, in milliseconds, @@ -360,16 +366,17 @@ public class PerformInteraction extends RPCRequest { * take place after SDL speaks the timeout prompt. If that times out as * well, the interaction will end completely. If omitted, the default is * 10000ms - * + * * @param timeout * an Integer value representing the amount of time, in * milliseconds, SDL will wait for the user to make a choice (VR * or Menu) *

    * Notes: Min Value: 5000; Max Value: 100000 - */ - public void setTimeout(Integer timeout) { - setParameters(KEY_TIMEOUT, timeout); + */ + public PerformInteraction setTimeout( Integer timeout) { + setParameters(KEY_TIMEOUT, timeout); + return this; } /** @@ -396,8 +403,9 @@ public class PerformInteraction extends RPCRequest { * Notes: Min=1; Max=100 * @since SmartDeviceLink 2.0 */ - public void setVrHelp(List vrHelp) { - setParameters(KEY_VR_HELP, vrHelp); + public PerformInteraction setVrHelp( List vrHelp) { + setParameters(KEY_VR_HELP, vrHelp); + return this; } /** @@ -418,8 +426,9 @@ public class PerformInteraction extends RPCRequest { * * @since SmartDeviceLink 3.0 */ - public void setInteractionLayout(LayoutMode interactionLayout ) { - setParameters(KEY_INTERACTION_LAYOUT, interactionLayout); + public PerformInteraction setInteractionLayout( LayoutMode interactionLayout) { + setParameters(KEY_INTERACTION_LAYOUT, interactionLayout); + return this; } /** @@ -440,7 +449,8 @@ public class PerformInteraction extends RPCRequest { * * @since SmartDeviceLink 6.0 */ - public void setCancelID(Integer cancelID) { - setParameters(KEY_CANCEL_ID, cancelID); - } + public PerformInteraction setCancelID( Integer cancelID) { + setParameters(KEY_CANCEL_ID, cancelID); + return this; + } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/PerformInteractionResponse.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/PerformInteractionResponse.java index 20fec4c85..9bd0e37a9 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/PerformInteractionResponse.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/PerformInteractionResponse.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -88,9 +88,10 @@ public class PerformInteractionResponse extends RPCResponse { /** * Sets the application-scoped identifier that uniquely identifies this choice. * @param choiceID Min: 0 Max: 65535 - */ - public void setChoiceID( Integer choiceID ) { + */ + public PerformInteractionResponse setChoiceID( Integer choiceID) { setParameters(KEY_CHOICE_ID, choiceID); + return this; } /** *

    Returns a TriggerSource object which will be shown in the HMI

    @@ -101,15 +102,17 @@ public class PerformInteractionResponse extends RPCResponse { } /** *

    Sets TriggerSource - * Indicates whether command was selected via VR or via a menu selection (using the OK button).

    + * Indicates whether command was selected via VR or via a menu selection (using the OK button).

    * @param triggerSource a TriggerSource object - */ - public void setTriggerSource( TriggerSource triggerSource ) { + */ + public PerformInteractionResponse setTriggerSource( TriggerSource triggerSource) { setParameters(KEY_TRIGGER_SOURCE, triggerSource); + return this; } - public void setManualTextEntry(String manualTextEntry) { + public PerformInteractionResponse setManualTextEntry( String manualTextEntry) { setParameters(KEY_MANUAL_TEXT_ENTRY, manualTextEntry); + return this; } public String getManualTextEntry() { return getString(KEY_MANUAL_TEXT_ENTRY); diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/PermissionItem.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/PermissionItem.java index ce0ec00a7..237fe84cc 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/PermissionItem.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/PermissionItem.java @@ -109,22 +109,25 @@ public class PermissionItem extends RPCStruct { public String getRpcName() { return getString(KEY_RPC_NAME); } - public void setRpcName(@NonNull String rpcName) { + public PermissionItem setRpcName(@NonNull String rpcName) { setValue(KEY_RPC_NAME, rpcName); + return this; } @SuppressWarnings("unchecked") public HMIPermissions getHMIPermissions() { return (HMIPermissions) getObject(HMIPermissions.class, KEY_HMI_PERMISSIONS); } - public void setHMIPermissions(@NonNull HMIPermissions hmiPermissions) { + public PermissionItem setHMIPermissions(@NonNull HMIPermissions hmiPermissions) { setValue(KEY_HMI_PERMISSIONS, hmiPermissions); + return this; } @SuppressWarnings("unchecked") public ParameterPermissions getParameterPermissions() { return (ParameterPermissions) getObject(ParameterPermissions.class, KEY_PARAMETER_PERMISSIONS); } - public void setParameterPermissions(@NonNull ParameterPermissions parameterPermissions) { + public PermissionItem setParameterPermissions(@NonNull ParameterPermissions parameterPermissions) { setValue(KEY_PARAMETER_PERMISSIONS, parameterPermissions); + return this; } /** @@ -139,7 +142,8 @@ public class PermissionItem extends RPCStruct { * Sets the encryption requirement for this item * @param isRequired the boolean requirement to be set */ - public void setRequireEncryption(Boolean isRequired) { + public PermissionItem setRequireEncryption( Boolean isRequired) { setValue(KEY_REQUIRE_ENCRYPTION, isRequired); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/PhoneCapability.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/PhoneCapability.java index 348f23f25..bffabdf09 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/PhoneCapability.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/PhoneCapability.java @@ -52,7 +52,8 @@ public class PhoneCapability extends RPCStruct { return getBoolean(KEY_DIALNUMBER_ENABLED); } - public void setDialNumberEnabled(Boolean dialNumberEnabled){ - setValue(KEY_DIALNUMBER_ENABLED, dialNumberEnabled); - } + public PhoneCapability setDialNumberEnabled( Boolean dialNumberEnabled) { + setValue(KEY_DIALNUMBER_ENABLED, dialNumberEnabled); + return this; + } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/PresetBankCapabilities.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/PresetBankCapabilities.java index 4b218e143..cb59d5f6c 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/PresetBankCapabilities.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/PresetBankCapabilities.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -86,8 +86,9 @@ public class PresetBankCapabilities extends RPCStruct { * set if Onscreen custom presets are available. * @param onScreenPresetsAvailable if Onscreen custom presets are available. */ - public void setOnScreenPresetsAvailable(@NonNull Boolean onScreenPresetsAvailable) { - setValue(KEY_ON_SCREEN_PRESETS_AVAILABLE, onScreenPresetsAvailable); + public PresetBankCapabilities setOnScreenPresetsAvailable(@NonNull Boolean onScreenPresetsAvailable) { + setValue(KEY_ON_SCREEN_PRESETS_AVAILABLE, onScreenPresetsAvailable); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/PublishAppService.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/PublishAppService.java index 9c121bc22..bc3e48e33 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/PublishAppService.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/PublishAppService.java @@ -79,9 +79,10 @@ public class PublishAppService extends RPCRequest { * If already published, the updated manifest for this service. * @param serviceManifest - the App Service Manifest */ - public void setAppServiceManifest(@NonNull AppServiceManifest serviceManifest){ - setParameters(KEY_APP_SERVICE_MANIFEST, serviceManifest); - } + public PublishAppService setAppServiceManifest(@NonNull AppServiceManifest serviceManifest) { + setParameters(KEY_APP_SERVICE_MANIFEST, serviceManifest); + return this; + } /** * The manifest of the service that wishes to be published. diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/PublishAppServiceResponse.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/PublishAppServiceResponse.java index 6fcddfd47..d52a310dd 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/PublishAppServiceResponse.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/PublishAppServiceResponse.java @@ -70,9 +70,10 @@ public class PublishAppServiceResponse extends RPCResponse { * for the published service. This will include the Core supplied service ID. * @param appServiceRecord - the App Service Record */ - public void setServiceRecord(AppServiceRecord appServiceRecord){ - setParameters(KEY_APP_SERVICE_RECORD, appServiceRecord); - } + public PublishAppServiceResponse setServiceRecord( AppServiceRecord appServiceRecord) { + setParameters(KEY_APP_SERVICE_RECORD, appServiceRecord); + return this; + } /** * If the request was successful, this object will be the current status of the service record diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/PutFile.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/PutFile.java index 2d01d9a47..da4adfb1d 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/PutFile.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/PutFile.java @@ -189,14 +189,15 @@ public class PutFile extends RPCRequest { /** * Sets a file reference name - * + * * @param sdlFileName * a String value representing a file reference name *

    * Notes: Maxlength=500, however the max file name length may vary based on remote filesystem limitations */ - public void setSdlFileName(@NonNull String sdlFileName) { + public PutFile setSdlFileName(@NonNull String sdlFileName) { setParameters(KEY_SDL_FILE_NAME, sdlFileName); + return this; } /** @@ -210,12 +211,13 @@ public class PutFile extends RPCRequest { /** * Sets file type - * + * * @param fileType * a FileType value representing a selected file type */ - public void setFileType(@NonNull FileType fileType) { + public PutFile setFileType(@NonNull FileType fileType) { setParameters(KEY_FILE_TYPE, fileType); + return this; } /** @@ -236,12 +238,13 @@ public class PutFile extends RPCRequest { * system, the app will receive a rejection and have to resend the file. If * omitted, the value will be set to false *

    - * + * * @param persistentFile * a Boolean value */ - public void setPersistentFile(Boolean persistentFile) { + public PutFile setPersistentFile( Boolean persistentFile) { setParameters(KEY_PERSISTENT_FILE, persistentFile); + return this; } /** @@ -254,8 +257,9 @@ public class PutFile extends RPCRequest { public Boolean getPersistentFile() { return getBoolean(KEY_PERSISTENT_FILE); } - public void setFileData(byte[] fileData) { + public PutFile setFileData( byte[] fileData) { setBulkData(fileData); + return this; } public byte[] getFileData() { return getBulkData(); @@ -265,19 +269,21 @@ public class PutFile extends RPCRequest { * @deprecated as of SmartDeviceLink 4.0 * @param offset Optional offset in bytes for resuming partial data chunks */ - public void setOffset(Integer offset) { - if(offset == null){ + public PutFile setOffset( Integer offset) { + if(offset == null){ setOffset((Long)null); }else{ setOffset(offset.longValue()); } + return this; } /** * @param offset Optional offset in bytes for resuming partial data chunks */ - public void setOffset(Long offset) { + public PutFile setOffset( Long offset) { setParameters(KEY_OFFSET, offset); + return this; } public Long getOffset() { @@ -300,20 +306,22 @@ public class PutFile extends RPCRequest { * @param length Optional length in bytes for resuming partial data chunks. If offset is set to 0, then length is * the total length of the file to be downloaded */ - public void setLength(Integer length) { - if(length == null){ + public PutFile setLength( Integer length) { + if(length == null){ setLength((Long)null); }else{ setLength(length.longValue()); } + return this; } /** * @param length Optional length in bytes for resuming partial data chunks. If offset is set to 0, then length is * the total length of the file to be downloaded */ - public void setLength(Long length) { + public PutFile setLength( Long length) { setParameters(KEY_LENGTH, length); + return this; } public Long getLength() { @@ -330,8 +338,9 @@ public class PutFile extends RPCRequest { return null; } - public void setSystemFile(Boolean systemFile) { + public PutFile setSystemFile( Boolean systemFile) { setParameters(KEY_SYSTEM_FILE, systemFile); + return this; } public Boolean getSystemFile() { @@ -348,15 +357,16 @@ public class PutFile extends RPCRequest { * CRC32 for it. * @param fileData - the file as a byte array */ - public void setCRC(byte[] fileData) { - if (fileData != null) { + public PutFile setCRC( byte[] fileData) { + if (fileData != null) { CRC32 crc = new CRC32(); crc.update(fileData); parameters.put(KEY_CRC, crc.getValue()); } else { parameters.remove(KEY_CRC); } - } + return this; + } /** * This assumes you have created your own CRC32 and are setting it with the file @@ -364,13 +374,14 @@ public class PutFile extends RPCRequest { * included in java.util * @param crc - the CRC32 of the file being set */ - public void setCRC(Long crc) { - if (crc != null) { + public PutFile setCRC( Long crc) { + if (crc != null) { parameters.put(KEY_CRC, crc); } else { parameters.remove(KEY_CRC); } - } + return this; + } /** * This returns the CRC, if it has been set, for the file object diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/PutFileResponse.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/PutFileResponse.java index e1bf71a43..1bc5a6887 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/PutFileResponse.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/PutFileResponse.java @@ -97,8 +97,9 @@ public class PutFileResponse extends RPCResponse { super.format(rpcVersion, formatParams); } - public void setSpaceAvailable(Integer spaceAvailable) { + public PutFileResponse setSpaceAvailable( Integer spaceAvailable) { setParameters(KEY_SPACE_AVAILABLE, spaceAvailable); + return this; } public Integer getSpaceAvailable() { diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/RGBColor.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/RGBColor.java index 0cac1951d..0a22821ac 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/RGBColor.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/RGBColor.java @@ -121,10 +121,11 @@ public class RGBColor extends RPCStruct{ * Sets the red value of the color object * @param color red value - min: 0; max: 255 */ - public void setRed(Integer color) { + public RGBColor setRed( Integer color) { if (color != null && color >= MIN_VALUE && color <= MAX_VALUE) { setValue(KEY_RED, color); } + return this; } /** @@ -139,10 +140,11 @@ public class RGBColor extends RPCStruct{ * Sets the green value of the color object * @param color green value - min: 0; max: 255 */ - public void setGreen(Integer color) { + public RGBColor setGreen( Integer color) { if (color != null && color >= MIN_VALUE && color <= MAX_VALUE) { setValue(KEY_GREEN, color); } + return this; } /** @@ -157,10 +159,11 @@ public class RGBColor extends RPCStruct{ * Sets the blue value of the color object * @param color blue value - min: 0; max: 255 */ - public void setBlue(Integer color) { + public RGBColor setBlue( Integer color) { if (color != null && color >= MIN_VALUE && color <= MAX_VALUE) { setValue(KEY_BLUE, color); } + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/RadioControlCapabilities.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/RadioControlCapabilities.java index 8ab552526..0b6297b68 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/RadioControlCapabilities.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/RadioControlCapabilities.java @@ -81,8 +81,9 @@ public class RadioControlCapabilities extends RPCStruct{ * The short friendly name of the climate control module. * It should not be used to identify a module by mobile application. */ - public void setModuleName(@NonNull String moduleName) { + public RadioControlCapabilities setModuleName(@NonNull String moduleName) { setValue(KEY_MODULE_NAME, moduleName); + return this; } /** @@ -101,8 +102,9 @@ public class RadioControlCapabilities extends RPCStruct{ * Availability of the control of enable/disable radio. * True: Available, False: Not Available, Not present: Not Available. */ - public void setRadioEnableAvailable(Boolean radioEnableAvailable) { + public RadioControlCapabilities setRadioEnableAvailable( Boolean radioEnableAvailable) { setValue(KEY_RADIO_ENABLE_AVAILABLE, radioEnableAvailable); + return this; } /** @@ -122,8 +124,9 @@ public class RadioControlCapabilities extends RPCStruct{ * Availability of the control of radio band. * True: Available, False: Not Available, Not present: Not Available. */ - public void setRadioBandAvailable(Boolean radioBandAvailable) { + public RadioControlCapabilities setRadioBandAvailable( Boolean radioBandAvailable) { setValue(KEY_RADIO_BAND_AVAILABLE, radioBandAvailable); + return this; } /** @@ -143,8 +146,9 @@ public class RadioControlCapabilities extends RPCStruct{ * Availability of the control of radio frequency. * True: Available, False: Not Available, Not present: Not Available. */ - public void setRadioFrequencyAvailable(Boolean radioFrequencyAvailable) { + public RadioControlCapabilities setRadioFrequencyAvailable( Boolean radioFrequencyAvailable) { setValue(KEY_RADIO_FREQUENCY_AVAILABLE, radioFrequencyAvailable); + return this; } /** @@ -164,8 +168,9 @@ public class RadioControlCapabilities extends RPCStruct{ * Availability of the control of HD radio channel. * True: Available, False: Not Available, Not present: Not Available. */ - public void setHdChannelAvailable(Boolean hdChannelAvailable) { + public RadioControlCapabilities setHdChannelAvailable( Boolean hdChannelAvailable) { setValue(KEY_HD_CHANNEL_AVAILABLE, hdChannelAvailable); + return this; } /** @@ -185,8 +190,9 @@ public class RadioControlCapabilities extends RPCStruct{ * Availability of the getting Radio Data System (RDS) data. * True: Available, False: Not Available, Not present: Not Available. */ - public void setRdsDataAvailable(Boolean rdsDataAvailable) { + public RadioControlCapabilities setRdsDataAvailable( Boolean rdsDataAvailable) { setValue(KEY_RDS_DATA_AVAILABLE, rdsDataAvailable); + return this; } /** @@ -207,8 +213,9 @@ public class RadioControlCapabilities extends RPCStruct{ * True: Available, False: Not Available, Not present: Not Available. */ @Deprecated - public void setAvailableHDsAvailable(Boolean availableHDsAvailable) { + public RadioControlCapabilities setAvailableHDsAvailable( Boolean availableHDsAvailable) { setValue(KEY_AVAILABLE_HDS_AVAILABLE, availableHDsAvailable); + return this; } /** @@ -229,8 +236,9 @@ public class RadioControlCapabilities extends RPCStruct{ * Availability of the list of available HD sub-channel indexes. * True: Available, False: Not Available, Not present: Not Available. */ - public void setAvailableHdChannelsAvailable(Boolean availableHdChannelsAvailable) { + public RadioControlCapabilities setAvailableHdChannelsAvailable( Boolean availableHdChannelsAvailable) { setValue(KEY_AVAILABLE_HD_CHANNELS_AVAILABLE, availableHdChannelsAvailable); + return this; } /** @@ -250,8 +258,9 @@ public class RadioControlCapabilities extends RPCStruct{ * Availability of the getting the Radio state. * True: Available, False: Not Available, Not present: Not Available. */ - public void setStateAvailable(Boolean stateAvailable) { + public RadioControlCapabilities setStateAvailable( Boolean stateAvailable) { setValue(KEY_STATE_AVAILABLE, stateAvailable); + return this; } /** @@ -271,8 +280,9 @@ public class RadioControlCapabilities extends RPCStruct{ * Availability of the getting the signal strength. * True: Available, False: Not Available, Not present: Not Available. */ - public void setSignalStrengthAvailable(Boolean signalStrengthAvailable) { + public RadioControlCapabilities setSignalStrengthAvailable( Boolean signalStrengthAvailable) { setValue(KEY_SIGNAL_STRENGTH_AVAILABLE, signalStrengthAvailable); + return this; } /** @@ -292,8 +302,9 @@ public class RadioControlCapabilities extends RPCStruct{ * Availability of the getting the signal Change Threshold. * True: Available, False: Not Available, Not present: Not Available. */ - public void setSignalChangeThresholdAvailable(Boolean signalChangeThresholdAvailable) { + public RadioControlCapabilities setSignalChangeThresholdAvailable( Boolean signalChangeThresholdAvailable) { setValue(KEY_SIGNAL_CHANGE_THRESHOLD_AVAILABLE, signalChangeThresholdAvailable); + return this; } /** @@ -312,8 +323,9 @@ public class RadioControlCapabilities extends RPCStruct{ * @param hdRadioEnableAvailable Availability of the control of enable/disable HD radio. * True: Available, False: Not Available, Not present: Not Available. */ - public void setHdRadioEnableAvailable(Boolean hdRadioEnableAvailable) { + public RadioControlCapabilities setHdRadioEnableAvailable( Boolean hdRadioEnableAvailable) { setValue(KEY_HD_RADIO_ENABLE_AVAILABLE, hdRadioEnableAvailable); + return this; } /** @@ -332,8 +344,9 @@ public class RadioControlCapabilities extends RPCStruct{ * @param siriusxmRadioAvailable Availability of sirius XM radio. * True: Available, False: Not Available, Not present: Not Available. */ - public void setSiriusXMRadioAvailable(Boolean siriusxmRadioAvailable) { + public RadioControlCapabilities setSiriusXMRadioAvailable( Boolean siriusxmRadioAvailable) { setValue(KEY_SIRIUS_XM_RADIO_AVAILABLE, siriusxmRadioAvailable); + return this; } /** @@ -352,8 +365,9 @@ public class RadioControlCapabilities extends RPCStruct{ * @param sisDataAvailable Availability of the getting HD radio Station Information Service (SIS) data. * True: Available, False: Not Available, Not present: Not Available. */ - public void setSisDataAvailable(Boolean sisDataAvailable) { + public RadioControlCapabilities setSisDataAvailable( Boolean sisDataAvailable) { setValue(KEY_SIS_DATA_AVAILABLE, sisDataAvailable); + return this; } /** @@ -370,8 +384,9 @@ public class RadioControlCapabilities extends RPCStruct{ * Sets ModuleInfo for this capability * @param info the ModuleInfo to be set */ - public void setModuleInfo(ModuleInfo info) { + public RadioControlCapabilities setModuleInfo( ModuleInfo info) { setValue(KEY_MODULE_INFO, info); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/RadioControlData.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/RadioControlData.java index 86cd9c962..433d7ad28 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/RadioControlData.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/RadioControlData.java @@ -70,8 +70,9 @@ public class RadioControlData extends RPCStruct{ * @param frequencyInteger * The integer part of the frequency i.e. for 101.7 this value should be 101 */ - public void setFrequencyInteger(Integer frequencyInteger) { + public RadioControlData setFrequencyInteger( Integer frequencyInteger) { setValue(KEY_FREQUENCY_INTEGER, frequencyInteger); + return this; } /** @@ -89,8 +90,9 @@ public class RadioControlData extends RPCStruct{ * @param frequencyFraction * The fractional part of the frequency i.e. for 101.7 is 7. */ - public void setFrequencyFraction(Integer frequencyFraction) { + public RadioControlData setFrequencyFraction( Integer frequencyFraction) { setValue(KEY_FREQUENCY_FRACTION, frequencyFraction); + return this; } /** @@ -108,8 +110,9 @@ public class RadioControlData extends RPCStruct{ * @param band * The radio band (AM|FM|XM) of the radio tuner. */ - public void setBand(RadioBand band) { + public RadioControlData setBand( RadioBand band) { setValue(KEY_BAND, band); + return this; } /** @@ -127,8 +130,9 @@ public class RadioControlData extends RPCStruct{ * @param rdsData * Read only parameter. See RdsData data type for details. */ - public void setRdsData(RdsData rdsData) { + public RadioControlData setRdsData( RdsData rdsData) { setValue(KEY_RDS_DATA, rdsData); + return this; } /** @@ -147,8 +151,9 @@ public class RadioControlData extends RPCStruct{ * Number of HD sub-channels if available. */ @Deprecated - public void setAvailableHDs(Integer availableHDs) { + public RadioControlData setAvailableHDs( Integer availableHDs) { setValue(KEY_AVAILABLE_HDS, availableHDs); + return this; } /** @@ -167,8 +172,9 @@ public class RadioControlData extends RPCStruct{ * @param hdChannel * Current HD sub-channel if available. */ - public void setHdChannel(Integer hdChannel) { + public RadioControlData setHdChannel( Integer hdChannel) { setValue(KEY_HD_CHANNEL, hdChannel); + return this; } /** @@ -186,8 +192,9 @@ public class RadioControlData extends RPCStruct{ * @param signalStrength * Read only parameter. Indicates the strength of receiving radio signal in current frequency. */ - public void setSignalStrength(Integer signalStrength) { + public RadioControlData setSignalStrength( Integer signalStrength) { setValue(KEY_SIGNAL_STRENGTH, signalStrength); + return this; } /** @@ -205,8 +212,9 @@ public class RadioControlData extends RPCStruct{ * @param signalChangeThreshold * If the signal strength falls below the set value for this parameter, the radio will tune to an alternative frequency. */ - public void setSignalChangeThreshold(Integer signalChangeThreshold) { + public RadioControlData setSignalChangeThreshold( Integer signalChangeThreshold) { setValue(KEY_SIGNAL_CHANGE_THRESHOLD, signalChangeThreshold); + return this; } /** @@ -226,8 +234,9 @@ public class RadioControlData extends RPCStruct{ * @param radioEnable * True if the radio is on, false is the radio is off. */ - public void setRadioEnable(Boolean radioEnable) { + public RadioControlData setRadioEnable( Boolean radioEnable) { setValue(KEY_RADIO_ENABLE, radioEnable); + return this; } /** @@ -246,8 +255,9 @@ public class RadioControlData extends RPCStruct{ * @param state * Read only parameter. See RadioState data type for details. */ - public void setState(RadioState state) { + public RadioControlData setState( RadioState state) { setValue(KEY_STATE, state); + return this; } /** @@ -264,8 +274,9 @@ public class RadioControlData extends RPCStruct{ * * @param hdRadioEnable True if the hd radio is on, false if the radio is off. */ - public void setHdRadioEnable(Boolean hdRadioEnable) { + public RadioControlData setHdRadioEnable( Boolean hdRadioEnable) { setValue(KEY_HD_RADIO_ENABLE, hdRadioEnable); + return this; } /** @@ -282,8 +293,9 @@ public class RadioControlData extends RPCStruct{ * * @param sisData Read-only Station Information Service (SIS) data provides basic information about the station such as call sign, as well as information not displayable to the consumer such as the station identification number. */ - public void setSisData(SisData sisData) { + public RadioControlData setSisData( SisData sisData) { setValue(KEY_SIS_DATA, sisData); + return this; } /** @@ -300,8 +312,9 @@ public class RadioControlData extends RPCStruct{ * * @param availableHdChannels List of available hd sub-channel indexes, empty list means no Hd channel is available, read-only. */ - public void setAvailableHdChannels(List availableHdChannels){ + public RadioControlData setAvailableHdChannels( List availableHdChannels) { setValue(KEY_AVAILABLE_HD_CHANNELS, availableHdChannels); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/RdsData.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/RdsData.java index 29326e550..223adebd7 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/RdsData.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/RdsData.java @@ -62,8 +62,9 @@ public class RdsData extends RPCStruct{ * @param programService * Program Service Name. */ - public void setProgramService(String programService) { + public RdsData setProgramService( String programService) { setValue(KEY_PS, programService); + return this; } /** @@ -81,8 +82,9 @@ public class RdsData extends RPCStruct{ * @param radioText * Radio Text. */ - public void setRadioText(String radioText) { + public RdsData setRadioText( String radioText) { setValue(KEY_RT, radioText); + return this; } /** @@ -100,8 +102,9 @@ public class RdsData extends RPCStruct{ * @param clockText * The clock text in UTC format as YYYY-MM-DDThh:mm:ss.sTZD. */ - public void setClockText(String clockText) { + public RdsData setClockText( String clockText) { setValue(KEY_CT, clockText); + return this; } /** @@ -119,8 +122,9 @@ public class RdsData extends RPCStruct{ * @param programIdentification * Program Identification - the call sign for the radio station. */ - public void setProgramIdentification(String programIdentification) { + public RdsData setProgramIdentification( String programIdentification) { setValue(KEY_PI, programIdentification); + return this; } /** @@ -138,8 +142,9 @@ public class RdsData extends RPCStruct{ * @param region * Region. */ - public void setRegion(String region) { + public RdsData setRegion( String region) { setValue(KEY_REG, region); + return this; } /** @@ -157,8 +162,9 @@ public class RdsData extends RPCStruct{ * @param trafficProgram * Traffic Program Identification - Identifies a station that offers traffic. */ - public void setTrafficProgram(Boolean trafficProgram) { + public RdsData setTrafficProgram( Boolean trafficProgram) { setValue(KEY_TP, trafficProgram); + return this; } /** @@ -176,8 +182,9 @@ public class RdsData extends RPCStruct{ * @param trafficAnnouncement * Traffic Announcement Identification - Indicates an ongoing traffic announcement. */ - public void setTrafficAnnouncement(Boolean trafficAnnouncement) { + public RdsData setTrafficAnnouncement( Boolean trafficAnnouncement) { setValue(KEY_TA, trafficAnnouncement); + return this; } /** @@ -195,8 +202,9 @@ public class RdsData extends RPCStruct{ * @param programType * The program type - The region should be used to differentiate between EU and North America program types. */ - public void setProgramType(Integer programType) { + public RdsData setProgramType( Integer programType) { setValue(KEY_PTY, programType); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/ReadDID.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/ReadDID.java index 553922e0f..b72524eeb 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/ReadDID.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/ReadDID.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -139,14 +139,15 @@ public class ReadDID extends RPCRequest { /** * Sets an ID of the vehicle module - * + * * @param ecuName * an Integer value representing the ID of the vehicle module *

    * Notes: Minvalue:0; Maxvalue:65535 */ - public void setEcuName(@NonNull Integer ecuName) { - setParameters(KEY_ECU_NAME, ecuName); + public ReadDID setEcuName(@NonNull Integer ecuName) { + setParameters(KEY_ECU_NAME, ecuName); + return this; } /** @@ -161,7 +162,7 @@ public class ReadDID extends RPCRequest { /** * Sets raw data from vehicle data DID location(s) - * + * * @param didLocation * a List value representing raw data from vehicle * data DID location(s) @@ -172,8 +173,9 @@ public class ReadDID extends RPCRequest { *
  • ArrayMin:0; ArrayMax:1000
  • * */ - public void setDidLocation(@NonNull List didLocation) { - setParameters(KEY_DID_LOCATION, didLocation); + public ReadDID setDidLocation(@NonNull List didLocation) { + setParameters(KEY_DID_LOCATION, didLocation); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/ReadDIDResponse.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/ReadDIDResponse.java index 41694c446..61158da36 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/ReadDIDResponse.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/ReadDIDResponse.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -64,8 +64,9 @@ public class ReadDIDResponse extends RPCResponse { setSuccess(success); setResultCode(resultCode); } - public void setDidResult(List didResult) { - setParameters(KEY_DID_RESULT, didResult); + public ReadDIDResponse setDidResult( List didResult) { + setParameters(KEY_DID_RESULT, didResult); + return this; } @SuppressWarnings("unchecked") public List getDidResult() { diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/Rectangle.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/Rectangle.java index fc7f16c26..69f6c26ef 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/Rectangle.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/Rectangle.java @@ -64,9 +64,10 @@ public class Rectangle extends RPCStruct { /** * Set the X-coordinate pixel in of the user control that starts in the upper left corner */ - public void setX(@NonNull Float x) { - setValue(KEY_X, x); - } + public Rectangle setX(@NonNull Float x) { + setValue(KEY_X, x); + return this; + } /** * @return the X-coordinate pixel of the user control that starts in the upper left corner @@ -78,9 +79,10 @@ public class Rectangle extends RPCStruct { /** * Set the Y-coordinate pixel of the user control that starts in the upper left corner */ - public void setY(@NonNull Float y) { - setValue(KEY_Y, y); - } + public Rectangle setY(@NonNull Float y) { + setValue(KEY_Y, y); + return this; + } /** * @return the Y-coordinate pixel of the user control that starts in the upper left corner @@ -92,9 +94,10 @@ public class Rectangle extends RPCStruct { /** * Set the width in pixels of the user control's bounding rectangle in pixels */ - public void setWidth(@NonNull Float width) { - setValue(KEY_WIDTH, width); - } + public Rectangle setWidth(@NonNull Float width) { + setValue(KEY_WIDTH, width); + return this; + } /** * @return the width in pixels of the user control's bounding rectangle in pixels @@ -106,9 +109,10 @@ public class Rectangle extends RPCStruct { /** * The height in pixels of the user control's bounding rectangle */ - public void setHeight(@NonNull Float height) { - setValue(KEY_HEIGHT, height); - } + public Rectangle setHeight(@NonNull Float height) { + setValue(KEY_HEIGHT, height); + return this; + } /** * @return the width in pixels of the user control's bounding rectangle in pixels diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/RegisterAppInterface.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/RegisterAppInterface.java index ee741f7c1..ae4c0e874 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/RegisterAppInterface.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/RegisterAppInterface.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -358,7 +358,7 @@ public class RegisterAppInterface extends RPCRequest { } /** * Sets the version of the SDL® SmartDeviceLink interface - * + * * @param sdlMsgVersion * a SdlMsgVersion object representing version of the SDL® * SmartDeviceLink interface @@ -375,9 +375,10 @@ public class RegisterAppInterface extends RPCRequest { * number sent from the app to SDL® (in RegisterAppInterface * request) is ignored by SDL® * - */ - public void setSdlMsgVersion(@NonNull SdlMsgVersion sdlMsgVersion) { + */ + public RegisterAppInterface setSdlMsgVersion(@NonNull SdlMsgVersion sdlMsgVersion) { setParameters(KEY_SDL_MSG_VERSION, sdlMsgVersion); + return this; } @SuppressWarnings("unchecked") @@ -385,9 +386,10 @@ public class RegisterAppInterface extends RPCRequest { return (DeviceInfo) getObject(DeviceInfo.class, KEY_DEVICE_INFO); } - public void setDeviceInfo(DeviceInfo deviceInfo) { - setParameters(KEY_DEVICE_INFO, deviceInfo); - } + public RegisterAppInterface setDeviceInfo( DeviceInfo deviceInfo) { + setParameters(KEY_DEVICE_INFO, deviceInfo); + return this; + } /** * Gets Mobile Application's Name * @@ -400,7 +402,7 @@ public class RegisterAppInterface extends RPCRequest { * Sets Mobile Application's Name, This name is displayed in the SDL® * Mobile Applications menu. It also serves as the unique identifier of the * application for SmartDeviceLink - * + * * @param appName * a String value representing the Mobile Application's Name *

    @@ -411,9 +413,10 @@ public class RegisterAppInterface extends RPCRequest { * the name or any synonym of any currently-registered * application * - */ - public void setAppName(@NonNull String appName) { - setParameters(KEY_APP_NAME, appName); + */ + public RegisterAppInterface setAppName(@NonNull String appName) { + setParameters(KEY_APP_NAME, appName); + return this; } /** @@ -428,7 +431,7 @@ public class RegisterAppInterface extends RPCRequest { } /** - * + * * @param ttsName * a List value represeting the TTS Name *

    @@ -445,8 +448,9 @@ public class RegisterAppInterface extends RPCRequest { * * @since SmartDeviceLink 2.0 */ - public void setTtsName(List ttsName) { - setParameters(KEY_TTS_NAME, ttsName); + public RegisterAppInterface setTtsName( List ttsName) { + setParameters(KEY_TTS_NAME, ttsName); + return this; } /** * Gets a String representing an abbreviated version of the mobile @@ -463,7 +467,7 @@ public class RegisterAppInterface extends RPCRequest { * Sets a String representing an abbreviated version of the mobile * applincation's name (if necessary) that will be displayed on the NGN * media screen - * + * * @param ngnMediaScreenAppName * a String value representing an abbreviated version of the * mobile applincation's name @@ -474,9 +478,10 @@ public class RegisterAppInterface extends RPCRequest { *
  • If not provided, value will be derived from appName * truncated to 5 characters
  • * - */ - public void setNgnMediaScreenAppName(String ngnMediaScreenAppName) { - setParameters(KEY_NGN_MEDIA_SCREEN_APP_NAME, ngnMediaScreenAppName); + */ + public RegisterAppInterface setNgnMediaScreenAppName( String ngnMediaScreenAppName) { + setParameters(KEY_NGN_MEDIA_SCREEN_APP_NAME, ngnMediaScreenAppName); + return this; } /** * Gets the List representing the an array of 1-100 elements, each @@ -493,7 +498,7 @@ public class RegisterAppInterface extends RPCRequest { /** * Sets a vrSynonyms representing the an array of 1-100 elements, each * element containing a voice-recognition synonym - * + * * @param vrSynonyms * a List value representing the an array of 1-100 * elements @@ -506,9 +511,10 @@ public class RegisterAppInterface extends RPCRequest { * the name or any synonym of any currently-registered * application * - */ - public void setVrSynonyms(List vrSynonyms) { - setParameters(KEY_VR_SYNONYMS, vrSynonyms); + */ + public RegisterAppInterface setVrSynonyms( List vrSynonyms) { + setParameters(KEY_VR_SYNONYMS, vrSynonyms); + return this; } /** * Gets a Boolean representing MediaApplication @@ -522,12 +528,13 @@ public class RegisterAppInterface extends RPCRequest { /** * Sets a Boolean to indicate a mobile application that is a media * application or not - * + * * @param isMediaApplication * a Boolean value - */ - public void setIsMediaApplication(@NonNull Boolean isMediaApplication) { - setParameters(KEY_IS_MEDIA_APPLICATION, isMediaApplication); + */ + public RegisterAppInterface setIsMediaApplication(@NonNull Boolean isMediaApplication) { + setParameters(KEY_IS_MEDIA_APPLICATION, isMediaApplication); + return this; } /** * Gets a Language enumeration indicating what language the application @@ -541,14 +548,15 @@ public class RegisterAppInterface extends RPCRequest { /** * Sets an enumeration indicating what language the application intends to * use for user interaction (Display, TTS and VR) - * + * * @param languageDesired * a Language Enumeration - * - * - */ - public void setLanguageDesired(@NonNull Language languageDesired) { - setParameters(KEY_LANGUAGE_DESIRED, languageDesired); + * + * + */ + public RegisterAppInterface setLanguageDesired(@NonNull Language languageDesired) { + setParameters(KEY_LANGUAGE_DESIRED, languageDesired); + return this; } /** @@ -567,12 +575,13 @@ public class RegisterAppInterface extends RPCRequest { /** * Sets an enumeration indicating what language the application intends to * use for user interaction ( Display) - * + * * @param hmiDisplayLanguageDesired the requested language to be used on the HMI/Display * @since SmartDeviceLink 2.0 */ - public void setHmiDisplayLanguageDesired(@NonNull Language hmiDisplayLanguageDesired) { - setParameters(KEY_HMI_DISPLAY_LANGUAGE_DESIRED, hmiDisplayLanguageDesired); + public RegisterAppInterface setHmiDisplayLanguageDesired(@NonNull Language hmiDisplayLanguageDesired) { + setParameters(KEY_HMI_DISPLAY_LANGUAGE_DESIRED, hmiDisplayLanguageDesired); + return this; } /** @@ -594,7 +603,7 @@ public class RegisterAppInterface extends RPCRequest { * Sets a a list of all applicable app types stating which classifications * to be given to the app. e.g. for platforms , like GEN2, this will * determine which "corner(s)" the app can populate - * + * * @param appHMIType * a List *

    @@ -605,16 +614,18 @@ public class RegisterAppInterface extends RPCRequest { * * @since SmartDeviceLink 2.0 */ - public void setAppHMIType(List appHMIType) { - setParameters(KEY_APP_HMI_TYPE, appHMIType); + public RegisterAppInterface setAppHMIType( List appHMIType) { + setParameters(KEY_APP_HMI_TYPE, appHMIType); + return this; } public String getHashID() { return getString(KEY_HASH_ID); } - public void setHashID(String hashID) { - setParameters(KEY_HASH_ID, hashID); + public RegisterAppInterface setHashID( String hashID) { + setParameters(KEY_HASH_ID, hashID); + return this; } /** @@ -629,9 +640,10 @@ public class RegisterAppInterface extends RPCRequest { * Sets detailed information about the registered application * @param appInfo - detailed information about the registered application */ - public void setAppInfo(AppInfo appInfo) { - setParameters(KEY_APP_INFO, appInfo); - } + public RegisterAppInterface setAppInfo( AppInfo appInfo) { + setParameters(KEY_APP_INFO, appInfo); + return this; + } /** * Gets the unique ID, which an app will be given when approved @@ -654,13 +666,14 @@ public class RegisterAppInterface extends RPCRequest { * Notes: Maxlength = 100 * @since SmartDeviceLink 2.0 */ - public void setAppID(@NonNull String appID) { - if (appID != null) { + public RegisterAppInterface setAppID(@NonNull String appID) { + if (appID != null) { setParameters(KEY_APP_ID, appID.toLowerCase()); } else { setParameters(KEY_APP_ID, appID); } - } + return this; + } /** * Gets the unique ID, which an app will be given when approved @@ -683,8 +696,8 @@ public class RegisterAppInterface extends RPCRequest { * Notes: Maxlength = 100 * @since SmartDeviceLink 5.0 */ - public void setFullAppID(String fullAppID) { - if (fullAppID != null) { + public RegisterAppInterface setFullAppID( String fullAppID) { + if (fullAppID != null) { fullAppID = fullAppID.toLowerCase(); setParameters(KEY_FULL_APP_ID, fullAppID); String appID; @@ -697,7 +710,8 @@ public class RegisterAppInterface extends RPCRequest { } else { setParameters(KEY_FULL_APP_ID, null); } - } + return this; + } @Override public void format(Version rpcVersion, boolean formatParams) { @@ -727,9 +741,10 @@ public class RegisterAppInterface extends RPCRequest { * used for day color scheme * @since SmartDeviceLink 5.0 */ - public void setDayColorScheme(TemplateColorScheme templateColorScheme){ - setParameters(KEY_DAY_COLOR_SCHEME, templateColorScheme); - } + public RegisterAppInterface setDayColorScheme( TemplateColorScheme templateColorScheme) { + setParameters(KEY_DAY_COLOR_SCHEME, templateColorScheme); + return this; + } /** * Gets the color scheme that is currently used for night @@ -749,7 +764,8 @@ public class RegisterAppInterface extends RPCRequest { * used for night color scheme * @since SmartDeviceLink 5.0 */ - public void setNightColorScheme(TemplateColorScheme templateColorScheme){ - setParameters(KEY_NIGHT_COLOR_SCHEME, templateColorScheme); - } + public RegisterAppInterface setNightColorScheme( TemplateColorScheme templateColorScheme) { + setParameters(KEY_NIGHT_COLOR_SCHEME, templateColorScheme); + return this; + } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/RegisterAppInterfaceResponse.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/RegisterAppInterfaceResponse.java index 449056871..967737c85 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/RegisterAppInterfaceResponse.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/RegisterAppInterfaceResponse.java @@ -143,7 +143,7 @@ public class RegisterAppInterfaceResponse extends RPCResponse { /** * Sets the version of the SDL® SmartDeviceLink interface - * + * * @param sdlMsgVersion * a SdlMsgVersion object representing version of the SDL® * SmartDeviceLink interface @@ -160,8 +160,9 @@ public class RegisterAppInterfaceResponse extends RPCResponse { * number sent from the app to SDL® (in RegisterAppInterface * request) is ignored by SDL® */ - public void setSdlMsgVersion(SdlMsgVersion sdlMsgVersion) { - setParameters(KEY_SDL_MSG_VERSION, sdlMsgVersion); + public RegisterAppInterfaceResponse setSdlMsgVersion( SdlMsgVersion sdlMsgVersion) { + setParameters(KEY_SDL_MSG_VERSION, sdlMsgVersion); + return this; } /** @@ -177,14 +178,15 @@ public class RegisterAppInterfaceResponse extends RPCResponse { /** * Sets an enumeration indicating what language the application intends to * use for user interaction (Display, TTS and VR) - * + * * @param language * a Language Enumeration - * - * + * + * */ - public void setLanguage(Language language) { - setParameters(KEY_LANGUAGE, language); + public RegisterAppInterfaceResponse setLanguage( Language language) { + setParameters(KEY_LANGUAGE, language); + return this; } /** @@ -203,12 +205,13 @@ public class RegisterAppInterfaceResponse extends RPCResponse { /** * Sets an enumeration indicating what language the application intends to * use for user interaction ( Display) - * + * * @param hmiDisplayLanguage * @since SmartDeviceLink 2.0 */ - public void setHmiDisplayLanguage(Language hmiDisplayLanguage) { - setParameters(KEY_HMI_DISPLAY_LANGUAGE, hmiDisplayLanguage); + public RegisterAppInterfaceResponse setHmiDisplayLanguage( Language hmiDisplayLanguage) { + setParameters(KEY_HMI_DISPLAY_LANGUAGE, hmiDisplayLanguage); + return this; } /** @@ -226,8 +229,9 @@ public class RegisterAppInterfaceResponse extends RPCResponse { * @param displayCapabilities */ @Deprecated - public void setDisplayCapabilities(DisplayCapabilities displayCapabilities) { - setParameters(KEY_DISPLAY_CAPABILITIES, displayCapabilities); + public RegisterAppInterfaceResponse setDisplayCapabilities( DisplayCapabilities displayCapabilities) { + setParameters(KEY_DISPLAY_CAPABILITIES, displayCapabilities); + return this; } /** @@ -245,8 +249,9 @@ public class RegisterAppInterfaceResponse extends RPCResponse { * @param buttonCapabilities */ @Deprecated - public void setButtonCapabilities(List buttonCapabilities) { - setParameters(KEY_BUTTON_CAPABILITIES, buttonCapabilities); + public RegisterAppInterfaceResponse setButtonCapabilities( List buttonCapabilities) { + setParameters(KEY_BUTTON_CAPABILITIES, buttonCapabilities); + return this; } /** * Gets getSoftButtonCapabilities set when application interface is registered. @@ -263,8 +268,9 @@ public class RegisterAppInterfaceResponse extends RPCResponse { * @param softButtonCapabilities */ @Deprecated - public void setSoftButtonCapabilities(List softButtonCapabilities) { - setParameters(KEY_SOFT_BUTTON_CAPABILITIES, softButtonCapabilities); + public RegisterAppInterfaceResponse setSoftButtonCapabilities( List softButtonCapabilities) { + setParameters(KEY_SOFT_BUTTON_CAPABILITIES, softButtonCapabilities); + return this; } /** @@ -282,8 +288,9 @@ public class RegisterAppInterfaceResponse extends RPCResponse { * @param presetBankCapabilities */ @Deprecated - public void setPresetBankCapabilities(PresetBankCapabilities presetBankCapabilities) { - setParameters(KEY_PRESET_BANK_CAPABILITIES, presetBankCapabilities); + public RegisterAppInterfaceResponse setPresetBankCapabilities( PresetBankCapabilities presetBankCapabilities) { + setParameters(KEY_PRESET_BANK_CAPABILITIES, presetBankCapabilities); + return this; } /** @@ -299,8 +306,9 @@ public class RegisterAppInterfaceResponse extends RPCResponse { * Sets hmiZoneCapabilities * @param hmiZoneCapabilities */ - public void setHmiZoneCapabilities(List hmiZoneCapabilities) { - setParameters(KEY_HMI_ZONE_CAPABILITIES, hmiZoneCapabilities); + public RegisterAppInterfaceResponse setHmiZoneCapabilities( List hmiZoneCapabilities) { + setParameters(KEY_HMI_ZONE_CAPABILITIES, hmiZoneCapabilities); + return this; } /** @@ -325,8 +333,9 @@ public class RegisterAppInterfaceResponse extends RPCResponse { * Sets speechCapabilities * @param speechCapabilities */ - public void setSpeechCapabilities(List speechCapabilities) { - setParameters(KEY_SPEECH_CAPABILITIES, speechCapabilities); + public RegisterAppInterfaceResponse setSpeechCapabilities( List speechCapabilities) { + setParameters(KEY_SPEECH_CAPABILITIES, speechCapabilities); + return this; } @@ -335,8 +344,9 @@ public class RegisterAppInterfaceResponse extends RPCResponse { return (List) getObject(PrerecordedSpeech.class, KEY_PRERECORDED_SPEECH); } - public void setPrerecordedSpeech(List prerecordedSpeech) { - setParameters(KEY_PRERECORDED_SPEECH, prerecordedSpeech); + public RegisterAppInterfaceResponse setPrerecordedSpeech( List prerecordedSpeech) { + setParameters(KEY_PRERECORDED_SPEECH, prerecordedSpeech); + return this; } @@ -353,8 +363,9 @@ public class RegisterAppInterfaceResponse extends RPCResponse { * Sets VrCapabilities * @param vrCapabilities */ - public void setVrCapabilities(List vrCapabilities) { - setParameters(KEY_VR_CAPABILITIES, vrCapabilities); + public RegisterAppInterfaceResponse setVrCapabilities( List vrCapabilities) { + setParameters(KEY_VR_CAPABILITIES, vrCapabilities); + return this; } /** @@ -370,8 +381,9 @@ public class RegisterAppInterfaceResponse extends RPCResponse { * Sets vehicleType * @param vehicleType */ - public void setVehicleType(VehicleType vehicleType) { - setParameters(KEY_VEHICLE_TYPE, vehicleType); + public RegisterAppInterfaceResponse setVehicleType( VehicleType vehicleType) { + setParameters(KEY_VEHICLE_TYPE, vehicleType); + return this; } /** @@ -387,8 +399,9 @@ public class RegisterAppInterfaceResponse extends RPCResponse { * Sets AudioPassThruCapabilities * @param audioPassThruCapabilities */ - public void setAudioPassThruCapabilities(List audioPassThruCapabilities) { - setParameters(KEY_AUDIO_PASS_THRU_CAPABILITIES, audioPassThruCapabilities); + public RegisterAppInterfaceResponse setAudioPassThruCapabilities( List audioPassThruCapabilities) { + setParameters(KEY_AUDIO_PASS_THRU_CAPABILITIES, audioPassThruCapabilities); + return this; } /** @@ -404,12 +417,14 @@ public class RegisterAppInterfaceResponse extends RPCResponse { * Sets pcmStreamingCapabilities * @param pcmStreamingCapabilities */ - public void setPcmStreamingCapabilities(AudioPassThruCapabilities pcmStreamingCapabilities) { - setParameters(KEY_PCM_STREAM_CAPABILITIES, pcmStreamingCapabilities); - } + public RegisterAppInterfaceResponse setPcmStreamingCapabilities( AudioPassThruCapabilities pcmStreamingCapabilities) { + setParameters(KEY_PCM_STREAM_CAPABILITIES, pcmStreamingCapabilities); + return this; + } - public void setSupportedDiagModes(List supportedDiagModes) { - setParameters(KEY_SUPPORTED_DIAG_MODES, supportedDiagModes); + public RegisterAppInterfaceResponse setSupportedDiagModes( List supportedDiagModes) { + setParameters(KEY_SUPPORTED_DIAG_MODES, supportedDiagModes); + return this; } @SuppressWarnings("unchecked") @@ -417,8 +432,9 @@ public class RegisterAppInterfaceResponse extends RPCResponse { return (List) getObject(Integer.class, KEY_SUPPORTED_DIAG_MODES); } - public void setHmiCapabilities(HMICapabilities hmiCapabilities) { - setParameters(KEY_HMI_CAPABILITIES, hmiCapabilities); + public RegisterAppInterfaceResponse setHmiCapabilities( HMICapabilities hmiCapabilities) { + setParameters(KEY_HMI_CAPABILITIES, hmiCapabilities); + return this; } @SuppressWarnings("unchecked") @@ -426,16 +442,18 @@ public class RegisterAppInterfaceResponse extends RPCResponse { return (HMICapabilities) getObject(HMICapabilities.class, KEY_HMI_CAPABILITIES); } - public void setSdlVersion(String sdlVersion) { - setParameters(KEY_SDL_VERSION, sdlVersion); + public RegisterAppInterfaceResponse setSdlVersion( String sdlVersion) { + setParameters(KEY_SDL_VERSION, sdlVersion); + return this; } public String getSdlVersion() { return getString(KEY_SDL_VERSION); } - public void setSystemSoftwareVersion(String systemSoftwareVersion) { - setParameters(KEY_SYSTEM_SOFTWARE_VERSION, systemSoftwareVersion); + public RegisterAppInterfaceResponse setSystemSoftwareVersion( String systemSoftwareVersion) { + setParameters(KEY_SYSTEM_SOFTWARE_VERSION, systemSoftwareVersion); + return this; } public String getSystemSoftwareVersion() { @@ -446,11 +464,12 @@ public class RegisterAppInterfaceResponse extends RPCResponse { * Sets Icon Resumed Boolean * @param iconResumed - if param not included, set to false */ - public void setIconResumed(Boolean iconResumed){ + public RegisterAppInterfaceResponse setIconResumed(Boolean iconResumed){ if(iconResumed == null){ iconResumed = false; } setParameters(KEY_ICON_RESUMED, iconResumed); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/ReleaseInteriorVehicleDataModule.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/ReleaseInteriorVehicleDataModule.java index 807e239da..0c52a9e0a 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/ReleaseInteriorVehicleDataModule.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/ReleaseInteriorVehicleDataModule.java @@ -32,8 +32,9 @@ public class ReleaseInteriorVehicleDataModule extends RPCRequest { * Sets the Module Type for this class * @param type the Module Type to be set */ - public void setModuleType(@NonNull ModuleType type) { + public ReleaseInteriorVehicleDataModule setModuleType(@NonNull ModuleType type) { setParameters(KEY_MODULE_TYPE, type); + return this; } /** @@ -48,8 +49,9 @@ public class ReleaseInteriorVehicleDataModule extends RPCRequest { * Sets the Module Ids for this class * @param id the ids to be set */ - public void setModuleId(String id) { + public ReleaseInteriorVehicleDataModule setModuleId( String id) { setParameters(KEY_MODULE_ID, id); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/RemoteControlCapabilities.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/RemoteControlCapabilities.java index 5703f1cc2..31fd12534 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/RemoteControlCapabilities.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/RemoteControlCapabilities.java @@ -58,9 +58,10 @@ public class RemoteControlCapabilities extends RPCStruct { * @param climateControlCapabilities If included, the platform supports RC climate controls. * For this baseline version, maxsize=1. i.e. only one climate control module is supported. */ - public void setClimateControlCapabilities(List climateControlCapabilities) { - setValue(KEY_CLIMATE_CONTROL_CAPABILITIES, climateControlCapabilities); - } + public RemoteControlCapabilities setClimateControlCapabilities( List climateControlCapabilities) { + setValue(KEY_CLIMATE_CONTROL_CAPABILITIES, climateControlCapabilities); + return this; + } /** * Gets the climateControlCapabilities portion of the RemoteControlCapabilities class @@ -79,9 +80,10 @@ public class RemoteControlCapabilities extends RPCStruct { * @param radioControlCapabilities If included, the platform supports RC climate controls. * For this baseline version, maxsize=1. i.e. only one radio control module is supported. */ - public void setRadioControlCapabilities(List radioControlCapabilities) { - setValue(KEY_RADIO_CONTROL_CAPABILITIES, radioControlCapabilities); - } + public RemoteControlCapabilities setRadioControlCapabilities( List radioControlCapabilities) { + setValue(KEY_RADIO_CONTROL_CAPABILITIES, radioControlCapabilities); + return this; + } /** * Gets the radioControlCapabilities portion of the RemoteControlCapabilities class @@ -99,9 +101,10 @@ public class RemoteControlCapabilities extends RPCStruct { * * @param buttonCapabilities If included, the platform supports RC button controls with the included button names. */ - public void setButtonCapabilities(List buttonCapabilities) { - setValue(KEY_BUTTON_CAPABILITIES, buttonCapabilities); - } + public RemoteControlCapabilities setButtonCapabilities( List buttonCapabilities) { + setValue(KEY_BUTTON_CAPABILITIES, buttonCapabilities); + return this; + } /** * Gets the buttonCapabilities portion of the RemoteControlCapabilities class @@ -118,9 +121,10 @@ public class RemoteControlCapabilities extends RPCStruct { * * @param seatControlCapabilities If included, the platform supports seat controls. */ - public void setSeatControlCapabilities(List seatControlCapabilities) { - setValue(KEY_SEAT_CONTROL_CAPABILITIES, seatControlCapabilities); - } + public RemoteControlCapabilities setSeatControlCapabilities( List seatControlCapabilities) { + setValue(KEY_SEAT_CONTROL_CAPABILITIES, seatControlCapabilities); + return this; + } /** * Gets the seatControlCapabilities portion of the RemoteControlCapabilities class @@ -137,9 +141,10 @@ public class RemoteControlCapabilities extends RPCStruct { * * @param audioControlCapabilities If included, the platform supports audio controls. */ - public void setAudioControlCapabilities(List audioControlCapabilities) { - setValue(KEY_AUDIO_CONTROL_CAPABILITIES, audioControlCapabilities); - } + public RemoteControlCapabilities setAudioControlCapabilities( List audioControlCapabilities) { + setValue(KEY_AUDIO_CONTROL_CAPABILITIES, audioControlCapabilities); + return this; + } /** * Gets the audioControlCapabilities portion of the RemoteControlCapabilities class @@ -156,9 +161,10 @@ public class RemoteControlCapabilities extends RPCStruct { * * @param hmiSettingsControlCapabilities If included, the platform supports hmi setting controls. */ - public void setHmiSettingsControlCapabilities(HMISettingsControlCapabilities hmiSettingsControlCapabilities) { - setValue(KEY_HMI_SETTINGS_CONTROL_CAPABILITIES, hmiSettingsControlCapabilities); - } + public RemoteControlCapabilities setHmiSettingsControlCapabilities( HMISettingsControlCapabilities hmiSettingsControlCapabilities) { + setValue(KEY_HMI_SETTINGS_CONTROL_CAPABILITIES, hmiSettingsControlCapabilities); + return this; + } /** * Gets the hmiSettingsControlCapabilities portion of the RemoteControlCapabilities class @@ -174,9 +180,10 @@ public class RemoteControlCapabilities extends RPCStruct { * * @param lightControlCapabilities If included, the platform supports light controls. */ - public void setLightControlCapabilities(LightControlCapabilities lightControlCapabilities) { - setValue(KEY_LIGHT_CONTROL_CAPABILITIES, lightControlCapabilities); - } + public RemoteControlCapabilities setLightControlCapabilities( LightControlCapabilities lightControlCapabilities) { + setValue(KEY_LIGHT_CONTROL_CAPABILITIES, lightControlCapabilities); + return this; + } /** * Gets the lightControlCapabilities portion of the RemoteControlCapabilities class diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/ResetGlobalProperties.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/ResetGlobalProperties.java index a88ca2950..1bd508186 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/ResetGlobalProperties.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/ResetGlobalProperties.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -132,15 +132,16 @@ public class ResetGlobalProperties extends RPCRequest { /** * Sets an array of one or more GlobalProperty enumeration elements * indicating which global properties to reset to their default value - * + * * @param properties * a List An array of one or more * GlobalProperty enumeration elements indicating which global * properties to reset to their default value *

    * Notes: Array must have at least one element - */ - public void setProperties(@NonNull List properties ) { - setParameters(KEY_PROPERTIES, properties); + */ + public ResetGlobalProperties setProperties(@NonNull List properties) { + setParameters(KEY_PROPERTIES, properties); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/ScreenParams.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/ScreenParams.java index a5b9e1525..fd644cb40 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/ScreenParams.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/ScreenParams.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -105,14 +105,16 @@ public class ScreenParams extends RPCStruct { public ImageResolution getImageResolution() { return (ImageResolution) getObject(ImageResolution.class, KEY_RESOLUTION); } - public void setImageResolution( @NonNull ImageResolution resolution ) { + public ScreenParams setImageResolution(@NonNull ImageResolution resolution) { setValue(KEY_RESOLUTION, resolution); + return this; } @SuppressWarnings("unchecked") public TouchEventCapabilities getTouchEventAvailable() { return (TouchEventCapabilities) getObject(TouchEventCapabilities.class, KEY_TOUCH_EVENT_AVAILABLE); } - public void setTouchEventAvailable( TouchEventCapabilities touchEventAvailable ) { - setValue(KEY_TOUCH_EVENT_AVAILABLE, touchEventAvailable); - } + public ScreenParams setTouchEventAvailable( TouchEventCapabilities touchEventAvailable) { + setValue(KEY_TOUCH_EVENT_AVAILABLE, touchEventAvailable); + return this; + } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/ScrollableMessage.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/ScrollableMessage.java index 1ad0d0846..cb331914a 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/ScrollableMessage.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/ScrollableMessage.java @@ -144,15 +144,16 @@ public class ScrollableMessage extends RPCRequest { /** * Sets a Body of text that can include newlines and tabs - * + * * @param scrollableMessageBody * a String value representing the Body of text that can include * newlines and tabs *

    * Notes: Maxlength=500 */ - public void setScrollableMessageBody(@NonNull String scrollableMessageBody) { - setParameters(KEY_SCROLLABLE_MESSAGE_BODY, scrollableMessageBody); + public ScrollableMessage setScrollableMessageBody(@NonNull String scrollableMessageBody) { + setParameters(KEY_SCROLLABLE_MESSAGE_BODY, scrollableMessageBody); + return this; } /** @@ -167,14 +168,15 @@ public class ScrollableMessage extends RPCRequest { /** * Sets an App defined timeout. Indicates how long of a timeout from the * last action - * + * * @param timeout * an Integer value representing an App defined timeout *

    * Notes:Minval=0; Maxval=65535;Default=30000 */ - public void setTimeout(Integer timeout) { - setParameters(KEY_TIMEOUT, timeout); + public ScrollableMessage setTimeout( Integer timeout) { + setParameters(KEY_TIMEOUT, timeout); + return this; } /** @@ -189,15 +191,16 @@ public class ScrollableMessage extends RPCRequest { /** * Sets App defined SoftButtons.If omitted on supported displays, only the * system defined "Close" SoftButton will be displayed - * + * * @param softButtons * a List value representing App defined * SoftButtons *

    * Notes: Minsize=0, Maxsize=8 */ - public void setSoftButtons(List softButtons) { - setParameters(KEY_SOFT_BUTTONS, softButtons); + public ScrollableMessage setSoftButtons( List softButtons) { + setParameters(KEY_SOFT_BUTTONS, softButtons); + return this; } /** @@ -227,7 +230,8 @@ public class ScrollableMessage extends RPCRequest { * * @since SmartDeviceLink 6.0 */ - public void setCancelID(Integer cancelID) { - setParameters(KEY_CANCEL_ID, cancelID); - } + public ScrollableMessage setCancelID( Integer cancelID) { + setParameters(KEY_CANCEL_ID, cancelID); + return this; + } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/SdlMsgVersion.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/SdlMsgVersion.java index 8a2135753..0e8f9453f 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/SdlMsgVersion.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/SdlMsgVersion.java @@ -138,10 +138,11 @@ public class SdlMsgVersion extends RPCStruct { *
  • minvalue="1"
  • *
  • maxvalue="10"
  • * - * @param majorVersion minvalue="1" and maxvalue="10" - */ - public void setMajorVersion( @NonNull Integer majorVersion ) { + * @param majorVersion minvalue="1" and maxvalue="10" + */ + public SdlMsgVersion setMajorVersion(@NonNull Integer majorVersion) { setValue(KEY_MAJOR_VERSION, majorVersion); + return this; } /** * Get minor version @@ -162,8 +163,9 @@ public class SdlMsgVersion extends RPCStruct { * * @param minorVersion min: 0; max: 1000 */ - public void setMinorVersion( @NonNull Integer minorVersion ) { + public SdlMsgVersion setMinorVersion(@NonNull Integer minorVersion) { setValue(KEY_MINOR_VERSION, minorVersion); + return this; } /** @@ -185,8 +187,9 @@ public class SdlMsgVersion extends RPCStruct { * * @param patchVersion min: 0; max: 1000 */ - public void setPatchVersion( Integer patchVersion ) { + public SdlMsgVersion setPatchVersion( Integer patchVersion) { setValue(KEY_PATCH_VERSION, patchVersion); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/SeatControlCapabilities.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/SeatControlCapabilities.java index 106edf2cb..82d3cf72c 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/SeatControlCapabilities.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/SeatControlCapabilities.java @@ -95,18 +95,20 @@ public class SeatControlCapabilities extends RPCStruct { * * @param moduleName - The short friendly name of the light control module. It should not be used to identify a module by mobile application. */ - public void setModuleName(@NonNull String moduleName) { - setValue(KEY_MODULE_NAME, moduleName); - } + public SeatControlCapabilities setModuleName(@NonNull String moduleName) { + setValue(KEY_MODULE_NAME, moduleName); + return this; + } /** * Sets the heatingEnabledAvailable portion of the SeatControlCapabilities class * * @param heatingEnabledAvailable */ - public void setHeatingEnabledAvailable(Boolean heatingEnabledAvailable) { - setValue(KEY_HEATING_ENABLED_AVAILABLE, heatingEnabledAvailable); - } + public SeatControlCapabilities setHeatingEnabledAvailable( Boolean heatingEnabledAvailable) { + setValue(KEY_HEATING_ENABLED_AVAILABLE, heatingEnabledAvailable); + return this; + } /** * Gets the heatingEnabledAvailable portion of the SeatControlCapabilities class @@ -122,9 +124,10 @@ public class SeatControlCapabilities extends RPCStruct { * * @param coolingEnabledAvailable */ - public void setCoolingEnabledAvailable(Boolean coolingEnabledAvailable) { - setValue(KEY_COOLING_ENABLED_AVAILABLE, coolingEnabledAvailable); - } + public SeatControlCapabilities setCoolingEnabledAvailable( Boolean coolingEnabledAvailable) { + setValue(KEY_COOLING_ENABLED_AVAILABLE, coolingEnabledAvailable); + return this; + } /** * Gets the coolingEnabledAvailable portion of the SeatControlCapabilities class @@ -140,9 +143,10 @@ public class SeatControlCapabilities extends RPCStruct { * * @param heatingLevelAvailable */ - public void setHeatingLevelAvailable(Boolean heatingLevelAvailable) { - setValue(KEY_HEATING_LEVEL_AVAILABLE, heatingLevelAvailable); - } + public SeatControlCapabilities setHeatingLevelAvailable( Boolean heatingLevelAvailable) { + setValue(KEY_HEATING_LEVEL_AVAILABLE, heatingLevelAvailable); + return this; + } /** * Gets the heatingLevelAvailable portion of the SeatControlCapabilities class @@ -158,9 +162,10 @@ public class SeatControlCapabilities extends RPCStruct { * * @param coolingLevelAvailable */ - public void setCoolingLevelAvailable(Boolean coolingLevelAvailable) { - setValue(KEY_COOLING_LEVEL_AVAILABLE, coolingLevelAvailable); - } + public SeatControlCapabilities setCoolingLevelAvailable( Boolean coolingLevelAvailable) { + setValue(KEY_COOLING_LEVEL_AVAILABLE, coolingLevelAvailable); + return this; + } /** * Gets the coolingLevelAvailable portion of the SeatControlCapabilities class @@ -176,9 +181,10 @@ public class SeatControlCapabilities extends RPCStruct { * * @param horizontalPositionAvailable */ - public void setHorizontalPositionAvailable(Boolean horizontalPositionAvailable) { - setValue(KEY_HORIZONTAL_POSITION_AVAILABLE, horizontalPositionAvailable); - } + public SeatControlCapabilities setHorizontalPositionAvailable( Boolean horizontalPositionAvailable) { + setValue(KEY_HORIZONTAL_POSITION_AVAILABLE, horizontalPositionAvailable); + return this; + } /** * Gets the horizontalPositionAvailable portion of the SeatControlCapabilities class @@ -194,9 +200,10 @@ public class SeatControlCapabilities extends RPCStruct { * * @param verticalPositionAvailable */ - public void setVerticalPositionAvailable(Boolean verticalPositionAvailable) { - setValue(KEY_VERTICAL_POSITION_AVAILABLE, verticalPositionAvailable); - } + public SeatControlCapabilities setVerticalPositionAvailable( Boolean verticalPositionAvailable) { + setValue(KEY_VERTICAL_POSITION_AVAILABLE, verticalPositionAvailable); + return this; + } /** * Gets the verticalPositionAvailable portion of the SeatControlCapabilities class @@ -212,9 +219,10 @@ public class SeatControlCapabilities extends RPCStruct { * * @param frontVerticalPositionAvailable */ - public void setFrontVerticalPositionAvailable(Boolean frontVerticalPositionAvailable) { - setValue(KEY_FRONT_VERTICAL_POSITION_AVAILABLE, frontVerticalPositionAvailable); - } + public SeatControlCapabilities setFrontVerticalPositionAvailable( Boolean frontVerticalPositionAvailable) { + setValue(KEY_FRONT_VERTICAL_POSITION_AVAILABLE, frontVerticalPositionAvailable); + return this; + } /** * Gets the frontVerticalPositionAvailable portion of the SeatControlCapabilities class @@ -230,9 +238,10 @@ public class SeatControlCapabilities extends RPCStruct { * * @param backVerticalPositionAvailable */ - public void setBackVerticalPositionAvailable(Boolean backVerticalPositionAvailable) { - setValue(KEY_BACK_VERTICAL_POSITION_AVAILABLE, backVerticalPositionAvailable); - } + public SeatControlCapabilities setBackVerticalPositionAvailable( Boolean backVerticalPositionAvailable) { + setValue(KEY_BACK_VERTICAL_POSITION_AVAILABLE, backVerticalPositionAvailable); + return this; + } /** * Gets the backVerticalPositionAvailable portion of the SeatControlCapabilities class @@ -248,9 +257,10 @@ public class SeatControlCapabilities extends RPCStruct { * * @param backTiltAngleAvailable */ - public void setBackTiltAngleAvailable(Boolean backTiltAngleAvailable) { - setValue(KEY_BACK_TILT_ANGLE_AVAILABLE, backTiltAngleAvailable); - } + public SeatControlCapabilities setBackTiltAngleAvailable( Boolean backTiltAngleAvailable) { + setValue(KEY_BACK_TILT_ANGLE_AVAILABLE, backTiltAngleAvailable); + return this; + } /** * Gets the backTiltAngleAvailable portion of the SeatControlCapabilities class @@ -266,9 +276,10 @@ public class SeatControlCapabilities extends RPCStruct { * * @param headSupportHorizontalPositionAvailable */ - public void setHeadSupportHorizontalPositionAvailable(Boolean headSupportHorizontalPositionAvailable) { - setValue(KEY_HEAD_SUPPORT_HORIZONTAL_POSITION_AVAILABLE, headSupportHorizontalPositionAvailable); - } + public SeatControlCapabilities setHeadSupportHorizontalPositionAvailable( Boolean headSupportHorizontalPositionAvailable) { + setValue(KEY_HEAD_SUPPORT_HORIZONTAL_POSITION_AVAILABLE, headSupportHorizontalPositionAvailable); + return this; + } /** * Gets the headSupportHorizontalPositionAvailable portion of the SeatControlCapabilities class @@ -284,9 +295,10 @@ public class SeatControlCapabilities extends RPCStruct { * * @param headSupportVerticalPositionAvailable */ - public void setHeadSupportVerticalPositionAvailable(Boolean headSupportVerticalPositionAvailable) { - setValue(KEY_HEAD_SUPPORT_VERTICAL_POSITION_AVAILABLE, headSupportVerticalPositionAvailable); - } + public SeatControlCapabilities setHeadSupportVerticalPositionAvailable( Boolean headSupportVerticalPositionAvailable) { + setValue(KEY_HEAD_SUPPORT_VERTICAL_POSITION_AVAILABLE, headSupportVerticalPositionAvailable); + return this; + } /** * Gets the headSupportVerticalPositionAvailable portion of the SeatControlCapabilities class @@ -302,9 +314,10 @@ public class SeatControlCapabilities extends RPCStruct { * * @param massageEnabledAvailable */ - public void setMassageEnabledAvailable(Boolean massageEnabledAvailable) { - setValue(KEY_MASSAGE_ENABLED_AVAILABLE, massageEnabledAvailable); - } + public SeatControlCapabilities setMassageEnabledAvailable( Boolean massageEnabledAvailable) { + setValue(KEY_MASSAGE_ENABLED_AVAILABLE, massageEnabledAvailable); + return this; + } /** * Gets the massageEnabledAvailable portion of the SeatControlCapabilities class @@ -320,9 +333,10 @@ public class SeatControlCapabilities extends RPCStruct { * * @param massageModeAvailable */ - public void setMassageModeAvailable(Boolean massageModeAvailable) { - setValue(KEY_MASSAGE_MODE_AVAILABLE, massageModeAvailable); - } + public SeatControlCapabilities setMassageModeAvailable( Boolean massageModeAvailable) { + setValue(KEY_MASSAGE_MODE_AVAILABLE, massageModeAvailable); + return this; + } /** * Gets the massageModeAvailable portion of the SeatControlCapabilities class @@ -338,9 +352,10 @@ public class SeatControlCapabilities extends RPCStruct { * * @param massageCushionFirmnessAvailable */ - public void setMassageCushionFirmnessAvailable(Boolean massageCushionFirmnessAvailable) { - setValue(KEY_MASSAGE_CUSHION_FIRMNESS_AVAILABLE, massageCushionFirmnessAvailable); - } + public SeatControlCapabilities setMassageCushionFirmnessAvailable( Boolean massageCushionFirmnessAvailable) { + setValue(KEY_MASSAGE_CUSHION_FIRMNESS_AVAILABLE, massageCushionFirmnessAvailable); + return this; + } /** * Gets the massageCushionFirmnessAvailable portion of the SeatControlCapabilities class @@ -356,9 +371,10 @@ public class SeatControlCapabilities extends RPCStruct { * * @param memoryAvailable */ - public void setMemoryAvailable(Boolean memoryAvailable) { - setValue(KEY_MEMORY_AVAILABLE, memoryAvailable); - } + public SeatControlCapabilities setMemoryAvailable( Boolean memoryAvailable) { + setValue(KEY_MEMORY_AVAILABLE, memoryAvailable); + return this; + } /** * Gets the memoryAvailable portion of the SeatControlCapabilities class @@ -373,9 +389,10 @@ public class SeatControlCapabilities extends RPCStruct { * Sets ModuleInfo for this capability * @param info the ModuleInfo to be set */ - public void setModuleInfo(ModuleInfo info) { - setValue(KEY_MODULE_INFO, info); - } + public SeatControlCapabilities setModuleInfo( ModuleInfo info) { + setValue(KEY_MODULE_INFO, info); + return this; + } /** * Gets a ModuleInfo of this capability diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/SeatControlData.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/SeatControlData.java index fbaf55fad..8f63ff39e 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/SeatControlData.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/SeatControlData.java @@ -90,9 +90,10 @@ public class SeatControlData extends RPCStruct { * * @param id */ - public void setId(@NonNull SupportedSeat id) { - setValue(KEY_ID, id); - } + public SeatControlData setId(@NonNull SupportedSeat id) { + setValue(KEY_ID, id); + return this; + } /** * Gets the id portion of the SeatControlData class @@ -108,9 +109,10 @@ public class SeatControlData extends RPCStruct { * * @param heatingEnabled */ - public void setHeatingEnabled(Boolean heatingEnabled) { - setValue(KEY_HEATING_ENABLED, heatingEnabled); - } + public SeatControlData setHeatingEnabled( Boolean heatingEnabled) { + setValue(KEY_HEATING_ENABLED, heatingEnabled); + return this; + } /** * Gets the heatingEnabled portion of the SeatControlData class @@ -126,9 +128,10 @@ public class SeatControlData extends RPCStruct { * * @param coolingEnabled */ - public void setCoolingEnabled(Boolean coolingEnabled) { - setValue(KEY_COOLING_ENABLED, coolingEnabled); - } + public SeatControlData setCoolingEnabled( Boolean coolingEnabled) { + setValue(KEY_COOLING_ENABLED, coolingEnabled); + return this; + } /** * Gets the coolingEnabled portion of the SeatControlData class @@ -144,9 +147,10 @@ public class SeatControlData extends RPCStruct { * * @param heatingLevel */ - public void setHeatingLevel(Integer heatingLevel) { - setValue(KEY_HEATING_LEVEL, heatingLevel); - } + public SeatControlData setHeatingLevel( Integer heatingLevel) { + setValue(KEY_HEATING_LEVEL, heatingLevel); + return this; + } /** * Gets the heatingLevel portion of the SeatControlData class @@ -162,9 +166,10 @@ public class SeatControlData extends RPCStruct { * * @param coolingLevel */ - public void setCoolingLevel(Integer coolingLevel) { - setValue(KEY_COOLING_LEVEL, coolingLevel); - } + public SeatControlData setCoolingLevel( Integer coolingLevel) { + setValue(KEY_COOLING_LEVEL, coolingLevel); + return this; + } /** * Gets the coolingLevel portion of the SeatControlData class @@ -180,9 +185,10 @@ public class SeatControlData extends RPCStruct { * * @param horizontalPosition */ - public void setHorizontalPosition(Integer horizontalPosition) { - setValue(KEY_HORIZONTAL_POSITION, horizontalPosition); - } + public SeatControlData setHorizontalPosition( Integer horizontalPosition) { + setValue(KEY_HORIZONTAL_POSITION, horizontalPosition); + return this; + } /** * Gets the horizontalPosition portion of the SeatControlData class @@ -198,9 +204,10 @@ public class SeatControlData extends RPCStruct { * * @param verticalPosition */ - public void setVerticalPosition(Integer verticalPosition) { - setValue(KEY_VERTICAL_POSITION, verticalPosition); - } + public SeatControlData setVerticalPosition( Integer verticalPosition) { + setValue(KEY_VERTICAL_POSITION, verticalPosition); + return this; + } /** * Gets the verticalPosition portion of the SeatControlData class @@ -216,9 +223,10 @@ public class SeatControlData extends RPCStruct { * * @param frontVerticalPosition */ - public void setFrontVerticalPosition(Integer frontVerticalPosition) { - setValue(KEY_FRONT_VERTICAL_POSITION, frontVerticalPosition); - } + public SeatControlData setFrontVerticalPosition( Integer frontVerticalPosition) { + setValue(KEY_FRONT_VERTICAL_POSITION, frontVerticalPosition); + return this; + } /** * Gets the frontVerticalPosition portion of the SeatControlData class @@ -234,9 +242,10 @@ public class SeatControlData extends RPCStruct { * * @param backVerticalPosition */ - public void setBackVerticalPosition(Integer backVerticalPosition) { - setValue(KEY_BACK_VERTICAL_POSITION, backVerticalPosition); - } + public SeatControlData setBackVerticalPosition( Integer backVerticalPosition) { + setValue(KEY_BACK_VERTICAL_POSITION, backVerticalPosition); + return this; + } /** * Gets the backVerticalPosition portion of the SeatControlData class @@ -252,9 +261,10 @@ public class SeatControlData extends RPCStruct { * * @param backTiltAngle */ - public void setBackTiltAngle(Integer backTiltAngle) { - setValue(KEY_BACK_TILT_ANGLE, backTiltAngle); - } + public SeatControlData setBackTiltAngle( Integer backTiltAngle) { + setValue(KEY_BACK_TILT_ANGLE, backTiltAngle); + return this; + } /** * Gets the backTiltAngle portion of the SeatControlData class @@ -270,9 +280,10 @@ public class SeatControlData extends RPCStruct { * * @param headSupportHorizontalPosition */ - public void setHeadSupportHorizontalPosition(Integer headSupportHorizontalPosition) { - setValue(KEY_HEAD_SUPPORT_HORIZONTAL_POSITION, headSupportHorizontalPosition); - } + public SeatControlData setHeadSupportHorizontalPosition( Integer headSupportHorizontalPosition) { + setValue(KEY_HEAD_SUPPORT_HORIZONTAL_POSITION, headSupportHorizontalPosition); + return this; + } /** * Gets the headSupportHorizontalPosition portion of the SeatControlData class @@ -288,9 +299,10 @@ public class SeatControlData extends RPCStruct { * * @param headSupportVerticalPosition */ - public void setHeadSupportVerticalPosition(Integer headSupportVerticalPosition) { - setValue(KEY_HEAD_SUPPORT_VERTICAL_POSITION, headSupportVerticalPosition); - } + public SeatControlData setHeadSupportVerticalPosition( Integer headSupportVerticalPosition) { + setValue(KEY_HEAD_SUPPORT_VERTICAL_POSITION, headSupportVerticalPosition); + return this; + } /** * Gets the headSupportVerticalPosition portion of the SeatControlData class @@ -306,9 +318,10 @@ public class SeatControlData extends RPCStruct { * * @param massageEnabled */ - public void setMassageEnabled(Boolean massageEnabled) { - setValue(KEY_MASSAGE_ENABLED, massageEnabled); - } + public SeatControlData setMassageEnabled( Boolean massageEnabled) { + setValue(KEY_MASSAGE_ENABLED, massageEnabled); + return this; + } /** * Gets the massageEnabled portion of the SeatControlData class @@ -334,9 +347,10 @@ public class SeatControlData extends RPCStruct { * * @param massageMode */ - public void setMassageMode(List massageMode) { - setValue(KEY_MASSAGE_MODE, massageMode); - } + public SeatControlData setMassageMode( List massageMode) { + setValue(KEY_MASSAGE_MODE, massageMode); + return this; + } /** * Gets the List portion of the SeatControlData class @@ -353,18 +367,20 @@ public class SeatControlData extends RPCStruct { * * @param massageCushionFirmness */ - public void setMassageCushionFirmness(List massageCushionFirmness) { - setValue(KEY_MASSAGE_CUSHION_FIRMNESS, massageCushionFirmness); - } + public SeatControlData setMassageCushionFirmness( List massageCushionFirmness) { + setValue(KEY_MASSAGE_CUSHION_FIRMNESS, massageCushionFirmness); + return this; + } /** * Sets the memory portion of the SeatControlData class * * @param memory */ - public void setMemory(SeatMemoryAction memory) { - setValue(KEY_MEMORY, memory); - } + public SeatControlData setMemory( SeatMemoryAction memory) { + setValue(KEY_MEMORY, memory); + return this; + } /** * Gets the memory portion of the SeatControlData class diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/SeatLocation.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/SeatLocation.java index a4b33d1bd..a0b1338e7 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/SeatLocation.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/SeatLocation.java @@ -17,8 +17,9 @@ public class SeatLocation extends RPCStruct { * Sets grid data for this seat location * @param grid the grid to be set */ - public void setGrid(Grid grid) { + public SeatLocation setGrid( Grid grid) { setValue(KEY_GRID, grid); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/SeatLocationCapability.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/SeatLocationCapability.java index 3fc34bada..160e6c33e 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/SeatLocationCapability.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/SeatLocationCapability.java @@ -22,8 +22,9 @@ public class SeatLocationCapability extends RPCStruct { * Sets the seat rows for this capability * @param rows rows to be set */ - public void setRows(Integer rows) { + public SeatLocationCapability setRows( Integer rows) { setValue(KEY_ROWS, rows); + return this; } /** @@ -38,8 +39,9 @@ public class SeatLocationCapability extends RPCStruct { * Sets the seat columns for this capability * @param cols the seat columns to be set */ - public void setCols(Integer cols) { + public SeatLocationCapability setCols( Integer cols) { setValue(KEY_COLS, cols); + return this; } /** @@ -54,8 +56,9 @@ public class SeatLocationCapability extends RPCStruct { * Sets the levels for this capability * @param levels the levels to be set */ - public void setLevels(Integer levels) { + public SeatLocationCapability setLevels( Integer levels) { setValue(KEY_LEVELS, levels); + return this; } /** @@ -70,8 +73,9 @@ public class SeatLocationCapability extends RPCStruct { * Sets the seat locations for this capability * @param locations the locations to be set */ - public void setSeats(List locations) { + public SeatLocationCapability setSeats( List locations) { setValue(KEY_SEATS, locations); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/SeatMemoryAction.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/SeatMemoryAction.java index af27805db..1dc2411ba 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/SeatMemoryAction.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/SeatMemoryAction.java @@ -75,9 +75,10 @@ public class SeatMemoryAction extends RPCStruct { * * @param id */ - public void setId(@NonNull Integer id) { - setValue(KEY_ID, id); - } + public SeatMemoryAction setId(@NonNull Integer id) { + setValue(KEY_ID, id); + return this; + } /** * Gets the id portion of the SeatMemoryAction class @@ -93,9 +94,10 @@ public class SeatMemoryAction extends RPCStruct { * * @param label */ - public void setLabel(String label) { - setValue(KEY_LABEL, label); - } + public SeatMemoryAction setLabel( String label) { + setValue(KEY_LABEL, label); + return this; + } /** * Gets the label portion of the SeatMemoryAction class @@ -111,9 +113,10 @@ public class SeatMemoryAction extends RPCStruct { * * @param action */ - public void setAction(@NonNull SeatMemoryActionType action) { - setValue(KEY_ACTION, action); - } + public SeatMemoryAction setAction(@NonNull SeatMemoryActionType action) { + setValue(KEY_ACTION, action); + return this; + } /** * Gets the action portion of the SeatMemoryAction class diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/SendHapticData.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/SendHapticData.java index 6cee332f1..34295d9c5 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/SendHapticData.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/SendHapticData.java @@ -71,9 +71,10 @@ public class SendHapticData extends RPCRequest { * When a request is sent, if successful, it will replace all spatial data previously sent through RPC. * If an empty array is sent, the existing spatial data will be cleared */ - public void setHapticRectData(List hapticRectData) { - setParameters(KEY_HAPTIC_RECT_DATA, hapticRectData); - } + public SendHapticData setHapticRectData( List hapticRectData) { + setParameters(KEY_HAPTIC_RECT_DATA, hapticRectData); + return this; + } /** * Get the haptic data diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/SendLocation.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/SendLocation.java index 87fa67bb6..1ed6cfb10 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/SendLocation.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/SendLocation.java @@ -97,8 +97,9 @@ public class SendLocation extends RPCRequest{ * Setter for longitude of the location to send. * @param longitudeDegrees degrees of the longitudinal position */ - public void setLongitudeDegrees(Double longitudeDegrees){ + public SendLocation setLongitudeDegrees( Double longitudeDegrees) { setParameters(KEY_LON_DEGREES, longitudeDegrees); + return this; } /** @@ -120,8 +121,9 @@ public class SendLocation extends RPCRequest{ * Setter for latitude of the location to send. * @param latitudeDegrees degrees of the latitudinal position */ - public void setLatitudeDegrees(Double latitudeDegrees){ + public SendLocation setLatitudeDegrees( Double latitudeDegrees) { setParameters(KEY_LAT_DEGREES, latitudeDegrees); + return this; } /** @@ -136,8 +138,9 @@ public class SendLocation extends RPCRequest{ * Setter for name of the location to send. * @param locationName The name of the location */ - public void setLocationName(String locationName){ + public SendLocation setLocationName( String locationName) { setParameters(KEY_LOCATION_NAME, locationName); + return this; } /** @@ -152,8 +155,9 @@ public class SendLocation extends RPCRequest{ * Setter for description of the location to send. * @param locationDescription The description of the location */ - public void setLocationDescription(String locationDescription){ + public SendLocation setLocationDescription( String locationDescription) { setParameters(KEY_LOCATION_DESCRIPTION, locationDescription); + return this; } /** @@ -168,8 +172,9 @@ public class SendLocation extends RPCRequest{ * Setter for phone number of the location to send. * @param phoneNumber The phone number of the location */ - public void setPhoneNumber(String phoneNumber){ + public SendLocation setPhoneNumber( String phoneNumber) { setParameters(KEY_PHONE_NUMBER, phoneNumber); + return this; } /** @@ -185,8 +190,9 @@ public class SendLocation extends RPCRequest{ * Setter for address lines of the location to send. * @param addressLines The address lines of the location */ - public void setAddressLines(List addressLines){ + public SendLocation setAddressLines( List addressLines) { setParameters(KEY_ADDRESS_LINES, addressLines); + return this; } /** @@ -202,33 +208,37 @@ public class SendLocation extends RPCRequest{ * Setter for image of the location to send. * @param locationImage The image of the location to send */ - public void setLocationImage(Image locationImage){ + public SendLocation setLocationImage( Image locationImage) { setParameters(KEY_LOCATION_IMAGE, locationImage); + return this; } public DeliveryMode getDeliveryMode() { return (DeliveryMode) getObject(DeliveryMode.class, KEY_DELIVERY_MODE); } - public void setDeliveryMode(DeliveryMode deliveryMode) { + public SendLocation setDeliveryMode( DeliveryMode deliveryMode) { setParameters(KEY_DELIVERY_MODE, deliveryMode); - } + return this; + } @SuppressWarnings("unchecked") public DateTime getTimeStamp() { return (DateTime) getObject(DateTime.class, KEY_TIME_STAMP); } - public void setTimeStamp(DateTime timeStamp) { + public SendLocation setTimeStamp( DateTime timeStamp) { setParameters(KEY_TIME_STAMP, timeStamp); - } + return this; + } @SuppressWarnings("unchecked") public OasisAddress getAddress() { return (OasisAddress) getObject(OasisAddress.class, KEY_ADDRESS); } - public void setAddress(OasisAddress address) { + public SendLocation setAddress( OasisAddress address) { setParameters(KEY_ADDRESS, address); - } + return this; + } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/SetAppIcon.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/SetAppIcon.java index 6443be188..084332432 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/SetAppIcon.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/SetAppIcon.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -109,14 +109,15 @@ public class SetAppIcon extends RPCRequest { /** * Sets a file reference name - * + * * @param sdlFileName * a String value representing a file reference name *

    * Notes: Maxlength=500, however the max file name length may vary based on remote filesystem limitations */ - public void setSdlFileName(@NonNull String sdlFileName) { - setParameters(KEY_SDL_FILE_NAME, sdlFileName); + public SetAppIcon setSdlFileName(@NonNull String sdlFileName) { + setParameters(KEY_SDL_FILE_NAME, sdlFileName); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/SetCloudAppProperties.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/SetCloudAppProperties.java index a457304e3..48bc1196d 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/SetCloudAppProperties.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/SetCloudAppProperties.java @@ -55,8 +55,9 @@ public class SetCloudAppProperties extends RPCRequest { setParameters(KEY_PROPERTIES, cloudAppProperties); } - public void setProperties(@NonNull CloudAppProperties cloudAppProperties){ + public SetCloudAppProperties setProperties(@NonNull CloudAppProperties cloudAppProperties) { setParameters(KEY_PROPERTIES, cloudAppProperties); + return this; } public CloudAppProperties getProperties(){ diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/SetDisplayLayout.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/SetDisplayLayout.java index 937c8e8da..1b07d047a 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/SetDisplayLayout.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/SetDisplayLayout.java @@ -131,12 +131,13 @@ public class SetDisplayLayout extends RPCRequest { * Currently only predefined screen layouts are defined. Predefined layouts * include: "ONSCREEN_PRESETS" Custom screen containing app-defined onscreen * presets. Currently defined for GEN2 - * + * * @param displayLayout * a String value representing a display layout */ - public void setDisplayLayout(@NonNull String displayLayout) { - setParameters(KEY_DISPLAY_LAYOUT, displayLayout); + public SetDisplayLayout setDisplayLayout(@NonNull String displayLayout) { + setParameters(KEY_DISPLAY_LAYOUT, displayLayout); + return this; } /** @@ -164,9 +165,10 @@ public class SetDisplayLayout extends RPCRequest { * used for day color scheme * @since SmartDeviceLink 5.0 */ - public void setDayColorScheme(TemplateColorScheme templateColorScheme){ - setParameters(KEY_DAY_COLOR_SCHEME, templateColorScheme); - } + public SetDisplayLayout setDayColorScheme( TemplateColorScheme templateColorScheme) { + setParameters(KEY_DAY_COLOR_SCHEME, templateColorScheme); + return this; + } /** * Gets the color scheme that is currently used for night @@ -186,7 +188,8 @@ public class SetDisplayLayout extends RPCRequest { * used for night color scheme * @since SmartDeviceLink 5.0 */ - public void setNightColorScheme(TemplateColorScheme templateColorScheme){ - setParameters(KEY_NIGHT_COLOR_SCHEME, templateColorScheme); - } + public SetDisplayLayout setNightColorScheme( TemplateColorScheme templateColorScheme) { + setParameters(KEY_NIGHT_COLOR_SCHEME, templateColorScheme); + return this; + } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/SetDisplayLayoutResponse.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/SetDisplayLayoutResponse.java index 011dcf6ac..eb4e641d9 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/SetDisplayLayoutResponse.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/SetDisplayLayoutResponse.java @@ -87,8 +87,9 @@ public class SetDisplayLayoutResponse extends RPCResponse { return (DisplayCapabilities) getObject(DisplayCapabilities.class, KEY_DISPLAY_CAPABILITIES); } - public void setDisplayCapabilities(DisplayCapabilities displayCapabilities) { + public SetDisplayLayoutResponse setDisplayCapabilities( DisplayCapabilities displayCapabilities) { setParameters(KEY_DISPLAY_CAPABILITIES, displayCapabilities); + return this; } @SuppressWarnings("unchecked") @@ -96,8 +97,9 @@ public class SetDisplayLayoutResponse extends RPCResponse { return (List) getObject(ButtonCapabilities.class, KEY_BUTTON_CAPABILITIES); } - public void setButtonCapabilities(List buttonCapabilities) { + public SetDisplayLayoutResponse setButtonCapabilities( List buttonCapabilities) { setParameters(KEY_BUTTON_CAPABILITIES, buttonCapabilities); + return this; } @SuppressWarnings("unchecked") @@ -105,8 +107,9 @@ public class SetDisplayLayoutResponse extends RPCResponse { return (List) getObject(SoftButtonCapabilities.class, KEY_SOFT_BUTTON_CAPABILITIES); } - public void setSoftButtonCapabilities(List softButtonCapabilities) { + public SetDisplayLayoutResponse setSoftButtonCapabilities( List softButtonCapabilities) { setParameters(KEY_SOFT_BUTTON_CAPABILITIES, softButtonCapabilities); + return this; } @SuppressWarnings("unchecked") @@ -114,8 +117,9 @@ public class SetDisplayLayoutResponse extends RPCResponse { return (PresetBankCapabilities) getObject(PresetBankCapabilities.class, KEY_PRESET_BANK_CAPABILITIES); } - public void setPresetBankCapabilities(PresetBankCapabilities presetBankCapabilities) { + public SetDisplayLayoutResponse setPresetBankCapabilities( PresetBankCapabilities presetBankCapabilities) { setParameters(KEY_PRESET_BANK_CAPABILITIES, presetBankCapabilities); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/SetGlobalProperties.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/SetGlobalProperties.java index 82e7738ee..28050a867 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/SetGlobalProperties.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/SetGlobalProperties.java @@ -188,7 +188,7 @@ public class SetGlobalProperties extends RPCRequest { * Sets a List for Help Prompt that Array of one or more * TTSChunk elements specifying the help prompt used in an interaction * started by PTT - * + * * @param helpPrompt * a List of one or more TTSChunk elements *

    @@ -197,9 +197,10 @@ public class SetGlobalProperties extends RPCRequest { *
  • Array must have at least one element
  • *
  • Only optional it timeoutPrompt has been specified
  • * - */ - public void setHelpPrompt(List helpPrompt) { - setParameters(KEY_HELP_PROMPT, helpPrompt); + */ + public SetGlobalProperties setHelpPrompt( List helpPrompt) { + setParameters(KEY_HELP_PROMPT, helpPrompt); + return this; } /** * Gets a List for Timeout Prompt representing Array of one or @@ -217,10 +218,11 @@ public class SetGlobalProperties extends RPCRequest { * Sets a List for Timeout Prompt representing Array of one or * more TTSChunk elements specifying the help prompt used in an interaction * started by PTT - * - */ - public void setTimeoutPrompt(List timeoutPrompt) { - setParameters(KEY_TIMEOUT_PROMPT, timeoutPrompt); + * + */ + public SetGlobalProperties setTimeoutPrompt( List timeoutPrompt) { + setParameters(KEY_TIMEOUT_PROMPT, timeoutPrompt); + return this; } /** @@ -236,7 +238,7 @@ public class SetGlobalProperties extends RPCRequest { /** * Sets a voice recognition Help Title - * + * * @param vrHelpTitle * a String value representing a voice recognition Help Title *

    @@ -250,8 +252,9 @@ public class SetGlobalProperties extends RPCRequest { * * @since SmartDeviceLink 2.0 */ - public void setVrHelpTitle(String vrHelpTitle) { - setParameters(KEY_VR_HELP_TITLE, vrHelpTitle); + public SetGlobalProperties setVrHelpTitle( String vrHelpTitle) { + setParameters(KEY_VR_HELP_TITLE, vrHelpTitle); + return this; } /** @@ -270,7 +273,7 @@ public class SetGlobalProperties extends RPCRequest { /** * Sets the items listed in the VR help screen used in an interaction * started by PTT - * + * * @param vrHelp * a List value representing items listed in the VR help screen * used in an interaction started by PTT @@ -288,20 +291,23 @@ public class SetGlobalProperties extends RPCRequest { * * @since SmartDeviceLink 2.0 */ - public void setVrHelp(List vrHelp) { - setParameters(KEY_VR_HELP, vrHelp); + public SetGlobalProperties setVrHelp( List vrHelp) { + setParameters(KEY_VR_HELP, vrHelp); + return this; } public String getMenuTitle() { return getString(KEY_MENU_TITLE); } - public void setMenuTitle(String menuTitle) { - setParameters(KEY_MENU_TITLE, menuTitle); + public SetGlobalProperties setMenuTitle( String menuTitle) { + setParameters(KEY_MENU_TITLE, menuTitle); + return this; } - public void setMenuIcon(Image menuIcon) { - setParameters(KEY_MENU_ICON, menuIcon); + public SetGlobalProperties setMenuIcon( Image menuIcon) { + setParameters(KEY_MENU_ICON, menuIcon); + return this; } @SuppressWarnings("unchecked") @@ -309,17 +315,19 @@ public class SetGlobalProperties extends RPCRequest { return (Image) getObject(Image.class, KEY_MENU_ICON); } - public void setKeyboardProperties(KeyboardProperties keyboardProperties) { - setParameters(KEY_KEYBOARD_PROPERTIES, keyboardProperties); + public SetGlobalProperties setKeyboardProperties( KeyboardProperties keyboardProperties) { + setParameters(KEY_KEYBOARD_PROPERTIES, keyboardProperties); + return this; } /** * Sets the user seat location * @param location the location to be set */ - public void setUserLocation(SeatLocation location) { - setParameters(KEY_USER_LOCATION, location); - } + public SetGlobalProperties setUserLocation( SeatLocation location) { + setParameters(KEY_USER_LOCATION, location); + return this; + } /** * Gets the user seat location @@ -339,9 +347,10 @@ public class SetGlobalProperties extends RPCRequest { * the head unit will change the display to the new layout type. * @param menuLayout - the menuLayout */ - public void setMenuLayout(MenuLayout menuLayout) { - setParameters(KEY_MENU_LAYOUT, menuLayout); - } + public SetGlobalProperties setMenuLayout( MenuLayout menuLayout) { + setParameters(KEY_MENU_LAYOUT, menuLayout); + return this; + } /** * Sets the layout of the main menu screen. If this is sent while a menu is already on-screen, diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/SetInteriorVehicleData.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/SetInteriorVehicleData.java index 130d1e277..60e792023 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/SetInteriorVehicleData.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/SetInteriorVehicleData.java @@ -78,8 +78,9 @@ public class SetInteriorVehicleData extends RPCRequest { * * @param moduleData */ - public void setModuleData(@NonNull ModuleData moduleData) { + public SetInteriorVehicleData setModuleData(@NonNull ModuleData moduleData) { setParameters(KEY_MODULE_DATA, moduleData); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/SetInteriorVehicleDataResponse.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/SetInteriorVehicleDataResponse.java index 81390e64a..01ceed4ea 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/SetInteriorVehicleDataResponse.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/SetInteriorVehicleDataResponse.java @@ -86,7 +86,8 @@ public class SetInteriorVehicleDataResponse extends RPCResponse { * * @param moduleData */ - public void setModuleData(ModuleData moduleData) { - setParameters(KEY_MODULE_DATA, moduleData); - } + public SetInteriorVehicleDataResponse setModuleData( ModuleData moduleData) { + setParameters(KEY_MODULE_DATA, moduleData); + return this; + } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/SetMediaClockTimer.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/SetMediaClockTimer.java index 67353132f..05a97cc62 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/SetMediaClockTimer.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/SetMediaClockTimer.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -268,7 +268,7 @@ public class SetMediaClockTimer extends RPCRequest { } /** * Sets a Start Time with specifying hour, minute, second values - * + * * @param startTime * a startTime object with specifying hour, minute, second values *

    @@ -278,9 +278,10 @@ public class SetMediaClockTimer extends RPCRequest { * must be provided *
  • Will be ignored for PAUSE/RESUME and CLEAR
  • * - */ - public void setStartTime( StartTime startTime ) { - setParameters(KEY_START_TIME, startTime); + */ + public SetMediaClockTimer setStartTime( StartTime startTime) { + setParameters(KEY_START_TIME, startTime); + return this; } @SuppressWarnings("unchecked") @@ -288,8 +289,9 @@ public class SetMediaClockTimer extends RPCRequest { return (StartTime) getObject(StartTime.class, KEY_END_TIME); } - public void setEndTime( StartTime endTime ) { - setParameters(KEY_END_TIME, endTime); + public SetMediaClockTimer setEndTime( StartTime endTime) { + setParameters(KEY_END_TIME, endTime); + return this; } /** @@ -302,7 +304,7 @@ public class SetMediaClockTimer extends RPCRequest { } /** * Sets the media clock/timer update mode (COUNTUP/COUNTDOWN/PAUSE/RESUME) - * + * * @param updateMode * a Enumeration value (COUNTUP/COUNTDOWN/PAUSE/RESUME) *

    @@ -313,9 +315,10 @@ public class SetMediaClockTimer extends RPCRequest { *
  • When updateMode is RESUME, the timer resumes counting from * the timer's value when it was paused
  • * - */ - public void setUpdateMode( @NonNull UpdateMode updateMode ) { - setParameters(KEY_UPDATE_MODE, updateMode); + */ + public SetMediaClockTimer setUpdateMode(@NonNull UpdateMode updateMode) { + setParameters(KEY_UPDATE_MODE, updateMode); + return this; } /** @@ -330,7 +333,8 @@ public class SetMediaClockTimer extends RPCRequest { /** * Sets the playback status of a media app */ - public void setAudioStreamingIndicator(AudioStreamingIndicator audioStreamingIndicator ) { - setParameters(KEY_AUDIO_STREAMING_INDICATOR, audioStreamingIndicator); - } + public SetMediaClockTimer setAudioStreamingIndicator( AudioStreamingIndicator audioStreamingIndicator) { + setParameters(KEY_AUDIO_STREAMING_INDICATOR, audioStreamingIndicator); + return this; + } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/Show.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/Show.java index e663c9f2b..dceae1a3b 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/Show.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/Show.java @@ -238,7 +238,7 @@ public class Show extends RPCRequest { /** * Sets the text displayed in a single-line display, or in the upper display * line in a two-line display - * + * * @param mainField1 * the String value representing the text displayed in a * single-line display, or in the upper display line in a @@ -251,9 +251,10 @@ public class Show extends RPCRequest { *
  • If this parameter is an empty string, the field will be * cleared
  • * - */ - public void setMainField1(String mainField1) { - setParameters(KEY_MAIN_FIELD_1, mainField1); + */ + public Show setMainField1( String mainField1) { + setParameters(KEY_MAIN_FIELD_1, mainField1); + return this; } /** * Gets the text displayed on the second display line of a two-line display @@ -266,7 +267,7 @@ public class Show extends RPCRequest { } /** * Sets the text displayed on the second display line of a two-line display - * + * * @param mainField2 * the String value representing the text displayed on the second * display line of a two-line display @@ -281,9 +282,10 @@ public class Show extends RPCRequest { * parameter is ignored *
  • Maxlength = 500
  • * - */ - public void setMainField2(String mainField2) { - setParameters(KEY_MAIN_FIELD_2, mainField2); + */ + public Show setMainField2( String mainField2) { + setParameters(KEY_MAIN_FIELD_2, mainField2); + return this; } /** @@ -299,7 +301,7 @@ public class Show extends RPCRequest { /** * Sets the text displayed on the first display line of the second page - * + * * @param mainField3 * the String value representing the text displayed on the first * display line of the second page @@ -316,8 +318,9 @@ public class Show extends RPCRequest { * * @since SmartDeviceLink 2.0 */ - public void setMainField3(String mainField3) { - setParameters(KEY_MAIN_FIELD_3, mainField3); + public Show setMainField3( String mainField3) { + setParameters(KEY_MAIN_FIELD_3, mainField3); + return this; } /** @@ -333,7 +336,7 @@ public class Show extends RPCRequest { /** * Sets the text displayed on the second display line of the second page - * + * * @param mainField4 * the String value representing the text displayed on the second * display line of the second page @@ -350,8 +353,9 @@ public class Show extends RPCRequest { * * @since SmartDeviceLink 2.0 */ - public void setMainField4(String mainField4) { - setParameters(KEY_MAIN_FIELD_4, mainField4); + public Show setMainField4( String mainField4) { + setParameters(KEY_MAIN_FIELD_4, mainField4); + return this; } /** * Gets the alignment that Specifies how mainField1 and mainField2 text @@ -365,7 +369,7 @@ public class Show extends RPCRequest { /** * Sets the alignment that Specifies how mainField1 and mainField2 text * should be aligned on display - * + * * @param alignment * an Enumeration value *

    @@ -377,9 +381,10 @@ public class Show extends RPCRequest { * mainField2 will be centered *
  • Has no effect with navigation display
  • * - */ - public void setAlignment(TextAlignment alignment) { - setParameters(KEY_ALIGNMENT, alignment); + */ + public Show setAlignment( TextAlignment alignment) { + setParameters(KEY_ALIGNMENT, alignment); + return this; } /** * Gets text in the Status Bar @@ -391,7 +396,7 @@ public class Show extends RPCRequest { } /** * Sets text in the Status Bar - * + * * @param statusBar * a String representing the text you want to add in the Status * Bar @@ -406,9 +411,10 @@ public class Show extends RPCRequest { *
  • If provided and the display has no status bar, this * parameter is ignored
  • * - */ - public void setStatusBar(String statusBar) { - setParameters(KEY_STATUS_BAR, statusBar); + */ + public Show setStatusBar( String statusBar) { + setParameters(KEY_STATUS_BAR, statusBar); + return this; } /** * Gets the String value of the MediaClock @@ -422,7 +428,7 @@ public class Show extends RPCRequest { /** * Sets the value for the MediaClock field using a format described in the * MediaClockFormat enumeration - * + * * @param mediaClock * a String value for the MdaiaClock *

    @@ -436,8 +442,9 @@ public class Show extends RPCRequest { * */ @Deprecated - public void setMediaClock(String mediaClock) { - setParameters(KEY_MEDIA_CLOCK, mediaClock); + public Show setMediaClock( String mediaClock) { + setParameters(KEY_MEDIA_CLOCK, mediaClock); + return this; } /** * Gets the text in the track field @@ -449,7 +456,7 @@ public class Show extends RPCRequest { } /** * Sets the text in the track field - * + * * @param mediaTrack * a String value displayed in the track field *

    @@ -459,14 +466,15 @@ public class Show extends RPCRequest { *
  • If an empty string is provided, the field will be cleared
  • *
  • This field is only valid for media applications on navigation displays
  • * - */ - public void setMediaTrack(String mediaTrack) { - setParameters(KEY_MEDIA_TRACK, mediaTrack); + */ + public Show setMediaTrack( String mediaTrack) { + setParameters(KEY_MEDIA_TRACK, mediaTrack); + return this; } /** * Sets an image to be shown on supported displays - * + * * @param graphic * the value representing the image shown on supported displays *

    @@ -474,8 +482,9 @@ public class Show extends RPCRequest { * graphic shall not change * @since SmartDeviceLink 2.0 */ - public void setGraphic(Image graphic) { - setParameters(KEY_GRAPHIC, graphic); + public Show setGraphic( Image graphic) { + setParameters(KEY_GRAPHIC, graphic); + return this; } /** @@ -491,8 +500,9 @@ public class Show extends RPCRequest { } - public void setSecondaryGraphic(Image secondaryGraphic) { - setParameters(KEY_SECONDARY_GRAPHIC, secondaryGraphic); + public Show setSecondaryGraphic( Image secondaryGraphic) { + setParameters(KEY_SECONDARY_GRAPHIC, secondaryGraphic); + return this; } @@ -516,7 +526,7 @@ public class Show extends RPCRequest { /** * Sets the the Soft buttons defined by the App - * + * * @param softButtons * a List value represemting the Soft buttons defined by the * App @@ -528,11 +538,12 @@ public class Show extends RPCRequest { *
  • Array Minsize: 0
  • *
  • Array Maxsize: 8
  • * - * + * * @since SmartDeviceLink 2.0 */ - public void setSoftButtons(List softButtons) { - setParameters(KEY_SOFT_BUTTONS, softButtons); + public Show setSoftButtons( List softButtons) { + setParameters(KEY_SOFT_BUTTONS, softButtons); + return this; } /** @@ -549,7 +560,7 @@ public class Show extends RPCRequest { /** * Sets the Custom Presets defined by the App - * + * * @param customPresets * a List value representing the Custom Presets defined by the * App @@ -561,8 +572,9 @@ public class Show extends RPCRequest { * * @since SmartDeviceLink 2.0 */ - public void setCustomPresets(List customPresets) { - setParameters(KEY_CUSTOM_PRESETS, customPresets); + public Show setCustomPresets( List customPresets) { + setParameters(KEY_CUSTOM_PRESETS, customPresets); + return this; } /** @@ -574,9 +586,10 @@ public class Show extends RPCRequest { *
      * @since SmartDeviceLink 4.5.0 */ - public void setMetadataTags(MetadataTags metadataTags){ - setParameters(KEY_METADATA_TAGS, metadataTags); - } + public Show setMetadataTags( MetadataTags metadataTags) { + setParameters(KEY_METADATA_TAGS, metadataTags); + return this; + } /** * Gets text field metadata defined by the App @@ -599,9 +612,10 @@ public class Show extends RPCRequest { * * @since 6.0 */ - public void setWindowID(Integer windowID) { - setParameters(KEY_WINDOW_ID, windowID); - } + public Show setWindowID( Integer windowID) { + setParameters(KEY_WINDOW_ID, windowID); + return this; + } /** * Gets the windowID. @@ -628,9 +642,10 @@ public class Show extends RPCRequest { * Sets the templateConfiguration. It's used to set an alternate template layout to a window. * @param templateConfiguration */ - public void setTemplateConfiguration(TemplateConfiguration templateConfiguration) { - setParameters(KEY_TEMPLATE_CONFIGURATION, templateConfiguration); - } + public Show setTemplateConfiguration( TemplateConfiguration templateConfiguration) { + setParameters(KEY_TEMPLATE_CONFIGURATION, templateConfiguration); + return this; + } /** * Sets the title of the new template that will be displayed. @@ -643,9 +658,10 @@ public class Show extends RPCRequest { *
    * @since SmartDeviceLink 6.0.0 */ - public void setTemplateTitle(String templateTitle){ - setParameters(KEY_TEMPLATE_TITLE, templateTitle); - } + public Show setTemplateTitle( String templateTitle) { + setParameters(KEY_TEMPLATE_TITLE, templateTitle); + return this; + } /** * Gets the title of the new template that will be displayed diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/ShowAppMenu.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/ShowAppMenu.java index 6c6c2e7c9..6531427d8 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/ShowAppMenu.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/ShowAppMenu.java @@ -68,9 +68,10 @@ public class ShowAppMenu extends RPCRequest { * previously added using `AddSubMenu`. * @param menuID - The SubMenu ID to open */ - public void setMenuID(Integer menuID){ - setParameters(KEY_MENU_ID, menuID); - } + public ShowAppMenu setMenuID( Integer menuID) { + setParameters(KEY_MENU_ID, menuID); + return this; + } /** * If omitted the HMI opens the apps menu. diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/ShowConstantTbt.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/ShowConstantTbt.java index 43ab3a137..a8e375b8f 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/ShowConstantTbt.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/ShowConstantTbt.java @@ -84,14 +84,15 @@ public class ShowConstantTbt extends RPCRequest{ /** * Sets a text for navigation text field 1 - * + * * @param navigationText1 * a String value representing a text for navigation text field 1 *

    * Notes: Maxlength=500 */ - public void setNavigationText1(String navigationText1){ + public ShowConstantTbt setNavigationText1( String navigationText1) { setParameters(KEY_TEXT1, navigationText1); + return this; } /** @@ -105,14 +106,15 @@ public class ShowConstantTbt extends RPCRequest{ /** * Sets a text for navigation text field 2 - * + * * @param navigationText2 * a String value representing a text for navigation text field 2 *

    * Notes: Maxlength=500 */ - public void setNavigationText2(String navigationText2){ + public ShowConstantTbt setNavigationText2( String navigationText2) { setParameters(KEY_TEXT2, navigationText2); + return this; } /** @@ -126,14 +128,15 @@ public class ShowConstantTbt extends RPCRequest{ /** * Sets a text field for estimated time of arrival - * + * * @param eta * a String value representing a text field for estimated time of arrival *

    * Notes: Maxlength=500 */ - public void setEta(String eta){ + public ShowConstantTbt setEta( String eta) { setParameters(KEY_ETA, eta); + return this; } /** @@ -147,14 +150,15 @@ public class ShowConstantTbt extends RPCRequest{ /** * Sets a text field for total distance - * + * * @param totalDistance * a String value representing a text field for total distance *

    * Notes: Maxlength=500 */ - public void setTotalDistance(String totalDistance){ + public ShowConstantTbt setTotalDistance( String totalDistance) { setParameters(KEY_TOTAL_DISTANCE, totalDistance); + return this; } /** @@ -168,12 +172,13 @@ public class ShowConstantTbt extends RPCRequest{ /** * Sets an Image for turnicon - * + * * @param turnIcon * an Image value */ - public void setTurnIcon(Image turnIcon){ + public ShowConstantTbt setTurnIcon( Image turnIcon) { setParameters(KEY_MANEUVER_IMAGE, turnIcon); + return this; } /** @@ -188,12 +193,13 @@ public class ShowConstantTbt extends RPCRequest{ /** * Sets an Image for nextTurnIcon - * + * * @param nextTurnIcon * an Image value */ - public void setNextTurnIcon(Image nextTurnIcon){ + public ShowConstantTbt setNextTurnIcon( Image nextTurnIcon) { setParameters(KEY_NEXT_MANEUVER_IMAGE, nextTurnIcon); + return this; } /** @@ -208,14 +214,15 @@ public class ShowConstantTbt extends RPCRequest{ /** * Sets a Fraction of distance till next maneuver - * + * * @param distanceToManeuver * a Double value representing a Fraction of distance till next maneuver *

    * Notes: Minvalue=0; Maxvalue=1000000000 */ - public void setDistanceToManeuver(Double distanceToManeuver){ + public ShowConstantTbt setDistanceToManeuver( Double distanceToManeuver) { setParameters(KEY_MANEUVER_DISTANCE, distanceToManeuver); + return this; } /** @@ -229,14 +236,15 @@ public class ShowConstantTbt extends RPCRequest{ /** * Sets a Distance till next maneuver (starting from) from previous maneuver - * + * * @param distanceToManeuverScale * a Double value representing a Distance till next maneuver (starting from) from previous maneuver *

    * Notes: Minvalue=0; Maxvalue=1000000000 */ - public void setDistanceToManeuverScale(Double distanceToManeuverScale){ + public ShowConstantTbt setDistanceToManeuverScale( Double distanceToManeuverScale) { setParameters(KEY_MANEUVER_DISTANCE_SCALE, distanceToManeuverScale); + return this; } /** @@ -252,13 +260,14 @@ public class ShowConstantTbt extends RPCRequest{ *

    Sets a maneuver complete flag. If and when a maneuver has completed while an AlertManeuver is active, the app * must send this value set to TRUE in order to clear the AlertManeuver overlay * If omitted the value will be assumed as FALSE

    - * - * + * + * * @param maneuverComplete * a Boolean value */ - public void setManeuverComplete(Boolean maneuverComplete){ + public ShowConstantTbt setManeuverComplete( Boolean maneuverComplete) { setParameters(KEY_MANEUVER_COMPLETE, maneuverComplete); + return this; } /** @@ -273,14 +282,15 @@ public class ShowConstantTbt extends RPCRequest{ /** *

    Sets Three dynamic SoftButtons available (first SoftButton is fixed to "Turns"). If omitted on supported * displays, the currently displayed SoftButton values will not change

    - * + * *

    Notes: Minsize=0; Maxsize=3

    - * + * * @param softButtons * a List value */ - public void setSoftButtons(List softButtons){ + public ShowConstantTbt setSoftButtons( List softButtons) { setParameters(KEY_SOFT_BUTTONS, softButtons); + return this; } /** @@ -294,8 +304,9 @@ public class ShowConstantTbt extends RPCRequest{ return (List) getObject(SoftButton.class, KEY_SOFT_BUTTONS); } - public void setTimeToDestination(String timeToDestination){ + public ShowConstantTbt setTimeToDestination( String timeToDestination) { setParameters(KEY_TIME_TO_DESTINATION, timeToDestination); + return this; } public String getTimeToDestination(){ diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/SingleTireStatus.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/SingleTireStatus.java index 7a0edfa3c..faadb2406 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/SingleTireStatus.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/SingleTireStatus.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -105,8 +105,9 @@ public class SingleTireStatus extends RPCStruct { * set the volume status of a single tire * @param status the volume status of a single tire */ - public void setStatus(@NonNull ComponentVolumeStatus status) { - setValue(KEY_STATUS, status); + public SingleTireStatus setStatus(@NonNull ComponentVolumeStatus status) { + setValue(KEY_STATUS, status); + return this; } /** @@ -121,7 +122,10 @@ public class SingleTireStatus extends RPCStruct { * Set the status of TPMS according to the particular tire. * @param tpms The status of TPMS */ - public void setTPMS(@NonNull TPMS tpms) { setValue(KEY_TPMS, tpms); } + public SingleTireStatus setTPMS(@NonNull TPMS tpms) { + setValue(KEY_TPMS, tpms); + return this; + } /** * Get the status of TPMS according to the particular tire. @@ -134,7 +138,10 @@ public class SingleTireStatus extends RPCStruct { /** * @param pressure The pressure value of the particular tire in kilo pascal. */ - public void setPressure(@NonNull Float pressure) { setValue(KEY_PRESSURE, pressure); } + public SingleTireStatus setPressure(@NonNull Float pressure) { + setValue(KEY_PRESSURE, pressure); + return this; + } /** * @return the pressure value of the particular tire in kilo pascal. diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/SisData.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/SisData.java index be97e14cd..e25ac69b9 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/SisData.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/SisData.java @@ -63,9 +63,10 @@ public class SisData extends RPCStruct { * * @param stationShortName Identifies the 4-alpha-character station call sign plus an optional (-FM) extension. */ - public void setStationShortName(String stationShortName) { - setValue(KEY_STATION_SHORT_NAME, stationShortName); - } + public SisData setStationShortName( String stationShortName) { + setValue(KEY_STATION_SHORT_NAME, stationShortName); + return this; + } /** * Gets the stationShortName portion of the SisData class @@ -81,9 +82,10 @@ public class SisData extends RPCStruct { * * @param stationIDNumber Consists of Country Code and FCC Facility ID */ - public void setStationIDNumber(StationIDNumber stationIDNumber) { - setValue(KEY_STATION_ID_NUMBER, stationIDNumber); - } + public SisData setStationIDNumber( StationIDNumber stationIDNumber) { + setValue(KEY_STATION_ID_NUMBER, stationIDNumber); + return this; + } /** * Gets the stationIDNumber which is used for network Application. Consists of Country Code and FCC Facility ID @@ -100,9 +102,10 @@ public class SisData extends RPCStruct { * * @param stationLongName Identifies the station call sign or other identifying information in the long format. */ - public void setStationLongName(String stationLongName) { - setValue(KEY_STATION_LONG_NAME, stationLongName); - } + public SisData setStationLongName( String stationLongName) { + setValue(KEY_STATION_LONG_NAME, stationLongName); + return this; + } /** * Gets the stationLongName portion of the SisData class @@ -118,9 +121,10 @@ public class SisData extends RPCStruct { * * @param stationLocation Provides the 3-dimensional geographic station location. */ - public void setStationLocation(GPSData stationLocation) { - setValue(KEY_STATION_LOCATION, stationLocation); - } + public SisData setStationLocation( GPSData stationLocation) { + setValue(KEY_STATION_LOCATION, stationLocation); + return this; + } /** * Gets the stationLocation portion of the SisData class @@ -138,9 +142,10 @@ public class SisData extends RPCStruct { * @param stationMessage May be used to convey textual information of general interest to the consumer such as weather forecasts or public service announcements. * Includes a high priority delivery feature to convey emergencies that may be in the listening area. */ - public void setStationMessage(String stationMessage) { - setValue(KEY_STATION_MESSAGE, stationMessage); - } + public SisData setStationMessage( String stationMessage) { + setValue(KEY_STATION_MESSAGE, stationMessage); + return this; + } /** * Gets the stationMessage portion of the SisData class diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/Slider.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/Slider.java index 374c610fe..0b9f10491 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/Slider.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/Slider.java @@ -168,15 +168,16 @@ public class Slider extends RPCRequest { /** * Sets a number of selectable items on a horizontal axis - * + * * @param numTicks * an Integer value representing a number of selectable items on * a horizontal axis *

    * Notes: Minvalue=2; Maxvalue=26 */ - public void setNumTicks(@NonNull Integer numTicks) { - setParameters(KEY_NUM_TICKS, numTicks); + public Slider setNumTicks(@NonNull Integer numTicks) { + setParameters(KEY_NUM_TICKS, numTicks); + return this; } /** @@ -191,15 +192,16 @@ public class Slider extends RPCRequest { /** * Sets an Initial position of slider control - * + * * @param position * an Integer value representing an Initial position of slider * control *

    * Notes: Minvalue=1; Maxvalue=26 */ - public void setPosition(@NonNull Integer position) { - setParameters(KEY_POSITION, position); + public Slider setPosition(@NonNull Integer position) { + setParameters(KEY_POSITION, position); + return this; } /** @@ -214,14 +216,15 @@ public class Slider extends RPCRequest { /** * Sets a text header to display - * + * * @param sliderHeader * a String value *

    * Notes: Maxlength=500 */ - public void setSliderHeader(@NonNull String sliderHeader) { - setParameters(KEY_SLIDER_HEADER, sliderHeader); + public Slider setSliderHeader(@NonNull String sliderHeader) { + setParameters(KEY_SLIDER_HEADER, sliderHeader); + return this; } /** @@ -235,14 +238,15 @@ public class Slider extends RPCRequest { /** * Sets a text footer to display - * + * * @param sliderFooter * a List value representing a text footer to display *

    * Notes: Maxlength=500; Minvalue=1; Maxvalue=26 */ - public void setSliderFooter(List sliderFooter) { - setParameters(KEY_SLIDER_FOOTER, sliderFooter); + public Slider setSliderFooter( List sliderFooter) { + setParameters(KEY_SLIDER_FOOTER, sliderFooter); + return this; } /** @@ -257,14 +261,15 @@ public class Slider extends RPCRequest { /** * Sets an App defined timeout - * + * * @param timeout * an Integer value representing an App defined timeout *

    * Notes: Minvalue=0; Maxvalue=65535; Defvalue=10000 */ - public void setTimeout(Integer timeout) { - setParameters(KEY_TIMEOUT, timeout); + public Slider setTimeout( Integer timeout) { + setParameters(KEY_TIMEOUT, timeout); + return this; } /** @@ -293,7 +298,8 @@ public class Slider extends RPCRequest { * * @since SmartDeviceLink 6.0 */ - public void setCancelID(Integer cancelID) { - setParameters(KEY_CANCEL_ID, cancelID); - } + public Slider setCancelID( Integer cancelID) { + setParameters(KEY_CANCEL_ID, cancelID); + return this; + } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/SliderResponse.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/SliderResponse.java index cad93b19b..5f802bd19 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/SliderResponse.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/SliderResponse.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -81,8 +81,9 @@ public class SliderResponse extends RPCResponse { * Sets an Initial position of slider control * @param sliderPosition the starting position of the slider control */ - public void setSliderPosition(Integer sliderPosition) { - setParameters(KEY_SLIDER_POSITION, sliderPosition); + public SliderResponse setSliderPosition( Integer sliderPosition) { + setParameters(KEY_SLIDER_POSITION, sliderPosition); + return this; } /** * Gets an Initial position of slider control diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/SoftButton.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/SoftButton.java index bfafea14e..ef25006da 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/SoftButton.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/SoftButton.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -136,39 +136,45 @@ public class SoftButton extends RPCStruct { setSoftButtonID(softButtonID); } - public void setType(@NonNull SoftButtonType type) { + public SoftButton setType(@NonNull SoftButtonType type) { setValue(KEY_TYPE, type); + return this; } public SoftButtonType getType() { return (SoftButtonType) getObject(SoftButtonType.class, KEY_TYPE); } - public void setText(String text) { + public SoftButton setText( String text) { setValue(KEY_TEXT, text); + return this; } public String getText() { return getString(KEY_TEXT); } - public void setImage(Image image) { + public SoftButton setImage( Image image) { setValue(KEY_IMAGE, image); + return this; } @SuppressWarnings("unchecked") public Image getImage() { return (Image) getObject(Image.class, KEY_IMAGE); } - public void setIsHighlighted(Boolean isHighlighted) { + public SoftButton setIsHighlighted( Boolean isHighlighted) { setValue(KEY_IS_HIGHLIGHTED, isHighlighted); + return this; } public Boolean getIsHighlighted() { return getBoolean(KEY_IS_HIGHLIGHTED); } - public void setSoftButtonID(@NonNull Integer softButtonID) { + public SoftButton setSoftButtonID(@NonNull Integer softButtonID) { setValue(KEY_SOFT_BUTTON_ID, softButtonID); + return this; } public Integer getSoftButtonID() { return getInteger(KEY_SOFT_BUTTON_ID); } - public void setSystemAction(SystemAction systemAction) { + public SoftButton setSystemAction( SystemAction systemAction) { setValue(KEY_SYSTEM_ACTION, systemAction); + return this; } public SystemAction getSystemAction() { return (SystemAction) getObject(SystemAction.class, KEY_SYSTEM_ACTION); diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/SoftButtonCapabilities.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/SoftButtonCapabilities.java index bdd2a0b9b..baac6ecda 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/SoftButtonCapabilities.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/SoftButtonCapabilities.java @@ -131,8 +131,9 @@ public class SoftButtonCapabilities extends RPCStruct { * set the button supports a short press. * @param shortPressAvailable whether the button supports a short press. */ - public void setShortPressAvailable(@NonNull Boolean shortPressAvailable) { + public SoftButtonCapabilities setShortPressAvailable(@NonNull Boolean shortPressAvailable) { setValue(KEY_SHORT_PRESS_AVAILABLE, shortPressAvailable); + return this; } /** @@ -147,8 +148,9 @@ public class SoftButtonCapabilities extends RPCStruct { * set the button supports a LONG press. * @param longPressAvailable whether the button supports a long press */ - public void setLongPressAvailable(@NonNull Boolean longPressAvailable) { + public SoftButtonCapabilities setLongPressAvailable(@NonNull Boolean longPressAvailable) { setValue(KEY_LONG_PRESS_AVAILABLE, longPressAvailable); + return this; } /** @@ -160,11 +162,12 @@ public class SoftButtonCapabilities extends RPCStruct { } /** - * set the button supports "button down" and "button up". - * @param upDownAvailable the button supports "button down" and "button up". + * set the button supports "button down" and "button up". + * @param upDownAvailable the button supports "button down" and "button up". */ - public void setUpDownAvailable(@NonNull Boolean upDownAvailable) { + public SoftButtonCapabilities setUpDownAvailable(@NonNull Boolean upDownAvailable) { setValue(KEY_UP_DOWN_AVAILABLE, upDownAvailable); + return this; } /** @@ -179,8 +182,9 @@ public class SoftButtonCapabilities extends RPCStruct { * set the button supports referencing a static or dynamic image. * @param imageSupported whether the button supports referencing a static or dynamic image. */ - public void setImageSupported(@NonNull Boolean imageSupported) { + public SoftButtonCapabilities setImageSupported(@NonNull Boolean imageSupported) { setValue(KEY_IMAGE_SUPPORTED, imageSupported); + return this; } /** @@ -196,8 +200,9 @@ public class SoftButtonCapabilities extends RPCStruct { * @param textSupported whether the button supports the use of text or not. * @since 6.0 */ - public void setTextSupported(Boolean textSupported) { + public SoftButtonCapabilities setTextSupported( Boolean textSupported) { setValue(KEY_TEXT_SUPPORTED, textSupported); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/Speak.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/Speak.java index a0c66a99f..d48e6e757 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/Speak.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/Speak.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -180,7 +180,7 @@ public class Speak extends RPCRequest { /** * Sets a List representing an array of 1-100 TTSChunk structs * which, taken together, specify the phrase to be spoken - * + * * @param ttsChunks * a List value representing an array of 1-100 TTSChunk structs * which specify the phrase to be spoken @@ -192,8 +192,9 @@ public class Speak extends RPCRequest { * be rejected *
  • Each chunk can be no more than 500 characters
  • * - */ - public void setTtsChunks( @NonNull List ttsChunks ) { - setParameters(KEY_TTS_CHUNKS, ttsChunks); + */ + public Speak setTtsChunks(@NonNull List ttsChunks) { + setParameters(KEY_TTS_CHUNKS, ttsChunks); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/StabilityControlsStatus.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/StabilityControlsStatus.java index 5ee5eb0b4..78eb84149 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/StabilityControlsStatus.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/StabilityControlsStatus.java @@ -101,8 +101,9 @@ public class StabilityControlsStatus extends RPCStruct { * * @param escSystem true if vehicle stability control is ON, else false */ - public void setEscSystem(VehicleDataStatus escSystem) { + public StabilityControlsStatus setEscSystem( VehicleDataStatus escSystem) { setValue(KEY_ESC_SYSTEM, escSystem); + return this; } /** @@ -110,8 +111,9 @@ public class StabilityControlsStatus extends RPCStruct { * * @param trailerSwayControl true if vehicle trailer sway control is ON, else false */ - public void setTrailerSwayControl(VehicleDataStatus trailerSwayControl) { + public StabilityControlsStatus setTrailerSwayControl( VehicleDataStatus trailerSwayControl) { setValue(KEY_TRAILER_SWAY_CONTROL, trailerSwayControl); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/StartTime.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/StartTime.java index 96060d535..fd7f640bf 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/StartTime.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/StartTime.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -124,9 +124,10 @@ public class StartTime extends RPCStruct { * Set the hour. Minvalue="0", maxvalue="59" *

    Note:

    Some display types only support a max value of 19. If out of range, it will be rejected. * @param hours min: 0; max: 59 - */ - public void setHours(@NonNull Integer hours ) { + */ + public StartTime setHours(@NonNull Integer hours) { setValue(KEY_HOURS, hours); + return this; } /** * Get the minute. Minvalue="0", maxvalue="59". @@ -138,9 +139,10 @@ public class StartTime extends RPCStruct { /** * Set the minute. Minvalue="0", maxvalue="59". * @param minutes min: 0; max: 59 - */ - public void setMinutes( @NonNull Integer minutes ) { + */ + public StartTime setMinutes(@NonNull Integer minutes) { setValue(KEY_MINUTES, minutes); + return this; } /** * Get the second. Minvalue="0", maxvalue="59". @@ -152,8 +154,9 @@ public class StartTime extends RPCStruct { /** * Set the second. Minvalue="0", maxvalue="59". * @param seconds min: 0 max: 59 - */ - public void setSeconds( @NonNull Integer seconds ) { + */ + public StartTime setSeconds(@NonNull Integer seconds) { setValue(KEY_SECONDS, seconds); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/StationIDNumber.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/StationIDNumber.java index b75cb3752..fd0365e66 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/StationIDNumber.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/StationIDNumber.java @@ -51,9 +51,10 @@ public class StationIDNumber extends RPCStruct { * * @param countryCode Binary Representation of ITU Country Code. USA Code is 001. */ - public void setCountryCode(Integer countryCode) { - setValue(KEY_COUNTRY_CODE, countryCode); - } + public StationIDNumber setCountryCode( Integer countryCode) { + setValue(KEY_COUNTRY_CODE, countryCode); + return this; + } /** * Gets the countryCode portion of the StationIDNumber class @@ -69,9 +70,10 @@ public class StationIDNumber extends RPCStruct { * * @param fccFacilityId Binary representation of unique facility ID assigned by the FCC; FCC controlled for U.S. territory. */ - public void setFccFacilityId(Integer fccFacilityId) { - setValue(KEY_FCC_FACILITY_ID, fccFacilityId); - } + public StationIDNumber setFccFacilityId( Integer fccFacilityId) { + setValue(KEY_FCC_FACILITY_ID, fccFacilityId); + return this; + } /** * Gets the fccFacilityId portion of the StationIDNumber class diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeButton.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeButton.java index 3c830dd61..171c4b18e 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeButton.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeButton.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -144,9 +144,10 @@ public class SubscribeButton extends RPCRequest { } /** * Sets a name of the button to subscribe to - * @param buttonName a {@linkplain com.smartdevicelink.proxy.rpc.enums.ButtonName} value - */ - public void setButtonName(@NonNull ButtonName buttonName ) { + * @param buttonName a {@linkplain ButtonName} value + */ + public SubscribeButton setButtonName(@NonNull ButtonName buttonName) { setParameters(KEY_BUTTON_NAME, buttonName); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeVehicleData.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeVehicleData.java index 20822e451..7dbbbc247 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeVehicleData.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeVehicleData.java @@ -391,12 +391,13 @@ public class SubscribeVehicleData extends RPCRequest { /** * Sets a boolean value. If true, subscribes Gps data - * + * * @param gps * a boolean value */ - public void setGps(Boolean gps) { - setParameters(KEY_GPS, gps); + public SubscribeVehicleData setGps( Boolean gps) { + setParameters(KEY_GPS, gps); + return this; } /** @@ -411,12 +412,13 @@ public class SubscribeVehicleData extends RPCRequest { /** * Sets a boolean value. If true, subscribes speed data - * + * * @param speed * a boolean value */ - public void setSpeed(Boolean speed) { - setParameters(KEY_SPEED, speed); + public SubscribeVehicleData setSpeed( Boolean speed) { + setParameters(KEY_SPEED, speed); + return this; } /** @@ -431,12 +433,13 @@ public class SubscribeVehicleData extends RPCRequest { /** * Sets a boolean value. If true, subscribes rpm data - * + * * @param rpm * a boolean value */ - public void setRpm(Boolean rpm) { - setParameters(KEY_RPM, rpm); + public SubscribeVehicleData setRpm( Boolean rpm) { + setParameters(KEY_RPM, rpm); + return this; } /** @@ -451,13 +454,14 @@ public class SubscribeVehicleData extends RPCRequest { /** * Sets the fuelLevel. - * + * * @param fuelLevel The fuel level in the tank (percentage). This parameter is deprecated starting RPC Spec * 7.0, please see fuelRange. */ @Deprecated - public void setFuelLevel(Boolean fuelLevel) { - setParameters(KEY_FUEL_LEVEL, fuelLevel); + public SubscribeVehicleData setFuelLevel( Boolean fuelLevel) { + setParameters(KEY_FUEL_LEVEL, fuelLevel); + return this; } /** @@ -473,13 +477,14 @@ public class SubscribeVehicleData extends RPCRequest { /** * Sets a boolean value. If true, subscribes fuelLevelState data - * + * * @param fuelLevelState * a boolean value */ @Deprecated - public void setFuelLevelState(Boolean fuelLevelState) { - setParameters(KEY_FUEL_LEVEL_STATE, fuelLevelState); + public SubscribeVehicleData setFuelLevelState( Boolean fuelLevelState) { + setParameters(KEY_FUEL_LEVEL_STATE, fuelLevelState); + return this; } /** @@ -496,12 +501,13 @@ public class SubscribeVehicleData extends RPCRequest { /** * Sets a boolean value. If true, subscribes instantFuelConsumption data - * + * * @param instantFuelConsumption * a boolean value */ - public void setInstantFuelConsumption(Boolean instantFuelConsumption) { - setParameters(KEY_INSTANT_FUEL_CONSUMPTION, instantFuelConsumption); + public SubscribeVehicleData setInstantFuelConsumption( Boolean instantFuelConsumption) { + setParameters(KEY_INSTANT_FUEL_CONSUMPTION, instantFuelConsumption); + return this; } /** @@ -517,12 +523,13 @@ public class SubscribeVehicleData extends RPCRequest { /** * Sets a boolean value. If true, subscribes externalTemperature data - * + * * @param externalTemperature * a boolean value */ - public void setExternalTemperature(Boolean externalTemperature) { - setParameters(KEY_EXTERNAL_TEMPERATURE, externalTemperature); + public SubscribeVehicleData setExternalTemperature( Boolean externalTemperature) { + setParameters(KEY_EXTERNAL_TEMPERATURE, externalTemperature); + return this; } /** @@ -542,8 +549,9 @@ public class SubscribeVehicleData extends RPCRequest { * @param gearStatus See GearStatus * @since SmartDeviceLink 7.0.0 */ - public void setGearStatus(Boolean gearStatus) { + public SubscribeVehicleData setGearStatus( Boolean gearStatus) { setParameters(KEY_GEAR_STATUS, gearStatus); + return this; } /** @@ -563,8 +571,9 @@ public class SubscribeVehicleData extends RPCRequest { * @deprecated in SmartDeviceLink 7.0.0 */ @Deprecated - public void setPrndl(Boolean prndl) { - setParameters(KEY_PRNDL, prndl); + public SubscribeVehicleData setPrndl( Boolean prndl) { + setParameters(KEY_PRNDL, prndl); + return this; } /** @@ -580,12 +589,13 @@ public class SubscribeVehicleData extends RPCRequest { /** * Sets a boolean value. If true, subscribes tire pressure status data - * + * * @param tirePressure * a boolean value */ - public void setTirePressure(Boolean tirePressure) { - setParameters(KEY_TIRE_PRESSURE, tirePressure); + public SubscribeVehicleData setTirePressure( Boolean tirePressure) { + setParameters(KEY_TIRE_PRESSURE, tirePressure); + return this; } /** @@ -601,12 +611,13 @@ public class SubscribeVehicleData extends RPCRequest { /** * Sets a boolean value. If true, subscribes odometer data - * + * * @param odometer * a boolean value */ - public void setOdometer(Boolean odometer) { - setParameters(KEY_ODOMETER, odometer); + public SubscribeVehicleData setOdometer( Boolean odometer) { + setParameters(KEY_ODOMETER, odometer); + return this; } /** @@ -622,12 +633,13 @@ public class SubscribeVehicleData extends RPCRequest { /** * Sets a boolean value. If true, subscribes belt Status data - * + * * @param beltStatus * a boolean value */ - public void setBeltStatus(Boolean beltStatus) { - setParameters(KEY_BELT_STATUS, beltStatus); + public SubscribeVehicleData setBeltStatus( Boolean beltStatus) { + setParameters(KEY_BELT_STATUS, beltStatus); + return this; } /** @@ -643,12 +655,13 @@ public class SubscribeVehicleData extends RPCRequest { /** * Sets a boolean value. If true, subscribes body Information data - * + * * @param bodyInformation * a boolean value */ - public void setBodyInformation(Boolean bodyInformation) { - setParameters(KEY_BODY_INFORMATION, bodyInformation); + public SubscribeVehicleData setBodyInformation( Boolean bodyInformation) { + setParameters(KEY_BODY_INFORMATION, bodyInformation); + return this; } /** @@ -664,12 +677,13 @@ public class SubscribeVehicleData extends RPCRequest { /** * Sets a boolean value. If true, subscribes device Status data - * + * * @param deviceStatus * a boolean value */ - public void setDeviceStatus(Boolean deviceStatus) { - setParameters(KEY_DEVICE_STATUS, deviceStatus); + public SubscribeVehicleData setDeviceStatus( Boolean deviceStatus) { + setParameters(KEY_DEVICE_STATUS, deviceStatus); + return this; } /** @@ -685,12 +699,13 @@ public class SubscribeVehicleData extends RPCRequest { /** * Sets a boolean value. If true, subscribes driver Braking data - * + * * @param driverBraking * a boolean value */ - public void setDriverBraking(Boolean driverBraking) { - setParameters(KEY_DRIVER_BRAKING, driverBraking); + public SubscribeVehicleData setDriverBraking( Boolean driverBraking) { + setParameters(KEY_DRIVER_BRAKING, driverBraking); + return this; } /** @@ -706,12 +721,13 @@ public class SubscribeVehicleData extends RPCRequest { /** * Sets a boolean value. If true, subscribes wiper Status data - * + * * @param wiperStatus * a boolean value */ - public void setWiperStatus(Boolean wiperStatus) { - setParameters(KEY_WIPER_STATUS, wiperStatus); + public SubscribeVehicleData setWiperStatus( Boolean wiperStatus) { + setParameters(KEY_WIPER_STATUS, wiperStatus); + return this; } /** @@ -727,12 +743,13 @@ public class SubscribeVehicleData extends RPCRequest { /** * Sets a boolean value. If true, subscribes Head Lamp Status data - * + * * @param headLampStatus * a boolean value */ - public void setHeadLampStatus(Boolean headLampStatus) { - setParameters(KEY_HEAD_LAMP_STATUS, headLampStatus); + public SubscribeVehicleData setHeadLampStatus( Boolean headLampStatus) { + setParameters(KEY_HEAD_LAMP_STATUS, headLampStatus); + return this; } /** @@ -752,9 +769,10 @@ public class SubscribeVehicleData extends RPCRequest { * @param engineTorque * a boolean value */ - public void setEngineTorque(Boolean engineTorque) { - setParameters(KEY_ENGINE_TORQUE, engineTorque); - } + public SubscribeVehicleData setEngineTorque( Boolean engineTorque) { + setParameters(KEY_ENGINE_TORQUE, engineTorque); + return this; + } /** * Gets a boolean value. If true, means the Engine Oil Life data has been @@ -773,9 +791,10 @@ public class SubscribeVehicleData extends RPCRequest { * @param engineOilLife * a boolean value */ - public void setEngineOilLife(Boolean engineOilLife) { - setParameters(KEY_ENGINE_OIL_LIFE, engineOilLife); - } + public SubscribeVehicleData setEngineOilLife( Boolean engineOilLife) { + setParameters(KEY_ENGINE_OIL_LIFE, engineOilLife); + return this; + } /** * Gets a boolean value. If true, means the Engine Torque data has been @@ -794,8 +813,9 @@ public class SubscribeVehicleData extends RPCRequest { * @param accPedalPosition * a boolean value */ - public void setAccPedalPosition(Boolean accPedalPosition) { - setParameters(KEY_ACC_PEDAL_POSITION, accPedalPosition); + public SubscribeVehicleData setAccPedalPosition( Boolean accPedalPosition) { + setParameters(KEY_ACC_PEDAL_POSITION, accPedalPosition); + return this; } /** @@ -809,39 +829,45 @@ public class SubscribeVehicleData extends RPCRequest { return getBoolean(KEY_ACC_PEDAL_POSITION); } - public void setSteeringWheelAngle(Boolean steeringWheelAngle) { - setParameters(KEY_STEERING_WHEEL_ANGLE, steeringWheelAngle); + public SubscribeVehicleData setSteeringWheelAngle( Boolean steeringWheelAngle) { + setParameters(KEY_STEERING_WHEEL_ANGLE, steeringWheelAngle); + return this; } public Boolean getSteeringWheelAngle() { return getBoolean(KEY_STEERING_WHEEL_ANGLE); } - public void setECallInfo(Boolean eCallInfo) { - setParameters(KEY_E_CALL_INFO, eCallInfo); + public SubscribeVehicleData setECallInfo( Boolean eCallInfo) { + setParameters(KEY_E_CALL_INFO, eCallInfo); + return this; } public Boolean getECallInfo() { return getBoolean(KEY_E_CALL_INFO); } - public void setAirbagStatus(Boolean airbagStatus) { - setParameters(KEY_AIRBAG_STATUS, airbagStatus); + public SubscribeVehicleData setAirbagStatus( Boolean airbagStatus) { + setParameters(KEY_AIRBAG_STATUS, airbagStatus); + return this; } public Boolean getAirbagStatus() { return getBoolean(KEY_AIRBAG_STATUS); } - public void setEmergencyEvent(Boolean emergencyEvent) { - setParameters(KEY_EMERGENCY_EVENT, emergencyEvent); + public SubscribeVehicleData setEmergencyEvent( Boolean emergencyEvent) { + setParameters(KEY_EMERGENCY_EVENT, emergencyEvent); + return this; } public Boolean getEmergencyEvent() { return getBoolean(KEY_EMERGENCY_EVENT); } - public void setClusterModeStatus(Boolean clusterModeStatus) { - setParameters(KEY_CLUSTER_MODE_STATUS, clusterModeStatus); + public SubscribeVehicleData setClusterModeStatus( Boolean clusterModeStatus) { + setParameters(KEY_CLUSTER_MODE_STATUS, clusterModeStatus); + return this; } public Boolean getClusterModeStatus() { return getBoolean(KEY_CLUSTER_MODE_STATUS); } - public void setMyKey(Boolean myKey) { - setParameters(KEY_MY_KEY, myKey); + public SubscribeVehicleData setMyKey( Boolean myKey) { + setParameters(KEY_MY_KEY, myKey); + return this; } public Boolean getMyKey() { return getBoolean(KEY_MY_KEY); @@ -854,9 +880,10 @@ public class SubscribeVehicleData extends RPCRequest { * vehicle. See struct FuelRange for details. * @since SmartDeviceLink 5.0.0 */ - public void setFuelRange(Boolean fuelRange) { - setParameters(KEY_FUEL_RANGE, fuelRange); - } + public SubscribeVehicleData setFuelRange( Boolean fuelRange) { + setParameters(KEY_FUEL_RANGE, fuelRange); + return this; + } /** * Gets the fuelRange. @@ -873,7 +900,10 @@ public class SubscribeVehicleData extends RPCRequest { * Sets a boolean value. If true, subscribes turnSignal data * @param turnSignal a boolean value */ - public void setTurnSignal(Boolean turnSignal) { setParameters(KEY_TURN_SIGNAL, turnSignal); } + public SubscribeVehicleData setTurnSignal( Boolean turnSignal) { + setParameters(KEY_TURN_SIGNAL, turnSignal); + return this; + } /** * Gets a boolean value. If true, means the turnSignal data has been subscribed. @@ -885,9 +915,10 @@ public class SubscribeVehicleData extends RPCRequest { * Sets a boolean value. If true, subscribes electronicParkBrakeStatus data * @param electronicParkBrakeStatus a boolean value */ - public void setElectronicParkBrakeStatus(boolean electronicParkBrakeStatus){ - setParameters(KEY_ELECTRONIC_PARK_BRAKE_STATUS, electronicParkBrakeStatus); - } + public SubscribeVehicleData setElectronicParkBrakeStatus( boolean electronicParkBrakeStatus) { + setParameters(KEY_ELECTRONIC_PARK_BRAKE_STATUS, electronicParkBrakeStatus); + return this; + } /** * Gets a boolean value. If true, means the electronicParkBrakeStatus data has been subscribed. @@ -901,9 +932,10 @@ public class SubscribeVehicleData extends RPCRequest { * Sets a boolean value. If true, subscribes cloudAppVehicleID data * @param cloudAppVehicleID a boolean value */ - public void setCloudAppVehicleID(boolean cloudAppVehicleID){ - setParameters(KEY_CLOUD_APP_VEHICLE_ID, cloudAppVehicleID); - } + public SubscribeVehicleData setCloudAppVehicleID( boolean cloudAppVehicleID) { + setParameters(KEY_CLOUD_APP_VEHICLE_ID, cloudAppVehicleID); + return this; + } /** * Gets a boolean value. If true, means the cloudAppVehicleDataID data has been subscribed. @@ -918,9 +950,10 @@ public class SubscribeVehicleData extends RPCRequest { * @param vehicleDataName a String value * @param vehicleDataState a boolean value */ - public void setOEMCustomVehicleData(String vehicleDataName, Boolean vehicleDataState){ - setParameters(vehicleDataName, vehicleDataState); - } + public SubscribeVehicleData setOEMCustomVehicleData( String vehicleDataName, Boolean vehicleDataState) { + setParameters(vehicleDataName, vehicleDataState); + return this; + } /** * Gets a boolean value for OEM Custom VehicleData. @@ -936,8 +969,9 @@ public class SubscribeVehicleData extends RPCRequest { * @param windowStatus See WindowStatus * @since SmartDeviceLink 7.0.0 */ - public void setWindowStatus(Boolean windowStatus) { + public SubscribeVehicleData setWindowStatus( Boolean windowStatus) { setParameters(KEY_WINDOW_STATUS, windowStatus); + return this; } /** @@ -956,8 +990,9 @@ public class SubscribeVehicleData extends RPCRequest { * @param handsOffSteering To indicate whether driver hands are off the steering wheel * @since SmartDeviceLink 7.0.0 */ - public void setHandsOffSteering(Boolean handsOffSteering) { + public SubscribeVehicleData setHandsOffSteering( Boolean handsOffSteering) { setParameters(KEY_HANDS_OFF_STEERING, handsOffSteering); + return this; } /** @@ -986,7 +1021,8 @@ public class SubscribeVehicleData extends RPCRequest { * @param stabilityControlsStatus See StabilityControlsStatus * @since SmartDeviceLink 7.0.0 */ - public void setStabilityControlsStatus(Boolean stabilityControlsStatus) { + public SubscribeVehicleData setStabilityControlsStatus( Boolean stabilityControlsStatus) { setParameters(KEY_STABILITY_CONTROLS_STATUS, stabilityControlsStatus); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeVehicleDataResponse.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeVehicleDataResponse.java index 670687814..dfe668f66 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeVehicleDataResponse.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeVehicleDataResponse.java @@ -118,8 +118,9 @@ public class SubscribeVehicleDataResponse extends RPCResponse { * Sets Gps * @param gps a VehicleDataResult related to GPS */ - public void setGps(VehicleDataResult gps) { + public SubscribeVehicleDataResponse setGps( VehicleDataResult gps) { setParameters(KEY_GPS, gps); + return this; } /** * Gets Gps @@ -133,8 +134,9 @@ public class SubscribeVehicleDataResponse extends RPCResponse { * Sets Speed * @param speed a VehicleDataResult related to speed */ - public void setSpeed(VehicleDataResult speed) { + public SubscribeVehicleDataResponse setSpeed( VehicleDataResult speed) { setParameters(KEY_SPEED, speed); + return this; } /** * Gets Speed @@ -148,8 +150,9 @@ public class SubscribeVehicleDataResponse extends RPCResponse { * Sets rpm * @param rpm a VehicleDataResult related to RPM */ - public void setRpm(VehicleDataResult rpm) { + public SubscribeVehicleDataResponse setRpm( VehicleDataResult rpm) { setParameters(KEY_RPM, rpm); + return this; } /** * Gets rpm @@ -166,8 +169,9 @@ public class SubscribeVehicleDataResponse extends RPCResponse { * 7.0, please see fuelRange. */ @Deprecated - public void setFuelLevel(VehicleDataResult fuelLevel) { + public SubscribeVehicleDataResponse setFuelLevel( VehicleDataResult fuelLevel) { setParameters(KEY_FUEL_LEVEL, fuelLevel); + return this; } /** * Gets the fuelLevel. @@ -185,8 +189,9 @@ public class SubscribeVehicleDataResponse extends RPCResponse { * @param fuelLevelState a VehicleDataResult related to FuelLevel State */ @Deprecated - public void setFuelLevelState(VehicleDataResult fuelLevelState) { + public SubscribeVehicleDataResponse setFuelLevelState( VehicleDataResult fuelLevelState) { setParameters(KEY_FUEL_LEVEL_STATE, fuelLevelState); + return this; } /** * Gets Fuel Level State @@ -201,8 +206,9 @@ public class SubscribeVehicleDataResponse extends RPCResponse { * Sets Instant Fuel Consumption * @param instantFuelConsumption a VehicleDataResult related to instant fuel consumption */ - public void setInstantFuelConsumption(VehicleDataResult instantFuelConsumption) { + public SubscribeVehicleDataResponse setInstantFuelConsumption( VehicleDataResult instantFuelConsumption) { setParameters(KEY_INSTANT_FUEL_CONSUMPTION, instantFuelConsumption); + return this; } /** * Gets Instant Fuel Consumption @@ -216,8 +222,9 @@ public class SubscribeVehicleDataResponse extends RPCResponse { * Sets External Temperature * @param externalTemperature a VehicleDataResult related to external temperature */ - public void setExternalTemperature(VehicleDataResult externalTemperature) { + public SubscribeVehicleDataResponse setExternalTemperature( VehicleDataResult externalTemperature) { setParameters(KEY_EXTERNAL_TEMPERATURE, externalTemperature); + return this; } /** * Gets External Temperature @@ -234,8 +241,9 @@ public class SubscribeVehicleDataResponse extends RPCResponse { * @deprecated in SmartDeviceLink 7.0.0 */ @Deprecated - public void setPrndl(VehicleDataResult prndl) { + public SubscribeVehicleDataResponse setPrndl( VehicleDataResult prndl) { setParameters(KEY_PRNDL, prndl); + return this; } /** * Gets the prndl. @@ -252,8 +260,9 @@ public class SubscribeVehicleDataResponse extends RPCResponse { * Sets Tire Pressure * @param tirePressure a VehicleDataResult related to tire pressure */ - public void setTirePressure(VehicleDataResult tirePressure) { + public SubscribeVehicleDataResponse setTirePressure( VehicleDataResult tirePressure) { setParameters(KEY_TIRE_PRESSURE, tirePressure); + return this; } /** * Gets Tire Pressure @@ -267,8 +276,9 @@ public class SubscribeVehicleDataResponse extends RPCResponse { * Sets Odometer * @param odometer a VehicleDataResult related to the odometer */ - public void setOdometer(VehicleDataResult odometer) { + public SubscribeVehicleDataResponse setOdometer( VehicleDataResult odometer) { setParameters(KEY_ODOMETER, odometer); + return this; } /** * Gets Odometer @@ -282,8 +292,9 @@ public class SubscribeVehicleDataResponse extends RPCResponse { * Sets Belt Status * @param beltStatus a VehicleDataResult related to the seat belt status */ - public void setBeltStatus(VehicleDataResult beltStatus) { + public SubscribeVehicleDataResponse setBeltStatus( VehicleDataResult beltStatus) { setParameters(KEY_BELT_STATUS, beltStatus); + return this; } /** * Gets Belt Status @@ -297,8 +308,9 @@ public class SubscribeVehicleDataResponse extends RPCResponse { * Sets Body Information * @param bodyInformation a VehicleDataResult related to the body info */ - public void setBodyInformation(VehicleDataResult bodyInformation) { + public SubscribeVehicleDataResponse setBodyInformation( VehicleDataResult bodyInformation) { setParameters(KEY_BODY_INFORMATION, bodyInformation); + return this; } /** * Gets Body Information @@ -312,8 +324,9 @@ public class SubscribeVehicleDataResponse extends RPCResponse { * Sets Device Status * @param deviceStatus a VehicleDataResult related to the device status of the connected device */ - public void setDeviceStatus(VehicleDataResult deviceStatus) { + public SubscribeVehicleDataResponse setDeviceStatus( VehicleDataResult deviceStatus) { setParameters(KEY_DEVICE_STATUS, deviceStatus); + return this; } /** * Gets Device Status @@ -327,8 +340,9 @@ public class SubscribeVehicleDataResponse extends RPCResponse { * Sets Driver Braking * @param driverBraking a VehicleDataResult related to the driver breaking status */ - public void setDriverBraking(VehicleDataResult driverBraking) { + public SubscribeVehicleDataResponse setDriverBraking( VehicleDataResult driverBraking) { setParameters(KEY_DRIVER_BRAKING, driverBraking); + return this; } /** * Gets Driver Braking @@ -342,8 +356,9 @@ public class SubscribeVehicleDataResponse extends RPCResponse { * Sets Wiper Status * @param wiperStatus a VehicleDataResult related to the wiper status */ - public void setWiperStatus(VehicleDataResult wiperStatus) { + public SubscribeVehicleDataResponse setWiperStatus( VehicleDataResult wiperStatus) { setParameters(KEY_WIPER_STATUS, wiperStatus); + return this; } /** * Gets Wiper Status @@ -357,8 +372,9 @@ public class SubscribeVehicleDataResponse extends RPCResponse { * Sets Head Lamp Status * @param headLampStatus a VehicleDataResult related to the headlamp status */ - public void setHeadLampStatus(VehicleDataResult headLampStatus) { + public SubscribeVehicleDataResponse setHeadLampStatus( VehicleDataResult headLampStatus) { setParameters(KEY_HEAD_LAMP_STATUS, headLampStatus); + return this; } /** * Gets Head Lamp Status @@ -372,8 +388,9 @@ public class SubscribeVehicleDataResponse extends RPCResponse { * Sets Engine Torque * @param engineTorque a VehicleDataResult related to the engine's torque */ - public void setEngineTorque(VehicleDataResult engineTorque) { + public SubscribeVehicleDataResponse setEngineTorque( VehicleDataResult engineTorque) { setParameters(KEY_ENGINE_TORQUE, engineTorque); + return this; } /** * Gets Engine Torque @@ -387,8 +404,9 @@ public class SubscribeVehicleDataResponse extends RPCResponse { * Sets Engine Oil Life * @param engineOilLife a VehicleDataResult related to the engine's oil life */ - public void setEngineOilLife(VehicleDataResult engineOilLife) { + public SubscribeVehicleDataResponse setEngineOilLife( VehicleDataResult engineOilLife) { setParameters(KEY_ENGINE_OIL_LIFE, engineOilLife); + return this; } /** * Gets Engine Oil Life @@ -402,8 +420,9 @@ public class SubscribeVehicleDataResponse extends RPCResponse { * Sets AccPedal Position * @param accPedalPosition a VehicleDataResult related to the accelerator pedal's position */ - public void setAccPedalPosition(VehicleDataResult accPedalPosition) { + public SubscribeVehicleDataResponse setAccPedalPosition( VehicleDataResult accPedalPosition) { setParameters(KEY_ACC_PEDAL_POSITION, accPedalPosition); + return this; } /** * Gets AccPedal Position @@ -414,8 +433,9 @@ public class SubscribeVehicleDataResponse extends RPCResponse { return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_ACC_PEDAL_POSITION); } - public void setSteeringWheelAngle(VehicleDataResult steeringWheelAngle) { + public SubscribeVehicleDataResponse setSteeringWheelAngle( VehicleDataResult steeringWheelAngle) { setParameters(KEY_STEERING_WHEEL_ANGLE, steeringWheelAngle); + return this; } @SuppressWarnings("unchecked") @@ -423,36 +443,41 @@ public class SubscribeVehicleDataResponse extends RPCResponse { return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_STEERING_WHEEL_ANGLE); } - public void setECallInfo(VehicleDataResult eCallInfo) { + public SubscribeVehicleDataResponse setECallInfo( VehicleDataResult eCallInfo) { setParameters(KEY_E_CALL_INFO, eCallInfo); + return this; } @SuppressWarnings("unchecked") public VehicleDataResult getECallInfo() { return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_E_CALL_INFO); } - public void setAirbagStatus(VehicleDataResult airbagStatus) { + public SubscribeVehicleDataResponse setAirbagStatus( VehicleDataResult airbagStatus) { setParameters(KEY_AIRBAG_STATUS, airbagStatus); + return this; } @SuppressWarnings("unchecked") public VehicleDataResult getAirbagStatus() { return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_AIRBAG_STATUS); } - public void setEmergencyEvent(VehicleDataResult emergencyEvent) { + public SubscribeVehicleDataResponse setEmergencyEvent( VehicleDataResult emergencyEvent) { setParameters(KEY_EMERGENCY_EVENT, emergencyEvent); + return this; } @SuppressWarnings("unchecked") public VehicleDataResult getEmergencyEvent() { return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_EMERGENCY_EVENT); } - public void setClusterModeStatus(VehicleDataResult clusterModeStatus) { + public SubscribeVehicleDataResponse setClusterModeStatus( VehicleDataResult clusterModeStatus) { setParameters(KEY_CLUSTER_MODE_STATUS, clusterModeStatus); + return this; } @SuppressWarnings("unchecked") public VehicleDataResult getClusterModeStatus() { return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_CLUSTER_MODE_STATUS); } - public void setMyKey(VehicleDataResult myKey) { + public SubscribeVehicleDataResponse setMyKey( VehicleDataResult myKey) { setParameters(KEY_MY_KEY, myKey); + return this; } @SuppressWarnings("unchecked") public VehicleDataResult getMyKey() { @@ -466,8 +491,9 @@ public class SubscribeVehicleDataResponse extends RPCResponse { * vehicle. See struct FuelRange for details. * @since SmartDeviceLink 5.0.0 */ - public void setFuelRange(VehicleDataResult fuelRange) { + public SubscribeVehicleDataResponse setFuelRange( VehicleDataResult fuelRange) { setParameters(KEY_FUEL_RANGE, fuelRange); + return this; } /** @@ -486,8 +512,9 @@ public class SubscribeVehicleDataResponse extends RPCResponse { * Sets turnSignal * @param turnSignal a VehicleDataResult related to the turn signal status */ - public void setTurnSignal(VehicleDataResult turnSignal) { + public SubscribeVehicleDataResponse setTurnSignal( VehicleDataResult turnSignal) { setParameters(KEY_TURN_SIGNAL, turnSignal); + return this; } /** @@ -503,8 +530,9 @@ public class SubscribeVehicleDataResponse extends RPCResponse { * Sets electronicParkBrakeStatus * @param electronicParkBrakeStatus a VehicleDataResult related to the electronic park brake status */ - public void setElectronicParkBrakeStatus(VehicleDataResult electronicParkBrakeStatus){ + public SubscribeVehicleDataResponse setElectronicParkBrakeStatus( VehicleDataResult electronicParkBrakeStatus) { setParameters(KEY_ELECTRONIC_PARK_BRAKE_STATUS, electronicParkBrakeStatus); + return this; } /** @@ -519,8 +547,9 @@ public class SubscribeVehicleDataResponse extends RPCResponse { * Sets cloudAppVehicleID * @param cloudAppVehicleID a VehicleDataResult related to the cloud app vehicle ID */ - public void setCloudAppVehicleID(VehicleDataResult cloudAppVehicleID){ + public SubscribeVehicleDataResponse setCloudAppVehicleID( VehicleDataResult cloudAppVehicleID) { setParameters(KEY_CLOUD_APP_VEHICLE_ID, cloudAppVehicleID); + return this; } /** @@ -536,8 +565,9 @@ public class SubscribeVehicleDataResponse extends RPCResponse { * @param vehicleDataName a String value * @param vehicleDataState a VehicleDataResult value */ - public void setOEMCustomVehicleData(String vehicleDataName, VehicleDataResult vehicleDataState){ + public SubscribeVehicleDataResponse setOEMCustomVehicleData( String vehicleDataName, VehicleDataResult vehicleDataState) { setParameters(vehicleDataName, vehicleDataState); + return this; } /** @@ -554,8 +584,9 @@ public class SubscribeVehicleDataResponse extends RPCResponse { * @param handsOffSteering To indicate whether driver hands are off the steering wheel * @since SmartDeviceLink 7.0.0 */ - public void setHandsOffSteering(VehicleDataResult handsOffSteering) { + public SubscribeVehicleDataResponse setHandsOffSteering( VehicleDataResult handsOffSteering) { setParameters(KEY_HANDS_OFF_STEERING, handsOffSteering); + return this; } /** @@ -573,8 +604,9 @@ public class SubscribeVehicleDataResponse extends RPCResponse { * @param gearStatus See GearStatus * @since SmartDeviceLink 7.0.0 */ - public void setGearStatus(VehicleDataResult gearStatus){ + public SubscribeVehicleDataResponse setGearStatus( VehicleDataResult gearStatus) { setParameters(KEY_GEAR_STATUS, gearStatus); + return this; } /** @@ -594,8 +626,9 @@ public class SubscribeVehicleDataResponse extends RPCResponse { * @param windowStatus See WindowStatus * @since SmartDeviceLink 7.0.0 */ - public void setWindowStatus(VehicleDataResult windowStatus) { + public SubscribeVehicleDataResponse setWindowStatus( VehicleDataResult windowStatus) { setParameters(KEY_WINDOW_STATUS, windowStatus); + return this; } /** @@ -624,7 +657,8 @@ public class SubscribeVehicleDataResponse extends RPCResponse { * @param stabilityControlsStatus See StabilityControlsStatus * @since SmartDeviceLink 7.0.0 */ - public void setStabilityControlsStatus(VehicleDataResult stabilityControlsStatus) { + public SubscribeVehicleDataResponse setStabilityControlsStatus( VehicleDataResult stabilityControlsStatus) { setParameters(KEY_STABILITY_CONTROLS_STATUS, stabilityControlsStatus); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/SubtleAlert.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/SubtleAlert.java index 42752ff8d..a3b96e4ec 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/SubtleAlert.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/SubtleAlert.java @@ -142,8 +142,9 @@ public class SubtleAlert extends RPCRequest { * * @param alertText1 The first line of the alert text field */ - public void setAlertText1(String alertText1) { + public SubtleAlert setAlertText1( String alertText1) { setParameters(KEY_ALERT_TEXT_1, alertText1); + return this; } /** @@ -160,8 +161,9 @@ public class SubtleAlert extends RPCRequest { * * @param alertText2 The second line of the alert text field */ - public void setAlertText2(String alertText2) { + public SubtleAlert setAlertText2( String alertText2) { setParameters(KEY_ALERT_TEXT_2, alertText2); + return this; } /** @@ -179,8 +181,9 @@ public class SubtleAlert extends RPCRequest { * @param alertIcon Image to be displayed for the corresponding alert. See Image. If omitted on supported * displays, no (or the default if applicable) icon should be displayed. */ - public void setAlertIcon(Image alertIcon) { + public SubtleAlert setAlertIcon( Image alertIcon) { setParameters(KEY_ALERT_ICON, alertIcon); + return this; } /** @@ -199,8 +202,9 @@ public class SubtleAlert extends RPCRequest { * @param ttsChunks An array of text chunks of type TTSChunk. See TTSChunk. The array must have at least one * item. */ - public void setTtsChunks(List ttsChunks) { + public SubtleAlert setTtsChunks( List ttsChunks) { setParameters(KEY_TTS_CHUNKS, ttsChunks); + return this; } /** @@ -220,8 +224,9 @@ public class SubtleAlert extends RPCRequest { * @param duration Timeout in milliseconds. Typical timeouts are 3-5 seconds. If omitted, timeout is set to * 5s. */ - public void setDuration(Integer duration) { + public SubtleAlert setDuration( Integer duration) { setParameters(KEY_DURATION, duration); + return this; } /** @@ -240,8 +245,9 @@ public class SubtleAlert extends RPCRequest { * @param softButtons App defined SoftButtons. If omitted on supported displays, the displayed alert shall not * have any SoftButtons. */ - public void setSoftButtons(List softButtons) { + public SubtleAlert setSoftButtons( List softButtons) { setParameters(KEY_SOFT_BUTTONS, softButtons); + return this; } /** @@ -260,8 +266,9 @@ public class SubtleAlert extends RPCRequest { * * @param cancelID An ID for this specific alert to allow cancellation through the `CancelInteraction` RPC. */ - public void setCancelID(Integer cancelID) { + public SubtleAlert setCancelID( Integer cancelID) { setParameters(KEY_CANCEL_ID, cancelID); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/SubtleAlertResponse.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/SubtleAlertResponse.java index a15dbe13b..9e1e5b2c3 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/SubtleAlertResponse.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/SubtleAlertResponse.java @@ -80,8 +80,9 @@ public class SubtleAlertResponse extends RPCResponse { * If provided, another system event or overlay currently has a higher priority than this alert. * An app must not send an alert without waiting at least the amount of time dictated. */ - public void setTryAgainTime(Integer tryAgainTime) { + public SubtleAlertResponse setTryAgainTime( Integer tryAgainTime) { setParameters(KEY_TRY_AGAIN_TIME, tryAgainTime); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/SystemCapability.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/SystemCapability.java index 470321627..6ae6fa914 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/SystemCapability.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/SystemCapability.java @@ -79,8 +79,9 @@ public class SystemCapability extends RPCStruct { /** * @param value Set the SystemCapabilityType that indicates which type of data should be changed and identifies which data object exists in this struct. */ - public void setSystemCapabilityType(@NonNull SystemCapabilityType value){ + public SystemCapability setSystemCapabilityType(@NonNull SystemCapabilityType value) { setValue(KEY_SYSTEM_CAPABILITY_TYPE, value); + return this; } public Object getCapabilityForType(SystemCapabilityType type) { @@ -107,9 +108,9 @@ public class SystemCapability extends RPCStruct { } } - public void setCapabilityForType(SystemCapabilityType type, Object capability) { + public SystemCapability setCapabilityForType( SystemCapabilityType type, Object capability) { if (type == null) { - return; + return this; } else if (type.equals(SystemCapabilityType.NAVIGATION)) { setValue(KEY_NAVIGATION_CAPABILITY, capability); } else if (type.equals(SystemCapabilityType.PHONE_CALL)) { @@ -127,8 +128,9 @@ public class SystemCapability extends RPCStruct { } else if (type.equals(SystemCapabilityType.DRIVER_DISTRACTION)) { setValue(KEY_DRIVER_DISTRACTION_CAPABILITY, capability); } else { - return; + return this; } + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/SystemRequest.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/SystemRequest.java index 5c02cfe7d..839d49953 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/SystemRequest.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/SystemRequest.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -118,31 +118,35 @@ public class SystemRequest extends RPCRequest { return (List) getObject(String.class, KEY_DATA); } - public void setLegacyData( List data ) { + public SystemRequest setLegacyData( List data) { setParameters(KEY_DATA, data); - } + return this; + } public String getFileName() { return getString(KEY_FILE_NAME); } - public void setFileName(String fileName) { + public SystemRequest setFileName( String fileName) { setParameters(KEY_FILE_NAME, fileName); - } + return this; + } public RequestType getRequestType() { return (RequestType) getObject(RequestType.class, KEY_REQUEST_TYPE); } - public void setRequestType(@NonNull RequestType requestType) { + public SystemRequest setRequestType(@NonNull RequestType requestType) { setParameters(KEY_REQUEST_TYPE, requestType); + return this; } public String getRequestSubType() { return getString(KEY_REQUEST_SUB_TYPE); } - public void setRequestSubType(String requestSubType) { + public SystemRequest setRequestSubType( String requestSubType) { setParameters(KEY_REQUEST_SUB_TYPE, requestSubType); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/TTSChunk.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/TTSChunk.java index fbd526b30..9eed92f3f 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/TTSChunk.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/TTSChunk.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -105,9 +105,10 @@ public class TTSChunk extends RPCStruct { /** * Set the text to be spoken, or a phoneme specification, or the name of a pre-recorded sound. The contents of this field are indicated by the "type" field. * @param text to be spoken, or a phoneme specification, or the name of a pre-recorded sound. - */ - public void setText(@NonNull String text ) { + */ + public TTSChunk setText(@NonNull String text) { setValue(KEY_TEXT, text); + return this; } /** * Get the type of information in the "text" field (e.g. phrase to be spoken, phoneme specification, name of pre-recorded sound). @@ -117,10 +118,11 @@ public class TTSChunk extends RPCStruct { return (SpeechCapabilities) getObject(SpeechCapabilities.class, KEY_TYPE); } /** - * Set the type of information in the "text" field (e.g. phrase to be spoken, phoneme specification, name of pre-recorded sound). + * Set the type of information in the "text" field (e.g. phrase to be spoken, phoneme specification, name of pre-recorded sound). * @param type the type of information in the "text" field - */ - public void setType(@NonNull SpeechCapabilities type ) { + */ + public TTSChunk setType(@NonNull SpeechCapabilities type) { setValue(KEY_TYPE, type); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/Temperature.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/Temperature.java index c2c809f13..9bd23d4a0 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/Temperature.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/Temperature.java @@ -65,8 +65,9 @@ public class Temperature extends RPCStruct{ * @param unit * Temperature Unit. */ - public void setUnit(@NonNull TemperatureUnit unit) { + public Temperature setUnit(@NonNull TemperatureUnit unit) { setValue(KEY_UNIT, unit); + return this; } /** @@ -94,7 +95,8 @@ public class Temperature extends RPCStruct{ * @param value * Temperature Value in TemperatureUnit specified unit. Range depends on OEM and is not checked by SDL. */ - public void setValue(@NonNull Float value) { + public Temperature setValue(@NonNull Float value) { setValue(KEY_VALUE, value); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/TemplateColorScheme.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/TemplateColorScheme.java index aa2e2b2f6..e65f25659 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/TemplateColorScheme.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/TemplateColorScheme.java @@ -94,8 +94,9 @@ public class TemplateColorScheme extends RPCStruct { * Sets the primaryColor of the scheme * @param color an RGBColor object representing the primaryColor */ - public void setPrimaryColor(RGBColor color) { + public TemplateColorScheme setPrimaryColor( RGBColor color) { setValue(KEY_PRIMARY_COLOR, color); + return this; } /** @@ -110,8 +111,9 @@ public class TemplateColorScheme extends RPCStruct { * Sets the secondaryColor of the scheme * @param color an RGBColor object representing the secondaryColor */ - public void setSecondaryColor(RGBColor color) { + public TemplateColorScheme setSecondaryColor( RGBColor color) { setValue(KEY_SECONDARY_COLOR, color); + return this; } /** @@ -126,8 +128,9 @@ public class TemplateColorScheme extends RPCStruct { * Sets the backgroundColor of the scheme * @param color an RGBColor object representing the backgroundColor */ - public void setBackgroundColor(RGBColor color) { + public TemplateColorScheme setBackgroundColor( RGBColor color) { setValue(KEY_BACKGROUND_COLOR, color); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/TemplateConfiguration.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/TemplateConfiguration.java index c82b4c481..edaf224e5 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/TemplateConfiguration.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/TemplateConfiguration.java @@ -55,8 +55,9 @@ public class TemplateConfiguration extends RPCStruct { * * @param template Predefined or dynamically created window template. Currently only predefined window template layouts are defined. */ - public void setTemplate(@NonNull String template) { + public TemplateConfiguration setTemplate(@NonNull String template) { setValue(KEY_TEMPLATE, template); + return this; } /** @@ -74,8 +75,9 @@ public class TemplateConfiguration extends RPCStruct { * * @param dayColorScheme TemplateColorScheme for the day */ - public void setDayColorScheme(TemplateColorScheme dayColorScheme) { + public TemplateConfiguration setDayColorScheme( TemplateColorScheme dayColorScheme) { setValue(KEY_DAY_COLOR_SCHEME, dayColorScheme); + return this; } /** @@ -93,7 +95,8 @@ public class TemplateConfiguration extends RPCStruct { * * @param nightColorScheme TemplateColorScheme for the night */ - public void setNightColorScheme(TemplateColorScheme nightColorScheme) { + public TemplateConfiguration setNightColorScheme( TemplateColorScheme nightColorScheme) { setValue(KEY_NIGHT_COLOR_SCHEME, nightColorScheme); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/TextField.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/TextField.java index dc9907bad..317138936 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/TextField.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/TextField.java @@ -135,11 +135,12 @@ public class TextField extends RPCStruct { return (TextFieldName) getObject(TextFieldName.class, KEY_NAME); } /** - * Set the enumeration identifying the field. + * Set the enumeration identifying the field. * @param name the name of TextField - */ - public void setName(@NonNull TextFieldName name ) { + */ + public TextField setName(@NonNull TextFieldName name) { setValue(KEY_NAME, name); + return this; } /** * Get the character set that is supported in this field. @@ -155,9 +156,10 @@ public class TextField extends RPCStruct { * @param characterSet - The set of characters that are supported by this text field. * All text is sent in UTF-8 format, but not all systems may support all of the characters expressed by UTF-8. * All systems will support at least ASCII, but they may support more, either the LATIN-1 character set, or the full UTF-8 character set. - */ - public void setCharacterSet(@NonNull CharacterSet characterSet ) { + */ + public TextField setCharacterSet(@NonNull CharacterSet characterSet) { setValue(KEY_CHARACTER_SET, characterSet); + return this; } /** * Get the number of characters in one row of this field. @@ -177,9 +179,10 @@ public class TextField extends RPCStruct { *
  • maxvalue="500"
  • * * @param width the number of characters in one row of this field - */ - public void setWidth(@NonNull Integer width ) { + */ + public TextField setWidth(@NonNull Integer width) { setValue(KEY_WIDTH, width); + return this; } /** *Get the number of rows for this text field. @@ -192,7 +195,8 @@ public class TextField extends RPCStruct { public Integer getRows() { return getInteger( KEY_ROWS ); } - public void setRows(@NonNull Integer rows ) { + public TextField setRows(@NonNull Integer rows) { setValue(KEY_ROWS, rows); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/TireStatus.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/TireStatus.java index c5e2626b8..92c524b79 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/TireStatus.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/TireStatus.java @@ -141,49 +141,56 @@ public class TireStatus extends RPCStruct { setInnerRightRear(innerRightRear); } - public void setPressureTellTale(@NonNull WarningLightStatus pressureTellTale) { - setValue(KEY_PRESSURE_TELL_TALE, pressureTellTale); + public TireStatus setPressureTellTale(@NonNull WarningLightStatus pressureTellTale) { + setValue(KEY_PRESSURE_TELL_TALE, pressureTellTale); + return this; } public WarningLightStatus getPressureTellTale() { return (WarningLightStatus) getObject(WarningLightStatus.class, KEY_PRESSURE_TELL_TALE); } - public void setLeftFront(@NonNull SingleTireStatus leftFront) { - setValue(KEY_LEFT_FRONT, leftFront); + public TireStatus setLeftFront(@NonNull SingleTireStatus leftFront) { + setValue(KEY_LEFT_FRONT, leftFront); + return this; } @SuppressWarnings("unchecked") public SingleTireStatus getLeftFront() { return (SingleTireStatus) getObject(SingleTireStatus.class, KEY_LEFT_FRONT); } - public void setRightFront(@NonNull SingleTireStatus rightFront) { - setValue(KEY_RIGHT_FRONT, rightFront); + public TireStatus setRightFront(@NonNull SingleTireStatus rightFront) { + setValue(KEY_RIGHT_FRONT, rightFront); + return this; } @SuppressWarnings("unchecked") public SingleTireStatus getRightFront() { return (SingleTireStatus) getObject(SingleTireStatus.class, KEY_RIGHT_FRONT); } - public void setLeftRear(@NonNull SingleTireStatus leftRear) { - setValue(KEY_LEFT_REAR, leftRear); + public TireStatus setLeftRear(@NonNull SingleTireStatus leftRear) { + setValue(KEY_LEFT_REAR, leftRear); + return this; } @SuppressWarnings("unchecked") public SingleTireStatus getLeftRear() { return (SingleTireStatus) getObject(SingleTireStatus.class, KEY_LEFT_REAR); } - public void setRightRear(@NonNull SingleTireStatus rightRear) { - setValue(KEY_RIGHT_REAR, rightRear); + public TireStatus setRightRear(@NonNull SingleTireStatus rightRear) { + setValue(KEY_RIGHT_REAR, rightRear); + return this; } @SuppressWarnings("unchecked") public SingleTireStatus getRightRear() { return (SingleTireStatus) getObject(SingleTireStatus.class, KEY_RIGHT_REAR); } - public void setInnerLeftRear(@NonNull SingleTireStatus innerLeftRear) { - setValue(KEY_INNER_LEFT_REAR, innerLeftRear); + public TireStatus setInnerLeftRear(@NonNull SingleTireStatus innerLeftRear) { + setValue(KEY_INNER_LEFT_REAR, innerLeftRear); + return this; } @SuppressWarnings("unchecked") public SingleTireStatus getInnerLeftRear() { return (SingleTireStatus) getObject(SingleTireStatus.class, KEY_INNER_LEFT_REAR); } - public void setInnerRightRear(@NonNull SingleTireStatus innerRightRear) { - setValue(KEY_INNER_RIGHT_REAR, innerRightRear); + public TireStatus setInnerRightRear(@NonNull SingleTireStatus innerRightRear) { + setValue(KEY_INNER_RIGHT_REAR, innerRightRear); + return this; } @SuppressWarnings("unchecked") public SingleTireStatus getInnerRightRear() { diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/TouchCoord.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/TouchCoord.java index 3e33369cf..c2f71e09e 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/TouchCoord.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/TouchCoord.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -101,16 +101,18 @@ public class TouchCoord extends RPCStruct { setY(y); } - public void setX(@NonNull Integer x) { + public TouchCoord setX(@NonNull Integer x) { setValue(KEY_X, x); + return this; } public Integer getX() { return getInteger(KEY_X); } - public void setY(@NonNull Integer y) { + public TouchCoord setY(@NonNull Integer y) { setValue(KEY_Y, y); + return this; } public Integer getY() { diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/TouchEvent.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/TouchEvent.java index 47f29c0b1..55bb75249 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/TouchEvent.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/TouchEvent.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -116,8 +116,9 @@ public class TouchEvent extends RPCStruct { setTouchCoordinates(c); } - public void setId(@NonNull Integer id) { + public TouchEvent setId(@NonNull Integer id) { setValue(KEY_ID, id); + return this; } public Integer getId() { @@ -156,18 +157,20 @@ public class TouchEvent extends RPCStruct { return null; } - public void setTimestamps(@NonNull List ts){ + public TouchEvent setTimestamps(@NonNull List ts) { setValue(KEY_TS, ts); + return this; } /** - * Use setTimestamps. + * Use setTimestamps. * @deprecated 4.0.2 * @param ts */ @Deprecated - public void setTs(List ts) { - setTimestamps(ts); + public TouchEvent setTs( List ts) { + setTimestamps(ts); + return this; } /** @@ -190,11 +193,13 @@ public class TouchEvent extends RPCStruct { * @return */ @Deprecated - public void setC( List c ) { - setTouchCoordinates(c); + public TouchEvent setC( List c) { + setTouchCoordinates(c); + return this; } - public void setTouchCoordinates(@NonNull List c ) { + public TouchEvent setTouchCoordinates(@NonNull List c) { setValue(KEY_C, c); - } + return this; + } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/TouchEventCapabilities.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/TouchEventCapabilities.java index 423ae4fa2..cb455bf59 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/TouchEventCapabilities.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/TouchEventCapabilities.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -99,24 +99,27 @@ public class TouchEventCapabilities extends RPCStruct { setDoublePressAvailable(doublePressAvailable); } - public void setPressAvailable(@NonNull Boolean pressAvailable) { + public TouchEventCapabilities setPressAvailable(@NonNull Boolean pressAvailable) { setValue(KEY_PRESS_AVAILABLE, pressAvailable); + return this; } public Boolean getPressAvailable() { return getBoolean(KEY_PRESS_AVAILABLE); } - public void setMultiTouchAvailable(@NonNull Boolean multiTouchAvailable) { + public TouchEventCapabilities setMultiTouchAvailable(@NonNull Boolean multiTouchAvailable) { setValue(KEY_MULTI_TOUCH_AVAILABLE, multiTouchAvailable); + return this; } public Boolean getMultiTouchAvailable() { return getBoolean(KEY_MULTI_TOUCH_AVAILABLE); } - public void setDoublePressAvailable(@NonNull Boolean doublePressAvailable) { + public TouchEventCapabilities setDoublePressAvailable(@NonNull Boolean doublePressAvailable) { setValue(KEY_DOUBLE_PRESS_AVAILABLE, doublePressAvailable); + return this; } public Boolean getDoublePressAvailable() { diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/Turn.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/Turn.java index 0498023ea..d282e6200 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/Turn.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/Turn.java @@ -77,12 +77,13 @@ public class Turn extends RPCStruct{ /** * set the text to describe the turn (e.g. streetname) - * + * * @param navigationText * the text to describe the turn (e.g. streetname) */ - public void setNavigationText(String navigationText){ + public Turn setNavigationText( String navigationText) { setValue(KEY_NAVIGATION_TEXT, navigationText); + return this; } /** @@ -96,12 +97,13 @@ public class Turn extends RPCStruct{ /** * set Image to be shown for a turn - * + * * @param turnIcon * the image to be shown for a turn */ - public void setTurnIcon(Image turnIcon){ + public Turn setTurnIcon( Image turnIcon) { setValue(KEY_TURN_IMAGE, turnIcon); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/UnpublishAppService.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/UnpublishAppService.java index 6e509fe1f..60a59f77b 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/UnpublishAppService.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/UnpublishAppService.java @@ -80,9 +80,10 @@ public class UnpublishAppService extends RPCRequest { * The ID of the service to be unpublished. * @param serviceID - set the service ID for the service to be unpublished */ - public void setServiceID(String serviceID){ - setParameters(KEY_SERVICE_ID, serviceID); - } + public UnpublishAppService setServiceID( String serviceID) { + setParameters(KEY_SERVICE_ID, serviceID); + return this; + } /** * The ID of the service to be unpublished. diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeButton.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeButton.java index 48c287ea8..87dcc9cfb 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeButton.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeButton.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -121,10 +121,11 @@ public class UnsubscribeButton extends RPCRequest { } /** * Sets the name of the button to unsubscribe from - * - * @param buttonName an enum value, see {@linkplain com.smartdevicelink.proxy.rpc.enums.ButtonName} + * + * @param buttonName an enum value, see {@linkplain ButtonName} */ - public void setButtonName(@NonNull ButtonName buttonName ) { - setParameters(KEY_BUTTON_NAME, buttonName); + public UnsubscribeButton setButtonName(@NonNull ButtonName buttonName) { + setParameters(KEY_BUTTON_NAME, buttonName); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleData.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleData.java index 663f8fbf8..8e7adb2d2 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleData.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleData.java @@ -378,12 +378,13 @@ public class UnsubscribeVehicleData extends RPCRequest { /** * Sets a boolean value. If true, unsubscribes from Gps data - * + * * @param gps * a boolean value */ - public void setGps(Boolean gps) { - setParameters(KEY_GPS, gps); + public UnsubscribeVehicleData setGps( Boolean gps) { + setParameters(KEY_GPS, gps); + return this; } /** @@ -398,12 +399,13 @@ public class UnsubscribeVehicleData extends RPCRequest { /** * Sets a boolean value. If true, unsubscribes from speed data - * + * * @param speed * a boolean value */ - public void setSpeed(Boolean speed) { - setParameters(KEY_SPEED, speed); + public UnsubscribeVehicleData setSpeed( Boolean speed) { + setParameters(KEY_SPEED, speed); + return this; } /** @@ -418,12 +420,13 @@ public class UnsubscribeVehicleData extends RPCRequest { /** * Sets a boolean value. If true, unsubscribe data - * + * * @param rpm * a boolean value */ - public void setRpm(Boolean rpm) { - setParameters(KEY_RPM, rpm); + public UnsubscribeVehicleData setRpm( Boolean rpm) { + setParameters(KEY_RPM, rpm); + return this; } /** @@ -438,13 +441,14 @@ public class UnsubscribeVehicleData extends RPCRequest { /** * Sets the fuelLevel. - * + * * @param fuelLevel The fuel level in the tank (percentage). This parameter is deprecated starting RPC Spec * 7.0, please see fuelRange. */ @Deprecated - public void setFuelLevel(Boolean fuelLevel) { - setParameters(KEY_FUEL_LEVEL, fuelLevel); + public UnsubscribeVehicleData setFuelLevel( Boolean fuelLevel) { + setParameters(KEY_FUEL_LEVEL, fuelLevel); + return this; } /** @@ -466,8 +470,9 @@ public class UnsubscribeVehicleData extends RPCRequest { * @since SmartDeviceLink 5.0.0 */ @Deprecated - public void setFuelLevelState(Boolean fuelLevelState) { - setParameters(KEY_FUEL_LEVEL_STATE, fuelLevelState); + public UnsubscribeVehicleData setFuelLevelState( Boolean fuelLevelState) { + setParameters(KEY_FUEL_LEVEL_STATE, fuelLevelState); + return this; } /** @@ -484,12 +489,13 @@ public class UnsubscribeVehicleData extends RPCRequest { /** * Sets a boolean value. If true, unsubscribes from instantFuelConsumption data - * + * * @param instantFuelConsumption * a boolean value */ - public void setInstantFuelConsumption(Boolean instantFuelConsumption) { - setParameters(KEY_INSTANT_FUEL_CONSUMPTION, instantFuelConsumption); + public UnsubscribeVehicleData setInstantFuelConsumption( Boolean instantFuelConsumption) { + setParameters(KEY_INSTANT_FUEL_CONSUMPTION, instantFuelConsumption); + return this; } /** @@ -505,12 +511,13 @@ public class UnsubscribeVehicleData extends RPCRequest { /** * Sets a boolean value. If true, unsubscribes from externalTemperature data - * + * * @param externalTemperature * a boolean value */ - public void setExternalTemperature(Boolean externalTemperature) { - setParameters(KEY_EXTERNAL_TEMPERATURE, externalTemperature); + public UnsubscribeVehicleData setExternalTemperature( Boolean externalTemperature) { + setParameters(KEY_EXTERNAL_TEMPERATURE, externalTemperature); + return this; } /** @@ -531,8 +538,9 @@ public class UnsubscribeVehicleData extends RPCRequest { * @deprecated in SmartDeviceLink 7.0.0 */ @Deprecated - public void setPrndl(Boolean prndl) { + public UnsubscribeVehicleData setPrndl( Boolean prndl) { setParameters(KEY_PRNDL, prndl); + return this; } /** @@ -548,12 +556,13 @@ public class UnsubscribeVehicleData extends RPCRequest { /** * Sets a boolean value. If true, unsubscribes from tire pressure status data - * + * * @param tirePressure * a boolean value */ - public void setTirePressure(Boolean tirePressure) { - setParameters(KEY_TIRE_PRESSURE, tirePressure); + public UnsubscribeVehicleData setTirePressure( Boolean tirePressure) { + setParameters(KEY_TIRE_PRESSURE, tirePressure); + return this; } /** @@ -569,12 +578,13 @@ public class UnsubscribeVehicleData extends RPCRequest { /** * Sets a boolean value. If true, unsubscribes from odometer data - * + * * @param odometer * a boolean value */ - public void setOdometer(Boolean odometer) { - setParameters(KEY_ODOMETER, odometer); + public UnsubscribeVehicleData setOdometer( Boolean odometer) { + setParameters(KEY_ODOMETER, odometer); + return this; } /** @@ -590,12 +600,13 @@ public class UnsubscribeVehicleData extends RPCRequest { /** * Sets a boolean value. If true, unsubscribes from belt Status data - * + * * @param beltStatus * a boolean value */ - public void setBeltStatus(Boolean beltStatus) { - setParameters(KEY_BELT_STATUS, beltStatus); + public UnsubscribeVehicleData setBeltStatus( Boolean beltStatus) { + setParameters(KEY_BELT_STATUS, beltStatus); + return this; } /** @@ -611,12 +622,13 @@ public class UnsubscribeVehicleData extends RPCRequest { /** * Sets a boolean value. If true, unsubscribes from body Information data - * + * * @param bodyInformation * a boolean value */ - public void setBodyInformation(Boolean bodyInformation) { - setParameters(KEY_BODY_INFORMATION, bodyInformation); + public UnsubscribeVehicleData setBodyInformation( Boolean bodyInformation) { + setParameters(KEY_BODY_INFORMATION, bodyInformation); + return this; } /** @@ -632,12 +644,13 @@ public class UnsubscribeVehicleData extends RPCRequest { /** * Sets a boolean value. If true, unsubscribes from device Status data - * + * * @param deviceStatus * a boolean value */ - public void setDeviceStatus(Boolean deviceStatus) { - setParameters(KEY_DEVICE_STATUS, deviceStatus); + public UnsubscribeVehicleData setDeviceStatus( Boolean deviceStatus) { + setParameters(KEY_DEVICE_STATUS, deviceStatus); + return this; } /** @@ -653,12 +666,13 @@ public class UnsubscribeVehicleData extends RPCRequest { /** * Sets a boolean value. If true, unsubscribes from driver Braking data - * + * * @param driverBraking * a boolean value */ - public void setDriverBraking(Boolean driverBraking) { - setParameters(KEY_DRIVER_BRAKING, driverBraking); + public UnsubscribeVehicleData setDriverBraking( Boolean driverBraking) { + setParameters(KEY_DRIVER_BRAKING, driverBraking); + return this; } /** @@ -674,12 +688,13 @@ public class UnsubscribeVehicleData extends RPCRequest { /** * Sets a boolean value. If true, unsubscribes from wiper Status data - * + * * @param wiperStatus * a boolean value */ - public void setWiperStatus(Boolean wiperStatus) { - setParameters(KEY_WIPER_STATUS, wiperStatus); + public UnsubscribeVehicleData setWiperStatus( Boolean wiperStatus) { + setParameters(KEY_WIPER_STATUS, wiperStatus); + return this; } /** @@ -695,12 +710,13 @@ public class UnsubscribeVehicleData extends RPCRequest { /** * Sets a boolean value. If true, unsubscribes from Head Lamp Status data - * + * * @param headLampStatus * a boolean value */ - public void setHeadLampStatus(Boolean headLampStatus) { - setParameters(KEY_HEAD_LAMP_STATUS, headLampStatus); + public UnsubscribeVehicleData setHeadLampStatus( Boolean headLampStatus) { + setParameters(KEY_HEAD_LAMP_STATUS, headLampStatus); + return this; } /** @@ -720,9 +736,10 @@ public class UnsubscribeVehicleData extends RPCRequest { * @param engineTorque * a boolean value */ - public void setEngineTorque(Boolean engineTorque) { - setParameters(KEY_ENGINE_TORQUE, engineTorque); - } + public UnsubscribeVehicleData setEngineTorque( Boolean engineTorque) { + setParameters(KEY_ENGINE_TORQUE, engineTorque); + return this; + } /** * Gets a boolean value. If true, means the Engine Torque data has been @@ -741,9 +758,10 @@ public class UnsubscribeVehicleData extends RPCRequest { * @param engineOilLife * a boolean value */ - public void setEngineOilLife(Boolean engineOilLife) { - setParameters(KEY_ENGINE_OIL_LIFE, engineOilLife); - } + public UnsubscribeVehicleData setEngineOilLife( Boolean engineOilLife) { + setParameters(KEY_ENGINE_OIL_LIFE, engineOilLife); + return this; + } /** * Gets a boolean value. If true, means the Engine Oil Life data has been @@ -759,12 +777,13 @@ public class UnsubscribeVehicleData extends RPCRequest { /** * Sets a boolean value. If true, unsubscribes from accPedalPosition data - * + * * @param accPedalPosition * a boolean value */ - public void setAccPedalPosition(Boolean accPedalPosition) { - setParameters(KEY_ACC_PEDAL_POSITION, accPedalPosition); + public UnsubscribeVehicleData setAccPedalPosition( Boolean accPedalPosition) { + setParameters(KEY_ACC_PEDAL_POSITION, accPedalPosition); + return this; } /** @@ -778,40 +797,46 @@ public class UnsubscribeVehicleData extends RPCRequest { return getBoolean(KEY_ACC_PEDAL_POSITION); } - public void setSteeringWheelAngle(Boolean steeringWheelAngle) { - setParameters(KEY_STEERING_WHEEL_ANGLE, steeringWheelAngle); + public UnsubscribeVehicleData setSteeringWheelAngle( Boolean steeringWheelAngle) { + setParameters(KEY_STEERING_WHEEL_ANGLE, steeringWheelAngle); + return this; } public Boolean getSteeringWheelAngle() { return getBoolean(KEY_STEERING_WHEEL_ANGLE); } - public void setECallInfo(Boolean eCallInfo) { - setParameters(KEY_E_CALL_INFO, eCallInfo); + public UnsubscribeVehicleData setECallInfo( Boolean eCallInfo) { + setParameters(KEY_E_CALL_INFO, eCallInfo); + return this; } public Boolean getECallInfo() { return getBoolean(KEY_E_CALL_INFO); } - public void setAirbagStatus(Boolean airbagStatus) { - setParameters(KEY_AIRBAG_STATUS, airbagStatus); + public UnsubscribeVehicleData setAirbagStatus( Boolean airbagStatus) { + setParameters(KEY_AIRBAG_STATUS, airbagStatus); + return this; } public Boolean getAirbagStatus() { return getBoolean(KEY_AIRBAG_STATUS); } - public void setEmergencyEvent(Boolean emergencyEvent) { - setParameters(KEY_EMERGENCY_EVENT, emergencyEvent); + public UnsubscribeVehicleData setEmergencyEvent( Boolean emergencyEvent) { + setParameters(KEY_EMERGENCY_EVENT, emergencyEvent); + return this; } public Boolean getEmergencyEvent() { return getBoolean(KEY_EMERGENCY_EVENT); } - public void setClusterModeStatus(Boolean clusterModeStatus) { - setParameters(KEY_CLUSTER_MODE_STATUS, clusterModeStatus); + public UnsubscribeVehicleData setClusterModeStatus( Boolean clusterModeStatus) { + setParameters(KEY_CLUSTER_MODE_STATUS, clusterModeStatus); + return this; } public Boolean getClusterModeStatus() { return getBoolean(KEY_CLUSTER_MODE_STATUS); } - public void setMyKey(Boolean myKey) { - setParameters(KEY_MY_KEY, myKey); + public UnsubscribeVehicleData setMyKey( Boolean myKey) { + setParameters(KEY_MY_KEY, myKey); + return this; } public Boolean getMyKey() { return getBoolean(KEY_MY_KEY); @@ -823,9 +848,10 @@ public class UnsubscribeVehicleData extends RPCRequest { * @param fuelRange * a boolean value */ - public void setFuelRange(Boolean fuelRange) { - setParameters(KEY_FUEL_RANGE, fuelRange); - } + public UnsubscribeVehicleData setFuelRange( Boolean fuelRange) { + setParameters(KEY_FUEL_RANGE, fuelRange); + return this; + } /** * Gets a boolean value. If true, means the fuelRange data has been @@ -842,7 +868,10 @@ public class UnsubscribeVehicleData extends RPCRequest { * Sets a boolean value. If true, unsubscribes from turnSignal data * @param turnSignal a boolean value */ - public void setTurnSignal(Boolean turnSignal) { setParameters(KEY_TURN_SIGNAL, turnSignal); } + public UnsubscribeVehicleData setTurnSignal( Boolean turnSignal) { + setParameters(KEY_TURN_SIGNAL, turnSignal); + return this; + } /** * Gets a boolean value. If true, means the turnSignal data has been unsubscribed. @@ -854,9 +883,10 @@ public class UnsubscribeVehicleData extends RPCRequest { * Sets a boolean value. If true, unsubscribes from electronicParkBrakeStatus data * @param electronicParkBrakeStatus a boolean value */ - public void setElectronicParkBrakeStatus(Boolean electronicParkBrakeStatus) { - setParameters(KEY_ELECTRONIC_PARK_BRAKE_STATUS, electronicParkBrakeStatus); - } + public UnsubscribeVehicleData setElectronicParkBrakeStatus( Boolean electronicParkBrakeStatus) { + setParameters(KEY_ELECTRONIC_PARK_BRAKE_STATUS, electronicParkBrakeStatus); + return this; + } /** * Gets a boolean value. If true, means the electronicParkBrakeStatus data has been subscribed. @@ -868,11 +898,12 @@ public class UnsubscribeVehicleData extends RPCRequest { /** * Sets a boolean value. If true, unsubscribes from cloudAppVehicleID data - * @param cloudAppVehicleID a boolean value. + * @param cloudAppVehicleID a boolean value. */ - public void setCloudAppVehicleID(boolean cloudAppVehicleID){ - setParameters(KEY_CLOUD_APP_VEHICLE_ID, cloudAppVehicleID); - } + public UnsubscribeVehicleData setCloudAppVehicleID( boolean cloudAppVehicleID) { + setParameters(KEY_CLOUD_APP_VEHICLE_ID, cloudAppVehicleID); + return this; + } /** * Gets a boolean value. If true, means the cloudAppVehicleID data has been unsubscribed. @@ -887,9 +918,10 @@ public class UnsubscribeVehicleData extends RPCRequest { * @param vehicleDataName a String value * @param vehicleDataState a boolean value */ - public void setOEMCustomVehicleData(String vehicleDataName, Boolean vehicleDataState){ - setParameters(vehicleDataName, vehicleDataState); - } + public UnsubscribeVehicleData setOEMCustomVehicleData( String vehicleDataName, Boolean vehicleDataState) { + setParameters(vehicleDataName, vehicleDataState); + return this; + } /** * Gets a boolean value for OEM Custom VehicleData. @@ -905,8 +937,9 @@ public class UnsubscribeVehicleData extends RPCRequest { * @param gearStatus See GearStatus * @since SmartDeviceLink 7.0.0 */ - public void setGearStatus(Boolean gearStatus) { + public UnsubscribeVehicleData setGearStatus( Boolean gearStatus) { setParameters(KEY_GEAR_STATUS, gearStatus); + return this; } /** @@ -925,8 +958,9 @@ public class UnsubscribeVehicleData extends RPCRequest { * @param handsOffSteering To indicate whether driver hands are off the steering wheel * @since SmartDeviceLink 7.0.0 */ - public void setHandsOffSteering(Boolean handsOffSteering) { + public UnsubscribeVehicleData setHandsOffSteering( Boolean handsOffSteering) { setParameters(KEY_HANDS_OFF_STEERING, handsOffSteering); + return this; } /** @@ -945,8 +979,9 @@ public class UnsubscribeVehicleData extends RPCRequest { * @param windowStatus See WindowStatus * @since SmartDeviceLink 7.0.0 */ - public void setWindowStatus(Boolean windowStatus) { + public UnsubscribeVehicleData setWindowStatus( Boolean windowStatus) { setParameters(KEY_WINDOW_STATUS, windowStatus); + return this; } /** @@ -965,8 +1000,9 @@ public class UnsubscribeVehicleData extends RPCRequest { * @param stabilityControlsStatus See StabilityControlsStatus * @since SmartDeviceLink 7.0.0 */ - public void setStabilityControlsStatus(Boolean stabilityControlsStatus) { + public UnsubscribeVehicleData setStabilityControlsStatus( Boolean stabilityControlsStatus) { setParameters(KEY_STABILITY_CONTROLS_STATUS, stabilityControlsStatus); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleDataResponse.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleDataResponse.java index 5abf391d1..4f3abd5b7 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleDataResponse.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleDataResponse.java @@ -120,8 +120,9 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse { * Sets Gps * @param gps a VehicleDataResult related to GPS */ - public void setGps(VehicleDataResult gps) { + public UnsubscribeVehicleDataResponse setGps( VehicleDataResult gps) { setParameters(KEY_GPS, gps); + return this; } /** * Gets Gps @@ -135,8 +136,9 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse { * Sets Speed * @param speed a VehicleDataResult related to speed */ - public void setSpeed(VehicleDataResult speed) { + public UnsubscribeVehicleDataResponse setSpeed( VehicleDataResult speed) { setParameters(KEY_SPEED, speed); + return this; } /** * Gets Speed @@ -150,8 +152,9 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse { * Sets rpm * @param rpm a VehicleDataResult related to RPM */ - public void setRpm(VehicleDataResult rpm) { + public UnsubscribeVehicleDataResponse setRpm( VehicleDataResult rpm) { setParameters(KEY_RPM, rpm); + return this; } /** * Gets rpm @@ -168,8 +171,9 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse { * 7.0, please see fuelRange. */ @Deprecated - public void setFuelLevel(VehicleDataResult fuelLevel) { + public UnsubscribeVehicleDataResponse setFuelLevel( VehicleDataResult fuelLevel) { setParameters(KEY_FUEL_LEVEL, fuelLevel); + return this; } /** * Gets the fuelLevel. @@ -187,8 +191,9 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse { * @param fuelLevelState a VehicleDataResult related to FuelLevel State */ @Deprecated - public void setFuelLevelState(VehicleDataResult fuelLevelState) { + public UnsubscribeVehicleDataResponse setFuelLevelState( VehicleDataResult fuelLevelState) { setParameters(KEY_FUEL_LEVEL_STATE, fuelLevelState); + return this; } /** * Gets Fuel Level State @@ -203,8 +208,9 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse { * Sets Instant Fuel Consumption * @param instantFuelConsumption a VehicleDataResult related to instant fuel consumption */ - public void setInstantFuelConsumption(VehicleDataResult instantFuelConsumption) { + public UnsubscribeVehicleDataResponse setInstantFuelConsumption( VehicleDataResult instantFuelConsumption) { setParameters(KEY_INSTANT_FUEL_CONSUMPTION, instantFuelConsumption); + return this; } /** * Gets Instant Fuel Consumption @@ -218,8 +224,9 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse { * Sets External Temperature * @param externalTemperature a VehicleDataResult related to external temperature */ - public void setExternalTemperature(VehicleDataResult externalTemperature) { + public UnsubscribeVehicleDataResponse setExternalTemperature( VehicleDataResult externalTemperature) { setParameters(KEY_EXTERNAL_TEMPERATURE, externalTemperature); + return this; } /** * Gets External Temperature @@ -236,8 +243,9 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse { * @deprecated in SmartDeviceLink 7.0.0 */ @Deprecated - public void setPrndl(VehicleDataResult prndl) { + public UnsubscribeVehicleDataResponse setPrndl( VehicleDataResult prndl) { setParameters(KEY_PRNDL, prndl); + return this; } /** * Gets the prndl. @@ -254,8 +262,9 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse { * Sets Tire Pressure * @param tirePressure a VehicleDataResult related to tire pressure */ - public void setTirePressure(VehicleDataResult tirePressure) { + public UnsubscribeVehicleDataResponse setTirePressure( VehicleDataResult tirePressure) { setParameters(KEY_TIRE_PRESSURE, tirePressure); + return this; } /** * Gets Tire Pressure @@ -269,8 +278,9 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse { * Sets Odometer * @param odometer a VehicleDataResult related to the odometer */ - public void setOdometer(VehicleDataResult odometer) { + public UnsubscribeVehicleDataResponse setOdometer( VehicleDataResult odometer) { setParameters(KEY_ODOMETER, odometer); + return this; } /** * Gets Odometer @@ -284,8 +294,9 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse { * Sets Belt Status * @param beltStatus a VehicleDataResult related to the seat belt status */ - public void setBeltStatus(VehicleDataResult beltStatus) { + public UnsubscribeVehicleDataResponse setBeltStatus( VehicleDataResult beltStatus) { setParameters(KEY_BELT_STATUS, beltStatus); + return this; } /** * Gets Belt Status @@ -299,8 +310,9 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse { * Sets Body Information * @param bodyInformation a VehicleDataResult related to the body info */ - public void setBodyInformation(VehicleDataResult bodyInformation) { + public UnsubscribeVehicleDataResponse setBodyInformation( VehicleDataResult bodyInformation) { setParameters(KEY_BODY_INFORMATION, bodyInformation); + return this; } /** * Gets Body Information @@ -314,8 +326,9 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse { * Sets Device Status * @param deviceStatus a VehicleDataResult related to the device status of the connected device */ - public void setDeviceStatus(VehicleDataResult deviceStatus) { + public UnsubscribeVehicleDataResponse setDeviceStatus( VehicleDataResult deviceStatus) { setParameters(KEY_DEVICE_STATUS, deviceStatus); + return this; } /** * Gets Device Status @@ -329,8 +342,9 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse { * Sets Driver Braking * @param driverBraking a VehicleDataResult related to the driver breaking status */ - public void setDriverBraking(VehicleDataResult driverBraking) { + public UnsubscribeVehicleDataResponse setDriverBraking( VehicleDataResult driverBraking) { setParameters(KEY_DRIVER_BRAKING, driverBraking); + return this; } /** * Gets Driver Braking @@ -344,8 +358,9 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse { * Sets Wiper Status * @param wiperStatus a VehicleDataResult related to the wiper status */ - public void setWiperStatus(VehicleDataResult wiperStatus) { + public UnsubscribeVehicleDataResponse setWiperStatus( VehicleDataResult wiperStatus) { setParameters(KEY_WIPER_STATUS, wiperStatus); + return this; } /** * Gets Wiper Status @@ -359,8 +374,9 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse { * Sets Head Lamp Status * @param headLampStatus a VehicleDataResult related to the headlamp status */ - public void setHeadLampStatus(VehicleDataResult headLampStatus) { + public UnsubscribeVehicleDataResponse setHeadLampStatus( VehicleDataResult headLampStatus) { setParameters(KEY_HEAD_LAMP_STATUS, headLampStatus); + return this; } /** * Gets Head Lamp Status @@ -374,8 +390,9 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse { * Sets Engine Torque * @param engineTorque a VehicleDataResult related to the engine's torque */ - public void setEngineTorque(VehicleDataResult engineTorque) { + public UnsubscribeVehicleDataResponse setEngineTorque( VehicleDataResult engineTorque) { setParameters(KEY_ENGINE_TORQUE, engineTorque); + return this; } /** * Gets Engine Torque @@ -389,8 +406,9 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse { * Sets Engine Oil Life * @param engineOilLife a VehicleDataResult related to the engine's oil life */ - public void setEngineOilLife(VehicleDataResult engineOilLife) { + public UnsubscribeVehicleDataResponse setEngineOilLife( VehicleDataResult engineOilLife) { setParameters(KEY_ENGINE_OIL_LIFE, engineOilLife); + return this; } /** * Gets Engine Oil Life @@ -404,8 +422,9 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse { * Sets AccPedal Position * @param accPedalPosition a VehicleDataResult related to the accelerator pedal's position */ - public void setAccPedalPosition(VehicleDataResult accPedalPosition) { + public UnsubscribeVehicleDataResponse setAccPedalPosition( VehicleDataResult accPedalPosition) { setParameters(KEY_ACC_PEDAL_POSITION, accPedalPosition); + return this; } /** * Gets AccPedal Position @@ -416,8 +435,9 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse { return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_ACC_PEDAL_POSITION); } - public void setSteeringWheelAngle(VehicleDataResult steeringWheelAngle) { + public UnsubscribeVehicleDataResponse setSteeringWheelAngle( VehicleDataResult steeringWheelAngle) { setParameters(KEY_STEERING_WHEEL_ANGLE, steeringWheelAngle); + return this; } @SuppressWarnings("unchecked") @@ -425,36 +445,41 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse { return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_STEERING_WHEEL_ANGLE); } - public void setECallInfo(VehicleDataResult eCallInfo) { + public UnsubscribeVehicleDataResponse setECallInfo( VehicleDataResult eCallInfo) { setParameters(KEY_E_CALL_INFO, eCallInfo); + return this; } @SuppressWarnings("unchecked") public VehicleDataResult getECallInfo() { return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_E_CALL_INFO); } - public void setAirbagStatus(VehicleDataResult airbagStatus) { + public UnsubscribeVehicleDataResponse setAirbagStatus( VehicleDataResult airbagStatus) { setParameters(KEY_AIRBAG_STATUS, airbagStatus); + return this; } @SuppressWarnings("unchecked") public VehicleDataResult getAirbagStatus() { return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_AIRBAG_STATUS); } - public void setEmergencyEvent(VehicleDataResult emergencyEvent) { + public UnsubscribeVehicleDataResponse setEmergencyEvent( VehicleDataResult emergencyEvent) { setParameters(KEY_EMERGENCY_EVENT, emergencyEvent); + return this; } @SuppressWarnings("unchecked") public VehicleDataResult getEmergencyEvent() { return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_EMERGENCY_EVENT); } - public void setClusterModeStatus(VehicleDataResult clusterModeStatus) { + public UnsubscribeVehicleDataResponse setClusterModeStatus( VehicleDataResult clusterModeStatus) { setParameters(KEY_CLUSTER_MODE_STATUS, clusterModeStatus); + return this; } @SuppressWarnings("unchecked") public VehicleDataResult getClusterModeStatus() { return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_CLUSTER_MODE_STATUS); } - public void setMyKey(VehicleDataResult myKey) { + public UnsubscribeVehicleDataResponse setMyKey( VehicleDataResult myKey) { setParameters(KEY_MY_KEY, myKey); + return this; } @SuppressWarnings("unchecked") public VehicleDataResult getMyKey() { @@ -468,8 +493,9 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse { * vehicle. See struct FuelRange for details. * @since SmartDeviceLink 5.0.0 */ - public void setFuelRange(VehicleDataResult fuelRange) { + public UnsubscribeVehicleDataResponse setFuelRange( VehicleDataResult fuelRange) { setParameters(KEY_FUEL_RANGE, fuelRange); + return this; } /** @@ -487,8 +513,9 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse { * Sets turnSignal * @param turnSignal a VehicleDataResult related to the turn signal status */ - public void setTurnSignal(VehicleDataResult turnSignal) { + public UnsubscribeVehicleDataResponse setTurnSignal( VehicleDataResult turnSignal) { setParameters(KEY_TURN_SIGNAL, turnSignal); + return this; } /** @@ -504,8 +531,9 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse { * Sets electronicParkBrakeStatus * @param electronicParkBrakeStatus a VehicleDataResult related to the electronic park brake status */ - public void setElectronicParkBrakeStatus(VehicleDataResult electronicParkBrakeStatus){ + public UnsubscribeVehicleDataResponse setElectronicParkBrakeStatus( VehicleDataResult electronicParkBrakeStatus) { setParameters(KEY_ELECTRONIC_PARK_BRAKE_STATUS, electronicParkBrakeStatus); + return this; } /** @@ -520,8 +548,9 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse { * Sets cloudAppVehicleID * @param cloudAppVehicleID a VehicleDataResult related to the cloud app vehicle ID */ - public void setCloudAppVehicleID(VehicleDataResult cloudAppVehicleID){ + public UnsubscribeVehicleDataResponse setCloudAppVehicleID( VehicleDataResult cloudAppVehicleID) { setParameters(KEY_CLOUD_APP_VEHICLE_ID, cloudAppVehicleID); + return this; } /** @@ -537,8 +566,9 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse { * @param vehicleDataName a String value * @param vehicleDataState a VehicleDataResult value */ - public void setOEMCustomVehicleData(String vehicleDataName, VehicleDataResult vehicleDataState){ + public UnsubscribeVehicleDataResponse setOEMCustomVehicleData( String vehicleDataName, VehicleDataResult vehicleDataState) { setParameters(vehicleDataName, vehicleDataState); + return this; } /** @@ -555,8 +585,9 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse { * @param handsOffSteering To indicate whether driver hands are off the steering wheel * @since SmartDeviceLink 7.0.0 */ - public void setHandsOffSteering(VehicleDataResult handsOffSteering) { + public UnsubscribeVehicleDataResponse setHandsOffSteering( VehicleDataResult handsOffSteering) { setParameters(KEY_HANDS_OFF_STEERING, handsOffSteering); + return this; } /** @@ -575,8 +606,9 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse { * @param windowStatus See WindowStatus * @since SmartDeviceLink 7.0.0 */ - public void setWindowStatus(VehicleDataResult windowStatus) { + public UnsubscribeVehicleDataResponse setWindowStatus( VehicleDataResult windowStatus) { setParameters(KEY_WINDOW_STATUS, windowStatus); + return this; } /** @@ -595,8 +627,9 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse { * @param gearStatus See GearStatus * @since SmartDeviceLink 7.0.0 */ - public void setGearStatus(VehicleDataResult gearStatus){ + public UnsubscribeVehicleDataResponse setGearStatus( VehicleDataResult gearStatus) { setParameters(KEY_GEAR_STATUS, gearStatus); + return this; } /** @@ -626,7 +659,8 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse { * @param stabilityControlsStatus See StabilityControlsStatus * @since SmartDeviceLink 7.0.0 */ - public void setStabilityControlsStatus(VehicleDataResult stabilityControlsStatus) { + public UnsubscribeVehicleDataResponse setStabilityControlsStatus( VehicleDataResult stabilityControlsStatus) { setParameters(KEY_STABILITY_CONTROLS_STATUS, stabilityControlsStatus); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/UpdateTurnList.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/UpdateTurnList.java index cafd04d88..a19a9c2ea 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/UpdateTurnList.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/UpdateTurnList.java @@ -75,14 +75,15 @@ public class UpdateTurnList extends RPCRequest{ /** * Sets a list of turns to be shown to the user - * + * * @param turnList * a List value representing a list of turns to be shown to the user *

    * Notes: Minsize=1; Maxsize=100

    */ - public void setTurnList(List turnList){ + public UpdateTurnList setTurnList( List turnList) { setParameters(KEY_TURN_LIST, turnList); + return this; } /** @@ -108,7 +109,7 @@ public class UpdateTurnList extends RPCRequest{ /** * Sets the SoftButtons - * + * * @param softButtons * a List value *

    @@ -121,8 +122,9 @@ public class UpdateTurnList extends RPCRequest{ * @since SmartDeviceLink 2.0 */ - public void setSoftButtons(List softButtons){ + public UpdateTurnList setSoftButtons( List softButtons) { setParameters(KEY_SOFT_BUTTONS, softButtons); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/VehicleDataResult.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/VehicleDataResult.java index 5e50f18e9..cf22bc11c 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/VehicleDataResult.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/VehicleDataResult.java @@ -100,25 +100,28 @@ public class VehicleDataResult extends RPCStruct { setResultCode(resultCode); } - public void setResultCode(@NonNull VehicleDataResultCode resultCode) { - setValue(KEY_RESULT_CODE, resultCode); - } + public VehicleDataResult setResultCode(@NonNull VehicleDataResultCode resultCode) { + setValue(KEY_RESULT_CODE, resultCode); + return this; + } public VehicleDataResultCode getResultCode() { return (VehicleDataResultCode) getObject(VehicleDataResultCode.class, KEY_RESULT_CODE); } - public void setDataType(@NonNull VehicleDataType dataType) { - setValue(KEY_DATA_TYPE, dataType); - } + public VehicleDataResult setDataType(@NonNull VehicleDataType dataType) { + setValue(KEY_DATA_TYPE, dataType); + return this; + } public VehicleDataType getDataType() { return (VehicleDataType) getObject(VehicleDataType.class, KEY_DATA_TYPE); } - public void setOEMCustomVehicleDataType(String oemCustomDataType) { - setValue(KEY_OEM_CUSTOM_DATA_TYPE, oemCustomDataType); - } + public VehicleDataResult setOEMCustomVehicleDataType( String oemCustomDataType) { + setValue(KEY_OEM_CUSTOM_DATA_TYPE, oemCustomDataType); + return this; + } public String getOEMCustomVehicleDataType() { return (String) getObject(String.class, KEY_OEM_CUSTOM_DATA_TYPE); diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/VehicleType.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/VehicleType.java index 5858ce39e..27b1ff42a 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/VehicleType.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/VehicleType.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import com.smartdevicelink.proxy.RPCStruct; @@ -119,8 +119,9 @@ public class VehicleType extends RPCStruct { * set the make of the vehicle *@param make the make of the vehicle */ - public void setMake(String make) { + public VehicleType setMake( String make) { setValue(KEY_MAKE, make); + return this; } /** @@ -135,8 +136,9 @@ public class VehicleType extends RPCStruct { * set the model of the vehicle * @param model the model of the vehicle */ - public void setModel(String model) { + public VehicleType setModel( String model) { setValue(KEY_MODEL, model); + return this; } /** @@ -151,8 +153,9 @@ public class VehicleType extends RPCStruct { * set the model year of the vehicle * @param modelYear the model year of the vehicle */ - public void setModelYear(String modelYear) { + public VehicleType setModelYear( String modelYear) { setValue(KEY_MODEL_YEAR, modelYear); + return this; } /** @@ -167,7 +170,8 @@ public class VehicleType extends RPCStruct { * set the trim of the vehicle * @param trim the trim of the vehicle */ - public void setTrim(String trim) { + public VehicleType setTrim( String trim) { setValue(KEY_TRIM, trim); + return this; } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/VideoStreamingCapability.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/VideoStreamingCapability.java index ca13ba74f..872992ba1 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/VideoStreamingCapability.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/VideoStreamingCapability.java @@ -53,9 +53,10 @@ public class VideoStreamingCapability extends RPCStruct { public VideoStreamingCapability(){} public VideoStreamingCapability(Hashtable hash){super(hash);} - public void setPreferredResolution(ImageResolution res){ - setValue(KEY_PREFERRED_RESOLUTION, res); - } + public VideoStreamingCapability setPreferredResolution( ImageResolution res) { + setValue(KEY_PREFERRED_RESOLUTION, res); + return this; + } public ImageResolution getPreferredResolution(){ return (ImageResolution) getObject(ImageResolution.class, KEY_PREFERRED_RESOLUTION); @@ -67,9 +68,10 @@ public class VideoStreamingCapability extends RPCStruct { * NOTE: Unit is in kbps. * @param maxBitrate in kbps */ - public void setMaxBitrate(Integer maxBitrate){ - setValue(KEY_MAX_BITRATE, maxBitrate); - } + public VideoStreamingCapability setMaxBitrate( Integer maxBitrate) { + setValue(KEY_MAX_BITRATE, maxBitrate); + return this; + } /** * Retrieves the max bitrate supported by this module. @@ -81,9 +83,10 @@ public class VideoStreamingCapability extends RPCStruct { return getInteger(KEY_MAX_BITRATE); } - public void setSupportedFormats(List formats){ - setValue(KEY_SUPPORTED_FORMATS, formats); - } + public VideoStreamingCapability setSupportedFormats( List formats) { + setValue(KEY_SUPPORTED_FORMATS, formats); + return this; + } public List getSupportedFormats(){ return (List) getObject(VideoStreamingFormat.class, KEY_SUPPORTED_FORMATS); @@ -93,9 +96,10 @@ public class VideoStreamingCapability extends RPCStruct { return getBoolean(KEY_HAPTIC_SPATIAL_DATA_SUPPORTED); } - public void setIsHapticSpatialDataSupported(Boolean hapticSpatialDataSupported) { - setValue(KEY_HAPTIC_SPATIAL_DATA_SUPPORTED, hapticSpatialDataSupported); - } + public VideoStreamingCapability setIsHapticSpatialDataSupported( Boolean hapticSpatialDataSupported) { + setValue(KEY_HAPTIC_SPATIAL_DATA_SUPPORTED, hapticSpatialDataSupported); + return this; + } /** * @return the diagonal screen size in inches. @@ -108,9 +112,10 @@ public class VideoStreamingCapability extends RPCStruct { /** * @param diagonalScreenSize the diagonal screen size in inches. */ - public void setDiagonalScreenSize(Double diagonalScreenSize) { - setValue(KEY_DIAGONAL_SCREEN_SIZE, diagonalScreenSize); - } + public VideoStreamingCapability setDiagonalScreenSize( Double diagonalScreenSize) { + setValue(KEY_DIAGONAL_SCREEN_SIZE, diagonalScreenSize); + return this; + } /** * @return the diagonal resolution in pixels divided by the diagonal screen size in inches. @@ -123,9 +128,10 @@ public class VideoStreamingCapability extends RPCStruct { /** * @param pixelPerInch the diagonal resolution in pixels divided by the diagonal screen size in inches. */ - public void setPixelPerInch(Double pixelPerInch) { - setValue(KEY_PIXEL_PER_INCH, pixelPerInch); - } + public VideoStreamingCapability setPixelPerInch( Double pixelPerInch) { + setValue(KEY_PIXEL_PER_INCH, pixelPerInch); + return this; + } /** * @return the scaling factor the app should use to change the size of the projecting view. @@ -138,7 +144,8 @@ public class VideoStreamingCapability extends RPCStruct { /** * @param scale the scaling factor the app should use to change the size of the projecting view. */ - public void setScale(Double scale) { - setValue(KEY_SCALE, scale); - } + public VideoStreamingCapability setScale( Double scale) { + setValue(KEY_SCALE, scale); + return this; + } } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/VideoStreamingFormat.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/VideoStreamingFormat.java index 92c16cebc..0fac119f2 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/VideoStreamingFormat.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/VideoStreamingFormat.java @@ -61,17 +61,19 @@ public class VideoStreamingFormat extends RPCStruct { setCodec(codec); } - public void setProtocol(@NonNull VideoStreamingProtocol protocol){ - setValue(KEY_PROTOCOL, protocol); - } + public VideoStreamingFormat setProtocol(@NonNull VideoStreamingProtocol protocol) { + setValue(KEY_PROTOCOL, protocol); + return this; + } public VideoStreamingProtocol getProtocol(){ return (VideoStreamingProtocol) getObject(VideoStreamingProtocol.class, KEY_PROTOCOL); } - public void setCodec(@NonNull VideoStreamingCodec codec){ - setValue(KEY_CODEC, codec); - } + public VideoStreamingFormat setCodec(@NonNull VideoStreamingCodec codec) { + setValue(KEY_CODEC, codec); + return this; + } public VideoStreamingCodec getCodec(){ return (VideoStreamingCodec) getObject(VideoStreamingCodec.class, KEY_CODEC); diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/VrHelpItem.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/VrHelpItem.java index 0acb5b8dd..2ba56c4db 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/VrHelpItem.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/VrHelpItem.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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. + */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; @@ -107,21 +107,24 @@ public class VrHelpItem extends RPCStruct { setPosition(position); } - public void setText(@NonNull String text) { + public VrHelpItem setText(@NonNull String text) { setValue(KEY_TEXT, text); + return this; } public String getText() { return getString(KEY_TEXT); } - public void setImage(Image image) { + public VrHelpItem setImage( Image image) { setValue(KEY_IMAGE, image); + return this; } @SuppressWarnings("unchecked") public Image getImage() { return (Image) getObject(Image.class, KEY_IMAGE); } - public void setPosition(@NonNull Integer position) { + public VrHelpItem setPosition(@NonNull Integer position) { setValue(KEY_POSITION, position); + return this; } public Integer getPosition() { return getInteger(KEY_POSITION); diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/WeatherAlert.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/WeatherAlert.java index 2d3afdfb4..23f183da5 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/WeatherAlert.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/WeatherAlert.java @@ -66,9 +66,10 @@ public class WeatherAlert extends RPCStruct { /** * @param title - */ - public void setTitle(String title) { - setValue(KEY_TITLE, title); - } + public WeatherAlert setTitle( String title) { + setValue(KEY_TITLE, title); + return this; + } /** * @return title @@ -80,9 +81,10 @@ public class WeatherAlert extends RPCStruct { /** * @param summary - */ - public void setSummary(String summary) { - setValue(KEY_SUMMARY, summary); - } + public WeatherAlert setSummary( String summary) { + setValue(KEY_SUMMARY, summary); + return this; + } /** * @return summary @@ -94,9 +96,10 @@ public class WeatherAlert extends RPCStruct { /** * @param severity - */ - public void setSeverity(String severity) { - setValue(KEY_SEVERITY, severity); - } + public WeatherAlert setSeverity( String severity) { + setValue(KEY_SEVERITY, severity); + return this; + } /** * @return severity @@ -109,9 +112,10 @@ public class WeatherAlert extends RPCStruct { * Min Size: 1, Max Size: 99 * @param regions - */ - public void setRegions(@NonNull List regions) { - setValue(KEY_REGIONS, regions); - } + public WeatherAlert setRegions(@NonNull List regions) { + setValue(KEY_REGIONS, regions); + return this; + } /** * @return regions list @@ -124,9 +128,10 @@ public class WeatherAlert extends RPCStruct { /** * @param expires - */ - public void setExpires(DateTime expires) { - setValue(KEY_EXPIRES, expires); - } + public WeatherAlert setExpires( DateTime expires) { + setValue(KEY_EXPIRES, expires); + return this; + } /** * @return expires @@ -138,9 +143,10 @@ public class WeatherAlert extends RPCStruct { /** * @param timeIssued - */ - public void setTimeIssued(DateTime timeIssued) { - setValue(KEY_TIME_ISSUED, timeIssued); - } + public WeatherAlert setTimeIssued( DateTime timeIssued) { + setValue(KEY_TIME_ISSUED, timeIssued); + return this; + } /** * @return timeIssued diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/WeatherData.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/WeatherData.java index a3b897acb..c9bbf02f4 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/WeatherData.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/WeatherData.java @@ -73,9 +73,10 @@ public class WeatherData extends RPCStruct { /** * @param currentTemperature - */ - public void setCurrentTemperature(Temperature currentTemperature) { - setValue(KEY_CURRENT_TEMPERATURE, currentTemperature); - } + public WeatherData setCurrentTemperature( Temperature currentTemperature) { + setValue(KEY_CURRENT_TEMPERATURE, currentTemperature); + return this; + } /** * @return currentTemperature @@ -87,9 +88,10 @@ public class WeatherData extends RPCStruct { /** * @param temperatureHigh - */ - public void setTemperatureHigh(Temperature temperatureHigh) { - setValue(KEY_TEMPERATURE_HIGH, temperatureHigh); - } + public WeatherData setTemperatureHigh( Temperature temperatureHigh) { + setValue(KEY_TEMPERATURE_HIGH, temperatureHigh); + return this; + } /** * @return temperatureHigh @@ -101,9 +103,10 @@ public class WeatherData extends RPCStruct { /** * @param temperatureLow - */ - public void setTemperatureLow(Temperature temperatureLow) { - setValue(KEY_TEMPERATURE_LOW, temperatureLow); - } + public WeatherData setTemperatureLow( Temperature temperatureLow) { + setValue(KEY_TEMPERATURE_LOW, temperatureLow); + return this; + } /** * @return temperatureLow @@ -115,9 +118,10 @@ public class WeatherData extends RPCStruct { /** * @param apparentTemperature - */ - public void setApparentTemperature(Temperature apparentTemperature) { - setValue(KEY_APPARENT_TEMPERATURE, apparentTemperature); - } + public WeatherData setApparentTemperature( Temperature apparentTemperature) { + setValue(KEY_APPARENT_TEMPERATURE, apparentTemperature); + return this; + } /** * @return apparentTemperature @@ -129,9 +133,10 @@ public class WeatherData extends RPCStruct { /** * @param apparentTemperatureHigh - */ - public void setApparentTemperatureHigh(Temperature apparentTemperatureHigh) { - setValue(KEY_APPARENT_TEMPERATURE_HIGH, apparentTemperatureHigh); - } + public WeatherData setApparentTemperatureHigh( Temperature apparentTemperatureHigh) { + setValue(KEY_APPARENT_TEMPERATURE_HIGH, apparentTemperatureHigh); + return this; + } /** * @return apparentTemperatureHigh @@ -143,9 +148,10 @@ public class WeatherData extends RPCStruct { /** * @param apparentTemperatureLow - */ - public void setApparentTemperatureLow(Temperature apparentTemperatureLow) { - setValue(KEY_APPARENT_TEMPERATURE_LOW, apparentTemperatureLow); - } + public WeatherData setApparentTemperatureLow( Temperature apparentTemperatureLow) { + setValue(KEY_APPARENT_TEMPERATURE_LOW, apparentTemperatureLow); + return this; + } /** * @return apparentTemperatureLow @@ -157,9 +163,10 @@ public class WeatherData extends RPCStruct { /** * @param weatherSummary - */ - public void setWeatherSummary(String weatherSummary) { - setValue(KEY_WEATHER_SUMMARY, weatherSummary); - } + public WeatherData setWeatherSummary( String weatherSummary) { + setValue(KEY_WEATHER_SUMMARY, weatherSummary); + return this; + } /** * @return weatherSummary @@ -171,9 +178,10 @@ public class WeatherData extends RPCStruct { /** * @param time - */ - public void setTime(DateTime time) { - setValue(KEY_TIME, time); - } + public WeatherData setTime( DateTime time) { + setValue(KEY_TIME, time); + return this; + } /** * @return time @@ -186,9 +194,10 @@ public class WeatherData extends RPCStruct { * minValue: 0, maxValue: 1 * @param humidity - percentage humidity */ - public void setHumidity(Float humidity) { - setValue(KEY_HUMIDITY, humidity); - } + public WeatherData setHumidity( Float humidity) { + setValue(KEY_HUMIDITY, humidity); + return this; + } /** * minValue: 0, maxValue: 1 @@ -202,9 +211,10 @@ public class WeatherData extends RPCStruct { * minValue: 0, maxValue: 1 * @param cloudCover - cloud cover */ - public void setCloudCover(Float cloudCover) { - setValue(KEY_CLOUD_COVER, cloudCover); - } + public WeatherData setCloudCover( Float cloudCover) { + setValue(KEY_CLOUD_COVER, cloudCover); + return this; + } /** * minValue: 0, maxValue: 1 @@ -218,9 +228,10 @@ public class WeatherData extends RPCStruct { * minValue: 0, maxValue: 1 * @param moonPhase - percentage of the moon seen, e.g. 0 = no moon, 0.25 = quarter moon */ - public void setMoonPhase(Float moonPhase) { - setValue(KEY_MOON_PHASE, moonPhase); - } + public WeatherData setMoonPhase( Float moonPhase) { + setValue(KEY_MOON_PHASE, moonPhase); + return this; + } /** * minValue: 0, maxValue: 1 @@ -233,9 +244,10 @@ public class WeatherData extends RPCStruct { /** * @param windBearing - In degrees, true north at 0 degrees */ - public void setWindBearing(Integer windBearing) { - setValue(KEY_WIND_BEARING, windBearing); - } + public WeatherData setWindBearing( Integer windBearing) { + setValue(KEY_WIND_BEARING, windBearing); + return this; + } /** * @return windBearing - In degrees, true north at 0 degrees @@ -247,9 +259,10 @@ public class WeatherData extends RPCStruct { /** * @param windGust - km/hr */ - public void setWindGust(Float windGust) { - setValue(KEY_WIND_GUST, windGust); - } + public WeatherData setWindGust( Float windGust) { + setValue(KEY_WIND_GUST, windGust); + return this; + } /** * @return windGust - km/hr @@ -261,9 +274,10 @@ public class WeatherData extends RPCStruct { /** * @param windSpeed - km/hr */ - public void setWindSpeed(Float windSpeed) { - setValue(KEY_WIND_SPEED, windSpeed); - } + public WeatherData setWindSpeed( Float windSpeed) { + setValue(KEY_WIND_SPEED, windSpeed); + return this; + } /** * @return windSpeed - km/hr @@ -275,9 +289,10 @@ public class WeatherData extends RPCStruct { /** * @param nearestStormBearing - In degrees, true north at 0 degrees */ - public void setNearestStormBearing(Integer nearestStormBearing) { - setValue(KEY_NEAREST_STORM_BEARING, nearestStormBearing); - } + public WeatherData setNearestStormBearing( Integer nearestStormBearing) { + setValue(KEY_NEAREST_STORM_BEARING, nearestStormBearing); + return this; + } /** * @return nearestStormBearing - In degrees, true north at 0 degrees @@ -289,9 +304,10 @@ public class WeatherData extends RPCStruct { /** * @param nearestStormDistance - In km */ - public void setNearestStormDistance(Integer nearestStormDistance) { - setValue(KEY_NEAREST_STORM_DISTANCE, nearestStormDistance); - } + public WeatherData setNearestStormDistance( Integer nearestStormDistance) { + setValue(KEY_NEAREST_STORM_DISTANCE, nearestStormDistance); + return this; + } /** * @return nearestStormDistance - In km @@ -303,9 +319,10 @@ public class WeatherData extends RPCStruct { /** * @param precipAccumulation - cm */ - public void setPrecipAccumulation(Float precipAccumulation) { - setValue(KEY_PRECIP_ACCUMULATION, precipAccumulation); - } + public WeatherData setPrecipAccumulation( Float precipAccumulation) { + setValue(KEY_PRECIP_ACCUMULATION, precipAccumulation); + return this; + } /** * @return precipAccumulation - cm @@ -317,9 +334,10 @@ public class WeatherData extends RPCStruct { /** * @param precipIntensity - cm of water per hour */ - public void setPrecipIntensity(Float precipIntensity) { - setValue(KEY_PRECIP_INTENSITY, precipIntensity); - } + public WeatherData setPrecipIntensity( Float precipIntensity) { + setValue(KEY_PRECIP_INTENSITY, precipIntensity); + return this; + } /** * @return precipIntensity - cm of water per hour @@ -332,9 +350,10 @@ public class WeatherData extends RPCStruct { * minValue: 0, maxValue: 1 * @param precipProbability - percentage chance */ - public void setPrecipProbability(Float precipProbability) { - setValue(KEY_PRECIP_PROBABILITY, precipProbability); - } + public WeatherData setPrecipProbability( Float precipProbability) { + setValue(KEY_PRECIP_PROBABILITY, precipProbability); + return this; + } /** * minValue: 0, maxValue: 1 @@ -347,9 +366,10 @@ public class WeatherData extends RPCStruct { /** * @param precipType - e.g. "rain", "snow", "sleet", "hail" */ - public void setPrecipType(String precipType) { - setValue(KEY_PRECIP_TYPE, precipType); - } + public WeatherData setPrecipType( String precipType) { + setValue(KEY_PRECIP_TYPE, precipType); + return this; + } /** * @return precipType - e.g. "rain", "snow", "sleet", "hail" @@ -361,9 +381,10 @@ public class WeatherData extends RPCStruct { /** * @param weatherIcon - */ - public void setWeatherIcon(Image weatherIcon) { - setValue(KEY_WEATHER_ICON, weatherIcon); - } + public WeatherData setWeatherIcon( Image weatherIcon) { + setValue(KEY_WEATHER_ICON, weatherIcon); + return this; + } /** * @return weatherIcon @@ -375,9 +396,10 @@ public class WeatherData extends RPCStruct { /** * @param visibility - In km */ - public void setVisibility(Float visibility) { - setValue(KEY_VISIBILITY, visibility); - } + public WeatherData setVisibility( Float visibility) { + setValue(KEY_VISIBILITY, visibility); + return this; + } /** * @return visibility - In km diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/WeatherServiceData.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/WeatherServiceData.java index 9ae1d4e0d..0d7a26648 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/WeatherServiceData.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/WeatherServiceData.java @@ -68,9 +68,10 @@ public class WeatherServiceData extends RPCStruct { /** * @param location - */ - public void setLocation(@NonNull LocationDetails location) { - setValue(KEY_LOCATION, location); - } + public WeatherServiceData setLocation(@NonNull LocationDetails location) { + setValue(KEY_LOCATION, location); + return this; + } /** * @return location @@ -82,9 +83,10 @@ public class WeatherServiceData extends RPCStruct { /** * @param currentForecast - */ - public void setCurrentForecast(WeatherData currentForecast) { - setValue(KEY_CURRENT_FORECAST, currentForecast); - } + public WeatherServiceData setCurrentForecast( WeatherData currentForecast) { + setValue(KEY_CURRENT_FORECAST, currentForecast); + return this; + } /** * @return currentForecast @@ -97,9 +99,10 @@ public class WeatherServiceData extends RPCStruct { * minsize: 15, maxsize: 60 * @param minuteForecast - */ - public void setMinuteForecast(List minuteForecast){ - setValue(KEY_MINUTE_FORECAST, minuteForecast); - } + public WeatherServiceData setMinuteForecast( List minuteForecast) { + setValue(KEY_MINUTE_FORECAST, minuteForecast); + return this; + } /** * minsize: 15, maxsize: 60 @@ -114,9 +117,10 @@ public class WeatherServiceData extends RPCStruct { * minsize: 1, maxsize: 96 * @param hourlyForecast - */ - public void setHourlyForecast(List hourlyForecast){ - setValue(KEY_HOURLY_FORECAST, hourlyForecast); - } + public WeatherServiceData setHourlyForecast( List hourlyForecast) { + setValue(KEY_HOURLY_FORECAST, hourlyForecast); + return this; + } /** * minsize: 1, maxsize: 96 @@ -131,9 +135,10 @@ public class WeatherServiceData extends RPCStruct { * minsize: 1, maxsize: 30 * @param multidayForecast - */ - public void setMultidayForecast(List multidayForecast){ - setValue(KEY_MULTIDAY_FORECAST, multidayForecast); - } + public WeatherServiceData setMultidayForecast( List multidayForecast) { + setValue(KEY_MULTIDAY_FORECAST, multidayForecast); + return this; + } /** * minsize: 1, maxsize: 30 @@ -148,9 +153,10 @@ public class WeatherServiceData extends RPCStruct { * minsize: 1, maxsize: 10 * @param alerts - */ - public void setAlerts(List alerts){ - setValue(KEY_ALERTS, alerts); - } + public WeatherServiceData setAlerts( List alerts) { + setValue(KEY_ALERTS, alerts); + return this; + } /** * minsize: 1, maxsize: 10 diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/WeatherServiceManifest.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/WeatherServiceManifest.java index 2f6a9f8d3..79a4e5528 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/WeatherServiceManifest.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/WeatherServiceManifest.java @@ -56,9 +56,10 @@ public class WeatherServiceManifest extends RPCStruct { * Set whether the current forecast is supported * @param currentForecastSupported - */ - public void setCurrentForecastSupported(Boolean currentForecastSupported){ - setValue(KEY_CURRENT_FORECAST_SUPPORTED, currentForecastSupported); - } + public WeatherServiceManifest setCurrentForecastSupported( Boolean currentForecastSupported) { + setValue(KEY_CURRENT_FORECAST_SUPPORTED, currentForecastSupported); + return this; + } /** * Get whether the current forecast is supported @@ -72,9 +73,10 @@ public class WeatherServiceManifest extends RPCStruct { * Set the max multi day forecast amount * @param maxMultidayForecastAmount - */ - public void setMaxMultidayForecastAmount(Integer maxMultidayForecastAmount){ - setValue(KEY_MAX_MULTIDAY_FORECAST_AMOUNT, maxMultidayForecastAmount); - } + public WeatherServiceManifest setMaxMultidayForecastAmount( Integer maxMultidayForecastAmount) { + setValue(KEY_MAX_MULTIDAY_FORECAST_AMOUNT, maxMultidayForecastAmount); + return this; + } /** * Get the max multi day forecast amount @@ -88,9 +90,10 @@ public class WeatherServiceManifest extends RPCStruct { * Set the max hourly forecast amount * @param maxHourlyForecastAmount - */ - public void setMaxHourlyForecastAmount(Integer maxHourlyForecastAmount){ - setValue(KEY_MAX_HOURLY_FORECAST_AMOUNT, maxHourlyForecastAmount); - } + public WeatherServiceManifest setMaxHourlyForecastAmount( Integer maxHourlyForecastAmount) { + setValue(KEY_MAX_HOURLY_FORECAST_AMOUNT, maxHourlyForecastAmount); + return this; + } /** * Get the max hourly forecast amount @@ -104,9 +107,10 @@ public class WeatherServiceManifest extends RPCStruct { * Set the max minutely forecast amount * @param maxMinutelyForecastAmount - */ - public void setMaxMinutelyForecastAmount(Integer maxMinutelyForecastAmount){ - setValue(KEY_MAX_MINUTELY_FORECAST_AMOUNT, maxMinutelyForecastAmount); - } + public WeatherServiceManifest setMaxMinutelyForecastAmount( Integer maxMinutelyForecastAmount) { + setValue(KEY_MAX_MINUTELY_FORECAST_AMOUNT, maxMinutelyForecastAmount); + return this; + } /** * Get the max minutely forecast amount @@ -120,9 +124,10 @@ public class WeatherServiceManifest extends RPCStruct { * Set whether the weather is supported for the current location * @param weatherForLocationSupported - */ - public void setWeatherForLocationSupported(Boolean weatherForLocationSupported){ - setValue(KEY_WEATHER_FOR_LOCATION_SUPPORTED, weatherForLocationSupported); - } + public WeatherServiceManifest setWeatherForLocationSupported( Boolean weatherForLocationSupported) { + setValue(KEY_WEATHER_FOR_LOCATION_SUPPORTED, weatherForLocationSupported); + return this; + } /** * Get whether the weather is supported for the current location diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/WindowCapability.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/WindowCapability.java index c93cb50ca..dcf05b4c3 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/WindowCapability.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/WindowCapability.java @@ -34,8 +34,9 @@ public class WindowCapability extends RPCStruct { * * @param windowID A unique ID to identify the window. The value of '0' will always be the default main window on the main display and should not be used in this context as it will already be created for the app. See PredefinedWindows enum. Creating a window with an ID that is already in use will be rejected with `INVALID_ID`. */ - public void setWindowID(Integer windowID) { + public WindowCapability setWindowID( Integer windowID) { setValue(KEY_WINDOW_ID, windowID); + return this; } /** @@ -63,8 +64,9 @@ public class WindowCapability extends RPCStruct { * * @param textFields the List of textFields */ - public void setTextFields(List textFields) { + public WindowCapability setTextFields( List textFields) { setValue(KEY_TEXT_FIELDS, textFields); + return this; } /** @@ -83,8 +85,9 @@ public class WindowCapability extends RPCStruct { * * @param imageFields the List of imageFields */ - public void setImageFields(List imageFields) { + public WindowCapability setImageFields( List imageFields) { setValue(KEY_IMAGE_FIELDS, imageFields); + return this; } /** @@ -103,8 +106,9 @@ public class WindowCapability extends RPCStruct { * * @param imageTypeSupported the List of ImageType */ - public void setImageTypeSupported(List imageTypeSupported) { + public WindowCapability setImageTypeSupported( List imageTypeSupported) { setValue(KEY_IMAGE_TYPE_SUPPORTED, imageTypeSupported); + return this; } /** @@ -123,8 +127,9 @@ public class WindowCapability extends RPCStruct { * * @param templatesAvailable the List of String */ - public void setTemplatesAvailable(List templatesAvailable) { + public WindowCapability setTemplatesAvailable( List templatesAvailable) { setValue(KEY_TEMPLATES_AVAILABLE, templatesAvailable); + return this; } /** @@ -142,8 +147,9 @@ public class WindowCapability extends RPCStruct { * * @param numCustomPresetsAvailable */ - public void setNumCustomPresetsAvailable(Integer numCustomPresetsAvailable) { + public WindowCapability setNumCustomPresetsAvailable( Integer numCustomPresetsAvailable) { setValue(KEY_NUM_CUSTOM_PRESETS_AVAILABLE, numCustomPresetsAvailable); + return this; } /** @@ -152,8 +158,9 @@ public class WindowCapability extends RPCStruct { * * @param buttonCapabilities It refers to number of buttons and the capabilities of each on-window button. */ - public void setButtonCapabilities(List buttonCapabilities) { + public WindowCapability setButtonCapabilities( List buttonCapabilities) { setValue(KEY_BUTTON_CAPABILITIES, buttonCapabilities); + return this; } /** @@ -173,8 +180,9 @@ public class WindowCapability extends RPCStruct { * * @param softButtonCapabilities It refers to number of soft buttons available on-window and the capabilities for each button. */ - public void setSoftButtonCapabilities(List softButtonCapabilities) { + public WindowCapability setSoftButtonCapabilities( List softButtonCapabilities) { setValue(KEY_SOFT_BUTTON_CAPABILITIES, softButtonCapabilities); + return this; } /** @@ -193,8 +201,9 @@ public class WindowCapability extends RPCStruct { * is assumed to be available * @param menuLayout - An array of MenuLayouts */ - public void setMenuLayoutsAvailable(List menuLayout) { + public WindowCapability setMenuLayoutsAvailable( List menuLayout) { setValue(KEY_MENU_LAYOUTS_AVAILABLE, menuLayout); + return this; } /** @@ -214,8 +223,9 @@ public class WindowCapability extends RPCStruct { * module will send dynamic update RPCs. * @since SmartDeviceLink 7.0.0 */ - public void setDynamicUpdateCapabilities(DynamicUpdateCapabilities dynamicUpdateCapabilities) { + public WindowCapability setDynamicUpdateCapabilities( DynamicUpdateCapabilities dynamicUpdateCapabilities) { setValue(KEY_DYNAMIC_UPDATE_CAPABILITIES, dynamicUpdateCapabilities); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/WindowState.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/WindowState.java index e17d9b7d9..9011f3865 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/WindowState.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/WindowState.java @@ -104,8 +104,9 @@ public class WindowState extends RPCStruct { * @param approximatePosition The approximate percentage that the window is open - 0 being fully closed, 100 being fully * open */ - public void setApproximatePosition(@NonNull Integer approximatePosition) { + public WindowState setApproximatePosition(@NonNull Integer approximatePosition) { setValue(KEY_APPROXIMATE_POSITION, approximatePosition); + return this; } /** @@ -124,8 +125,9 @@ public class WindowState extends RPCStruct { * @param deviation The percentage deviation of the approximatePosition. e.g. If the approximatePosition is 50 * and the deviation is 10, then the window's location is somewhere between 40 and 60. */ - public void setDeviation(@NonNull Integer deviation) { + public WindowState setDeviation(@NonNull Integer deviation) { setValue(KEY_DEVIATION, deviation); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/WindowStatus.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/WindowStatus.java index 075d5f142..ebae89ea8 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/WindowStatus.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/WindowStatus.java @@ -103,8 +103,9 @@ public class WindowStatus extends RPCStruct { * * @param location */ - public void setLocation(@NonNull Grid location) { + public WindowStatus setLocation(@NonNull Grid location) { setValue(KEY_LOCATION, location); + return this; } /** @@ -121,8 +122,9 @@ public class WindowStatus extends RPCStruct { * * @param state */ - public void setState(@NonNull WindowState state) { + public WindowStatus setState(@NonNull WindowState state) { setValue(KEY_STATE, state); + return this; } /** diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/WindowTypeCapabilities.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/WindowTypeCapabilities.java index 4853a29a2..c145dc455 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/WindowTypeCapabilities.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/WindowTypeCapabilities.java @@ -47,8 +47,9 @@ public class WindowTypeCapabilities extends RPCStruct { * * @param type Type of windows available, to create. */ - public void setType(@NonNull WindowType type) { + public WindowTypeCapabilities setType(@NonNull WindowType type) { setValue(KEY_TYPE, type); + return this; } /** @@ -65,8 +66,9 @@ public class WindowTypeCapabilities extends RPCStruct { * * @param maximumNumberOfWindows Number of windows available, to create. */ - public void setMaximumNumberOfWindows(@NonNull Integer maximumNumberOfWindows) { + public WindowTypeCapabilities setMaximumNumberOfWindows(@NonNull Integer maximumNumberOfWindows) { setValue(KEY_MAXIMUM_NUMBER_OF_WINDOWS, maximumNumberOfWindows); + return this; } /** -- cgit v1.2.1