From e9942337a6edfe80397af31fdb25b07f46590c92 Mon Sep 17 00:00:00 2001 From: Mike Burke Date: Wed, 18 Feb 2015 15:00:46 -0500 Subject: [PATCH 1/4] Implemented TBT APIs. Fixes #109 Signed-off-by: Mike Burke --- .../proxy/rpc/AlertManeuver.java | 139 +++++++ .../proxy/rpc/AlertManeuverResponse.java | 35 ++ .../proxy/rpc/ShowConstantTbt.java | 356 ++++++++++++++++++ .../proxy/rpc/ShowConstantTbtResponse.java | 23 ++ .../com/smartdevicelink/proxy/rpc/Turn.java | 101 +++++ .../proxy/rpc/UpdateTurnList.java | 140 +++++++ .../proxy/rpc/UpdateTurnListResponse.java | 26 ++ 7 files changed, 820 insertions(+) create mode 100644 sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AlertManeuver.java create mode 100644 sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AlertManeuverResponse.java create mode 100644 sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ShowConstantTbt.java create mode 100644 sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ShowConstantTbtResponse.java create mode 100644 sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Turn.java create mode 100644 sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UpdateTurnList.java create mode 100644 sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UpdateTurnListResponse.java diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AlertManeuver.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AlertManeuver.java new file mode 100644 index 0000000000..791c89a1b8 --- /dev/null +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AlertManeuver.java @@ -0,0 +1,139 @@ +package com.smartdevicelink.proxy.rpc; + +import java.util.ArrayList; +import java.util.Hashtable; +import java.util.List; + +import com.smartdevicelink.protocol.enums.FunctionID; +import com.smartdevicelink.proxy.RPCRequest; + +/** + * This will bring up an alert with information related to the next navigation maneuver including potential voice + * navigation instructions. Shown information will be taken from the ShowConstantTBT function + *

+ * Function Group: Navigation + *

+ * HMILevel needs to be FULL, LIMITED or BACKGROUND + *

