From 0c407d8bc5f0f5b760ae9f5b7f60a4d6e71dd1a2 Mon Sep 17 00:00:00 2001 From: "Dahiya, Anil (A.)" Date: Tue, 25 Nov 2014 10:04:59 -0500 Subject: [PATCH 1/2] BugFix changes : getImageTypeSupported needs to return array, Proper Instance checking in getInteractionLayout and getKeyboardProperties --- .../smartdevicelink/proxy/rpc/ImageField.java | 45 ++++++++++++------- .../proxy/rpc/PerformInteraction.java | 2 +- .../proxy/rpc/SetGlobalProperties.java | 2 +- 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ImageField.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ImageField.java index 3700b909a4..34925bc5cc 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ImageField.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ImageField.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.proxy.RPCStruct; import com.smartdevicelink.proxy.rpc.enums.FileType; @@ -41,21 +43,34 @@ public void setName( ImageFieldName name ) { store.remove(KEY_NAME); } } - public FileType getImageTypeSupported() { - Object obj = store.get(KEY_IMAGE_TYPE_SUPPORTED); - if (obj instanceof FileType) { - return (FileType) obj; - } else if (obj instanceof String) { - FileType theCode = null; - try { - theCode = FileType.valueForString((String) obj); - } catch (Exception e) { - DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_IMAGE_TYPE_SUPPORTED, e); - } - return theCode; - } - return null; - } + @SuppressWarnings("unchecked") + public List getImageTypeSupported() { + if (store.get(KEY_IMAGE_TYPE_SUPPORTED) instanceof List) { + List list = (List)store.get(KEY_IMAGE_TYPE_SUPPORTED); + if (list != null && list.size() > 0) { + Object obj = list.get(0); + if (obj instanceof FileType) { + return (List) list; + } else if (obj instanceof String) { + List newList = new ArrayList(); + for (Object hashObj : list) { + String strFormat = (String)hashObj; + FileType theCode = null; + try { + theCode = FileType.valueForString(strFormat); + } catch (Exception e) { + DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_IMAGE_TYPE_SUPPORTED, e); + } + if (theCode != null) { + newList.add(theCode); + } + } + return newList; + } + } + } + return null; + } public void setImageTypeSupported( FileType imageTypeSupported ) { if (imageTypeSupported != null) { store.put(KEY_IMAGE_TYPE_SUPPORTED, imageTypeSupported ); diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PerformInteraction.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PerformInteraction.java index 7ebde6b43f..dce60bf251 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PerformInteraction.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PerformInteraction.java @@ -377,7 +377,7 @@ public void setVrHelp(List vrHelp) { public LayoutMode getInteractionLayout() { Object obj = parameters.get(KEY_INTERACTION_LAYOUT); - if (obj instanceof DisplayType) { + if (obj instanceof LayoutMode) { return (LayoutMode) obj; } else if (obj instanceof String) { LayoutMode theCode = null; diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetGlobalProperties.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetGlobalProperties.java index 5b15ebf61f..f4c4dee712 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetGlobalProperties.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetGlobalProperties.java @@ -269,7 +269,7 @@ public void setKeyboardProperties(KeyboardProperties keyboardProperties) { @SuppressWarnings("unchecked") public KeyboardProperties getKeyboardProperties() { Object obj = parameters.get(KEY_KEYBOARD_PROPERTIES); - if (obj instanceof Image) { + if (obj instanceof KeyboardProperties) { return (KeyboardProperties) obj; } else if (obj instanceof Hashtable) { try { From 7a5c0ff3d001532c49a9d2b5c36113bf5ea36169 Mon Sep 17 00:00:00 2001 From: "Dahiya, Anil (A.)" Date: Fri, 12 Dec 2014 10:32:40 -0500 Subject: [PATCH 2/2] Additional Changes in setImageTypeSupported() method to take input as List of FileType. Also, removed unnecessary import in PerformInteraction.java to prevent additional warning. --- .../src/com/smartdevicelink/proxy/rpc/ImageField.java | 2 +- .../src/com/smartdevicelink/proxy/rpc/PerformInteraction.java | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ImageField.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ImageField.java index 34925bc5cc..bad10b8c1b 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ImageField.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ImageField.java @@ -71,7 +71,7 @@ public List getImageTypeSupported() { } return null; } - public void setImageTypeSupported( FileType imageTypeSupported ) { + public void setImageTypeSupported( List imageTypeSupported ) { if (imageTypeSupported != null) { store.put(KEY_IMAGE_TYPE_SUPPORTED, imageTypeSupported ); } diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PerformInteraction.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PerformInteraction.java index dce60bf251..728b6a5659 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PerformInteraction.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PerformInteraction.java @@ -6,7 +6,6 @@ import com.smartdevicelink.protocol.enums.FunctionID; import com.smartdevicelink.proxy.RPCRequest; -import com.smartdevicelink.proxy.rpc.enums.DisplayType; import com.smartdevicelink.proxy.rpc.enums.InteractionMode; import com.smartdevicelink.proxy.rpc.enums.LayoutMode; import com.smartdevicelink.util.DebugTool;