summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRHenigan <heniganr1@gmail.com>2020-08-14 10:50:48 -0400
committerRHenigan <heniganr1@gmail.com>2020-08-14 10:50:48 -0400
commitdafdc05c00bb4f39fd48eacb603bd7728b832465 (patch)
tree5f5d4df85c2632437f31c17ca58d2c7f0c8f7039
parentd707b683d9818210e4c4062baec4ff97cbe71f3a (diff)
parent9a1a356160e0d994349306da87b448e881159195 (diff)
downloadsdl_android-dafdc05c00bb4f39fd48eacb603bd7728b832465.tar.gz
Merge branch 'develop' into feature/0268_MainMenuUpdating_Pagination
-rw-r--r--android/sdl_android/src/androidTest/assets/json/SubtleAlert.json57
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lifecycle/SystemCapabilityManagerTests.java7
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/ImageFieldNameTests.java3
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/TextFieldNameTests.java3
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SubtleAlertTests.java202
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SubtleAlertResponseTests.java106
-rw-r--r--base/src/main/java/com/smartdevicelink/protocol/enums/FunctionID.java2
-rw-r--r--base/src/main/java/com/smartdevicelink/proxy/rpc/CancelInteraction.java8
-rw-r--r--base/src/main/java/com/smartdevicelink/proxy/rpc/OnSubtleAlertPressed.java62
-rw-r--r--base/src/main/java/com/smartdevicelink/proxy/rpc/SubtleAlert.java275
-rw-r--r--base/src/main/java/com/smartdevicelink/proxy/rpc/SubtleAlertResponse.java97
-rw-r--r--base/src/main/java/com/smartdevicelink/proxy/rpc/enums/ImageFieldName.java6
-rw-r--r--base/src/main/java/com/smartdevicelink/proxy/rpc/enums/TextFieldName.java18
13 files changed, 838 insertions, 8 deletions
diff --git a/android/sdl_android/src/androidTest/assets/json/SubtleAlert.json b/android/sdl_android/src/androidTest/assets/json/SubtleAlert.json
new file mode 100644
index 000000000..e845990c6
--- /dev/null
+++ b/android/sdl_android/src/androidTest/assets/json/SubtleAlert.json
@@ -0,0 +1,57 @@
+{
+ "request": {
+ "name": "SubtleAlert",
+ "correlationID": 444,
+ "parameters": {
+ "alertText1": "alertText1",
+ "alertText2": "alertText2",
+ "alertIcon": {
+ "value": "alertIconImage1.png",
+ "imageType": "DYNAMIC"
+ },
+ "ttsChunks": [
+ {
+ "text": "Phrase 1",
+ "type": "TEXT"
+ },
+ {
+ "text": "Phrase 2",
+ "type": "TEXT"
+ }
+ ],
+ "duration": 3000,
+ "softButtons": [
+ {
+ "isHighlighted": true,
+ "softButtonID": 6,
+ "systemAction": "STEAL_FOCUS",
+ "text": "Button 1",
+ "type": "IMAGE",
+ "image": {
+ "value": "image.png",
+ "imageType": "STATIC"
+ }
+ },
+ {
+ "isHighlighted": false,
+ "softButtonID": 3,
+ "systemAction": "DEFAULT_ACTION",
+ "text": "Button 2",
+ "type": "BOTH",
+ "image": {
+ "value": "image.png",
+ "imageType": "DYNAMIC"
+ }
+ }
+ ],
+ "cancelID": 30
+ }
+ },
+ "response": {
+ "name": "SubtleAlertResponse",
+ "correlationID": 444,
+ "parameters": {
+ "tryAgainTime": 400
+ }
+ }
+} \ No newline at end of file
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 112a8ca4f..d6ad2d669 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
@@ -1,8 +1,9 @@
package com.smartdevicelink.managers.lifecycle;
-import androidx.test.ext.junit.runners.AndroidJUnit4;
import android.util.SparseArray;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
import com.livio.taskmaster.Taskmaster;
import com.smartdevicelink.managers.ManagerUtility;
import com.smartdevicelink.protocol.enums.FunctionID;
@@ -208,8 +209,8 @@ public class SystemCapabilityManagerTests {
@Test
public void testNullDisplayCapabilitiesEnablesAllTextAndImageFields() {
List<DisplayCapability> displayCapabilityList = createDisplayCapabilityList(null, TestValues.GENERAL_BUTTONCAPABILITIES_LIST, TestValues.GENERAL_SOFTBUTTONCAPABILITIES_LIST);
- assertEquals(displayCapabilityList.get(0).getWindowCapabilities().get(0).getTextFields().size(), 29);
- assertEquals(displayCapabilityList.get(0).getWindowCapabilities().get(0).getImageFields().size(), 15);
+ assertEquals(displayCapabilityList.get(0).getWindowCapabilities().get(0).getTextFields().size(), 32);
+ assertEquals(displayCapabilityList.get(0).getWindowCapabilities().get(0).getImageFields().size(), 16);
}
@Test
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/ImageFieldNameTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/ImageFieldNameTests.java
index 805f1f862..c1b0b6cd7 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/ImageFieldNameTests.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/ImageFieldNameTests.java
@@ -10,7 +10,7 @@ import java.util.List;
/**
* This is a unit test class for the SmartDeviceLink library project class :
- * {@link com.smartdevicelink.rpc.enums.ImageFieldName}
+ * {@link com.smartdevicelink.proxy.rpc.enums.ImageFieldName}
*/
public class ImageFieldNameTests extends TestCase {
@@ -109,6 +109,7 @@ public class ImageFieldNameTests extends TestCase {
enumTestList.add(ImageFieldName.locationImage);
enumTestList.add(ImageFieldName.secondaryGraphic);
enumTestList.add(ImageFieldName.alertIcon);
+ enumTestList.add(ImageFieldName.subtleAlertIcon);
enumTestList.add(ImageFieldName.subMenuIcon);
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/TextFieldNameTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/TextFieldNameTests.java
index cb55330eb..8c8122fd8 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/TextFieldNameTests.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/TextFieldNameTests.java
@@ -175,6 +175,9 @@ public class TextFieldNameTests extends TestCase {
enumTestList.add(TextFieldName.addressLines);
enumTestList.add(TextFieldName.phoneNumber);
enumTestList.add(TextFieldName.templateTitle);
+ enumTestList.add(TextFieldName.subtleAlertText1);
+ enumTestList.add(TextFieldName.subtleAlertText2);
+ enumTestList.add(TextFieldName.subtleAlertSoftButtonText);
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/requests/SubtleAlertTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SubtleAlertTests.java
new file mode 100644
index 000000000..7c5a49534
--- /dev/null
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SubtleAlertTests.java
@@ -0,0 +1,202 @@
+/*
+ * 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.
+ *
+ * Created by Nicole Yarroch on 7/17/19 10:06 AM
+ */
+
+package com.smartdevicelink.test.rpc.requests;
+
+import com.smartdevicelink.marshal.JsonRPCMarshaller;
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCMessage;
+import com.smartdevicelink.proxy.rpc.Image;
+import com.smartdevicelink.proxy.rpc.SoftButton;
+import com.smartdevicelink.proxy.rpc.SubtleAlert;
+import com.smartdevicelink.proxy.rpc.TTSChunk;
+import com.smartdevicelink.test.BaseRpcTests;
+import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.TestValues;
+import com.smartdevicelink.test.Validator;
+import com.smartdevicelink.test.json.rpc.JsonFileReader;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+
+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.assertNull;
+import static junit.framework.TestCase.assertTrue;
+import static junit.framework.TestCase.fail;
+
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.proxy.rpc.SubtleAlert}
+ */
+public class SubtleAlertTests extends BaseRpcTests {
+
+ @Override
+ protected RPCMessage createMessage() {
+ SubtleAlert msg = new SubtleAlert();
+ msg.setAlertText1(TestValues.GENERAL_STRING);
+ msg.setAlertText2(TestValues.GENERAL_STRING);
+ msg.setAlertIcon(TestValues.GENERAL_IMAGE);
+ msg.setTtsChunks(TestValues.GENERAL_TTSCHUNK_LIST);
+ msg.setDuration(TestValues.GENERAL_INTEGER);
+ msg.setSoftButtons(TestValues.GENERAL_SOFTBUTTON_LIST);
+ msg.setCancelID(TestValues.GENERAL_INTEGER);
+ return msg;
+ }
+
+ @Override
+ protected String getMessageType(){
+ return RPCMessage.KEY_REQUEST;
+ }
+
+ @Override
+ protected String getCommandType(){
+ return FunctionID.SUBTLE_ALERT.toString();
+ }
+
+ @Override
+ protected JSONObject getExpectedParameters(int sdlVersion) {
+ JSONObject result = new JSONObject();
+
+ try {
+ result.put(SubtleAlert.KEY_ALERT_TEXT_1, TestValues.GENERAL_STRING);
+ result.put(SubtleAlert.KEY_ALERT_TEXT_2, TestValues.GENERAL_STRING);
+ result.put(SubtleAlert.KEY_ALERT_ICON, TestValues.JSON_IMAGE);
+ result.put(SubtleAlert.KEY_TTS_CHUNKS, TestValues.JSON_TTSCHUNKS);
+ result.put(SubtleAlert.KEY_DURATION, TestValues.GENERAL_INTEGER);
+ result.put(SubtleAlert.KEY_SOFT_BUTTONS, TestValues.JSON_SOFTBUTTONS);
+ result.put(SubtleAlert.KEY_CANCEL_ID, TestValues.GENERAL_INTEGER);
+ } catch (JSONException e) {
+ fail(TestValues.JSON_FAIL);
+ }
+
+ return result;
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ @Test
+ public void testRpcValues () {
+ // Test Values
+ String testAlertText1 = ((SubtleAlert) msg).getAlertText1();
+ String testAlertText2 = ((SubtleAlert) msg).getAlertText2();
+ Image testAlertIcon = ((SubtleAlert) msg).getAlertIcon();
+ List<TTSChunk> testTtsChunks = ((SubtleAlert) msg).getTtsChunks();
+ Integer testDuration = ((SubtleAlert) msg).getDuration();
+ List<SoftButton> testSoftButtons = ((SubtleAlert) msg).getSoftButtons();
+ Integer testCancelID = ((SubtleAlert) msg).getCancelID();
+
+ // Valid Tests
+ assertEquals(TestValues.MATCH, TestValues.GENERAL_STRING, testAlertText1);
+ assertEquals(TestValues.MATCH, TestValues.GENERAL_STRING, testAlertText2);
+ assertEquals(TestValues.MATCH, TestValues.GENERAL_IMAGE, testAlertIcon);
+ assertEquals(TestValues.MATCH, TestValues.GENERAL_TTSCHUNK_LIST, testTtsChunks);
+ assertEquals(TestValues.MATCH, TestValues.GENERAL_INTEGER, testDuration);
+ assertEquals(TestValues.MATCH, TestValues.GENERAL_SOFTBUTTON_LIST, testSoftButtons);
+ assertEquals(TestValues.MATCH, TestValues.GENERAL_INTEGER, testCancelID);
+
+ // Invalid/Null Tests
+ SubtleAlert msg = new SubtleAlert();
+ assertNotNull(TestValues.NOT_NULL, msg);
+ testNullBase(msg);
+
+ assertNull(TestValues.NULL, msg.getAlertText1());
+ assertNull(TestValues.NULL, msg.getAlertText2());
+ assertNull(TestValues.NULL, msg.getAlertIcon());
+ assertNull(TestValues.NULL, msg.getTtsChunks());
+ assertNull(TestValues.NULL, msg.getDuration());
+ assertNull(TestValues.NULL, msg.getSoftButtons());
+ assertNull(TestValues.NULL, msg.getCancelID());
+ }
+
+ /**
+ * Tests a valid JSON construction of this RPC message.
+ */
+ @Test
+ public void testJsonConstructor () {
+ JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType());
+ assertNotNull(TestValues.NOT_NULL, commandJson);
+
+ try {
+ Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson);
+ SubtleAlert cmd = new SubtleAlert(hash);
+ JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType());
+ assertNotNull(TestValues.NOT_NULL, body);
+
+ // Test everything in the json body.
+ assertEquals(TestValues.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName());
+ assertEquals(TestValues.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID());
+ JSONObject parameters = JsonUtils.readJsonObjectFromJsonObject(body, RPCMessage.KEY_PARAMETERS);
+
+ assertEquals(TestValues.MATCH, JsonUtils.readStringFromJsonObject(parameters, SubtleAlert.KEY_ALERT_TEXT_1), cmd.getAlertText1());
+ assertEquals(TestValues.MATCH, JsonUtils.readStringFromJsonObject(parameters, SubtleAlert.KEY_ALERT_TEXT_2), cmd.getAlertText2());
+
+ JSONObject alertIcon = JsonUtils.readJsonObjectFromJsonObject(parameters, SubtleAlert.KEY_ALERT_ICON);
+ Image referenceAlertIcon = new Image(JsonRPCMarshaller.deserializeJSONObject(alertIcon));
+ assertTrue(TestValues.TRUE, Validator.validateImage(referenceAlertIcon, cmd.getAlertIcon()));
+
+ JSONArray ttsChunkArray = JsonUtils.readJsonArrayFromJsonObject(parameters, SubtleAlert.KEY_TTS_CHUNKS);
+ List<TTSChunk> ttsChunkList = new ArrayList<TTSChunk>();
+ for (int index = 0; index < ttsChunkArray.length(); index++) {
+ TTSChunk chunk = new TTSChunk(JsonRPCMarshaller.deserializeJSONObject( (JSONObject)ttsChunkArray.get(index)) );
+ ttsChunkList.add(chunk);
+ }
+ assertTrue(TestValues.TRUE, Validator.validateTtsChunks(ttsChunkList, cmd.getTtsChunks()));
+
+ assertEquals(TestValues.MATCH, JsonUtils.readIntegerFromJsonObject(parameters, SubtleAlert.KEY_DURATION), cmd.getDuration());
+
+ JSONArray softButtonArray = JsonUtils.readJsonArrayFromJsonObject(parameters, SubtleAlert.KEY_SOFT_BUTTONS);
+ List<SoftButton> softButtonList = new ArrayList<SoftButton>();
+ for (int index = 0; index < softButtonArray.length(); index++) {
+ SoftButton chunk = new SoftButton(JsonRPCMarshaller.deserializeJSONObject( (JSONObject)softButtonArray.get(index)) );
+ softButtonList.add(chunk);
+ }
+ assertTrue(TestValues.TRUE, Validator.validateSoftButtons(softButtonList, cmd.getSoftButtons()));
+
+ assertEquals(TestValues.MATCH, JsonUtils.readIntegerFromJsonObject(parameters, SubtleAlert.KEY_CANCEL_ID), cmd.getCancelID());
+
+ }
+ catch (JSONException e) {
+ fail(TestValues.JSON_FAIL);
+ }
+ }
+}
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SubtleAlertResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SubtleAlertResponseTests.java
new file mode 100644
index 000000000..8d2e6370f
--- /dev/null
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SubtleAlertResponseTests.java
@@ -0,0 +1,106 @@
+package com.smartdevicelink.test.rpc.responses;
+
+import com.smartdevicelink.marshal.JsonRPCMarshaller;
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCMessage;
+import com.smartdevicelink.proxy.rpc.SubtleAlertResponse;
+import com.smartdevicelink.test.BaseRpcTests;
+import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.TestValues;
+import com.smartdevicelink.test.json.rpc.JsonFileReader;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.junit.Test;
+
+import java.util.Hashtable;
+
+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.assertNull;
+import static junit.framework.TestCase.fail;
+
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.proxy.rpc.SubtleAlertResponse}
+ */
+public class SubtleAlertResponseTests extends BaseRpcTests {
+
+ private static final int TRY_AGAIN_TIME = 400;
+
+ @Override
+ protected RPCMessage createMessage() {
+ SubtleAlertResponse alert = new SubtleAlertResponse();
+ alert.setTryAgainTime(TRY_AGAIN_TIME);
+ return alert;
+ }
+
+ @Override
+ protected String getMessageType() {
+ return RPCMessage.KEY_RESPONSE;
+ }
+
+ @Override
+ protected String getCommandType() {
+ return FunctionID.SUBTLE_ALERT.toString();
+ }
+
+ @Override
+ protected JSONObject getExpectedParameters(int sdlVersion) {
+ JSONObject result = new JSONObject();
+
+ try {
+ result.put(SubtleAlertResponse.KEY_TRY_AGAIN_TIME, TRY_AGAIN_TIME);
+ } catch (JSONException e) {
+ fail(TestValues.JSON_FAIL);
+ }
+
+ return result;
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ @Test
+ public void testRpcValues() {
+ // Test Values
+ int tryAgainTime = ((SubtleAlertResponse) msg).getTryAgainTime();
+
+ // Valid Tests
+ assertEquals(TestValues.MATCH, TRY_AGAIN_TIME, tryAgainTime);
+
+ // Invalid/Null Tests
+ SubtleAlertResponse msg = new SubtleAlertResponse();
+ assertNotNull(TestValues.NOT_NULL, msg);
+ testNullBase(msg);
+
+ assertNull(TestValues.NULL, msg.getTryAgainTime());
+ }
+
+ /**
+ * Tests a valid JSON construction of this RPC message.
+ */
+ @Test
+ public void testJsonConstructor() {
+ JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType());
+ assertNotNull(TestValues.NOT_NULL, commandJson);
+
+ try {
+ Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson);
+ SubtleAlertResponse cmd = new SubtleAlertResponse(hash);
+ JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType());
+ assertNotNull(TestValues.NOT_NULL, body);
+
+ // Test everything in the json body.
+ assertEquals(TestValues.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName());
+ assertEquals(TestValues.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID());
+
+ JSONObject parameters = JsonUtils.readJsonObjectFromJsonObject(body, RPCMessage.KEY_PARAMETERS);
+ assertEquals(TestValues.MATCH, JsonUtils.readIntegerFromJsonObject(parameters, SubtleAlertResponse.KEY_TRY_AGAIN_TIME), cmd.getTryAgainTime());
+
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ }
+} \ No newline at end of file
diff --git a/base/src/main/java/com/smartdevicelink/protocol/enums/FunctionID.java b/base/src/main/java/com/smartdevicelink/protocol/enums/FunctionID.java
index ddbb146c2..8848e16d9 100644
--- a/base/src/main/java/com/smartdevicelink/protocol/enums/FunctionID.java
+++ b/base/src/main/java/com/smartdevicelink/protocol/enums/FunctionID.java
@@ -110,6 +110,7 @@ public enum FunctionID{
DELETE_WINDOW(61, "DeleteWindow"),
GET_INTERIOR_VEHICLE_DATA_CONSENT(62, "GetInteriorVehicleDataConsent"),
RELEASE_INTERIOR_VEHICLE_MODULE(63, "ReleaseInteriorVehicleDataModule"),
+ SUBTLE_ALERT(64, "SubtleAlert"),
// NOTIFICATIONS
ON_HMI_STATUS(32768, "OnHMIStatus"),
ON_APP_INTERFACE_UNREGISTERED(32769, "OnAppInterfaceUnregistered"),
@@ -131,6 +132,7 @@ public enum FunctionID{
ON_RC_STATUS(32785, "OnRCStatus"),
ON_APP_SERVICE_DATA(32786, "OnAppServiceData"),
ON_SYSTEM_CAPABILITY_UPDATED(32787, "OnSystemCapabilityUpdated"),
+ ON_SUBTLE_ALERT_PRESSED(32788, "OnSubtleAlertPressed"),
ON_UPDATE_FILE(32789, "OnUpdateFile"),
ON_UPDATE_SUB_MENU(32790, "OnUpdateSubMenu"),
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 7df082734..9016458a6 100644
--- a/base/src/main/java/com/smartdevicelink/proxy/rpc/CancelInteraction.java
+++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/CancelInteraction.java
@@ -91,8 +91,8 @@ public class CancelInteraction extends RPCRequest {
// Custom Getters / Setters
/**
- * The ID of the type of interaction to dismiss.
- * Only values 10 (PerformInteractionID), 12 (AlertID), 25 (ScrollableMessageID), and 26 (SliderID) are permitted.
+ * Gets the ID of the type of interaction the developer wants to dismiss.
+ * Only values 10 (PerformInteractionID), 12 (AlertID), 25 (ScrollableMessageID), 26 (SliderID), and 64 (SubtleAlertID) are permitted.
* @return - the functionID
*/
public Integer getInteractionFunctionID() {
@@ -100,8 +100,8 @@ public class CancelInteraction extends RPCRequest {
}
/**
- * The ID of the type of interaction to dismiss.
- * Only values 10 (PerformInteractionID), 12 (AlertID), 25 (ScrollableMessageID), and 26 (SliderID) are permitted.
+ * Sets the ID of the type of interaction the developer wants to dismiss.
+ * 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) {
diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnSubtleAlertPressed.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnSubtleAlertPressed.java
new file mode 100644
index 000000000..6715cd0c6
--- /dev/null
+++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnSubtleAlertPressed.java
@@ -0,0 +1,62 @@
+/*
+ * 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.proxy.rpc;
+
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCNotification;
+
+import java.util.Hashtable;
+
+/**
+ * Sent when the alert itself is touched (outside of a soft button). Touching (or otherwise
+ * selecting) the alert should open the app before sending this notification.
+ *
+ * @since SmartDeviceLink 7.0.0
+ */
+public class OnSubtleAlertPressed extends RPCNotification {
+
+ /**
+ * Constructs a new OnSubtleAlertPressed object
+ */
+ public OnSubtleAlertPressed() {
+ super(FunctionID.ON_SUBTLE_ALERT_PRESSED.toString());
+ }
+
+ /**
+ * Constructs a new OnSubtleAlertPressed object indicated by the Hashtable parameter
+ *
+ * @param hash The Hashtable to use
+ */
+ public OnSubtleAlertPressed(Hashtable<String, Object> hash) {
+ super(hash);
+ }
+}
diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/SubtleAlert.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/SubtleAlert.java
new file mode 100644
index 000000000..42752ff8d
--- /dev/null
+++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/SubtleAlert.java
@@ -0,0 +1,275 @@
+/*
+ * 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.proxy.rpc;
+
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCRequest;
+
+import java.util.Hashtable;
+import java.util.List;
+
+/**
+ * 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.
+ *
+ * <p><b>Parameter List</b></p>
+ *
+ * <table border="1" rules="all">
+ * <tr>
+ * <th>Param Name</th>
+ * <th>Type</th>
+ * <th>Description</th>
+ * <th>Required</th>
+ * <th>Notes</th>
+ * <th>Version Available</th>
+ * </tr>
+ * <tr>
+ * <td>alertText1</td>
+ * <td>String</td>
+ * <td>The first line of the alert text field</td>
+ * <td>N</td>
+ * <td>Max Value: 500</td>
+ * <td></td>
+ * </tr>
+ * <tr>
+ * <td>alertText2</td>
+ * <td>String</td>
+ * <td>The second line of the alert text field</td>
+ * <td>N</td>
+ * <td>Max Value: 500</td>
+ * <td></td>
+ * </tr>
+ * <tr>
+ * <td>alertIcon</td>
+ * <td>Image</td>
+ * <td>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.</td>
+ * <td>N</td>
+ * <td></td>
+ * <td></td>
+ * </tr>
+ * <tr>
+ * <td>ttsChunks</td>
+ * <td>List<TTSChunk></td>
+ * <td>An array of text chunks of type TTSChunk. See TTSChunk. The array must have at least oneitem.</td>
+ * <td>N</td>
+ * <td>Min Value: 1; Max Value: 100</td>
+ * <td></td>
+ * </tr>
+ * <tr>
+ * <td>duration</td>
+ * <td>Integer</td>
+ * <td>Timeout in milliseconds. Typical timeouts are 3-5 seconds. If omitted, timeout is set to5s.</td>
+ * <td>N</td>
+ * <td>Min Value: 3000; Max Value: 10000; Default Value: 5000</td>
+ * <td></td>
+ * </tr>
+ * <tr>
+ * <td>softButtons</td>
+ * <td>List<SoftButton></td>
+ * <td>App defined SoftButtons. If omitted on supported displays, the displayed alert shall nothave any SoftButtons.</td>
+ * <td>N</td>
+ * <td>Min Value: 0; Max Value: 2</td>
+ * <td></td>
+ * </tr>
+ * <tr>
+ * <td>cancelID</td>
+ * <td>Integer</td>
+ * <td>An ID for this specific alert to allow cancellation through the `CancelInteraction` RPC.</td>
+ * <td>N</td>
+ * <td></td>
+ * <td></td>
+ * </tr>
+ * </table>
+ *
+ * @since SmartDeviceLink 7.0.0
+ */
+public class SubtleAlert extends RPCRequest {
+ public static final String KEY_ALERT_TEXT_1 = "alertText1";
+ public static final String KEY_ALERT_TEXT_2 = "alertText2";
+ public static final String KEY_ALERT_ICON = "alertIcon";
+ public static final String KEY_TTS_CHUNKS = "ttsChunks";
+ public static final String KEY_DURATION = "duration";
+ public static final String KEY_SOFT_BUTTONS = "softButtons";
+ public static final String KEY_CANCEL_ID = "cancelID";
+
+ /**
+ * Constructs a new SubtleAlert object
+ */
+ public SubtleAlert() {
+ super(FunctionID.SUBTLE_ALERT.toString());
+ }
+
+ /**
+ * Constructs a new SubtleAlert object indicated by the Hashtable parameter
+ *
+ * @param hash The Hashtable to use
+ */
+ public SubtleAlert(Hashtable<String, Object> hash) {
+ super(hash);
+ }
+
+ /**
+ * Sets the alertText1.
+ *
+ * @param alertText1 The first line of the alert text field
+ */
+ public void setAlertText1(String alertText1) {
+ setParameters(KEY_ALERT_TEXT_1, alertText1);
+ }
+
+ /**
+ * Gets the alertText1.
+ *
+ * @return String The first line of the alert text field
+ */
+ public String getAlertText1() {
+ return getString(KEY_ALERT_TEXT_1);
+ }
+
+ /**
+ * Sets the alertText2.
+ *
+ * @param alertText2 The second line of the alert text field
+ */
+ public void setAlertText2(String alertText2) {
+ setParameters(KEY_ALERT_TEXT_2, alertText2);
+ }
+
+ /**
+ * Gets the alertText2.
+ *
+ * @return String The second line of the alert text field
+ */
+ public String getAlertText2() {
+ return getString(KEY_ALERT_TEXT_2);
+ }
+
+ /**
+ * Sets the alertIcon.
+ *
+ * @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) {
+ setParameters(KEY_ALERT_ICON, alertIcon);
+ }
+
+ /**
+ * Gets the alertIcon.
+ *
+ * @return Image 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 Image getAlertIcon() {
+ return (Image) getObject(Image.class, KEY_ALERT_ICON);
+ }
+
+ /**
+ * Sets the ttsChunks.
+ *
+ * @param ttsChunks An array of text chunks of type TTSChunk. See TTSChunk. The array must have at least one
+ * item.
+ */
+ public void setTtsChunks(List<TTSChunk> ttsChunks) {
+ setParameters(KEY_TTS_CHUNKS, ttsChunks);
+ }
+
+ /**
+ * Gets the ttsChunks.
+ *
+ * @return List<TTSChunk> An array of text chunks of type TTSChunk. See TTSChunk. The array must have at least one
+ * item.
+ */
+ @SuppressWarnings("unchecked")
+ public List<TTSChunk> getTtsChunks() {
+ return (List<TTSChunk>) getObject(TTSChunk.class, KEY_TTS_CHUNKS);
+ }
+
+ /**
+ * Sets the duration.
+ *
+ * @param duration Timeout in milliseconds. Typical timeouts are 3-5 seconds. If omitted, timeout is set to
+ * 5s.
+ */
+ public void setDuration(Integer duration) {
+ setParameters(KEY_DURATION, duration);
+ }
+
+ /**
+ * Gets the duration.
+ *
+ * @return Integer Timeout in milliseconds. Typical timeouts are 3-5 seconds. If omitted, timeout is set to
+ * 5s.
+ */
+ public Integer getDuration() {
+ return getInteger(KEY_DURATION);
+ }
+
+ /**
+ * Sets the softButtons.
+ *
+ * @param softButtons App defined SoftButtons. If omitted on supported displays, the displayed alert shall not
+ * have any SoftButtons.
+ */
+ public void setSoftButtons(List<SoftButton> softButtons) {
+ setParameters(KEY_SOFT_BUTTONS, softButtons);
+ }
+
+ /**
+ * Gets the softButtons.
+ *
+ * @return List<SoftButton> App defined SoftButtons. If omitted on supported displays, the displayed alert shall not
+ * have any SoftButtons.
+ */
+ @SuppressWarnings("unchecked")
+ public List<SoftButton> getSoftButtons() {
+ return (List<SoftButton>) getObject(SoftButton.class, KEY_SOFT_BUTTONS);
+ }
+
+ /**
+ * Sets the cancelID.
+ *
+ * @param cancelID An ID for this specific alert to allow cancellation through the `CancelInteraction` RPC.
+ */
+ public void setCancelID(Integer cancelID) {
+ setParameters(KEY_CANCEL_ID, cancelID);
+ }
+
+ /**
+ * Gets the cancelID.
+ *
+ * @return Integer An ID for this specific alert to allow cancellation through the `CancelInteraction` RPC.
+ */
+ public Integer getCancelID() {
+ return getInteger(KEY_CANCEL_ID);
+ }
+}
diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/SubtleAlertResponse.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/SubtleAlertResponse.java
new file mode 100644
index 000000000..a15dbe13b
--- /dev/null
+++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/SubtleAlertResponse.java
@@ -0,0 +1,97 @@
+/*
+ * 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.proxy.rpc;
+
+import androidx.annotation.NonNull;
+
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCResponse;
+import com.smartdevicelink.proxy.rpc.enums.Result;
+
+import java.util.Hashtable;
+
+/**
+ * @since SmartDeviceLink 7.0.0
+ */
+public class SubtleAlertResponse extends RPCResponse {
+ public static final String KEY_TRY_AGAIN_TIME = "tryAgainTime";
+
+ /**
+ * Constructs a new SubtleAlertResponse object
+ */
+ public SubtleAlertResponse() {
+ super(FunctionID.SUBTLE_ALERT.toString());
+ }
+
+ /**
+ * Constructs a new SubtleAlertResponse object indicated by the Hashtable parameter
+ *
+ * @param hash The Hashtable to use
+ */
+ public SubtleAlertResponse(Hashtable<String, Object> hash) {
+ super(hash);
+ }
+
+ /**
+ * Constructs a new SubtleAlertResponse object
+ *
+ * @param success whether the request is successfully processed
+ * @param resultCode additional information about a response returning a failed outcome
+ */
+ public SubtleAlertResponse(@NonNull Boolean success, @NonNull Result resultCode) {
+ this();
+ setSuccess(success);
+ setResultCode(resultCode);
+ }
+
+ /**
+ * Sets the tryAgainTime.
+ *
+ * @param tryAgainTime Amount of time (in milliseconds) 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.
+ */
+ public void setTryAgainTime(Integer tryAgainTime) {
+ setParameters(KEY_TRY_AGAIN_TIME, tryAgainTime);
+ }
+
+ /**
+ * Gets the tryAgainTime.
+ *
+ * @return Integer Amount of time (in milliseconds) 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.
+ */
+ public Integer getTryAgainTime() {
+ return getInteger(KEY_TRY_AGAIN_TIME);
+ }
+}
diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/enums/ImageFieldName.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/enums/ImageFieldName.java
index 13f4af0d3..cb595fc9d 100644
--- a/base/src/main/java/com/smartdevicelink/proxy/rpc/enums/ImageFieldName.java
+++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/enums/ImageFieldName.java
@@ -110,6 +110,12 @@ public enum ImageFieldName {
*/
alertIcon,
/**
+ * The image of the subtle alert; applies to `SubtleAlert` `alertIcon`
+ *
+ * @since SmartDeviceLink 7.0.0
+ */
+ subtleAlertIcon,
+ /**
* The image field for AddSubMenu.menuIcon
*
* @since SmartDeviceLink 7.0.0
diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/enums/TextFieldName.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/enums/TextFieldName.java
index a8fe4bd38..cf33b73e0 100644
--- a/base/src/main/java/com/smartdevicelink/proxy/rpc/enums/TextFieldName.java
+++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/enums/TextFieldName.java
@@ -186,6 +186,24 @@ public enum TextFieldName {
* @since SmartDeviceLink 6.0
*/
templateTitle,
+ /**
+ * The first line of the subtle alert text field; applies to `SubtleAlert` `alertText1`
+ *
+ * @since SmartDeviceLink 7.0.0
+ */
+ subtleAlertText1,
+ /**
+ * The second line of the subtle alert text field; applies to `SubtleAlert` `alertText2`
+ *
+ * @since SmartDeviceLink 7.0.0
+ */
+ subtleAlertText2,
+ /**
+ * A text field in the soft button of a subtle alert; applies to `SubtleAlert` `softButtons`
+ *
+ * @since SmartDeviceLink 7.0.0
+ */
+ subtleAlertSoftButtonText;
;
/**
* Convert String to TextFieldName