+ * + * @since SmartDeviceLink 2.0 + * @see ShowConstantTbt + */ +public class AlertManeuver extends RPCRequest{ + + public static final String KEY_TTS_CHUNKS = "ttsChunks"; + public static final String KEY_SOFT_BUTTONS = "softButtons"; + + /** + * Constructs a new AlertManeuver object + */ + public AlertManeuver(){ + super(FunctionID.ALERT_MANEUVER); + } + + /** + *

+ * Constructs a new AlertManeuver object indicated by the Hashtable parameter + *

+ * + * @param hash + * The Hashtable to use + */ + public AlertManeuver(Hashtable hash){ + super(hash); + } + + /** + * Gets the SoftButton List object + * + * @return List -a List representing the List object + * @since SmartDeviceLink 2.0 + */ + @SuppressWarnings("unchecked") + public List getSoftButtons(){ + if(parameters.get(KEY_SOFT_BUTTONS) instanceof List){ + List list = (List) parameters.get(KEY_SOFT_BUTTONS); + if(list != null && list.size() > 0){ + Object obj = list.get(0); + if(obj instanceof SoftButton){ + return (List) list; + } + else if(obj instanceof Hashtable){ + List newList = new ArrayList(); + for(Object hashObj : list){ + newList.add(new SoftButton((Hashtable) hashObj)); + } + return newList; + } + } + } + return null; + } + + /** + * Sets the SoftButtons + * + * @param softButtons + * a List value + *

+ * Notes:
+ *

    + *
  • If omitted on supported displays, the alert will not have any SoftButton
  • + *
  • ArrayMin: 0
  • + *
  • ArrayMax: 4
  • + *
+ * @since SmartDeviceLink 2.0 + */ + + public void setSoftButtons(List softButtons){ + if(softButtons != null){ + parameters.put(KEY_SOFT_BUTTONS, softButtons); + } + else{ + parameters.remove(KEY_SOFT_BUTTONS); + } + } + + /** + * Gets TTSChunk[], the Array of type TTSChunk which, taken together, specify what is to be spoken to the user + * + * @return List -a List value specify what is to be spoken to the user + */ + @SuppressWarnings("unchecked") + public List getTtsChunks(){ + if(parameters.get(KEY_TTS_CHUNKS) instanceof List){ + List list = (List) parameters.get(KEY_TTS_CHUNKS); + if(list != null && list.size() > 0){ + Object obj = list.get(0); + if(obj instanceof TTSChunk){ + return (List) list; + } + else if(obj instanceof Hashtable){ + List newList = new ArrayList(); + for(Object hashObj : list){ + newList.add(new TTSChunk((Hashtable) hashObj)); + } + return newList; + } + } + } + return null; + } + + /** + * Sets array of type TTSChunk which, taken together, specify what is to be spoken to the user + * + * @param ttsChunks + *

+ * Notes: Array must have a least one element + */ + public void setTtsChunks(List ttsChunks){ + if(ttsChunks != null){ + parameters.put(KEY_TTS_CHUNKS, ttsChunks); + } + else{ + parameters.remove(KEY_TTS_CHUNKS); + } + } + +} diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AlertManeuverResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AlertManeuverResponse.java new file mode 100644 index 0000000000..24d5dc7107 --- /dev/null +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AlertManeuverResponse.java @@ -0,0 +1,35 @@ +package com.smartdevicelink.proxy.rpc; + +import java.util.Hashtable; + +import com.smartdevicelink.protocol.enums.FunctionID; +import com.smartdevicelink.proxy.RPCResponse; + +/** + * Alert Maneuver Response is sent, when AlertManeuver has been called + * + * @since SmartDeviceLink 2.0 + */ +public class AlertManeuverResponse extends RPCResponse{ + + /** + * Constructs a new AlertManeuverResponse object + */ + public AlertManeuverResponse() { + super(FunctionID.ALERT_MANEUVER); + } + + /** + *

+ * Constructs a new AlertManeuverResponse object indicated by the Hashtable + * parameter + *

+ * + * @param hash + * The Hashtable to use + */ + public AlertManeuverResponse(Hashtable hash) { + super(hash); + } + +} diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ShowConstantTbt.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ShowConstantTbt.java new file mode 100644 index 0000000000..e53851e946 --- /dev/null +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ShowConstantTbt.java @@ -0,0 +1,356 @@ +package com.smartdevicelink.proxy.rpc; + +import java.util.ArrayList; +import java.util.Hashtable; +import java.util.List; + +import com.smartdevicelink.protocol.enums.FunctionID; +import com.smartdevicelink.proxy.RPCRequest; + +/** + * This RPC is used to update the user with navigation information for the constantly shown screen (base screen), but + * also for the alert type screen + *

+ * Function Group: Navigation + *

+ * HMILevel needs to be FULL, LIMITED or BACKGROUND + *

+ * + * @since SmartDeviceLink 2.0 + * @see AlertManeuver + * @see UpdateTurnList + */ +public class ShowConstantTbt extends RPCRequest{ + + public static final String KEY_TEXT1 = "navigationText1"; + public static final String KEY_TEXT2 = "navigationText2"; + public static final String KEY_ETA = "eta"; + public static final String KEY_TOTAL_DISTANCE = "totalDistance"; + public static final String KEY_MANEUVER_DISTANCE = "distanceToManeuver"; + public static final String KEY_MANEUVER_DISTANCE_SCALE = "distanceToManeuverScale"; + public static final String KEY_MANEUVER_IMAGE = "turnIcon"; + public static final String KEY_NEXT_MANEUVER_IMAGE = "nextTurnIcon"; + public static final String KEY_MANEUVER_COMPLETE = "maneuverComplete"; + public static final String KEY_SOFT_BUTTONS = "softButtons"; + public static final String KEY_TIME_TO_DESTINATION = "timeToDestination"; + + /** + * Constructs a new ShowConstantTbt object + */ + public ShowConstantTbt(){ + super(FunctionID.SHOW_CONSTANT_TBT); + } + + /** + * Constructs a new ShowConstantTbt object indicated by the Hashtable parameter + *

+ * + * @param hash + * The Hashtable to use + */ + public ShowConstantTbt(Hashtable hash){ + super(hash); + } + + /** + * Sets a text for navigation text field 1 + * + * @param navigationText1 + * a String value representing a text for navigation text field 1 + *

+ * Notes: Maxlength=500 + */ + public void setNavigationText1(String navigationText1){ + if(navigationText1 != null){ + parameters.put(KEY_TEXT1, navigationText1); + } + else{ + parameters.remove(KEY_TEXT1); + } + } + + /** + * Gets a text for navigation text field 1 + * + * @return String -a String value representing a text for navigation text field 1 + */ + public String getNavigationText1(){ + return (String) parameters.get(KEY_TEXT1); + } + + /** + * Sets a text for navigation text field 2 + * + * @param navigationText2 + * a String value representing a text for navigation text field 2 + *

+ * Notes: Maxlength=500 + */ + public void setNavigationText2(String navigationText2){ + if(navigationText2 != null){ + parameters.put(KEY_TEXT2, navigationText2); + } + else{ + parameters.remove(KEY_TEXT2); + } + } + + /** + * Gets a text for navigation text field 2 + * + * @return String -a String value representing a text for navigation text field 2 + */ + public String getNavigationText2(){ + return (String) parameters.get(KEY_TEXT2); + } + + /** + * Sets a text field for estimated time of arrival + * + * @param eta + * a String value representing a text field for estimated time of arrival + *

+ * Notes: Maxlength=500 + */ + public void setEta(String eta){ + if(eta != null){ + parameters.put(KEY_ETA, eta); + } + else{ + parameters.remove(KEY_ETA); + } + } + + /** + * Gets a text field for estimated time of arrival + * + * @return String -a String value representing a text field for estimated time of arrival + */ + public String getEta(){ + return (String) parameters.get(KEY_ETA); + } + + /** + * Sets a text field for total distance + * + * @param totalDistance + * a String value representing a text field for total distance + *

+ * Notes: Maxlength=500 + */ + public void setTotalDistance(String totalDistance){ + if(totalDistance != null){ + parameters.put(KEY_TOTAL_DISTANCE, totalDistance); + } + else{ + parameters.remove(KEY_TOTAL_DISTANCE); + } + } + + /** + * Gets a text field for total distance + * + * @return String -a String value representing a text field for total distance + */ + public String getTotalDistance(){ + return (String) parameters.get(KEY_TOTAL_DISTANCE); + } + + /** + * Sets an Image for turnicon + * + * @param turnIcon + * an Image value + */ + public void setTurnIcon(Image turnIcon){ + if(turnIcon != null){ + parameters.put(KEY_MANEUVER_IMAGE, turnIcon); + } + else{ + parameters.remove(KEY_MANEUVER_IMAGE); + } + } + + /** + * Gets an Image for turnicon + * + * @return Image -an Image value representing an Image for turnicon + */ + @SuppressWarnings("unchecked") + public Image getTurnIcon(){ + Object obj = parameters.get(KEY_MANEUVER_IMAGE); + if (obj instanceof Image) { + return (Image) obj; + } else if (obj instanceof Hashtable) { + return new Image((Hashtable) obj); + } + return null; + } + + /** + * Sets an Image for nextTurnIcon + * + * @param nextTurnIcon + * an Image value + */ + public void setNextTurnIcon(Image nextTurnIcon){ + if(nextTurnIcon != null){ + parameters.put(KEY_NEXT_MANEUVER_IMAGE, nextTurnIcon); + } + else{ + parameters.remove(KEY_NEXT_MANEUVER_IMAGE); + } + } + + /** + * Gets an Image for nextTurnIcon + * + * @return Image -an Image value representing an Image for nextTurnIcon + */ + @SuppressWarnings("unchecked") + public Image getNextTurnIcon(){ + Object obj = parameters.get(KEY_NEXT_MANEUVER_IMAGE); + if (obj instanceof Image) { + return (Image) obj; + } else if (obj instanceof Hashtable) { + return new Image((Hashtable) obj); + } + return null; + } + + /** + * Sets a Fraction of distance till next maneuver + * + * @param distanceToManeuver + * a Double value representing a Fraction of distance till next maneuver + *

+ * Notes: Minvalue=0; Maxvalue=1000000000 + */ + public void setDistanceToManeuver(Double distanceToManeuver){ + if(distanceToManeuver != null){ + parameters.put(KEY_MANEUVER_DISTANCE, distanceToManeuver); + } + else{ + parameters.remove(KEY_MANEUVER_DISTANCE); + } + } + + /** + * Gets a Fraction of distance till next maneuver + * + * @return Double -a Double value representing a Fraction of distance till next maneuver + */ + public Double getDistanceToManeuver(){ + return (Double) parameters.get(KEY_MANEUVER_DISTANCE); + } + + /** + * Sets a Distance till next maneuver (starting from) from previous maneuver + * + * @param distanceToManeuverScale + * a Double value representing a Distance till next maneuver (starting from) from previous maneuver + *

+ * Notes: Minvalue=0; Maxvalue=1000000000 + */ + public void setDistanceToManeuverScale(Double distanceToManeuverScale){ + if(distanceToManeuverScale != null){ + parameters.put(KEY_MANEUVER_DISTANCE_SCALE, distanceToManeuverScale); + } + else{ + parameters.remove(KEY_MANEUVER_DISTANCE_SCALE); + } + } + + /** + * Gets a Distance till next maneuver (starting from) from previous maneuver + * + * @return Double -a Double value representing a Distance till next maneuver (starting from) from previous maneuver + */ + public Double getDistanceToManeuverScale(){ + return (Double) parameters.get(KEY_MANEUVER_DISTANCE_SCALE); + } + + /** + * Sets a maneuver complete flag. If and when a maneuver has completed while an AlertManeuver is active, the app + * must send this value set to TRUE in order to clear the AlertManeuver overlay
+ * If omitted the value will be assumed as FALSE + *

+ * + * @param maneuverComplete + * a Boolean value + */ + public void setManeuverComplete(Boolean maneuverComplete){ + if(maneuverComplete != null){ + parameters.put(KEY_MANEUVER_COMPLETE, maneuverComplete); + } + else{ + parameters.remove(KEY_MANEUVER_COMPLETE); + } + } + + /** + * Gets a maneuver complete flag + * + * @return Boolean -a Boolean value + */ + public Boolean getManeuverComplete(){ + return (Boolean) parameters.get(KEY_MANEUVER_COMPLETE); + } + + /** + * Sets Three dynamic SoftButtons available (first SoftButton is fixed to "Turns"). If omitted on supported + * displays, the currently displayed SoftButton values will not change + *

+ * Notes: Minsize=0; Maxsize=3 + * + * @param softButtons + * a List value + */ + public void setSoftButtons(List softButtons){ + if(softButtons != null){ + parameters.put(KEY_SOFT_BUTTONS, softButtons); + } + else{ + parameters.remove(KEY_SOFT_BUTTONS); + } + } + + /** + * Gets Three dynamic SoftButtons available (first SoftButton is fixed to "Turns"). If omitted on supported + * displays, the currently displayed SoftButton values will not change + * + * @return Vector -a Vector value + */ + @SuppressWarnings("unchecked") + public List getSoftButtons(){ + if (parameters.get(KEY_SOFT_BUTTONS) instanceof List) { + List list = (List)parameters.get(KEY_SOFT_BUTTONS); + if (list != null && list.size() > 0) { + Object obj = list.get(0); + if (obj instanceof SoftButton) { + return (List) list; + } else if (obj instanceof Hashtable) { + List newList = new ArrayList(); + for (Object hashObj : list) { + newList.add(new SoftButton((Hashtable)hashObj)); + } + return newList; + } + } + } + return null; + } + + public void setTimeToDestination(String timeToDestination){ + if(timeToDestination != null){ + parameters.put(KEY_TIME_TO_DESTINATION, timeToDestination); + } + else{ + parameters.remove(KEY_TIME_TO_DESTINATION); + } + } + + public String getTimeToDestination(){ + return (String) parameters.get(KEY_TIME_TO_DESTINATION); + } +} diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ShowConstantTbtResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ShowConstantTbtResponse.java new file mode 100644 index 0000000000..fb00da92e2 --- /dev/null +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ShowConstantTbtResponse.java @@ -0,0 +1,23 @@ +package com.smartdevicelink.proxy.rpc; + +import java.util.Hashtable; + +import com.smartdevicelink.protocol.enums.FunctionID; +import com.smartdevicelink.proxy.RPCResponse; + +/** + * Show Constant TBT Response is sent, when ShowConstantTBT has been called + * + * @since SmartDeviceLink 2.0 + */ +public class ShowConstantTbtResponse extends RPCResponse{ + + public ShowConstantTbtResponse() { + super(FunctionID.SHOW_CONSTANT_TBT); + } + + public ShowConstantTbtResponse(Hashtable hash) { + super(hash); + } + +} diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Turn.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Turn.java new file mode 100644 index 0000000000..1bfb8652ca --- /dev/null +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Turn.java @@ -0,0 +1,101 @@ +package com.smartdevicelink.proxy.rpc; + +import java.util.Hashtable; + +import com.smartdevicelink.proxy.RPCStruct; + +/** + * Describes a navigation turn including an optional icon + *

+ * Parameter List + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
NameTypeDescriptionSmartDeviceLink Ver. Available
navigationTextStringText to describe the turn (e.g. streetname) + *
    + *
  • Maxlength = 500
  • + *
+ *
SmartDeviceLink 2.0
turnIconImageImage to be shown for a turnSmartDeviceLink 2.0
+ * + * @since SmartDeviceLink 2.0 + */ +public class Turn extends RPCStruct{ + public static final String KEY_NAVIGATION_TEXT = "navigationText"; + public static final String KEY_TURN_IMAGE = "turnIcon"; + + public Turn() { } + public Turn(Hashtable hash) { + super(hash); + } + + /** + * set the text to describe the turn (e.g. streetname) + * + * @param navigationText + * the text to describe the turn (e.g. streetname) + */ + public void setNavigationText(String navigationText){ + if(navigationText != null){ + store.put(KEY_NAVIGATION_TEXT, navigationText); + } + else{ + store.remove(KEY_NAVIGATION_TEXT); + } + } + + /** + * get the text to describe the turn (e.g. streetname) + * + * @return the text to describe the turn (e.g. streetname) + */ + public String getNavigationText(){ + return (String) store.get(KEY_NAVIGATION_TEXT); + } + + /** + * set Image to be shown for a turn + * + * @param turnIcon + * the image to be shown for a turn + */ + public void setTurnIcon(Image turnIcon){ + if (turnIcon != null) { + store.put(KEY_TURN_IMAGE, turnIcon); + } else { + store.remove(KEY_TURN_IMAGE); + } + } + + /** + * get the image to be shown for a turn + * + * @return the image to be shown for a turn + */ + @SuppressWarnings("unchecked") + public Image getTurnIcon(){ + Object obj = store.get(KEY_TURN_IMAGE); + if (obj instanceof Image) { + return (Image) obj; + } else if (obj instanceof Hashtable) { + return new Image((Hashtable) obj); + } + return null; + } + +} diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UpdateTurnList.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UpdateTurnList.java new file mode 100644 index 0000000000..442c0dee20 --- /dev/null +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UpdateTurnList.java @@ -0,0 +1,140 @@ +package com.smartdevicelink.proxy.rpc; + +import java.util.ArrayList; +import java.util.Hashtable; +import java.util.List; + +import com.smartdevicelink.protocol.enums.FunctionID; +import com.smartdevicelink.proxy.RPCRequest; + +/** + * Updates the list of next maneuvers, which can be requested by the user pressing the softbutton "Turns" on the + * Navigation base screen. Three softbuttons are predefined by the system: Up, Down, Close + *

+ * Function Group: Navigation + *

+ * HMILevel needs to be FULL, LIMITED or BACKGROUND + *

+ * + * @since SmartDeviceLink 2.0 + * @see ShowConstantTbt + */ +public class UpdateTurnList extends RPCRequest{ + public static final String KEY_TURN_LIST = "turnList"; + public static final String KEY_SOFT_BUTTONS = "softButtons"; + + /** + * Constructs a new UpdateTurnList object + */ + public UpdateTurnList() { + super(FunctionID.UPDATE_TURN_LIST); + } + + /** + *

+ * Constructs a new UpdateTurnList object indicated by the Hashtable + * parameter + *

+ * + * @param hash + * The Hashtable to use + */ + public UpdateTurnList(Hashtable hash) { + super(hash); + } + + /** + * Sets a list of turns to be shown to the user + * + * @param turnList + * a List value representing a list of turns to be shown to the user + *

+ * Notes: Minsize=1; Maxsize=100 + */ + public void setTurnList(List turnList){ + if(turnList != null){ + parameters.put(KEY_TURN_LIST, turnList); + } + else{ + parameters.remove(KEY_TURN_LIST); + } + } + + /** + * Gets a list of turns to be shown to the user + * + * @return List -a List value representing a list of turns + */ + @SuppressWarnings("unchecked") + public List getTurnList(){ + if(parameters.get(KEY_SOFT_BUTTONS) instanceof List){ + List list = (List) parameters.get(KEY_SOFT_BUTTONS); + if(list != null && list.size() > 0){ + Object obj = list.get(0); + if(obj instanceof Turn){ + return (List) list; + } + else if(obj instanceof Hashtable){ + List newList = new ArrayList(); + for(Object hashObj : list){ + newList.add(new Turn((Hashtable) hashObj)); + } + return newList; + } + } + } + return null; + } + + /** + * Gets the SoftButton List object + * + * @return List -a List representing the List object + * @since SmartDeviceLink 2.0 + */ + @SuppressWarnings("unchecked") + public List getSoftButtons(){ + if(parameters.get(KEY_SOFT_BUTTONS) instanceof List){ + List list = (List) parameters.get(KEY_SOFT_BUTTONS); + if(list != null && list.size() > 0){ + Object obj = list.get(0); + if(obj instanceof SoftButton){ + return (List) list; + } + else if(obj instanceof Hashtable){ + List newList = new ArrayList(); + for(Object hashObj : list){ + newList.add(new SoftButton((Hashtable) hashObj)); + } + return newList; + } + } + } + return null; + } + + /** + * Sets the SoftButtons + * + * @param softButtons + * a List value + *

+ * Notes:
+ *

    + *
  • If omitted on supported displays, the alert will not have any SoftButton
  • + *
  • ArrayMin: 0
  • + *
  • ArrayMax: 4
  • + *
+ * @since SmartDeviceLink 2.0 + */ + + public void setSoftButtons(List softButtons){ + if(softButtons != null){ + parameters.put(KEY_SOFT_BUTTONS, softButtons); + } + else{ + parameters.remove(KEY_SOFT_BUTTONS); + } + } + +} diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UpdateTurnListResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UpdateTurnListResponse.java new file mode 100644 index 0000000000..c623151885 --- /dev/null +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UpdateTurnListResponse.java @@ -0,0 +1,26 @@ +package com.smartdevicelink.proxy.rpc; + +import java.util.Hashtable; + +import com.smartdevicelink.protocol.enums.FunctionID; +import com.smartdevicelink.proxy.RPCResponse; + +/** + * Update Turn List Response is sent, when UpdateTurnList has been called + * + * @since SmartDeviceLink 2.0 + */ +public class UpdateTurnListResponse extends RPCResponse{ + + /** + * Constructs a new UpdateTurnListResponse object + */ + public UpdateTurnListResponse() { + super(FunctionID.UPDATE_TURN_LIST); + } + + public UpdateTurnListResponse(Hashtable hash) { + super(hash); + } + +} From d1ab2d4abf97c1a24372493b5fff3bff495a9a51 Mon Sep 17 00:00:00 2001 From: Mike Burke Date: Wed, 18 Feb 2015 15:21:16 -0500 Subject: [PATCH 2/4] Added ecuHeader field to GetDTCsResponse. Fixes #117 Signed-off-by: Mike Burke --- .../proxy/rpc/GetDTCsResponse.java | 53 +++++++++++++------ 1 file changed, 36 insertions(+), 17 deletions(-) diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/GetDTCsResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/GetDTCsResponse.java index 8b27f19b13..8d19df40d7 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/GetDTCsResponse.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/GetDTCsResponse.java @@ -11,33 +11,52 @@ * * @since SmartDeviceLink 2.0 */ -public class GetDTCsResponse extends RPCResponse { - public static final String KEY_DTC = "dtc"; +public class GetDTCsResponse extends RPCResponse{ - public GetDTCsResponse() { + public static final String KEY_ECU_HEADER = "ecuHeader"; + public static final String KEY_DTC = "dtc"; + + public GetDTCsResponse(){ super(FunctionID.GET_DTCS); } - public GetDTCsResponse(Hashtable hash) { + + public GetDTCsResponse(Hashtable hash){ super(hash); } + @SuppressWarnings("unchecked") - public List getDtc() { - if(parameters.get(KEY_DTC) instanceof List){ - List list = (List)parameters.get(KEY_DTC); - if(list != null && list.size()>0){ - Object obj = list.get(0); - if(obj instanceof String){ - return (List) list; - } - } + public List getDtc(){ + if(parameters.get(KEY_DTC) instanceof List){ + List list = (List) parameters.get(KEY_DTC); + if(list != null && list.size() > 0){ + Object obj = list.get(0); + if(obj instanceof String){ + return (List) list; + } } + } return null; } - public void setDtc(List dtc) { - if (dtc != null) { + + public void setDtc(List dtc){ + if(dtc != null){ parameters.put(KEY_DTC, dtc); - } else { - parameters.remove(KEY_DTC); + } + else{ + parameters.remove(KEY_DTC); + } + } + + public Integer getEcuHeader(){ + return (Integer) parameters.get(KEY_ECU_HEADER); + } + + public void setEcuHeader(Integer ecuHeader){ + if(ecuHeader != null){ + parameters.put(KEY_ECU_HEADER, ecuHeader); + } + else{ + parameters.remove(KEY_ECU_HEADER); } } } From ec6151cef0456bdd0065fdf04580524c430a2d5a Mon Sep 17 00:00:00 2001 From: Mike Burke Date: Wed, 18 Feb 2015 17:50:07 -0500 Subject: [PATCH 3/4] Implemented SendLocation APIs. Fixes #105 Signed-off-by: Mike Burke --- .../protocol/enums/FunctionID.java | 3 + .../proxy/rpc/SendLocation.java | 209 ++++++++++++++++++ .../proxy/rpc/SendLocationResponse.java | 22 ++ 3 files changed, 234 insertions(+) create mode 100644 sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SendLocation.java create mode 100644 sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SendLocationResponse.java diff --git a/sdl_android_lib/src/com/smartdevicelink/protocol/enums/FunctionID.java b/sdl_android_lib/src/com/smartdevicelink/protocol/enums/FunctionID.java index 7f1b2f2e48..e3e017114b 100644 --- a/sdl_android_lib/src/com/smartdevicelink/protocol/enums/FunctionID.java +++ b/sdl_android_lib/src/com/smartdevicelink/protocol/enums/FunctionID.java @@ -64,6 +64,8 @@ public class FunctionID { public static final String SLIDER = "Slider"; public static final String ON_LOCK_SCREEN_STATUS = "OnLockScreenStatus"; public static final String ON_SDL_CHOICE_CHOSEN = "OnSdlChoiceChosen"; + + public static final String SEND_LOCATION = "SendLocation"; public FunctionID() { } @@ -141,6 +143,7 @@ static public void initFunctionIds() { put(FunctionID.SET_DISPLAY_LAYOUT, 36); put(FunctionID.DIAGNOSTIC_MESSAGE, 37); put(FunctionID.SYSTEM_REQUEST, 38); + put(FunctionID.SEND_LOCATION, 39); /* Base Notifications diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SendLocation.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SendLocation.java new file mode 100644 index 0000000000..cd37eea744 --- /dev/null +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SendLocation.java @@ -0,0 +1,209 @@ +package com.smartdevicelink.proxy.rpc; + +import java.util.Hashtable; +import java.util.List; + +import com.smartdevicelink.protocol.enums.FunctionID; +import com.smartdevicelink.proxy.RPCRequest; + + +/** + * Sends a location to the head-unit to display on a map or list. + * + * @since SmartDeviceLink 3.0 + * + */ +public class SendLocation extends RPCRequest{ + + public static final String KEY_LAT_DEGREES = "latitudeDegrees"; + public static final String KEY_LON_DEGREES = "longitudeDegrees"; + public static final String KEY_LOCATION_NAME = "locationName"; + public static final String KEY_LOCATION_DESCRIPTION = "locationDescription"; + public static final String KEY_PHONE_NUMBER = "phoneNumber"; + public static final String KEY_ADDRESS_LINES = "addressLines"; + public static final String KEY_LOCATION_IMAGE = "locationImage"; + + /** + * Constructs a new SendLocation object + */ + public SendLocation(){ + super(FunctionID.SEND_LOCATION); + } + + /** + *

