diff options
author | Joey Grover <joeygrover@gmail.com> | 2017-09-08 15:41:06 -0400 |
---|---|---|
committer | Joey Grover <joeygrover@gmail.com> | 2017-09-08 15:41:06 -0400 |
commit | 96eb784b5b39b93a37a60323f028327802671a53 (patch) | |
tree | 1acc4359371f854ed3450905e0b5324545fa0b7b | |
parent | 13fee2070e8fa627c28535c5d6dac844de9e40fa (diff) | |
parent | 08dac84f24989d6dda11486f40df8dcc82047022 (diff) | |
download | sdl_android-96eb784b5b39b93a37a60323f028327802671a53.tar.gz |
Merge branch 'feature/sdl_0075_specific_HID_support' of https://github.com/smartdevicelink/sdl_android into develop
# Conflicts:
# sdl_android/src/androidTest/java/com/smartdevicelink/test/Test.java
19 files changed, 688 insertions, 7 deletions
diff --git a/sdl_android/src/androidTest/assets/json/SendHapticData.json b/sdl_android/src/androidTest/assets/json/SendHapticData.json new file mode 100644 index 000000000..42b863aae --- /dev/null +++ b/sdl_android/src/androidTest/assets/json/SendHapticData.json @@ -0,0 +1,22 @@ +{ + "request":{ + "name":"SendHapticData", + "correlationID":1234, + "parameters":{ + "hapticRectData":[ + {"id":123, + "rect":{ + "height":1, + "width":1, + "x":1, + "y":1 + } + } + ] + } + }, + "response":{ + "name":"SendHapticData", + "correlationID":1234 + } +}
\ No newline at end of file diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/Test.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/Test.java index 40202a71d..58ee7065c 100644 --- a/sdl_android/src/androidTest/java/com/smartdevicelink/test/Test.java +++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/Test.java @@ -11,6 +11,7 @@ import com.smartdevicelink.proxy.rpc.DIDResult; import com.smartdevicelink.proxy.rpc.DeviceInfo; import com.smartdevicelink.proxy.rpc.DisplayCapabilities; import com.smartdevicelink.proxy.rpc.HMIPermissions; +import com.smartdevicelink.proxy.rpc.HapticRect; import com.smartdevicelink.proxy.rpc.Image; import com.smartdevicelink.proxy.rpc.ImageField; import com.smartdevicelink.proxy.rpc.ImageResolution; @@ -22,6 +23,7 @@ import com.smartdevicelink.proxy.rpc.OasisAddress; import com.smartdevicelink.proxy.rpc.ParameterPermissions; import com.smartdevicelink.proxy.rpc.PermissionItem; import com.smartdevicelink.proxy.rpc.PresetBankCapabilities; +import com.smartdevicelink.proxy.rpc.Rectangle; import com.smartdevicelink.proxy.rpc.ScreenParams; import com.smartdevicelink.proxy.rpc.SdlMsgVersion; import com.smartdevicelink.proxy.rpc.SoftButton; @@ -123,9 +125,10 @@ public class Test { // RPC Request/Response/Notification/Datatype Test Values public static final int GENERAL_INT = 100; + public static final Integer GENERAL_INTEGER = 100; public static final Long GENERAL_LONG = 100L; public static final Turn GENERAL_TURN = new Turn(); - public static final float GENERAL_FLOAT = 100f; + public static final Float GENERAL_FLOAT = 100f; public static final Image GENERAL_IMAGE = new Image(); public static final Choice GENERAL_CHOICE = new Choice(); public static final String GENERAL_STRING = "test"; @@ -217,7 +220,8 @@ public class Test { public static final VideoStreamingCapability GENERAL_VIDEOSTREAMINGCAPABILITY = new VideoStreamingCapability(); public static final VideoStreamingFormat GENERAL_VIDEOSTREAMINGFORMAT = new VideoStreamingFormat(); public static final MetadataTags GENERAL_METADATASTRUCT = new MetadataTags(); - + public static final Rectangle GENERAL_RECTANGLE = new Rectangle(); + public static final HapticRect GENERAL_HAPTIC_RECT = new HapticRect(); public static final List<Long> GENERAL_LONG_LIST = Arrays.asList(new Long[]{ 1L, 2L }); public static final List<Turn> GENERAL_TURN_LIST = new ArrayList<Turn>(); public static final List<Choice> GENERAL_CHOICE_LIST = new ArrayList<Choice>(); @@ -497,7 +501,15 @@ public class Test { GENERAL_METADATASTRUCT.setMainField3(exampleList); GENERAL_METADATASTRUCT.setMainField4(exampleList); - try { + GENERAL_RECTANGLE.setX(GENERAL_FLOAT); + GENERAL_RECTANGLE.setY(GENERAL_FLOAT); + GENERAL_RECTANGLE.setWidth(GENERAL_FLOAT); + GENERAL_RECTANGLE.setHeight(GENERAL_FLOAT); + + GENERAL_HAPTIC_RECT.setId(GENERAL_INTEGER); + GENERAL_HAPTIC_RECT.setRect(GENERAL_RECTANGLE); + + try { JSON_HMIPERMISSIONS.put(HMIPermissions.KEY_ALLOWED, GENERAL_HMILEVEL_LIST); JSON_HMIPERMISSIONS.put(HMIPermissions.KEY_USER_DISALLOWED, GENERAL_HMILEVEL_LIST); diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/Validator.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/Validator.java index ae64ec28b..966370e54 100644 --- a/sdl_android/src/androidTest/java/com/smartdevicelink/test/Validator.java +++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/Validator.java @@ -35,6 +35,7 @@ import com.smartdevicelink.proxy.rpc.OasisAddress; import com.smartdevicelink.proxy.rpc.ParameterPermissions; import com.smartdevicelink.proxy.rpc.PermissionItem; import com.smartdevicelink.proxy.rpc.PresetBankCapabilities; +import com.smartdevicelink.proxy.rpc.Rectangle; import com.smartdevicelink.proxy.rpc.ScreenParams; import com.smartdevicelink.proxy.rpc.SdlMsgVersion; import com.smartdevicelink.proxy.rpc.SingleTireStatus; @@ -320,6 +321,33 @@ public class Validator{ return true; } + public static boolean validateRectangle(Rectangle c1, Rectangle c2){ + if(c1 == null){ + return ( c2 == null ); + } + if(c2 == null){ + return ( c1 == null ); + } + + if(c1.getX() != c2.getX()){ + return false; + } + + if(c1.getY() != c2.getY()){ + return false; + } + + if(c1.getWidth() != c2.getWidth()){ + return false; + } + + if(c1.getHeight() != c2.getHeight()){ + return false; + } + + return true; + } + public static boolean validateOasisAddress(OasisAddress a1, OasisAddress a2){ if(a1 == null){ return ( a2 == null ); diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SdlProxyBaseTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SdlProxyBaseTests.java index b8b705cfe..ee8d7d0ee 100644 --- a/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SdlProxyBaseTests.java +++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SdlProxyBaseTests.java @@ -55,6 +55,7 @@ import com.smartdevicelink.proxy.rpc.PutFileResponse; import com.smartdevicelink.proxy.rpc.ReadDIDResponse; import com.smartdevicelink.proxy.rpc.ResetGlobalPropertiesResponse; import com.smartdevicelink.proxy.rpc.ScrollableMessageResponse; +import com.smartdevicelink.proxy.rpc.SendHapticDataResponse; import com.smartdevicelink.proxy.rpc.SendLocationResponse; import com.smartdevicelink.proxy.rpc.SetAppIconResponse; import com.smartdevicelink.proxy.rpc.SetDisplayLayoutResponse; @@ -450,5 +451,10 @@ public class SdlProxyBaseTests extends AndroidTestCase{ public void onGenericResponse(GenericResponse response) { Log.i(TAG, "Generic response from SDL: " + response.getResultCode().name() + " Info: " + response.getInfo()); } + + @Override + public void onSendHapticDataResponse(SendHapticDataResponse response) { + Log.i(TAG, "SendHapticDataResponse response from SDL: " + response); + } } } diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/HapticRectTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/HapticRectTests.java new file mode 100644 index 000000000..c72204640 --- /dev/null +++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/HapticRectTests.java @@ -0,0 +1,73 @@ +package com.smartdevicelink.test.rpc.datatypes; + +import com.smartdevicelink.marshal.JsonRPCMarshaller; +import com.smartdevicelink.proxy.rpc.HapticRect; +import com.smartdevicelink.proxy.rpc.Rectangle; +import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.Test; +import com.smartdevicelink.test.Validator; + +import junit.framework.TestCase; + +import org.json.JSONException; +import org.json.JSONObject; + +/** + * Created by brettywhite on 8/24/17. + */ + +public class HapticRectTests extends TestCase { + + private HapticRect msg; + + @Override + public void setUp() { + msg = new HapticRect(); + + msg.setId(Test.GENERAL_INTEGER); + msg.setRect(Test.GENERAL_RECTANGLE); + } + + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Test Values + Integer id = msg.getId(); + Rectangle rect = msg.getRect(); + + // Valid Tests + assertEquals(Test.MATCH, Test.GENERAL_INTEGER, id); + assertEquals(Test.MATCH, Test.GENERAL_RECTANGLE, rect); + + // Invalid/Null Tests + HapticRect msg = new HapticRect(); + assertNotNull(Test.NOT_NULL, msg); + + assertNull(Test.NULL, msg.getId()); + assertNull(Test.NULL, msg.getRect()); + } + + public void testJson(){ + JSONObject reference = new JSONObject(); + + try{ + reference.put(HapticRect.KEY_ID, Test.GENERAL_INTEGER); + reference.put(HapticRect.KEY_RECT, Test.GENERAL_RECTANGLE); + + JSONObject underTest = msg.serializeJSON(); + assertEquals(Test.MATCH, reference.length(), underTest.length()); + + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(reference, HapticRect.KEY_ID), + JsonUtils.readIntegerFromJsonObject(underTest, HapticRect.KEY_ID)); + + assertTrue(Validator.validateRectangle( + (Rectangle) JsonUtils.readObjectFromJsonObject(reference, HapticRect.KEY_RECT), + new Rectangle(JsonRPCMarshaller.deserializeJSONObject( (JSONObject) JsonUtils.readObjectFromJsonObject(underTest, HapticRect.KEY_RECT)))) + ); + + } catch(JSONException e){ + fail(Test.JSON_FAIL); + } + } +} diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/RectangleTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/RectangleTests.java new file mode 100644 index 000000000..569a4db83 --- /dev/null +++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/RectangleTests.java @@ -0,0 +1,79 @@ +package com.smartdevicelink.test.rpc.datatypes; + +import com.smartdevicelink.proxy.rpc.Rectangle; +import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.Test; + +import junit.framework.TestCase; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.Iterator; + +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link Rectangle} + */ +public class RectangleTests extends TestCase { + + private Rectangle msg; + + @Override + public void setUp() { + msg = new Rectangle(); + + msg.setX(Test.GENERAL_FLOAT); + msg.setY(Test.GENERAL_FLOAT); + msg.setWidth(Test.GENERAL_FLOAT); + msg.setHeight(Test.GENERAL_FLOAT); + } + + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Test Values + Float x = msg.getX(); + Float y = msg.getY(); + Float width = msg.getWidth(); + Float height = msg.getHeight(); + + // Valid Tests + assertEquals(Test.MATCH, Test.GENERAL_FLOAT, x); + assertEquals(Test.MATCH, Test.GENERAL_FLOAT, y); + assertEquals(Test.MATCH, Test.GENERAL_FLOAT, width); + assertEquals(Test.MATCH, Test.GENERAL_FLOAT, height); + + // Invalid/Null Tests + Rectangle msg = new Rectangle(); + assertNotNull(Test.NOT_NULL, msg); + + assertNull(Test.NULL, msg.getX()); + assertNull(Test.NULL, msg.getY()); + assertNull(Test.NULL, msg.getWidth()); + assertNull(Test.NULL, msg.getHeight()); + } + + public void testJson() { + JSONObject reference = new JSONObject(); + + try { + reference.put(Rectangle.KEY_X, (Test.GENERAL_FLOAT)); + reference.put(Rectangle.KEY_Y, (Test.GENERAL_FLOAT)); + reference.put(Rectangle.KEY_WIDTH, (Test.GENERAL_FLOAT)); + reference.put(Rectangle.KEY_HEIGHT, (Test.GENERAL_FLOAT)); + + JSONObject underTest = msg.serializeJSON(); + assertEquals(Test.MATCH, reference.length(), underTest.length()); + + Iterator<?> iterator = reference.keys(); + while (iterator.hasNext()) { + String key = (String) iterator.next(); + assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key)); + } + } catch (JSONException e) { + fail(Test.JSON_FAIL); + } + } +} diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/VideoStreamingCapabilityTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/VideoStreamingCapabilityTests.java index 8a417f1b1..54cfc1a22 100644 --- a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/VideoStreamingCapabilityTests.java +++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/VideoStreamingCapabilityTests.java @@ -29,6 +29,7 @@ public class VideoStreamingCapabilityTests extends TestCase { msg.setSupportedFormats(Test.GENERAL_VIDEOSTREAMINGFORMAT_LIST); msg.setPreferredResolution(Test.GENERAL_IMAGERESOLUTION); msg.setMaxBitrate(Test.GENERAL_INT); + msg.setIsHapticSpatialDataSupported(Test.GENERAL_BOOLEAN); } /** @@ -39,11 +40,13 @@ public class VideoStreamingCapabilityTests extends TestCase { List<VideoStreamingFormat> format = msg.getSupportedFormats(); ImageResolution res = msg.getPreferredResolution(); Integer maxBitrate = msg.getMaxBitrate(); + Boolean isHapticSpatialDataSupported = msg.getIsHapticSpatialDataSupported(); // Valid Tests assertEquals(Test.MATCH, (List<VideoStreamingFormat>) Test.GENERAL_VIDEOSTREAMINGFORMAT_LIST, format); assertEquals(Test.MATCH, (ImageResolution) Test.GENERAL_IMAGERESOLUTION, res); assertEquals(Test.MATCH, (Integer) Test.GENERAL_INT, maxBitrate); + assertEquals(Test.MATCH, (Boolean) Test.GENERAL_BOOLEAN, isHapticSpatialDataSupported); // Invalid/Null Tests VideoStreamingCapability msg = new VideoStreamingCapability(); @@ -52,6 +55,7 @@ public class VideoStreamingCapabilityTests extends TestCase { assertNull(Test.NULL, msg.getMaxBitrate()); assertNull(Test.NULL, msg.getPreferredResolution()); assertNull(Test.NULL, msg.getSupportedFormats()); + assertNull(Test.NULL, msg.getIsHapticSpatialDataSupported()); } public void testJson() { @@ -61,6 +65,7 @@ public class VideoStreamingCapabilityTests extends TestCase { reference.put(VideoStreamingCapability.KEY_MAX_BITRATE, Test.GENERAL_INT); reference.put(VideoStreamingCapability.KEY_PREFERRED_RESOLUTION, Test.GENERAL_IMAGERESOLUTION); reference.put(VideoStreamingCapability.KEY_SUPPORTED_FORMATS, Test.GENERAL_VIDEOSTREAMINGFORMAT_LIST); + reference.put(VideoStreamingCapability.KEY_HAPTIC_SPATIAL_DATA_SUPPORTED, Test.GENERAL_BOOLEAN); JSONObject underTest = msg.serializeJSON(); assertEquals(Test.MATCH, reference.length(), underTest.length()); @@ -69,7 +74,7 @@ public class VideoStreamingCapabilityTests extends TestCase { while (iterator.hasNext()) { String key = (String) iterator.next(); - if (key.equals(VideoStreamingCapability.KEY_MAX_BITRATE)) { + if (key.equals(VideoStreamingCapability.KEY_MAX_BITRATE) || key.equals(VideoStreamingCapability.KEY_HAPTIC_SPATIAL_DATA_SUPPORTED)) { assertTrue(Test.TRUE, JsonUtils.readIntegerFromJsonObject(reference, key) == JsonUtils.readIntegerFromJsonObject(underTest, key)); } else if (key.equals(VideoStreamingCapability.KEY_PREFERRED_RESOLUTION)) { ImageResolution irReference = (ImageResolution) JsonUtils.readObjectFromJsonObject(reference, key); diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SendHapticDataTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SendHapticDataTests.java new file mode 100644 index 000000000..7c3b0ed90 --- /dev/null +++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SendHapticDataTests.java @@ -0,0 +1,86 @@ +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.HapticRect; +import com.smartdevicelink.proxy.rpc.SendHapticData; +import com.smartdevicelink.test.BaseRpcTests; +import com.smartdevicelink.test.Test; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by brettywhite on 8/9/17. + */ + +public class SendHapticDataTests extends BaseRpcTests { + + private SendHapticData msg; + + @Override + protected RPCMessage createMessage(){ + msg = new SendHapticData(); + + List<HapticRect> list = new ArrayList<>(); + list.add(Test.GENERAL_HAPTIC_RECT); + + msg.setHapticRectData(list); + + return msg; + } + + @Override + protected String getMessageType(){ + return RPCMessage.KEY_REQUEST; + } + + @Override + protected String getCommandType(){ + return FunctionID.SEND_HAPTIC_DATA.toString(); + } + + @Override + protected JSONObject getExpectedParameters(int sdlVersion){ + JSONObject result = new JSONObject(); + + JSONArray jsonArray = new JSONArray(); + try { + jsonArray.put(JsonRPCMarshaller.serializeHashtable(Test.GENERAL_HAPTIC_RECT.getStore())); + } catch (JSONException e) { + e.printStackTrace(); + } + + try { + result.put(SendHapticData.KEY_HAPTIC_RECT_DATA, jsonArray); + } catch (JSONException e) { + e.printStackTrace(); + } + + return result; + } + + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Test Values + List<HapticRect> list = msg.getHapticRectData(); + + // Valid Tests + assertEquals(Test.MATCH, Test.GENERAL_HAPTIC_RECT, list.get(0)); + + // Invalid/Null Tests + SendHapticData msg = new SendHapticData(); + assertNotNull(Test.NOT_NULL, msg); + testNullBase(msg); + + assertNull(Test.NULL, msg.getHapticRectData()); + } + +} diff --git a/sdl_android/src/main/java/com/smartdevicelink/protocol/enums/FunctionID.java b/sdl_android/src/main/java/com/smartdevicelink/protocol/enums/FunctionID.java index 9c34a4c67..06116c5b9 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/protocol/enums/FunctionID.java +++ b/sdl_android/src/main/java/com/smartdevicelink/protocol/enums/FunctionID.java @@ -57,6 +57,7 @@ public enum FunctionID{ SUBSCRIBE_WAY_POINTS(46, "SubscribeWayPoints"),
UNSUBSCRIBE_WAY_POINTS(47, "UnsubscribeWayPoints"),
GET_SYSTEM_CAPABILITY(48, "GetSystemCapability"),
+ SEND_HAPTIC_DATA(49, "SendHapticData"),
// NOTIFICATIONS
ON_HMI_STATUS(32768, "OnHMIStatus"),
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCMessage.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCMessage.java index ab4763103..e55292aad 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCMessage.java +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCMessage.java @@ -104,6 +104,11 @@ public class RPCMessage extends RPCStruct { }
@Override
+ public Float getFloat(String key) {
+ return (Float) parameters.get(key);
+ }
+
+ @Override
public Double getDouble(String key) {
return (Double) parameters.get(key);
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCStruct.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCStruct.java index f1911b121..116c491df 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCStruct.java +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCStruct.java @@ -231,6 +231,10 @@ public class RPCStruct { return (Double) store.get(key);
}
+ public Float getFloat(String key) {
+ return (Float) store.get(key);
+ }
+
public Boolean getBoolean(String key) { return (Boolean) store.get(key); }
public Long getLong(String key){
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java index a7cb2a5c0..e71f1d97a 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java @@ -2850,10 +2850,27 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> _proxyListener.onGetSystemCapabilityResponse(msg);
onRPCResponseReceived(msg);
}
- } else {
+ }
+ else if (functionName.equals(FunctionID.SEND_HAPTIC_DATA.toString())) {
+ final SendHapticDataResponse msg = new SendHapticDataResponse(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onSendHapticDataResponse((SendHapticDataResponse) msg);
+ onRPCResponseReceived(msg);
+ }
+ });
+ } else {
+ _proxyListener.onSendHapticDataResponse((SendHapticDataResponse) msg);
+ onRPCResponseReceived(msg);
+ }
+ }
+ else {
if (_sdlMsgVersion != null) {
DebugTool.logError("Unrecognized response Message: " + functionName.toString() +
- "SDL Message Version = " + _sdlMsgVersion);
+ " SDL Message Version = " + _sdlMsgVersion);
} else {
DebugTool.logError("Unrecognized response Message: " + functionName.toString());
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/IProxyListenerBase.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/IProxyListenerBase.java index 62ddbc1e0..80842cfc2 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/IProxyListenerBase.java +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/IProxyListenerBase.java @@ -44,6 +44,7 @@ import com.smartdevicelink.proxy.rpc.PutFileResponse; import com.smartdevicelink.proxy.rpc.ReadDIDResponse;
import com.smartdevicelink.proxy.rpc.ResetGlobalPropertiesResponse;
import com.smartdevicelink.proxy.rpc.ScrollableMessageResponse;
+import com.smartdevicelink.proxy.rpc.SendHapticDataResponse;
import com.smartdevicelink.proxy.rpc.SendLocationResponse;
import com.smartdevicelink.proxy.rpc.SetAppIconResponse;
import com.smartdevicelink.proxy.rpc.SetDisplayLayoutResponse;
@@ -338,4 +339,6 @@ public interface IProxyListenerBase { public void onOnWayPointChange(OnWayPointChange notification);
public void onGetSystemCapabilityResponse(GetSystemCapabilityResponse response);
+
+ public void onSendHapticDataResponse(SendHapticDataResponse response);
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/HapticRect.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/HapticRect.java new file mode 100644 index 000000000..64a9f8354 --- /dev/null +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/HapticRect.java @@ -0,0 +1,82 @@ +package com.smartdevicelink.proxy.rpc; + +import com.smartdevicelink.proxy.RPCStruct; + +import java.util.Hashtable; + +/* + * Copyright (c) 2017 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. + */ + +/** + * Defines a haptic rectangle that contains a reference ID and the spatial data of a rectangle UI component. + * @since SmartDeviceLink 4.5.0 + * + */ + +public class HapticRect extends RPCStruct { + public static final String KEY_ID = "id"; + public static final String KEY_RECT = "rect"; + + public HapticRect() {} + + public HapticRect(Hashtable<String, Object> hash) { + super(hash); + } + + /** + * Set a user control spatial identifier that references the supplied spatial data + */ + public void setId(Integer id) { + setValue(KEY_ID, id); + } + + /** + * @return a user control spatial identifier that references the supplied spatial data + */ + public Integer getId() { + return getInteger(KEY_ID); + } + + /** + * Set the position of the haptic rectangle to be highlighted. The center of this rectangle will be "touched" when a press occurs. + */ + public void setRect(Rectangle rect) { + setValue(KEY_RECT, rect); + } + + /** + * @return the position of the haptic rectangle to be highlighted. The center of this rectangle will be "touched" when a press occurs. + */ + public Rectangle getRect() { + return (Rectangle) getObject(Rectangle.class, KEY_RECT); + } +} diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Rectangle.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Rectangle.java new file mode 100644 index 000000000..e0d50e073 --- /dev/null +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Rectangle.java @@ -0,0 +1,109 @@ +package com.smartdevicelink.proxy.rpc; + +import com.smartdevicelink.proxy.RPCStruct; + +import java.util.Hashtable; +/* + * Copyright (c) 2017 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. + */ + +/** + * Defines Rectangle for each user control object for video streaming application + * @since SmartDeviceLink 4.5.0 + */ + +public class Rectangle extends RPCStruct { + public static final String KEY_X = "x"; + public static final String KEY_Y = "y"; + public static final String KEY_WIDTH = "width"; + public static final String KEY_HEIGHT = "height"; + + public Rectangle() {} + public Rectangle(Hashtable<String, Object> hash) { + super(hash); + } + + /** + * Set the X-coordinate pixel in of the user control that starts in the upper left corner + */ + public void setX(Float x) { + setValue(KEY_X, x); + } + + /** + * @return the X-coordinate pixel of the user control that starts in the upper left corner + */ + public Float getX() { + return getFloat(KEY_X); + } + + /** + * Set the Y-coordinate pixel of the user control that starts in the upper left corner + */ + public void setY(Float y) { + setValue(KEY_Y, y); + } + + /** + * @return the Y-coordinate pixel of the user control that starts in the upper left corner + */ + public Float getY() { + return getFloat(KEY_Y); + } + + /** + * Set the width in pixels of the user control's bounding rectangle in pixels + */ + public void setWidth(Float width) { + setValue(KEY_WIDTH, width); + } + + /** + * @return the width in pixels of the user control's bounding rectangle in pixels + */ + public Float getWidth() { + return getFloat(KEY_WIDTH); + } + + /** + * The height in pixels of the user control's bounding rectangle + */ + public void setHeight(Float height) { + setValue(KEY_HEIGHT, height); + } + + /** + * @return the width in pixels of the user control's bounding rectangle in pixels + */ + public Float getHeight() { + return getFloat(KEY_HEIGHT); + } +} diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SendHapticData.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SendHapticData.java new file mode 100644 index 000000000..a93fd2b98 --- /dev/null +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SendHapticData.java @@ -0,0 +1,86 @@ +package com.smartdevicelink.proxy.rpc; + +import com.smartdevicelink.protocol.enums.FunctionID; +import com.smartdevicelink.proxy.RPCRequest; + +import java.util.Hashtable; +import java.util.List; + +/* + * Copyright (c) 2017 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. + */ + +/** + * Request to describe UI elements boundaries to a connected modules. + * @since SmartDeviceLink 4.5.0 + */ +public class SendHapticData extends RPCRequest { + + public static final String KEY_HAPTIC_RECT_DATA = "hapticRectData"; + + /** + * Constructs a new SendHapticData object + */ + public SendHapticData(){ + super(FunctionID.SEND_HAPTIC_DATA.toString()); + } + + /** + * <p> + * Send the spatial data gathered from SDLCarWindow or VirtualDisplayEncoder to the HMI. + * This data will be utilized by the HMI to determine how and when haptic events should occur + * </p> + * + * @param hash The Hashtable to use + */ + public SendHapticData(Hashtable<String, Object> hash){ + super(hash); + } + + /** + * Array of spatial data structures that represent the locations of all user controls present on the app's layout. + * This data should be updated if/when the application presents a new screen. + * When a request is sent, if successful, it will replace all spatial data previously sent through RPC. + * If an empty array is sent, the existing spatial data will be cleared + */ + public void setHapticRectData(List<HapticRect> hapticRectData) { + setParameters(KEY_HAPTIC_RECT_DATA, hapticRectData); + } + + @SuppressWarnings("unchecked") + /** + * @return array of spatial data structures that represent the locations of all user controls present on the app's layout. + */ + public List<HapticRect> getHapticRectData() { + return (List<HapticRect>) getObject(HapticRect.class, KEY_HAPTIC_RECT_DATA); + } + +} diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SendHapticDataResponse.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SendHapticDataResponse.java new file mode 100644 index 000000000..e7c0c7d30 --- /dev/null +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SendHapticDataResponse.java @@ -0,0 +1,54 @@ +package com.smartdevicelink.proxy.rpc; + +import com.smartdevicelink.protocol.enums.FunctionID; +import com.smartdevicelink.proxy.RPCResponse; + +import java.util.Hashtable; + +/* + * Copyright (c) 2017 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. + */ + +/** + * Response to request that described UI elements boundaries to a connected modules. + * @since SmartDeviceLink 4.5.0 + */ + +public class SendHapticDataResponse extends RPCResponse { + + public SendHapticDataResponse(){ + super(FunctionID.SEND_HAPTIC_DATA.toString()); + } + + public SendHapticDataResponse(Hashtable<String, Object> hash){ + super(hash); + } +} diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/TouchEvent.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/TouchEvent.java index 58433f26c..f99b0a8e2 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/TouchEvent.java +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/TouchEvent.java @@ -136,7 +136,7 @@ public class TouchEvent extends RPCStruct { public List<TouchCoord> getC() {
return getTouchCoordinates();
}
- @SuppressWarnings("unchecked")
+ @SuppressWarnings("unchecked")
public List<TouchCoord> getTouchCoordinates() {
return (List<TouchCoord>) getObject(TouchCoord.class, KEY_C);
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/VideoStreamingCapability.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/VideoStreamingCapability.java index bc96056ac..6600cf38d 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/VideoStreamingCapability.java +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/VideoStreamingCapability.java @@ -13,6 +13,7 @@ public class VideoStreamingCapability extends RPCStruct { public static final String KEY_PREFERRED_RESOLUTION = "preferredResolution"; public static final String KEY_MAX_BITRATE = "maxBitrate"; public static final String KEY_SUPPORTED_FORMATS = "supportedFormats"; + public static final String KEY_HAPTIC_SPATIAL_DATA_SUPPORTED = "hapticSpatialDataSupported"; public VideoStreamingCapability(){} public VideoStreamingCapability(Hashtable<String, Object> hash){super(hash);} @@ -40,4 +41,12 @@ public class VideoStreamingCapability extends RPCStruct { public List<VideoStreamingFormat> getSupportedFormats(){ return (List<VideoStreamingFormat>) getObject(VideoStreamingFormat.class, KEY_SUPPORTED_FORMATS); } + + public Boolean getIsHapticSpatialDataSupported() { + return getBoolean(KEY_HAPTIC_SPATIAL_DATA_SUPPORTED); + } + + public void setIsHapticSpatialDataSupported(Boolean hapticSpatialDataSupported) { + setValue(KEY_HAPTIC_SPATIAL_DATA_SUPPORTED, hapticSpatialDataSupported); + } } |