From 2147963ab2aba4bad0e5a7fb14112c2feea79ae0 Mon Sep 17 00:00:00 2001 From: Bilal Date: Tue, 1 May 2018 12:14:10 -0400 Subject: [PATCH 1/6] Add seek bar bascic implementation --- .../protocol/enums/FunctionID.java | 1 + .../smartdevicelink/proxy/SdlProxyBase.java | 23 +++++-- .../proxy/interfaces/IProxyListenerBase.java | 3 + .../proxy/rpc/OnSeekMediaClockTimer.java | 69 +++++++++++++++++++ .../proxy/rpc/SetMediaClockTimer.java | 47 +++++++++++-- 5 files changed, 132 insertions(+), 11 deletions(-) create mode 100644 sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnSeekMediaClockTimer.java 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 412d3f8577..686a1b30eb 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 @@ -82,6 +82,7 @@ public enum FunctionID{ ON_HASH_CHANGE(32782, "OnHashChange"), ON_INTERIOR_VEHICLE_DATA(32783, "OnInteriorVehicleData"), ON_WAY_POINT_CHANGE(32784, "OnWayPointChange"), + ON_SEEK_MEDIA_CLOCK_TIMER(32785, "OnSeekMediaClockTimer"), // MOCKED FUNCTIONS (NOT SENT FROM HEAD-UNIT) ON_LOCK_SCREEN_STATUS(-1, "OnLockScreenStatus"), 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 79ee5a0ff2..9b76f51cd1 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java @@ -41,7 +41,6 @@ import android.view.MotionEvent; import android.view.Surface; -import com.smartdevicelink.BuildConfig; import com.smartdevicelink.Dispatcher.IDispatchingStrategy; import com.smartdevicelink.Dispatcher.ProxyMessageDispatcher; import com.smartdevicelink.SdlConnection.ISdlConnectionListener; @@ -1954,7 +1953,7 @@ private void handleRPCMessage(Hashtable hash) { RPCMessage rpcMsg = new RPCMessage(hash); String functionName = rpcMsg.getFunctionName(); String messageType = rpcMsg.getMessageType(); - + if (messageType.equals(RPCMessage.KEY_RESPONSE)) { SdlTrace.logRPCEvent(InterfaceActivityDirection.Receive, new RPCResponse(rpcMsg), SDL_LIB_TRACE_KEY); @@ -2744,7 +2743,7 @@ public void run() { }); } else { _proxyListener.onGetVehicleDataResponse(msg); - onRPCResponseReceived(msg); + onRPCResponseReceived(msg); } } else if (functionName.equals(FunctionID.SUBSCRIBE_WAY_POINTS.toString())) { // SubscribeWayPoints @@ -3139,7 +3138,7 @@ public void run() { } } else if (functionName.equals(FunctionID.ON_PERMISSIONS_CHANGE.toString())) { //OnPermissionsChange - + final OnPermissionsChange msg = new OnPermissionsChange(hash); if (_callbackToUIThread) { // Run in UI thread @@ -3401,6 +3400,22 @@ public void run() { onRPCNotificationReceived(msg); } } + else if (functionName.equals(FunctionID.ON_SEEK_MEDIA_CLOCK_TIMER.toString())) { + final OnSeekMediaClockTimer msg = new OnSeekMediaClockTimer(hash); + if (_callbackToUIThread) { + // Run in UI thread + _mainUIHandler.post(new Runnable() { + @Override + public void run() { + _proxyListener.onSeekMediaClockTimer(msg); + onRPCNotificationReceived(msg); + } + }); + } else { + _proxyListener.onSeekMediaClockTimer(msg); + onRPCNotificationReceived(msg); + } + } else if (functionName.equals(FunctionID.ON_INTERIOR_VEHICLE_DATA.toString())) { final OnInteriorVehicleData msg = new OnInteriorVehicleData(hash); if (_callbackToUIThread) { 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 618819f20b..9dbaca6eb3 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 @@ -35,6 +35,7 @@ import com.smartdevicelink.proxy.rpc.OnLanguageChange; import com.smartdevicelink.proxy.rpc.OnLockScreenStatus; import com.smartdevicelink.proxy.rpc.OnPermissionsChange; +import com.smartdevicelink.proxy.rpc.OnSeekMediaClockTimer; import com.smartdevicelink.proxy.rpc.OnStreamRPC; import com.smartdevicelink.proxy.rpc.OnSystemRequest; import com.smartdevicelink.proxy.rpc.OnTBTClientState; @@ -353,4 +354,6 @@ public interface IProxyListenerBase { public void onOnInteriorVehicleData(OnInteriorVehicleData notification); public void onSendHapticDataResponse(SendHapticDataResponse response); + + public void onSeekMediaClockTimer(OnSeekMediaClockTimer notification); } diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnSeekMediaClockTimer.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnSeekMediaClockTimer.java new file mode 100644 index 0000000000..e6df928ca2 --- /dev/null +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnSeekMediaClockTimer.java @@ -0,0 +1,69 @@ +package com.smartdevicelink.proxy.rpc; + +import com.smartdevicelink.protocol.enums.FunctionID; +import com.smartdevicelink.proxy.RPCNotification; + +import java.util.Hashtable; + +/** + * Callback for the seek media clock timer notification. Notifies the application of + * progress bar seek event on the media clock timer. System will automatically update + * the media clock timer position based on the seek notification location. + *

+ *

+ * Parameter List: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
NameTypeDescriptionReqNotesSmartDeviceLink Ver Available
seekTimeStartTimeDescribes the hour, minute and second values used for the current media clock timer.YSmartDeviceLink 4.7
+ *

+ */ + +public class OnSeekMediaClockTimer extends RPCNotification { + public static final String KEY_SEEK_TIME = "seekTime"; + + /** + *Constructs a newly allocated OnSeekMediaClockTimer object + */ + public OnSeekMediaClockTimer() { + super(FunctionID.ON_SEEK_MEDIA_CLOCK_TIMER.toString()); + } + /** + *

Constructs a newly allocated OnSeekMediaClockTimer object indicated by the Hashtable parameter

+ *@param hash The Hashtable to use + */ + public OnSeekMediaClockTimer(Hashtable hash) { + super(hash); + } + /** + * Gets the StartTime object representing the current media clock timer + * + * @return seekTime -a StartTime object specifying hour, minute, second values + */ + public StartTime getSeekTime() { + return (StartTime) getObject(StartTime.class, KEY_SEEK_TIME); + } + /** + * Sets a seekTime with specifying hour, minute, second values + * + * @param seekTime -a StartTime object with specifying hour, minute, second values + */ + public void setSeekTime( StartTime seekTime ) { + setParameters(KEY_SEEK_TIME, seekTime); + } + +} diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetMediaClockTimer.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetMediaClockTimer.java index bcef52745b..29951c773e 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetMediaClockTimer.java +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetMediaClockTimer.java @@ -52,6 +52,14 @@ * SmartDeviceLink 1.0 * * + * enableSeek + * Boolean + * Defines if seek media clock timer functionality will be available. + * N + * If omitted, the value is set to false. The value is retained until the next SetMediaClockTimer is sent. + * SmartDeviceLink 4.7 + * + * * * * @@ -74,6 +82,7 @@ public class SetMediaClockTimer extends RPCRequest { public static final String KEY_START_TIME = "startTime"; public static final String KEY_END_TIME = "endTime"; public static final String KEY_UPDATE_MODE = "updateMode"; + public static final String KEY_ENABLE_SEEK = "enableSeek"; /** * Constructs a new SetMediaClockTimer object */ @@ -131,13 +140,13 @@ public void setEndTime( StartTime endTime ) { * Gets the media clock/timer update mode (COUNTUP/COUNTDOWN/PAUSE/RESUME) * * @return UpdateMode -a Enumeration value (COUNTUP/COUNTDOWN/PAUSE/RESUME) - */ - public UpdateMode getUpdateMode() { + */ + public UpdateMode getUpdateMode() { return (UpdateMode) getObject(UpdateMode.class, KEY_UPDATE_MODE); - } + } /** * Sets the media clock/timer update mode (COUNTUP/COUNTDOWN/PAUSE/RESUME) - * + * * @param updateMode * a Enumeration value (COUNTUP/COUNTDOWN/PAUSE/RESUME) *

@@ -148,8 +157,32 @@ public UpdateMode getUpdateMode() { *
  • When updateMode is RESUME, the timer resumes counting from * the timer's value when it was paused
  • * - */ - public void setUpdateMode( UpdateMode updateMode ) { + */ + public void setUpdateMode( UpdateMode updateMode ) { setParameters(KEY_UPDATE_MODE, updateMode); - } + } + + /** + * Gets enableSeek + * + * @return enableSeek -a Boolean representing whether seek media clock timer functionality will be available + */ + public Boolean getEnableSeek() { + return getBoolean(KEY_ENABLE_SEEK); + } + /** + * Sets enableSeek + * + * @param enableSeek + * a Boolean representing whether seek media clock timer functionality will be available + *

    + * Notes: + *
      + *
    • If omitted, the value is set to false.
    • + *
    • The value is retained until the next SetMediaClockTimer is sent.
    • + *
    + */ + public void setEnableSeek( Boolean enableSeek ) { + setParameters(KEY_ENABLE_SEEK, enableSeek); + } } From 4aae4a690ea02aa11d7aed135438678dd750cfdf Mon Sep 17 00:00:00 2001 From: Bilal Date: Tue, 1 May 2018 17:08:55 -0400 Subject: [PATCH 2/6] Add unit tests --- .../assets/json/SetMediaClockTimer.json | 3 +- .../test/proxy/RPCRequestFactoryTests.java | 7 +- .../test/proxy/SdlProxyBaseTests.java | 6 ++ .../OnSeekMediaClockTimerTests.java | 62 ++++++++++++++++ .../rpc/requests/SetMediaClockTimerTests.java | 13 +++- .../proxy/RPCRequestFactory.java | 20 ++++- .../smartdevicelink/proxy/SdlProxyBase.java | 74 ++++++++++++++++--- 7 files changed, 166 insertions(+), 19 deletions(-) create mode 100644 sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnSeekMediaClockTimerTests.java diff --git a/sdl_android/src/androidTest/assets/json/SetMediaClockTimer.json b/sdl_android/src/androidTest/assets/json/SetMediaClockTimer.json index af16712009..57fbacfa05 100644 --- a/sdl_android/src/androidTest/assets/json/SetMediaClockTimer.json +++ b/sdl_android/src/androidTest/assets/json/SetMediaClockTimer.json @@ -13,7 +13,8 @@ "seconds":19, "hours":12 }, - "updateMode":"COUNTDOWN" + "updateMode":"COUNTDOWN", + "enableSeek": true } }, "response":{ diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCRequestFactoryTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCRequestFactoryTests.java index e31aedbe70..f30febd11d 100644 --- a/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCRequestFactoryTests.java +++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCRequestFactoryTests.java @@ -722,20 +722,23 @@ public void testBuildSetGlobalProperties () { public void testBuildSetMediaClockTimer () { Integer hours = 0, minutes = 0, seconds = 0, testCorrelationID = 0; + Boolean enableSeek = true; UpdateMode testMode = UpdateMode.COUNTUP; SetMediaClockTimer testSMCT; // Test -- buildSetMediaClockTimer(Integer hours, Integer minutes, Integer seconds, UpdateMode updateMode, Integer correlationID) - testSMCT = RPCRequestFactory.buildSetMediaClockTimer(hours, minutes, seconds, testMode, testCorrelationID); + testSMCT = RPCRequestFactory.buildSetMediaClockTimer(hours, minutes, seconds, testMode, enableSeek, testCorrelationID); assertEquals(Test.MATCH, hours, testSMCT.getStartTime().getHours()); assertEquals(Test.MATCH, minutes, testSMCT.getStartTime().getMinutes()); assertEquals(Test.MATCH, seconds, testSMCT.getStartTime().getSeconds()); assertEquals(Test.MATCH, testMode, testSMCT.getUpdateMode()); + assertEquals(Test.MATCH, enableSeek, testSMCT.getEnableSeek()); assertEquals(Test.MATCH, testCorrelationID, testSMCT.getCorrelationID()); - testSMCT = RPCRequestFactory.buildSetMediaClockTimer(null, null, null, null, null); + testSMCT = RPCRequestFactory.buildSetMediaClockTimer(null, null, null, null, null, null); assertNull(Test.NULL, testSMCT.getStartTime()); assertNull(Test.NULL, testSMCT.getUpdateMode()); + assertNull(Test.NULL, testSMCT.getEnableSeek()); assertNotNull(Test.NOT_NULL, testSMCT.getCorrelationID()); // Test -- buildSetMediaClockTimer(UpdateMode updateMode, Integer correlationID) 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 b50f6f48d2..1792b68023 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 @@ -50,6 +50,7 @@ import com.smartdevicelink.proxy.rpc.OnLanguageChange; import com.smartdevicelink.proxy.rpc.OnLockScreenStatus; import com.smartdevicelink.proxy.rpc.OnPermissionsChange; +import com.smartdevicelink.proxy.rpc.OnSeekMediaClockTimer; import com.smartdevicelink.proxy.rpc.OnStreamRPC; import com.smartdevicelink.proxy.rpc.OnSystemRequest; import com.smartdevicelink.proxy.rpc.OnTBTClientState; @@ -619,5 +620,10 @@ public void onGenericResponse(GenericResponse response) { public void onSendHapticDataResponse(SendHapticDataResponse response) { Log.i(TAG, "SendHapticDataResponse response from SDL: " + response); } + + @Override + public void onSeekMediaClockTimer(OnSeekMediaClockTimer notification) { + + } } } diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnSeekMediaClockTimerTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnSeekMediaClockTimerTests.java new file mode 100644 index 0000000000..4c7d97b38b --- /dev/null +++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnSeekMediaClockTimerTests.java @@ -0,0 +1,62 @@ +package com.smartdevicelink.test.rpc.notifications; + +import com.smartdevicelink.protocol.enums.FunctionID; +import com.smartdevicelink.proxy.RPCMessage; +import com.smartdevicelink.proxy.rpc.OnSeekMediaClockTimer; +import com.smartdevicelink.proxy.rpc.StartTime; +import com.smartdevicelink.test.BaseRpcTests; +import com.smartdevicelink.test.Test; + +import org.json.JSONException; +import org.json.JSONObject; + + +public class OnSeekMediaClockTimerTests extends BaseRpcTests { + @Override + protected RPCMessage createMessage(){ + OnSeekMediaClockTimer msg = new OnSeekMediaClockTimer(); + msg.setSeekTime(Test.GENERAL_STARTTIME); + + return msg; + } + + @Override + protected String getMessageType(){ + return RPCMessage.KEY_NOTIFICATION; + } + + @Override + protected String getCommandType(){ + return FunctionID.ON_SEEK_MEDIA_CLOCK_TIMER.toString(); + } + + @Override + protected JSONObject getExpectedParameters(int sdlVersion){ + JSONObject result = new JSONObject(); + try { + result.put(OnSeekMediaClockTimer.KEY_SEEK_TIME, Test.JSON_STARTTIME); + } catch (JSONException e) { + e.printStackTrace(); + } + + return result; + } + + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Test Values + StartTime seekTime = ((OnSeekMediaClockTimer) msg).getSeekTime(); + + // Valid Tests + assertEquals(Test.MATCH, Test.GENERAL_STARTTIME, seekTime); + + // Invalid/Null Tests + OnSeekMediaClockTimer msg = new OnSeekMediaClockTimer(); + assertNotNull(Test.NOT_NULL, msg); + testNullBase(msg); + + assertNull(Test.NULL, msg.getSeekTime()); + } +} diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetMediaClockTimerTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetMediaClockTimerTests.java index 7d52bb75ce..27234291b9 100644 --- a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetMediaClockTimerTests.java +++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetMediaClockTimerTests.java @@ -19,7 +19,7 @@ /** * This is a unit test class for the SmartDeviceLink library project class : - * {@link com.smartdevicelink.rpc.SetMediaClockTimer} + * {@link com.smartdevicelink.proxy.rpc.SetMediaClockTimer} */ public class SetMediaClockTimerTests extends BaseRpcTests { @@ -30,6 +30,7 @@ protected RPCMessage createMessage() { msg.setStartTime(Test.GENERAL_STARTTIME); msg.setEndTime(Test.GENERAL_STARTTIME); msg.setUpdateMode(Test.GENERAL_UPDATEMODE); + msg.setEnableSeek(Test.GENERAL_BOOLEAN); return msg; } @@ -51,7 +52,8 @@ protected JSONObject getExpectedParameters(int sdlVersion) { try { result.put(SetMediaClockTimer.KEY_START_TIME, Test.JSON_STARTTIME); result.put(SetMediaClockTimer.KEY_END_TIME, Test.JSON_STARTTIME); - result.put(SetMediaClockTimer.KEY_UPDATE_MODE, Test.GENERAL_UPDATEMODE); + result.put(SetMediaClockTimer.KEY_UPDATE_MODE, Test.GENERAL_UPDATEMODE); + result.put(SetMediaClockTimer.KEY_ENABLE_SEEK, Test.GENERAL_BOOLEAN); } catch (JSONException e) { fail(Test.JSON_FAIL); } @@ -67,12 +69,14 @@ public void testRpcValues () { StartTime testStartTime = ( (SetMediaClockTimer) msg ).getStartTime(); StartTime testEndTime = ( (SetMediaClockTimer) msg ).getEndTime(); UpdateMode testUpdateMode = ( (SetMediaClockTimer) msg ).getUpdateMode(); + Boolean testEnableSeek = ( (SetMediaClockTimer) msg ).getEnableSeek(); // Valid Tests assertEquals(Test.MATCH, Test.GENERAL_UPDATEMODE, testUpdateMode); assertTrue(Test.TRUE, Validator.validateStartTime(Test.GENERAL_STARTTIME, testStartTime)); assertTrue(Test.TRUE, Validator.validateStartTime(Test.GENERAL_STARTTIME, testEndTime)); - + assertEquals(Test.MATCH, Boolean.valueOf(Test.GENERAL_BOOLEAN), testEnableSeek); + // Invalid/Null Tests SetMediaClockTimer msg = new SetMediaClockTimer(); assertNotNull(Test.NOT_NULL, msg); @@ -81,6 +85,7 @@ public void testRpcValues () { assertNull(Test.NULL, msg.getStartTime()); assertNull(Test.NULL, msg.getEndTime()); assertNull(Test.NULL, msg.getUpdateMode()); + assertNull(Test.NULL, msg.getEnableSeek()); } /** @@ -110,6 +115,8 @@ public void testJsonConstructor () { StartTime referenceEndTime = new StartTime(JsonRPCMarshaller.deserializeJSONObject(endTime)); assertTrue(Test.TRUE, Validator.validateStartTime(referenceEndTime, cmd.getEndTime())); assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(parameters, SetMediaClockTimer.KEY_UPDATE_MODE), cmd.getUpdateMode().toString()); + + assertEquals(Test.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, SetMediaClockTimer.KEY_ENABLE_SEEK), cmd.getEnableSeek()); } catch (JSONException e) { fail(Test.JSON_FAIL); } diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCRequestFactory.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCRequestFactory.java index e249839d5b..80ddf36b01 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCRequestFactory.java +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCRequestFactory.java @@ -691,10 +691,10 @@ public static SetGlobalProperties buildSetGlobalProperties( return req; } - + public static SetMediaClockTimer buildSetMediaClockTimer(Integer hours, - Integer minutes, Integer seconds, UpdateMode updateMode, - Integer correlationID) { + Integer minutes, Integer seconds, UpdateMode updateMode, + Boolean enableSeek, Integer correlationID) { SetMediaClockTimer msg = new SetMediaClockTimer(); if (hours != null || minutes != null || seconds != null) { @@ -706,10 +706,21 @@ public static SetMediaClockTimer buildSetMediaClockTimer(Integer hours, } msg.setUpdateMode(updateMode); + msg.setEnableSeek(enableSeek); msg.setCorrelationID(correlationID); return msg; } + + @Deprecated + public static SetMediaClockTimer buildSetMediaClockTimer(Integer hours, + Integer minutes, Integer seconds, UpdateMode updateMode, + Integer correlationID) { + + SetMediaClockTimer msg = buildSetMediaClockTimer(hours, minutes, seconds, updateMode, null, correlationID); + + return msg; + } @Deprecated public static SetMediaClockTimer buildSetMediaClockTimer( @@ -717,9 +728,10 @@ public static SetMediaClockTimer buildSetMediaClockTimer( Integer hours = null; Integer minutes = null; Integer seconds = null; + Boolean enableSeek = null; SetMediaClockTimer msg = buildSetMediaClockTimer(hours, minutes, - seconds, updateMode, correlationID); + seconds, updateMode, enableSeek, correlationID); return msg; } 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 9b76f51cd1..eaaa81ae64 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java @@ -5422,8 +5422,29 @@ public void resetGlobalProperties(Vector properties, sendRPCRequest(req); } - - + + /** + * Sends a SetMediaClockTimer RPCRequest to SDL. Responses are captured through callback on IProxyListener. + * + * @param hours integer for hours + * @param minutes integer for minutes + * @param seconds integer for seconds + * @param updateMode mode in which the media clock timer should be updated + * @param correlationID ID to be attached to the RPCRequest that correlates the RPCResponse + * @param enableSeek a Boolean representing whether seek media clock timer functionality will be available + * @throws SdlException if an unrecoverable error is encountered + */ + @SuppressWarnings("unused") + public void setMediaClockTimer(Integer hours, + Integer minutes, Integer seconds, UpdateMode updateMode, + Boolean enableSeek, Integer correlationID) throws SdlException { + + SetMediaClockTimer msg = RPCRequestFactory.buildSetMediaClockTimer(hours, + minutes, seconds, updateMode, null, correlationID); + + sendRPCRequest(msg); + } + /** * Sends a SetMediaClockTimer RPCRequest to SDL. Responses are captured through callback on IProxyListener. * @@ -5435,19 +5456,37 @@ public void resetGlobalProperties(Vector properties, * @throws SdlException if an unrecoverable error is encountered */ @SuppressWarnings("unused") + @Deprecated public void setMediaClockTimer(Integer hours, Integer minutes, Integer seconds, UpdateMode updateMode, Integer correlationID) throws SdlException { SetMediaClockTimer msg = RPCRequestFactory.buildSetMediaClockTimer(hours, - minutes, seconds, updateMode, correlationID); + minutes, seconds, updateMode, null, correlationID); sendRPCRequest(msg); } - + /** * Pauses the media clock. Responses are captured through callback on IProxyListener. - * + * + * @param correlationID ID to be attached to the RPCRequest that correlates the RPCResponse + * @param enableSeek a Boolean representing whether seek media clock timer functionality will be available + * @throws SdlException if an unrecoverable error is encountered + */ + @SuppressWarnings("unused") + public void pauseMediaClockTimer(Integer correlationID, Boolean enableSeek) + throws SdlException { + + SetMediaClockTimer msg = RPCRequestFactory.buildSetMediaClockTimer(0, + 0, 0, UpdateMode.PAUSE, enableSeek, correlationID); + + sendRPCRequest(msg); + } + + /** + * Pauses the media clock. Responses are captured through callback on IProxyListener. + * * @param correlationID ID to be attached to the RPCRequest that correlates the RPCResponse * @throws SdlException if an unrecoverable error is encountered */ @@ -5456,11 +5495,28 @@ public void pauseMediaClockTimer(Integer correlationID) throws SdlException { SetMediaClockTimer msg = RPCRequestFactory.buildSetMediaClockTimer(0, - 0, 0, UpdateMode.PAUSE, correlationID); + 0, 0, UpdateMode.PAUSE, null, correlationID); sendRPCRequest(msg); } - + + /** + * Resumes the media clock. Responses are captured through callback on IProxyListener. + * + * @param correlationID ID to be attached to the RPCRequest that correlates the RPCResponse + * @param enableSeek a Boolean representing whether seek media clock timer functionality will be available + * @throws SdlException if an unrecoverable error is encountered + */ + @SuppressWarnings("unused") + public void resumeMediaClockTimer(Integer correlationID, Boolean enableSeek) + throws SdlException { + + SetMediaClockTimer msg = RPCRequestFactory.buildSetMediaClockTimer(0, + 0, 0, UpdateMode.RESUME, enableSeek, correlationID); + + sendRPCRequest(msg); + } + /** * Resumes the media clock. Responses are captured through callback on IProxyListener. * @@ -5472,11 +5528,11 @@ public void resumeMediaClockTimer(Integer correlationID) throws SdlException { SetMediaClockTimer msg = RPCRequestFactory.buildSetMediaClockTimer(0, - 0, 0, UpdateMode.RESUME, correlationID); + 0, 0, UpdateMode.RESUME, null, correlationID); sendRPCRequest(msg); } - + /** * Clears the media clock. Responses are captured through callback on IProxyListener. * From 80d4892a2f9bf3182a42084f1631876f6e19628e Mon Sep 17 00:00:00 2001 From: Bilal Date: Wed, 2 May 2018 09:36:57 -0400 Subject: [PATCH 3/6] Update Javadoc comments --- .../proxy/RPCRequestFactory.java | 5 +-- .../proxy/rpc/OnSeekMediaClockTimer.java | 37 +++++++++---------- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCRequestFactory.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCRequestFactory.java index 80ddf36b01..f24fcafce8 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCRequestFactory.java +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCRequestFactory.java @@ -692,9 +692,8 @@ public static SetGlobalProperties buildSetGlobalProperties( return req; } - public static SetMediaClockTimer buildSetMediaClockTimer(Integer hours, - Integer minutes, Integer seconds, UpdateMode updateMode, - Boolean enableSeek, Integer correlationID) { + public static SetMediaClockTimer buildSetMediaClockTimer(Integer hours, Integer minutes, + Integer seconds, UpdateMode updateMode, Boolean enableSeek, Integer correlationID) { SetMediaClockTimer msg = new SetMediaClockTimer(); if (hours != null || minutes != null || seconds != null) { diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnSeekMediaClockTimer.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnSeekMediaClockTimer.java index e6df928ca2..da6d27d9be 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnSeekMediaClockTimer.java +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnSeekMediaClockTimer.java @@ -9,28 +9,25 @@ * Callback for the seek media clock timer notification. Notifies the application of * progress bar seek event on the media clock timer. System will automatically update * the media clock timer position based on the seek notification location. - *

    - *

    - * Parameter List: + *

    Parameter List

    * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * *
    NameTypeDescriptionReqNotesSmartDeviceLink Ver Available
    seekTimeStartTimeDescribes the hour, minute and second values used for the current media clock timer.YSmartDeviceLink 4.7
    NameTypeDescriptionReqNotesSmartDeviceLink Ver Available
    seekTimeStartTimeDescribes the hour, minute and second values used for the current media clock timer.YSmartDeviceLink 4.7
    - *

    */ public class OnSeekMediaClockTimer extends RPCNotification { From 78db0111b92b3a36f7f97af98bee2ca73472f1a2 Mon Sep 17 00:00:00 2001 From: Bilal Date: Wed, 2 May 2018 11:19:49 -0400 Subject: [PATCH 4/6] Deprecate old methods --- .../src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java | 2 ++ 1 file changed, 2 insertions(+) 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 eaaa81ae64..4570bb3384 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java @@ -5491,6 +5491,7 @@ public void pauseMediaClockTimer(Integer correlationID, Boolean enableSeek) * @throws SdlException if an unrecoverable error is encountered */ @SuppressWarnings("unused") + @Deprecated public void pauseMediaClockTimer(Integer correlationID) throws SdlException { @@ -5524,6 +5525,7 @@ public void resumeMediaClockTimer(Integer correlationID, Boolean enableSeek) * @throws SdlException if an unrecoverable error is encountered */ @SuppressWarnings("unused") + @Deprecated public void resumeMediaClockTimer(Integer correlationID) throws SdlException { From 31ac2dd40a01282adbd5e89cf386bfc5559944a9 Mon Sep 17 00:00:00 2001 From: Bilal Date: Wed, 2 May 2018 13:25:00 -0400 Subject: [PATCH 5/6] Added JSON file to test OnSeekMediaClockTimer --- .../assets/json/OnSeekMediaClockTimer.json | 13 ++++++++ .../OnSeekMediaClockTimerTests.java | 33 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 sdl_android/src/androidTest/assets/json/OnSeekMediaClockTimer.json diff --git a/sdl_android/src/androidTest/assets/json/OnSeekMediaClockTimer.json b/sdl_android/src/androidTest/assets/json/OnSeekMediaClockTimer.json new file mode 100644 index 0000000000..4b3aff677f --- /dev/null +++ b/sdl_android/src/androidTest/assets/json/OnSeekMediaClockTimer.json @@ -0,0 +1,13 @@ +{ + "notification":{ + "name":"OnSeekMediaClockTimer", + "correlationID":150, + "parameters":{ + "seekTime":{ + "minutes":55, + "seconds":19, + "hours":12 + } + } + } +} \ No newline at end of file diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnSeekMediaClockTimerTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnSeekMediaClockTimerTests.java index 4c7d97b38b..ac6477bcf3 100644 --- a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnSeekMediaClockTimerTests.java +++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnSeekMediaClockTimerTests.java @@ -1,15 +1,21 @@ package com.smartdevicelink.test.rpc.notifications; +import com.smartdevicelink.marshal.JsonRPCMarshaller; import com.smartdevicelink.protocol.enums.FunctionID; import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.proxy.rpc.OnSeekMediaClockTimer; import com.smartdevicelink.proxy.rpc.StartTime; import com.smartdevicelink.test.BaseRpcTests; +import com.smartdevicelink.test.JsonUtils; import com.smartdevicelink.test.Test; +import com.smartdevicelink.test.Validator; +import com.smartdevicelink.test.json.rpc.JsonFileReader; import org.json.JSONException; import org.json.JSONObject; +import java.util.Hashtable; + public class OnSeekMediaClockTimerTests extends BaseRpcTests { @Override @@ -59,4 +65,31 @@ public void testRpcValues () { assertNull(Test.NULL, msg.getSeekTime()); } + + /** + * Tests a valid JSON construction of this RPC message. + */ + public void testJsonConstructor () { + JSONObject commandJson = JsonFileReader.readId(this.mContext, getCommandType(), getMessageType()); + assertNotNull(Test.NOT_NULL, commandJson); + + try { + Hashtable hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); + OnSeekMediaClockTimer cmd = new OnSeekMediaClockTimer(hash); + + JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); + assertNotNull(Test.NOT_NULL, body); + + // Test everything in the json body. + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); + + JSONObject parameters = JsonUtils.readJsonObjectFromJsonObject(body, RPCMessage.KEY_PARAMETERS); + JSONObject seekTime = JsonUtils.readJsonObjectFromJsonObject(parameters, OnSeekMediaClockTimer.KEY_SEEK_TIME); + StartTime referenceSeekTime = new StartTime(JsonRPCMarshaller.deserializeJSONObject(seekTime)); + assertTrue(Test.TRUE, Validator.validateStartTime(referenceSeekTime, cmd.getSeekTime())); + + } catch (JSONException e) { + fail(Test.JSON_FAIL); + } + } } From d9ea6ac7185bfc54d58279a3455313f51360bfd9 Mon Sep 17 00:00:00 2001 From: Bilal Date: Wed, 23 May 2018 11:56:31 -0400 Subject: [PATCH 6/6] =?UTF-8?q?Updates=20per=20Joey=E2=80=99s=20comments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sdl_android/build.gradle | 1 + .../proxy/rpc/OnSeekMediaClockTimer.java | 13 +++++++++++-- .../proxy/rpc/SetMediaClockTimer.java | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/sdl_android/build.gradle b/sdl_android/build.gradle index 7904206a95..bdce1c53dd 100644 --- a/sdl_android/build.gradle +++ b/sdl_android/build.gradle @@ -42,6 +42,7 @@ dependencies { }) testImplementation 'junit:junit:4.12' testImplementation 'org.mockito:mockito-core:2.9.0' + implementation 'com.android.support:support-annotations:27.1.1' } diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnSeekMediaClockTimer.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnSeekMediaClockTimer.java index da6d27d9be..445594fb65 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnSeekMediaClockTimer.java +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnSeekMediaClockTimer.java @@ -1,5 +1,7 @@ package com.smartdevicelink.proxy.rpc; +import android.support.annotation.NonNull; + import com.smartdevicelink.protocol.enums.FunctionID; import com.smartdevicelink.proxy.RPCNotification; @@ -25,7 +27,7 @@ * Describes the hour, minute and second values used for the current media clock timer. * Y * - * SmartDeviceLink 4.7 + * SmartDeviceLink 4.6 * * */ @@ -46,6 +48,13 @@ public OnSeekMediaClockTimer() { public OnSeekMediaClockTimer(Hashtable hash) { super(hash); } + /** + *Constructs a newly allocated OnSeekMediaClockTimer object + */ + public OnSeekMediaClockTimer(@NonNull StartTime seekTime) { + this(); + setSeekTime(seekTime); + } /** * Gets the StartTime object representing the current media clock timer * @@ -59,7 +68,7 @@ public StartTime getSeekTime() { * * @param seekTime -a StartTime object with specifying hour, minute, second values */ - public void setSeekTime( StartTime seekTime ) { + public void setSeekTime( @NonNull StartTime seekTime ) { setParameters(KEY_SEEK_TIME, seekTime); } diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetMediaClockTimer.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetMediaClockTimer.java index 29951c773e..b24905a79c 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetMediaClockTimer.java +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetMediaClockTimer.java @@ -57,7 +57,7 @@ * Defines if seek media clock timer functionality will be available. * N * If omitted, the value is set to false. The value is retained until the next SetMediaClockTimer is sent. - * SmartDeviceLink 4.7 + * SmartDeviceLink 4.6 * * *