+ * Constructs a new SendLocation object indicated by the Hashtable parameter + *

+ * + * @param hash + * The Hashtable to use + */ + public SendLocation(Hashtable hash){ + super(hash); + } + + /** + * Getter for longitude of the location to send. + * @return The longitude of the location + */ + public Float getLongitudeDegrees(){ + return (Float) parameters.get(KEY_LON_DEGREES); + } + + /** + * Setter for longitude of the location to send. + * @param longitudeDegrees + */ + public void setLongitudeDegrees(Float longitudeDegrees){ + if(longitudeDegrees != null){ + parameters.put(KEY_LON_DEGREES, longitudeDegrees); + } + else{ + parameters.remove(KEY_LON_DEGREES); + } + } + + /** + * Getter for latitude of the location to send. + * @return The latitude of the location + */ + public Float getLatitudeDegrees(){ + return (Float) parameters.get(KEY_LAT_DEGREES); + } + + /** + * Setter for latitude of the location to send. + * @param latitudeDegrees + */ + public void setLatitudeDegrees(Float latitudeDegrees){ + if(latitudeDegrees != null){ + parameters.put(KEY_LAT_DEGREES, latitudeDegrees); + } + else{ + parameters.remove(KEY_LAT_DEGREES); + } + } + + /** + * Getter for name of the location to send. + * @return The name of the location + */ + public String getLocationName(){ + return (String) parameters.get(KEY_LOCATION_NAME); + } + + /** + * Setter for name of the location to send. + * @param locationName The name of the location + */ + public void setLocationName(String locationName){ + if(locationName != null){ + parameters.put(KEY_LOCATION_NAME, locationName); + } + else{ + parameters.remove(KEY_LOCATION_NAME); + } + } + + /** + * Getter for description of the location to send. + * @return The description of the location to send + */ + public String getLocationDescription(){ + return (String) parameters.get(KEY_LOCATION_DESCRIPTION); + } + + /** + * Setter for description of the location to send. + * @param locationDescription The description of the location + */ + public void setLocationDescription(String locationDescription){ + if(locationDescription != null){ + parameters.put(KEY_LOCATION_DESCRIPTION, locationDescription); + } + else{ + parameters.remove(KEY_LOCATION_DESCRIPTION); + } + } + + /** + * Getter for phone number of the location to send. + * @return + */ + public String getPhoneNumber(){ + return (String) parameters.get(KEY_PHONE_NUMBER); + } + + /** + * Setter for phone number of the location to send. + * @param phoneNumber The phone number of the location + */ + public void setPhoneNumber(String phoneNumber){ + if(phoneNumber != null){ + parameters.put(KEY_PHONE_NUMBER, phoneNumber); + } + else{ + parameters.remove(KEY_PHONE_NUMBER); + } + } + + /** + * Getter for address lines of the location to send. + * @return The address lines of the location + */ + @SuppressWarnings("unchecked") + public List getAddressLines(){ + if(parameters.get(KEY_ADDRESS_LINES) instanceof List){ + List list = (List) parameters.get(KEY_ADDRESS_LINES); + if(list != null && list.size() > 0){ + Object obj = list.get(0); + if(obj instanceof String){ + return (List) list; + } + } + } + return null; + } + + /** + * Setter for address lines of the location to send. + * @param addressLines The address lines of the location + */ + public void setAddressLines(List addressLines){ + if(addressLines != null){ + parameters.put(KEY_ADDRESS_LINES, addressLines); + } + else{ + parameters.remove(KEY_ADDRESS_LINES); + } + } + + /** + * Getter for image of the location to send. + * @return The image of the location to send + */ + @SuppressWarnings("unchecked") + public Image getLocationImage(){ + Object obj = parameters.get(KEY_LOCATION_IMAGE); + if (obj instanceof Image) { + return (Image) obj; + } else if (obj instanceof Hashtable) { + return new Image((Hashtable) obj); + } + return null; + } + + /** + * Setter for image of the location to send. + * @param locationImage The image of the location to send + */ + public void setLocationImage(Image locationImage){ + if(locationImage != null){ + parameters.put(KEY_LOCATION_IMAGE, locationImage); + } + else{ + parameters.remove(KEY_LOCATION_IMAGE); + } + } + +} diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SendLocationResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SendLocationResponse.java new file mode 100644 index 0000000000..32037188cd --- /dev/null +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SendLocationResponse.java @@ -0,0 +1,22 @@ +package com.smartdevicelink.proxy.rpc; + +import java.util.Hashtable; + +import com.smartdevicelink.protocol.enums.FunctionID; +import com.smartdevicelink.proxy.RPCResponse; + +/** + * Add SendLocation Response is sent, when SendLocation has been called + * + * @since SmartDeviceLink 1.0 + */ +public class SendLocationResponse extends RPCResponse{ + + public SendLocationResponse(){ + super(FunctionID.SEND_LOCATION); + } + + public SendLocationResponse(Hashtable hash){ + super(hash); + } +} From 829e6dbd6300df09c70eed2b62b92b68903030c9 Mon Sep 17 00:00:00 2001 From: Mike Burke Date: Wed, 18 Feb 2015 18:02:41 -0500 Subject: [PATCH 4/4] Added missing parameters to ChangeRegistration. Fixes #104. Signed-off-by: Mike Burke --- .../proxy/rpc/ChangeRegistration.java | 140 +++++++++++++++++- 1 file changed, 139 insertions(+), 1 deletion(-) diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ChangeRegistration.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ChangeRegistration.java index 26c4f216e0..5ab4abe1bb 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ChangeRegistration.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ChangeRegistration.java @@ -1,6 +1,8 @@ package com.smartdevicelink.proxy.rpc; +import java.util.ArrayList; import java.util.Hashtable; +import java.util.List; import com.smartdevicelink.protocol.enums.FunctionID; import com.smartdevicelink.proxy.RPCRequest; @@ -23,7 +25,11 @@ */ public class ChangeRegistration extends RPCRequest { public static final String KEY_LANGUAGE = "language"; - public static final String KEY_HMI_DISPLAY_LANGUAGE = "hmiDisplayLanguage"; + public static final String KEY_HMI_DISPLAY_LANGUAGE = "hmiDisplayLanguage"; + public static final String KEY_APP_NAME = "appName"; + public static final String KEY_TTS_NAME = "ttsName"; + public static final String KEY_NGN_MEDIA_SCREEN_NAME = "ngnMediaScreenAppName"; + public static final String KEY_VR_SYNONYMS = "vrSynonyms"; /** * Constructs a new ChangeRegistration object @@ -113,4 +119,136 @@ public Language getHmiDisplayLanguage() { } return null; } + + /** + * Sets app name + * + * @param appName App name to set + */ + public void setAppName(String appName){ + if(appName != null){ + parameters.put(KEY_APP_NAME, appName); + } + else{ + parameters.remove(KEY_APP_NAME); + } + } + + /** + * Gets app name + * + * @return The app name + */ + public String getAppName(){ + return (String) parameters.get(KEY_APP_NAME); + } + + /** + * Sets NGN media screen app name + * + * @param ngnAppName The NGN app name + */ + public void setNgnMediaScreenAppName(String ngnAppName){ + if(ngnAppName != null){ + parameters.put(KEY_NGN_MEDIA_SCREEN_NAME, ngnAppName); + } + else{ + parameters.remove(KEY_NGN_MEDIA_SCREEN_NAME); + } + } + + /** + * Gets NGN media screen app name + * + * @return The NGN app name + */ + public String getNgnMediaScreenAppName(){ + return (String) parameters.get(KEY_NGN_MEDIA_SCREEN_NAME); + } + + /** + * Sets the TTS name + * + * @param ttsName The TTS name to set + */ + public void setTtsName(List ttsName){ + if(ttsName != null){ + parameters.put(KEY_TTS_NAME, ttsName); + } + else{ + parameters.remove(KEY_TTS_NAME); + } + } + + /** + * Gets the TTS name + * + * @return The TTS name + */ + @SuppressWarnings("unchecked") + public List getTtsName(){ + if (parameters.get(KEY_TTS_NAME) instanceof List) { + List list = (List)parameters.get(KEY_TTS_NAME); + if (list != null && list.size() > 0) { + Object obj = list.get(0); + if (obj instanceof TTSChunk) { + return (List) list; + } else if (obj instanceof Hashtable) { + List newList = new ArrayList(); + for (Object hashObj : list) { + newList.add(new TTSChunk((Hashtable)hashObj)); + } + return newList; + } + } + } + return null; + } + + /** + * Gets the List representing the an array of 1-100 elements, each + * element containing a voice-recognition synonym + * + * @return List -a List value representing the an array of + * 1-100 elements, each element containing a voice-recognition + * synonym + */ + @SuppressWarnings("unchecked") + public List getVrSynonyms() { + if (parameters.get(KEY_VR_SYNONYMS) instanceof List) { + List list = (List)parameters.get(KEY_VR_SYNONYMS); + if (list != null && list.size()>0) { + Object obj = list.get(0); + if (obj instanceof String) { + return (List) list; + } + } + } + return null; + } + + /** + * Sets a vrSynonyms representing the an array of 1-100 elements, each + * element containing a voice-recognition synonym + * + * @param vrSynonyms + * a List value representing the an array of 1-100 + * elements + *

+ * Notes: + *

    + *
  • Each vr synonym is limited to 40 characters, and there can + * be 1-100 synonyms in array
  • + *
  • May not be the same (by case insensitive comparison) as + * the name or any synonym of any currently-registered + * application
  • + *
+ */ + public void setVrSynonyms(List vrSynonyms) { + if (vrSynonyms != null) { + parameters.put(KEY_VR_SYNONYMS, vrSynonyms); + } else { + parameters.remove(KEY_VR_SYNONYMS); + } + } }