diff options
author | Brett <geekman3454@protonmail.com> | 2018-08-23 10:38:17 -0400 |
---|---|---|
committer | Brett <geekman3454@protonmail.com> | 2018-08-23 10:38:17 -0400 |
commit | 0cfa13825e7d86e8e4842ffe97a1722085de3aa7 (patch) | |
tree | eff43f4fe1aa7c2fafe34aea49ee4aab71fc463a | |
parent | 84c9d04b0f662e65ed46fdf0331571743a6596b2 (diff) | |
download | sdl_android-0cfa13825e7d86e8e4842ffe97a1722085de3aa7.tar.gz |
update javadocs
-rw-r--r-- | sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Choice.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Choice.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Choice.java index 59c722263..8c2dbac98 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Choice.java +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Choice.java @@ -3,7 +3,9 @@ package com.smartdevicelink.proxy.rpc; import android.support.annotation.NonNull;
import com.smartdevicelink.proxy.RPCStruct;
+import com.smartdevicelink.util.Version;
+import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
@@ -85,6 +87,38 @@ public class Choice extends RPCStruct { setChoiceID(choiceID);
setMenuName(menuName);
}
+
+ /**
+ * VrCommands became optional as of RPC Spec 5.0. On legacy systems, we must still set VrCommands, as
+ * they are expected, even though the developer may not specify them. <br>
+ *
+ * Additionally, VrCommands must be unique, therefore we will use the string value of the command's ID
+ *
+ * @param rpcVersion the rpc spec version that has been negotiated. If value is null the
+ * the max value of RPC spec version this library supports should be used.
+ * @param formatParams if true, the format method will be called on subsequent params
+ */
+ @Override
+ public void format(Version rpcVersion, boolean formatParams){
+
+ if (rpcVersion == null || rpcVersion.getMajor() < 5){
+
+ // make sure there is at least one vr param
+ List<String> existingVrCommands = getVrCommands();
+
+ if (existingVrCommands == null || existingVrCommands.size() == 0) {
+ // if no commands set, set one due to a legacy head unit requirement
+ Integer choiceID = getChoiceID();
+ List<String> vrCommands = new ArrayList<>();
+ vrCommands.add(String.valueOf(choiceID));
+ setVrCommands(vrCommands);
+ }
+ }
+
+ super.format(rpcVersion, formatParams);
+ }
+
+
/**
* Constructs a newly allocated Choice object
* @param choiceID Min: 0 Max: 65535
|