diff options
author | Bilal Alsharifi <bilal.alsharifi@gmail.com> | 2020-08-17 16:35:42 -0400 |
---|---|---|
committer | Bilal Alsharifi <bilal.alsharifi@gmail.com> | 2020-08-17 16:35:42 -0400 |
commit | 4081edfd518e0f3903af1edd5f74c8a5de2d50d3 (patch) | |
tree | 53b0f3473be0af4690d66b508aa4116c24cb7596 | |
parent | d9aac82aa1a8626c32bd3cd09df49b0b878e8d66 (diff) | |
parent | c92ff5dbd99ff663c4a81ab95868bc8967ee7842 (diff) | |
download | sdl_android-4081edfd518e0f3903af1edd5f74c8a5de2d50d3.tar.gz |
Merge branch 'develop' into feature/issue_1446_remove_deprecated_rpcsfeature/issue_1446_remove_deprecated_rpcs
# Conflicts:
# base/src/main/java/com/smartdevicelink/protocol/enums/FunctionID.java
23 files changed, 783 insertions, 25 deletions
@@ -66,7 +66,7 @@ Developers using Proguard to shrink and obfuscate their code should be sure to i ### JavaSE -[ ![Download JavaSE](https://api.bintray.com/packages/smartdevicelink/sdl_java_se/sdl_java_se/images/download.svg) ](https://bintray.com/smartdevicelink/sdl_java_se/sdl_java_se/_latestVersion) +[ ![Download JavaSE](https://api.bintray.com/packages/smartdevicelink/sdl_java_se/sdl_javase/images/download.svg) ](https://bintray.com/smartdevicelink/sdl_java_se/sdl_javase/_latestVersion) The JavaSE project is meant to allow SDL compatibility for embedded applications. @@ -85,7 +85,7 @@ dependencies { ### JavaEE -[ ![Download JavaEE](https://api.bintray.com/packages/smartdevicelink/sdl_java_ee/sdl_java_ee/images/download.svg) ](https://bintray.com/smartdevicelink/sdl_java_ee/sdl_java_ee/_latestVersion) +[ ![Download JavaEE](https://api.bintray.com/packages/smartdevicelink/sdl_java_ee/sdl_javaee/images/download.svg) ](https://bintray.com/smartdevicelink/sdl_java_ee/sdl_javaee/_latestVersion) The JavaEE project is meant to allow SDL compatibility for web applications. diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/file/filetypes/SdlFileTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/file/filetypes/SdlFileTests.java index 86f328e8a..99d34fdff 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/file/filetypes/SdlFileTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/file/filetypes/SdlFileTests.java @@ -40,6 +40,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import static junit.framework.TestCase.assertEquals; +import static junit.framework.TestCase.assertFalse; @RunWith(AndroidJUnit4.class) public class SdlFileTests { @@ -60,6 +61,7 @@ public class SdlFileTests { assertEquals(sdlFile.getType(), TestValues.GENERAL_FILETYPE); sdlFile.setPersistent(TestValues.GENERAL_BOOLEAN); assertEquals(sdlFile.isPersistent(), TestValues.GENERAL_BOOLEAN); + assertFalse(sdlFile.getOverwrite()); // Case 2 (Setting resourceId) sdlFile = new SdlFile(); @@ -73,6 +75,7 @@ public class SdlFileTests { assertEquals(sdlFile.getType(), TestValues.GENERAL_FILETYPE); sdlFile.setPersistent(TestValues.GENERAL_BOOLEAN); assertEquals(sdlFile.isPersistent(), TestValues.GENERAL_BOOLEAN); + assertFalse(sdlFile.getOverwrite()); // Case 3 (Setting URI) sdlFile = new SdlFile(); @@ -86,6 +89,7 @@ public class SdlFileTests { assertEquals(sdlFile.getType(), TestValues.GENERAL_FILETYPE); sdlFile.setPersistent(TestValues.GENERAL_BOOLEAN); assertEquals(sdlFile.isPersistent(), TestValues.GENERAL_BOOLEAN); + assertFalse(sdlFile.getOverwrite()); } @Test @@ -96,6 +100,7 @@ public class SdlFileTests { assertEquals(sdlFile1.getType(), TestValues.GENERAL_FILETYPE); assertEquals((Integer) sdlFile1.getResourceId(), TestValues.GENERAL_INTEGER); assertEquals(sdlFile1.isPersistent(), TestValues.GENERAL_BOOLEAN); + assertFalse(sdlFile1.getOverwrite()); // Case2 (Let the library generate a name) SdlFile sdlFile2 = new SdlFile(null, TestValues.GENERAL_FILETYPE, TestValues.GENERAL_INTEGER, TestValues.GENERAL_BOOLEAN); @@ -105,6 +110,7 @@ public class SdlFileTests { assertEquals(sdlFile2.getType(), TestValues.GENERAL_FILETYPE); assertEquals((Integer) sdlFile2.getResourceId(), TestValues.GENERAL_INTEGER); assertEquals(sdlFile2.isPersistent(), TestValues.GENERAL_BOOLEAN); + assertFalse(sdlFile2.getOverwrite()); } @Test @@ -115,6 +121,7 @@ public class SdlFileTests { assertEquals(sdlFile1.getType(), TestValues.GENERAL_FILETYPE); assertEquals(sdlFile1.getFileData(), TestValues.GENERAL_BYTE_ARRAY); assertEquals(sdlFile1.isPersistent(), TestValues.GENERAL_BOOLEAN); + assertFalse(sdlFile1.getOverwrite()); // Case2 (Let the library generate a name) SdlFile sdlFile2 = new SdlFile(null, TestValues.GENERAL_FILETYPE, TestValues.GENERAL_BYTE_ARRAY, TestValues.GENERAL_BOOLEAN); @@ -124,6 +131,7 @@ public class SdlFileTests { assertEquals(sdlFile2.getType(), TestValues.GENERAL_FILETYPE); assertEquals(sdlFile2.getFileData(), TestValues.GENERAL_BYTE_ARRAY); assertEquals(sdlFile2.isPersistent(), TestValues.GENERAL_BOOLEAN); + assertFalse(sdlFile2.getOverwrite()); } @Test @@ -134,6 +142,7 @@ public class SdlFileTests { assertEquals(sdlFile1.getType(), TestValues.GENERAL_FILETYPE); assertEquals(sdlFile1.getUri(), TestValues.GENERAL_URI); assertEquals(sdlFile1.isPersistent(), TestValues.GENERAL_BOOLEAN); + assertFalse(sdlFile1.getOverwrite()); // Case2 (Let the library generate a name) SdlFile sdlFile2 = new SdlFile(null, TestValues.GENERAL_FILETYPE, TestValues.GENERAL_URI, TestValues.GENERAL_BOOLEAN); @@ -143,5 +152,6 @@ public class SdlFileTests { assertEquals(sdlFile2.getType(), TestValues.GENERAL_FILETYPE); assertEquals(sdlFile2.getUri(), TestValues.GENERAL_URI); assertEquals(sdlFile2.isPersistent(), TestValues.GENERAL_BOOLEAN); + assertFalse(sdlFile2.getOverwrite()); } } 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 3e8b228c5..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; @@ -209,7 +210,7 @@ public class SystemCapabilityManagerTests { 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(), 32); - assertEquals(displayCapabilityList.get(0).getWindowCapabilities().get(0).getImageFields().size(), 15); + assertEquals(displayCapabilityList.get(0).getWindowCapabilities().get(0).getImageFields().size(), 16); } @Test 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 b76fbade1..d15c1a300 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 @@ -38,6 +38,7 @@ import com.smartdevicelink.proxy.rpc.DeviceInfo; import com.smartdevicelink.proxy.rpc.DisplayCapabilities; import com.smartdevicelink.proxy.rpc.DisplayCapability; import com.smartdevicelink.proxy.rpc.DriverDistractionCapability; +import com.smartdevicelink.proxy.rpc.DynamicUpdateCapabilities; import com.smartdevicelink.proxy.rpc.EqualizerSettings; import com.smartdevicelink.proxy.rpc.Grid; import com.smartdevicelink.proxy.rpc.HMICapabilities; @@ -418,6 +419,7 @@ public class TestValues { public static final AudioControlData GENERAL_AUDIOCONTROLDATA = new AudioControlData(); public static final LightControlData GENERAL_LIGHTCONTROLDATA = new LightControlData(); public static final HMISettingsControlData GENERAL_HMISETTINGSCONTROLDATA = new HMISettingsControlData(); + public static final DynamicUpdateCapabilities GENERAL_DYNAMICUPDATECAPABILITIES = new DynamicUpdateCapabilities(); public static final VehicleDataResult GENERAL_OEM_CUSTOM_VEHICLE_DATA = new VehicleDataResult(); public static final TemplateConfiguration GENERAL_TEMPLATE_CONFIGURATION = new TemplateConfiguration(); @@ -574,6 +576,7 @@ public class TestValues { public static final JSONArray JSON_IMAGE_TYPES = new JSONArray(); public static final JSONObject JSON_DISPLAYCAPABILITY = new JSONObject(); public static final JSONArray JSON_DISPLAYCAPABILITY_LIST = new JSONArray(); + public static final JSONObject JSON_DYNAMICUPDATECAPABILITIES = new JSONObject(); static { GENERAL_TOUCHEVENTCAPABILITIES.setDoublePressAvailable(GENERAL_BOOLEAN); GENERAL_TOUCHEVENTCAPABILITIES.setMultiTouchAvailable(GENERAL_BOOLEAN); @@ -626,6 +629,9 @@ public class TestValues { GENERAL_HMISETTINGSCONTROLDATA.setTemperatureUnit(GENERAL_TEMPERATUREUNIT); GENERAL_HMISETTINGSCONTROLDATA.setDisplayMode(GENERAL_DISPLAYMODE); + GENERAL_DYNAMICUPDATECAPABILITIES.setSupportsDynamicSubMenus(GENERAL_BOOLEAN); + GENERAL_DYNAMICUPDATECAPABILITIES.setSupportedDynamicImageFieldNames(Collections.singletonList(GENERAL_IMAGEFIELDNAME)); + GENERAL_LIGHTCONTROLDATA.setLightState(GENERAL_LIGHTSTATE_LIST); GENERAL_STATIONIDNUMBER.setCountryCode(GENERAL_INT); @@ -1342,6 +1348,9 @@ public class TestValues { JSON_DISPLAYCAPABILITY.put(DisplayCapability.KEY_WINDOW_CAPABILITIES, JSON_WINDOW_CAPABILITIES); JSON_DISPLAYCAPABILITY_LIST.put(JSON_DISPLAYCAPABILITY); + JSON_DYNAMICUPDATECAPABILITIES.put(DynamicUpdateCapabilities.KEY_SUPPORTS_DYNAMIC_SUB_MENUS, GENERAL_BOOLEAN); + JSON_DYNAMICUPDATECAPABILITIES.put(DynamicUpdateCapabilities.KEY_SUPPORTED_DYNAMIC_IMAGE_FIELD_NAMES, JsonUtils.createJsonArray(Collections.singletonList(GENERAL_IMAGEFIELDNAME))); + JSON_TOUCHCOORD.put(TouchCoord.KEY_X, GENERAL_INT); JSON_TOUCHCOORD.put(TouchCoord.KEY_Y, GENERAL_INT); JSON_TOUCHCOORDS.put(JSON_TOUCHCOORD); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/DynamicUpdateCapabilitiesTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/DynamicUpdateCapabilitiesTests.java new file mode 100644 index 000000000..01e318e8a --- /dev/null +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/DynamicUpdateCapabilitiesTests.java @@ -0,0 +1,95 @@ +package com.smartdevicelink.test.rpc.datatypes; + +import com.smartdevicelink.proxy.rpc.DynamicUpdateCapabilities; +import com.smartdevicelink.proxy.rpc.enums.ImageFieldName; +import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.TestValues; + +import junit.framework.TestCase; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.proxy.rpc.DynamicUpdateCapabilities} + */ +public class DynamicUpdateCapabilitiesTests extends TestCase { + + private DynamicUpdateCapabilities msg; + + @Override + protected void setUp() throws Exception { + msg = new DynamicUpdateCapabilities(); + + msg.setSupportsDynamicSubMenus(TestValues.GENERAL_BOOLEAN); + msg.setSupportedDynamicImageFieldNames(Collections.singletonList(TestValues.GENERAL_IMAGEFIELDNAME)); + } + + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues() { + boolean supportDynamicSubMenu = msg.getSupportsDynamicSubMenus(); + List<ImageFieldName> imageFieldNames = msg.getSupportedDynamicImageFieldNames(); + + assertEquals(TestValues.MATCH, TestValues.GENERAL_BOOLEAN, supportDynamicSubMenu); + assertEquals(TestValues.MATCH, Collections.singletonList(TestValues.GENERAL_IMAGEFIELDNAME).size(), imageFieldNames.size()); + + for (int i = 0; i < Collections.singletonList(TestValues.GENERAL_IMAGEFIELDNAME).size(); i++) { + assertEquals(TestValues.MATCH, TestValues.GENERAL_IMAGEFIELDNAME, imageFieldNames.get(i)); + } + + DynamicUpdateCapabilities msg = new DynamicUpdateCapabilities(); + assertNotNull(TestValues.NOT_NULL, msg); + + assertNull(TestValues.NULL, msg.getSupportsDynamicSubMenus()); + assertNull(TestValues.NULL, msg.getSupportedDynamicImageFieldNames()); + } + + public void testJson() { + JSONObject reference = new JSONObject(); + + try { + reference.put(DynamicUpdateCapabilities.KEY_SUPPORTS_DYNAMIC_SUB_MENUS, TestValues.GENERAL_BOOLEAN); + reference.put(DynamicUpdateCapabilities.KEY_SUPPORTED_DYNAMIC_IMAGE_FIELD_NAMES, JsonUtils.createJsonArray(Collections.singletonList(TestValues.GENERAL_IMAGEFIELDNAME))); + + JSONObject underTest = msg.serializeJSON(); + assertEquals(TestValues.MATCH, reference.length(), underTest.length()); + + Iterator<?> iterator = reference.keys(); + while (iterator.hasNext()) { + String key = (String) iterator.next(); + + if (key.equals(DynamicUpdateCapabilities.KEY_SUPPORTED_DYNAMIC_IMAGE_FIELD_NAMES)) { + JSONArray referenceArray = JsonUtils.readJsonArrayFromJsonObject(reference, key); + JSONArray underTestArray = JsonUtils.readJsonArrayFromJsonObject(underTest, key); + List<ImageFieldName> imageFieldNameListReference = new ArrayList<>(); + List<ImageFieldName> imageFieldNameListTest = new ArrayList<>(); + + assertEquals(TestValues.MATCH, referenceArray.length(), underTestArray.length()); + + for (int i = 0; i < referenceArray.length(); i++) { + imageFieldNameListReference.add( (ImageFieldName) referenceArray.get(i)); + imageFieldNameListTest.add( (ImageFieldName) underTestArray.get(i)); + } + assertTrue(TestValues.TRUE, imageFieldNameListReference.containsAll(imageFieldNameListTest) && imageFieldNameListTest.containsAll(imageFieldNameListReference)); + } else if (key.equals(DynamicUpdateCapabilities.KEY_SUPPORTS_DYNAMIC_SUB_MENUS)) { + boolean referenceBool = JsonUtils.readBooleanFromJsonObject(reference, key); + boolean underTestBool = JsonUtils.readBooleanFromJsonObject(underTest, key); + assertEquals(TestValues.MATCH, referenceBool, underTestBool); + } else { + assertEquals(TestValues.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key)); + } + } + } catch (JSONException e) { + fail(TestValues.JSON_FAIL); + } + } +} diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/WindowCapabilityTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/WindowCapabilityTests.java index 62f2e4337..6ddee819b 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/WindowCapabilityTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/WindowCapabilityTests.java @@ -2,10 +2,12 @@ package com.smartdevicelink.test.rpc.datatypes; import com.smartdevicelink.marshal.JsonRPCMarshaller; import com.smartdevicelink.proxy.rpc.ButtonCapabilities; +import com.smartdevicelink.proxy.rpc.DynamicUpdateCapabilities; import com.smartdevicelink.proxy.rpc.ImageField; import com.smartdevicelink.proxy.rpc.SoftButtonCapabilities; import com.smartdevicelink.proxy.rpc.TextField; import com.smartdevicelink.proxy.rpc.WindowCapability; +import com.smartdevicelink.proxy.rpc.enums.ImageFieldName; import com.smartdevicelink.proxy.rpc.enums.ImageType; import com.smartdevicelink.proxy.rpc.enums.MenuLayout; import com.smartdevicelink.test.JsonUtils; @@ -43,6 +45,7 @@ public class WindowCapabilityTests extends TestCase { msg.setButtonCapabilities(TestValues.GENERAL_BUTTONCAPABILITIES_LIST); msg.setSoftButtonCapabilities(TestValues.GENERAL_SOFTBUTTONCAPABILITIES_LIST); msg.setMenuLayoutsAvailable(TestValues.GENERAL_MENU_LAYOUT_LIST); + msg.setDynamicUpdateCapabilities(TestValues.GENERAL_DYNAMICUPDATECAPABILITIES); } /** @@ -59,6 +62,7 @@ public class WindowCapabilityTests extends TestCase { List<ButtonCapabilities> buttonCapabilities = msg.getButtonCapabilities(); List<SoftButtonCapabilities> softButtonCapabilities = msg.getSoftButtonCapabilities(); List<MenuLayout> menuLayouts = msg.getMenuLayoutsAvailable(); + DynamicUpdateCapabilities dynamicUpdateCapabilities = msg.getDynamicUpdateCapabilities(); // Valid Tests assertEquals(TestValues.MATCH, TestValues.GENERAL_INT, windowID); @@ -70,6 +74,7 @@ public class WindowCapabilityTests extends TestCase { assertEquals(TestValues.MATCH, TestValues.GENERAL_BUTTONCAPABILITIES_LIST.size(), buttonCapabilities.size()); assertEquals(TestValues.MATCH, TestValues.GENERAL_SOFTBUTTONCAPABILITIES_LIST.size(), softButtonCapabilities.size()); assertEquals(TestValues.MATCH, TestValues.GENERAL_MENU_LAYOUT_LIST.size(), menuLayouts.size()); + assertEquals(TestValues.MATCH, TestValues.GENERAL_DYNAMICUPDATECAPABILITIES, dynamicUpdateCapabilities); for (int i = 0; i < TestValues.GENERAL_TEXTFIELD_LIST.size(); i++) { assertTrue(TestValues.TRUE, Validator.validateTextFields(TestValues.GENERAL_TEXTFIELD_LIST.get(i), textFields.get(i))); @@ -107,6 +112,7 @@ public class WindowCapabilityTests extends TestCase { assertNull(TestValues.NULL, msg.getButtonCapabilities()); assertNull(TestValues.NULL, msg.getSoftButtonCapabilities()); assertNull(TestValues.NULL, msg.getMenuLayoutsAvailable()); + assertNull(TestValues.NULL, msg.getDynamicUpdateCapabilities()); } public void testJson() { @@ -122,6 +128,7 @@ public class WindowCapabilityTests extends TestCase { reference.put(WindowCapability.KEY_BUTTON_CAPABILITIES, TestValues.JSON_BUTTONCAPABILITIES); reference.put(WindowCapability.KEY_SOFT_BUTTON_CAPABILITIES, TestValues.JSON_SOFTBUTTONCAPABILITIES); reference.put(WindowCapability.KEY_MENU_LAYOUTS_AVAILABLE, JsonUtils.createJsonArray(TestValues.GENERAL_MENU_LAYOUT_LIST)); + reference.put(WindowCapability.KEY_DYNAMIC_UPDATE_CAPABILITIES, TestValues.JSON_DYNAMICUPDATECAPABILITIES); JSONObject underTest = msg.serializeJSON(); assertEquals(TestValues.MATCH, reference.length(), underTest.length()); @@ -191,6 +198,22 @@ public class WindowCapabilityTests extends TestCase { for (int i = 0; i < referenceList.size(); i++) { assertEquals(TestValues.MATCH, referenceList.get(i), underTestList.get(i)); } + } else if (key.equals(WindowCapability.KEY_DYNAMIC_UPDATE_CAPABILITIES)) { + JSONArray referenceArray = JsonUtils.readJsonArrayFromJsonObject(reference.getJSONObject(key), DynamicUpdateCapabilities.KEY_SUPPORTED_DYNAMIC_IMAGE_FIELD_NAMES); + JSONArray underTestArray = JsonUtils.readJsonArrayFromJsonObject(underTest.getJSONObject(key), DynamicUpdateCapabilities.KEY_SUPPORTED_DYNAMIC_IMAGE_FIELD_NAMES); + List<ImageFieldName> imageFieldNameListReference = new ArrayList<>(); + List<ImageFieldName> imageFieldNameListTest = new ArrayList<>(); + boolean referenceBool = JsonUtils.readBooleanFromJsonObject(reference.getJSONObject(key), DynamicUpdateCapabilities.KEY_SUPPORTS_DYNAMIC_SUB_MENUS); + boolean underTestBool = JsonUtils.readBooleanFromJsonObject(underTest.getJSONObject(key), DynamicUpdateCapabilities.KEY_SUPPORTS_DYNAMIC_SUB_MENUS); + + assertEquals(TestValues.MATCH, referenceBool, underTestBool); + assertEquals(TestValues.MATCH, referenceArray.length(), underTestArray.length()); + + for (int i = 0; i < referenceArray.length(); i++) { + imageFieldNameListReference.add( (ImageFieldName) referenceArray.get(i)); + imageFieldNameListTest.add( (ImageFieldName) underTestArray.get(i)); + } + assertTrue(TestValues.TRUE, imageFieldNameListReference.containsAll(imageFieldNameListTest) && imageFieldNameListTest.containsAll(imageFieldNameListReference)); } else { assertEquals(TestValues.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key)); } 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 4d7563aba..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 @@ -110,6 +110,7 @@ public class ImageFieldNameTests extends TestCase { enumTestList.add(ImageFieldName.secondaryGraphic); enumTestList.add(ImageFieldName.alertIcon); enumTestList.add(ImageFieldName.subtleAlertIcon); + enumTestList.add(ImageFieldName.subMenuIcon); assertTrue("Enum value list does not match enum class list", diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnUpdateFileTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnUpdateFileTest.java new file mode 100644 index 000000000..03dc524a1 --- /dev/null +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnUpdateFileTest.java @@ -0,0 +1,73 @@ +package com.smartdevicelink.test.rpc.notifications; + +import com.smartdevicelink.protocol.enums.FunctionID; +import com.smartdevicelink.proxy.RPCMessage; +import com.smartdevicelink.proxy.rpc.OnUpdateFile; +import com.smartdevicelink.test.BaseRpcTests; +import com.smartdevicelink.test.TestValues; + +import org.json.JSONException; +import org.json.JSONObject; +import org.junit.Test; + +import static junit.framework.TestCase.assertNotNull; +import static junit.framework.TestCase.fail; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.proxy.rpc.OnUpdateFile} + */ +public class OnUpdateFileTest extends BaseRpcTests { + @Override + protected RPCMessage createMessage() { + OnUpdateFile msg = new OnUpdateFile(); + + msg.setFileName(TestValues.GENERAL_STRING); + + return msg; + } + + @Override + protected String getMessageType() { + return RPCMessage.KEY_NOTIFICATION; + } + + @Override + protected String getCommandType() { + return FunctionID.ON_UPDATE_FILE.toString(); + } + + @Override + protected JSONObject getExpectedParameters(int sdlVersion) { + JSONObject result = new JSONObject(); + + try{ + result.put(OnUpdateFile.KEY_FILE_NAME, TestValues.GENERAL_STRING); + }catch(JSONException e){ + fail(TestValues.JSON_FAIL); + } + + return result; + } + + /** + * Tests the expected values of the RPC message. + */ + @Test + public void testRpcValues () { + // Test Values + String fileName = ( (OnUpdateFile) msg).getFileName(); + + // Valid Tests + assertEquals(TestValues.MATCH, TestValues.GENERAL_STRING, fileName); + + // Invalid/Null Tests + OnUpdateFile msg = new OnUpdateFile(); + assertNotNull(TestValues.NOT_NULL, msg); + testNullBase(msg); + + assertNull(TestValues.NULL, msg.getFileName()); + } +} diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnUpdateSubMenuTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnUpdateSubMenuTest.java new file mode 100644 index 000000000..afcaf1310 --- /dev/null +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnUpdateSubMenuTest.java @@ -0,0 +1,78 @@ +package com.smartdevicelink.test.rpc.notifications; + +import com.smartdevicelink.protocol.enums.FunctionID; +import com.smartdevicelink.proxy.RPCMessage; +import com.smartdevicelink.proxy.rpc.OnUpdateSubMenu; +import com.smartdevicelink.test.BaseRpcTests; +import com.smartdevicelink.test.TestValues; + +import org.json.JSONException; +import org.json.JSONObject; +import org.junit.Test; + +import static junit.framework.TestCase.assertNotNull; +import static junit.framework.TestCase.fail; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.proxy.rpc.OnUpdateSubMenu} + */ +public class OnUpdateSubMenuTest extends BaseRpcTests { + @Override + protected RPCMessage createMessage() { + OnUpdateSubMenu msg = new OnUpdateSubMenu(); + + msg.setMenuID(TestValues.GENERAL_INT); + msg.setUpdateSubCells(TestValues.GENERAL_BOOLEAN); + + return msg; + } + + @Override + protected String getMessageType() { + return RPCMessage.KEY_NOTIFICATION; + } + + @Override + protected String getCommandType() { + return FunctionID.ON_UPDATE_SUB_MENU.toString(); + } + + @Override + protected JSONObject getExpectedParameters(int sdlVersion) { + JSONObject result = new JSONObject(); + + try{ + result.put(OnUpdateSubMenu.KEY_MENU_ID, TestValues.GENERAL_INT); + result.put(OnUpdateSubMenu.KEY_UPDATE_SUB_CELLS, TestValues.GENERAL_BOOLEAN); + }catch(JSONException e){ + fail(TestValues.JSON_FAIL); + } + + return result; + } + + /** + * Tests the expected values of the RPC message. + */ + @Test + public void testRpcValues () { + // Test Values + int menuId = ( (OnUpdateSubMenu) msg ).getMenuID(); + boolean updateSubCells = ( (OnUpdateSubMenu) msg ).getUpdateSubCells(); + + // Valid Tests + assertEquals(TestValues.MATCH, TestValues.GENERAL_INT, menuId); + assertEquals(TestValues.MATCH, TestValues.GENERAL_BOOLEAN, updateSubCells); + + // Invalid/Null Tests + OnUpdateSubMenu msg = new OnUpdateSubMenu(); + assertNotNull(TestValues.NOT_NULL, msg); + testNullBase(msg); + + assertNull(TestValues.NULL, msg.getMenuID()); + assertNull(TestValues.NULL, msg.getUpdateSubCells()); + } +} diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlFile.java b/android/sdl_android/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlFile.java index ac8942dcb..4fe5e3898 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlFile.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlFile.java @@ -53,8 +53,8 @@ public class SdlFile{ 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; + // Overwrite property by default is set to false in SdlFile constructors indicating that a file will not be overwritten + private boolean overwrite = false; /** * Creates a new instance of SdlFile @@ -248,7 +248,7 @@ public class SdlFile{ } /** - * Gets the overwrite property for an SdlFile by default its set to true + * Gets the overwrite property for an SdlFile by default its set to false * @return a boolean value that indicates if a file can be overwritten. */ public boolean getOverwrite() { @@ -256,7 +256,7 @@ public class SdlFile{ } /** - * Sets the overwrite property for an SdlFile by default its set to true + * Sets the overwrite property for an SdlFile by default its set to false * @param overwrite a boolean value that indicates if a file can be overwritten */ public void setOverwrite(boolean overwrite) { 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 cba2cb7ad..b9471209c 100644 --- a/base/src/main/java/com/smartdevicelink/protocol/enums/FunctionID.java +++ b/base/src/main/java/com/smartdevicelink/protocol/enums/FunctionID.java @@ -133,6 +133,8 @@ public enum FunctionID{ 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"),
;
public static final int INVALID_ID = -1;
diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/DynamicUpdateCapabilities.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/DynamicUpdateCapabilities.java new file mode 100644 index 000000000..f8b16ce29 --- /dev/null +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/DynamicUpdateCapabilities.java @@ -0,0 +1,137 @@ +/* + * 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.ImageFieldName; + +import java.util.Hashtable; +import java.util.List; + +/** + * + * <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>Version Available</th> + * </tr> + * <tr> + * <td>supportedDynamicImageFieldNames</td> + * <td>List<ImageFieldName></td> + * <td>An array of ImageFieldName values for which the system supports sending OnFileUpdatenotifications. If you send an Image struct for that image field with a name without havinguploaded the image data using PutFile that matches that name, the system will request thatyou upload the data with PutFile at a later point when the HMI needs it. The HMI will thendisplay the image in the appropriate field. If not sent, assume false.</td> + * <td>N</td> + * <td></td> + * </tr> + * <tr> + * <td>supportsDynamicSubMenus</td> + * <td>Boolean</td> + * <td>If true, the head unit supports dynamic sub-menus by sending OnUpdateSubMenunotifications. If true, you should not send AddCommands that attach to a parentID for anAddSubMenu until OnUpdateSubMenu is received with the menuID. At that point, you shouldsend all AddCommands with a parentID that match the menuID. If not set, assume false.</td> + * <td>N</td> + * <td></td> + * </tr> + * </table> + * @since SmartDeviceLink 7.0.0 + */ +public class DynamicUpdateCapabilities extends RPCStruct { + public static final String KEY_SUPPORTED_DYNAMIC_IMAGE_FIELD_NAMES = "supportedDynamicImageFieldNames"; + public static final String KEY_SUPPORTS_DYNAMIC_SUB_MENUS = "supportsDynamicSubMenus"; + + /** + * Constructs a new DynamicUpdateCapabilities object + */ + public DynamicUpdateCapabilities() { } + + /** + * Constructs a new DynamicUpdateCapabilities object indicated by the Hashtable parameter + * + * @param hash The Hashtable to use + */ + public DynamicUpdateCapabilities(Hashtable<String, Object> hash) { + super(hash); + } + + /** + * Sets the supportedDynamicImageFieldNames. + * + * @param supportedDynamicImageFieldNames An array of ImageFieldName values for which the system supports sending OnFileUpdate + * notifications. If you send an Image struct for that image field with a name without having + * uploaded the image data using PutFile that matches that name, the system will request that + * 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<ImageFieldName> supportedDynamicImageFieldNames) { + setValue(KEY_SUPPORTED_DYNAMIC_IMAGE_FIELD_NAMES, supportedDynamicImageFieldNames); + } + + /** + * Gets the supportedDynamicImageFieldNames. + * + * @return List<ImageFieldName> An array of ImageFieldName values for which the system supports sending OnFileUpdate + * notifications. If you send an Image struct for that image field with a name without having + * uploaded the image data using PutFile that matches that name, the system will request that + * 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. + */ + @SuppressWarnings("unchecked") + public List<ImageFieldName> getSupportedDynamicImageFieldNames() { + return (List<ImageFieldName>) getObject(ImageFieldName.class, KEY_SUPPORTED_DYNAMIC_IMAGE_FIELD_NAMES); + } + + /** + * Sets the supportsDynamicSubMenus. + * + * @param supportsDynamicSubMenus If true, the head unit supports dynamic sub-menus by sending OnUpdateSubMenu + * notifications. If true, you should not send AddCommands that attach to a parentID for an + * 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) { + setValue(KEY_SUPPORTS_DYNAMIC_SUB_MENUS, supportsDynamicSubMenus); + } + + /** + * Gets the supportsDynamicSubMenus. + * + * @return Boolean If true, the head unit supports dynamic sub-menus by sending OnUpdateSubMenu + * notifications. If true, you should not send AddCommands that attach to a parentID for an + * 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 Boolean getSupportsDynamicSubMenus() { + return getBoolean(KEY_SUPPORTS_DYNAMIC_SUB_MENUS); + } +} diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnUpdateFile.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnUpdateFile.java new file mode 100644 index 000000000..2f1c63cf8 --- /dev/null +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnUpdateFile.java @@ -0,0 +1,111 @@ +/* + * 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 androidx.annotation.NonNull; + +import com.smartdevicelink.protocol.enums.FunctionID; +import com.smartdevicelink.proxy.RPCNotification; + +import java.util.Hashtable; + +/** + * This notification tells an app to upload and update a file with a given name. + * + * <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>Version Available</th> + * </tr> + * <tr> + * <td>fileName</td> + * <td>String</td> + * <td>File reference name.</td> + * <td>Y</td> + * <td></td> + * </tr> + * </table> + * + * @since SmartDeviceLink 7.0.0 + */ +public class OnUpdateFile extends RPCNotification { + public static final String KEY_FILE_NAME = "fileName"; + + /** + * Constructs a new OnUpdateFile object + */ + public OnUpdateFile() { + super(FunctionID.ON_UPDATE_FILE.toString()); + } + + /** + * Constructs a new OnUpdateFile object indicated by the Hashtable parameter + * + * @param hash The Hashtable to use + */ + public OnUpdateFile(Hashtable<String, Object> hash) { + super(hash); + } + + /** + * Constructs a new OnUpdateFile object + * + * @param fileName File reference name. + */ + public OnUpdateFile(@NonNull String fileName) { + this(); + setFileName(fileName); + } + + /** + * Sets the fileName. + * + * @param fileName File reference name. + */ + public void setFileName(@NonNull String fileName) { + setParameters(KEY_FILE_NAME, fileName); + } + + /** + * Gets the fileName. + * + * @return String File reference name. + */ + public String getFileName() { + return getString(KEY_FILE_NAME); + } +} diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnUpdateSubMenu.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnUpdateSubMenu.java new file mode 100644 index 000000000..e6fb05829 --- /dev/null +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnUpdateSubMenu.java @@ -0,0 +1,142 @@ +/* + * 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 androidx.annotation.NonNull; + +import com.smartdevicelink.protocol.enums.FunctionID; +import com.smartdevicelink.proxy.RPCNotification; + +import java.util.Hashtable; + +/** + * This notification tells an app to update the AddSubMenu or its 'sub' AddCommand and + * AddSubMenus with the requested data + * + * <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>Version Available</th> + * </tr> + * <tr> + * <td>menuID</td> + * <td>Integer</td> + * <td>This menuID must match a menuID in the current menu structure</td> + * <td>Y</td> + * <td></td> + * </tr> + * <tr> + * <td>updateSubCells</td> + * <td>Boolean</td> + * <td>If not set, assume false. If true, the app should send AddCommands with parentIDs matchingthe menuID. These AddCommands will then be attached to the submenu and displayed if thesubmenu is selected.</td> + * <td>N</td> + * <td></td> + * </tr> + * </table> + * + * @since SmartDeviceLink 7.0.0 + */ +public class OnUpdateSubMenu extends RPCNotification { + public static final String KEY_MENU_ID = "menuID"; + public static final String KEY_UPDATE_SUB_CELLS = "updateSubCells"; + + /** + * Constructs a new OnUpdateSubMenu object + */ + public OnUpdateSubMenu() { + super(FunctionID.ON_UPDATE_SUB_MENU.toString()); + } + + /** + * Constructs a new OnUpdateSubMenu object indicated by the Hashtable parameter + * + * @param hash The Hashtable to use + */ + public OnUpdateSubMenu(Hashtable<String, Object> hash) { + super(hash); + } + + /** + * Constructs a new OnUpdateSubMenu object + * + * @param menuID This menuID must match a menuID in the current menu structure + */ + public OnUpdateSubMenu(@NonNull Integer menuID) { + this(); + setMenuID(menuID); + } + + /** + * Sets the menuID. + * + * @param menuID This menuID must match a menuID in the current menu structure + */ + public void setMenuID(@NonNull Integer menuID) { + setParameters(KEY_MENU_ID, menuID); + } + + /** + * Gets the menuID. + * + * @return Integer This menuID must match a menuID in the current menu structure + */ + public Integer getMenuID() { + return getInteger(KEY_MENU_ID); + } + + /** + * Sets the updateSubCells. + * + * @param updateSubCells If not set, assume false. If true, the app should send AddCommands with parentIDs matching + * the menuID. These AddCommands will then be attached to the submenu and displayed if the + * submenu is selected. + */ + public void setUpdateSubCells(Boolean updateSubCells) { + setParameters(KEY_UPDATE_SUB_CELLS, updateSubCells); + } + + /** + * Gets the updateSubCells. + * + * @return Boolean If not set, assume false. If true, the app should send AddCommands with parentIDs matching + * the menuID. These AddCommands will then be attached to the submenu and displayed if the + * submenu is selected. + */ + public Boolean getUpdateSubCells() { + return getBoolean(KEY_UPDATE_SUB_CELLS); + } +} 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 6974c82db..c93cb50ca 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/WindowCapability.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/WindowCapability.java @@ -20,6 +20,7 @@ public class WindowCapability extends RPCStruct { public static final String KEY_BUTTON_CAPABILITIES = "buttonCapabilities"; public static final String KEY_SOFT_BUTTON_CAPABILITIES = "softButtonCapabilities"; public static final String KEY_MENU_LAYOUTS_AVAILABLE = "menuLayoutsAvailable"; + public static final String KEY_DYNAMIC_UPDATE_CAPABILITIES = "dynamicUpdateCapabilities"; public WindowCapability() { } @@ -205,4 +206,26 @@ public class WindowCapability extends RPCStruct { public List<MenuLayout> getMenuLayoutsAvailable() { return (List<MenuLayout>) getObject(MenuLayout.class, KEY_MENU_LAYOUTS_AVAILABLE); } + + /** + * Sets the dynamicUpdateCapabilities. + * + * @param dynamicUpdateCapabilities Contains the head unit's capabilities for dynamic updating features declaring if the + * module will send dynamic update RPCs. + * @since SmartDeviceLink 7.0.0 + */ + public void setDynamicUpdateCapabilities(DynamicUpdateCapabilities dynamicUpdateCapabilities) { + setValue(KEY_DYNAMIC_UPDATE_CAPABILITIES, dynamicUpdateCapabilities); + } + + /** + * Gets the dynamicUpdateCapabilities. + * + * @return DynamicUpdateCapabilities Contains the head unit's capabilities for dynamic updating features declaring if the + * module will send dynamic update RPCs. + * @since SmartDeviceLink 7.0.0 + */ + public DynamicUpdateCapabilities getDynamicUpdateCapabilities() { + return (DynamicUpdateCapabilities) getObject(DynamicUpdateCapabilities.class, KEY_DYNAMIC_UPDATE_CAPABILITIES); + } } 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 cc5572ef2..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 @@ -114,7 +114,13 @@ public enum ImageFieldName { *
* @since SmartDeviceLink 7.0.0
*/
- subtleAlertIcon
+ subtleAlertIcon,
+ /**
+ * The image field for AddSubMenu.menuIcon
+ *
+ * @since SmartDeviceLink 7.0.0
+ */
+ subMenuIcon
;
/**
diff --git a/generator/README.md b/generator/README.md index ae3934d18..d87ec0a17 100644 --- a/generator/README.md +++ b/generator/README.md @@ -430,7 +430,7 @@ Where `[name]` is the value from the `"name"` attribute of `<struct>`. ### Constructor with all required parameters, based on `"mandatory"` attribute of the `<param>` This constructor requires the import of `NonNull` annotation ```java -import android.support.annotation.NonNull; +import androidx.annotation.NonNull; ``` The constructor should include all set of `<param>` with the `"mandatory"` attribute is "true". JavaDoc should include all constructor parameters and the constructor should call all corresponding setters inside itself. @@ -590,7 +590,7 @@ Output (javadoc comments skipped): ```java package com.smartdevicelink.proxy.rpc; -import android.support.annotation.NonNull; +import androidx.annotation.NonNull; import com.smartdevicelink.proxy.RPCStruct; import com.smartdevicelink.proxy.rpc.enums.TemperatureUnit; @@ -768,7 +768,7 @@ Where `[name]` is the value from the `"name"` attribute of `<function>`. ### Constructor with all required parameters, based on `"mandatory"` attribute of the `<param>` This constructor requires the import of `NonNull` annotation ```java -import android.support.annotation.NonNull; +import androidx.annotation.NonNull; ``` The constructor should include all set of `<param>` with the `"mandatory"` attribute is "true". JavaDoc should include all constructor parameters and the constructor should call all corresponding setters inside itself. @@ -997,7 +997,7 @@ Output (javadoc comments skipped): ```java package com.smartdevicelink.proxy.rpc; -import android.support.annotation.NonNull; +import androidx.annotation.NonNull; import com.smartdevicelink.protocol.enums.FunctionID; import com.smartdevicelink.proxy.RPCResponse; @@ -1039,7 +1039,7 @@ Output (javadoc comments skipped): ```java package com.smartdevicelink.proxy.rpc; -import android.support.annotation.NonNull; +import androidx.annotation.NonNull; import com.smartdevicelink.protocol.enums.FunctionID; import com.smartdevicelink.proxy.RPCNotification; diff --git a/generator/templates/base_template.java b/generator/templates/base_template.java index 0f1d58c95..2cd4f450d 100644 --- a/generator/templates/base_template.java +++ b/generator/templates/base_template.java @@ -53,6 +53,7 @@ import {{i}};{{ '\n' if loop.last }} * <th>Type</th> * <th>Description</th> * <th>Required</th> + * <th>Notes</th> * <th>Version Available</th> * </tr> {%- for param in params %} @@ -61,6 +62,7 @@ import {{i}};{{ '\n' if loop.last }} * <td>{{param.return_type}}</td> * <td>{%- for d in param.description %}{{d}}{%- endfor %}</td> * <td>{%- if param.mandatory is eq true %}Y{%- else %}N{%- endif %}</td> + * <td>{%- for k in param.values %}{{ '{' if loop.first}}"{{k}}": {{param.values[k]}}{{ ', ' if not loop.last else '}'}}{%- endfor %}</td> * <td>{%- if param.since is defined %}SmartDeviceLink {{param.since}}{%- endif %}</td> * </tr> {%- endfor %} diff --git a/generator/templates/javadoc_return.java b/generator/templates/javadoc_return.java index d2f4a3c54..e37a69b87 100644 --- a/generator/templates/javadoc_return.java +++ b/generator/templates/javadoc_return.java @@ -8,6 +8,9 @@ {%- else %} * @return {{p.return_type}} {%- endif %} + {%- if p.values is defined and p.values %} + * {%- for k in p.values %}{{ ' {' if loop.first}}"{{k}}": {{p.values[k]}}{{ ', ' if not loop.last else '}'}}{%- endfor %} + {%- endif %} {%- if p.since is defined %} * @since SmartDeviceLink {{p.since}} {%- endif %}
\ No newline at end of file diff --git a/generator/templates/javadoc_template.java b/generator/templates/javadoc_template.java index 5b5d3bc0c..93d4e7740 100644 --- a/generator/templates/javadoc_template.java +++ b/generator/templates/javadoc_template.java @@ -8,6 +8,9 @@ {%- else %} * @param {{p.last}} {%- endif %} + {%- if p.values is defined and p.values %} + * {%- for k in p.values %}{{ ' {' if loop.first}}"{{k}}": {{p.values[k]}}{{ ', ' if not loop.last else '}'}}{%- endfor %} + {%- endif %} {%- if p.since is defined %} * @since SmartDeviceLink {{p.since}} {%- endif %}
\ No newline at end of file diff --git a/generator/transformers/common_producer.py b/generator/transformers/common_producer.py index ceb4b3cec..ba8daf18e 100644 --- a/generator/transformers/common_producer.py +++ b/generator/transformers/common_producer.py @@ -5,7 +5,7 @@ Common transformation import logging import re from abc import ABC -from collections import namedtuple +from collections import namedtuple, OrderedDict from model.array import Array from model.enum import Enum @@ -79,6 +79,44 @@ class InterfaceProducerCommon(ABC): return re.sub(r'(\s{2,}|\n|\[@TODO.+)', ' ', ''.join(d)).strip() if d else '' @staticmethod + def extract_values(param): + p = OrderedDict() + if hasattr(param.param_type, 'min_size'): + p['array_min_size'] = param.param_type.min_size + if hasattr(param.param_type, 'max_size'): + p['array_max_size'] = param.param_type.max_size + if hasattr(param, 'default_value'): + if hasattr(param.default_value, 'name'): + p['default_value'] = param.default_value.name + else: + p['default_value'] = param.default_value + elif hasattr(param.param_type, 'default_value'): + if hasattr(param.param_type.default_value, 'name'): + p['default_value'] = param.param_type.default_value.name + else: + p['default_value'] = param.param_type.default_value + if hasattr(param.param_type, 'min_value'): + p['num_min_value'] = param.param_type.min_value + elif hasattr(param.param_type, 'element_type') and hasattr(param.param_type.element_type, 'min_value'): + p['num_min_value'] = param.param_type.element_type.min_value + if hasattr(param.param_type, 'max_value'): + p['num_max_value'] = param.param_type.max_value + elif hasattr(param.param_type, 'element_type') and hasattr(param.param_type.element_type, 'max_value'): + p['num_max_value'] = param.param_type.element_type.max_value + if hasattr(param.param_type, 'min_length'): + p['string_min_length'] = param.param_type.min_length + elif hasattr(param.param_type, 'element_type') and hasattr(param.param_type.element_type, 'min_length'): + p['string_min_length'] = param.param_type.element_type.min_length + if hasattr(param.param_type, 'max_length'): + p['string_max_length'] = param.param_type.max_length + elif hasattr(param.param_type, 'element_type') and hasattr(param.param_type.element_type, 'max_length'): + p['string_max_length'] = param.param_type.element_type.max_length + + # Filter None values + filtered_values = {k: v for k, v in p.items() if v is not None} + return filtered_values + + @staticmethod def replace_sync(name): """ :param name: string with item name diff --git a/generator/transformers/functions_producer.py b/generator/transformers/functions_producer.py index df8ab2936..c121de557 100644 --- a/generator/transformers/functions_producer.py +++ b/generator/transformers/functions_producer.py @@ -46,7 +46,7 @@ class FunctionsProducer(InterfaceProducerCommon): if not class_name.endswith("Response"): class_name += 'Response' imports.add('com.smartdevicelink.proxy.rpc.enums.Result') - imports.add('android.support.annotation.NonNull') + imports.add('androidx.annotation.NonNull') elif item.message_type.name == 'request': extends_class = self.request_class elif item.message_type.name == 'notification': @@ -87,9 +87,9 @@ class FunctionsProducer(InterfaceProducerCommon): def sort_imports(self, imports: set): sorted_imports = [] - if 'android.support.annotation.NonNull' in imports: - sorted_imports.append('android.support.annotation.NonNull') - imports.remove('android.support.annotation.NonNull') + if 'androidx.annotation.NonNull' in imports: + sorted_imports.append('androidx.annotation.NonNull') + imports.remove('androidx.annotation.NonNull') sorted_imports.append('') sorted_imports.append('com.smartdevicelink.protocol.enums.FunctionID') imports.remove('com.smartdevicelink.protocol.enums.FunctionID') @@ -119,6 +119,7 @@ class FunctionsProducer(InterfaceProducerCommon): p['since'] = param.since p['deprecated'] = param.deprecated p['origin'] = param.origin + p['values'] = self.extract_values(param) d = self.extract_description(param.description) if param.name == 'success': d = 'whether the request is successfully processed' @@ -143,7 +144,7 @@ class FunctionsProducer(InterfaceProducerCommon): if tr in self.struct_names: imports.add('{}.{}'.format(self.structs_package, tr)) if param.is_mandatory: - imports.add('android.support.annotation.NonNull') + imports.add('androidx.annotation.NonNull') Params = namedtuple('Params', sorted(p)) return imports, Params(**p) diff --git a/generator/transformers/structs_producer.py b/generator/transformers/structs_producer.py index a1af54fe8..400e36800 100644 --- a/generator/transformers/structs_producer.py +++ b/generator/transformers/structs_producer.py @@ -76,9 +76,9 @@ class StructsProducer(InterfaceProducerCommon): def sort_imports(self, imports: set): sorted_imports = [] - if 'android.support.annotation.NonNull' in imports: - sorted_imports.append('android.support.annotation.NonNull') - imports.remove('android.support.annotation.NonNull') + if 'androidx.annotation.NonNull' in imports: + sorted_imports.append('androidx.annotation.NonNull') + imports.remove('androidx.annotation.NonNull') sorted_imports.append('') tmp = [] for i in imports: @@ -105,7 +105,7 @@ class StructsProducer(InterfaceProducerCommon): p['since'] = param.since p['deprecated'] = param.deprecated p['origin'] = param.origin - + p['values'] = self.extract_values(param) d = self.extract_description(param.description) if d: p['description'] = textwrap.wrap(d, 90) @@ -124,7 +124,7 @@ class StructsProducer(InterfaceProducerCommon): if tr in self.struct_names: imports.add('{}.{}'.format(self.structs_package, tr)) if param.is_mandatory: - imports.add('android.support.annotation.NonNull') + imports.add('androidx.annotation.NonNull') Params = namedtuple('Params', sorted(p)) return imports, Params(**p) |