summaryrefslogtreecommitdiff
path: root/base/src/main/java/com/smartdevicelink/proxy
diff options
context:
space:
mode:
authorVladyslav Mustafin <vmustafin@luxoft.com>2020-08-06 15:28:29 +0300
committerVladyslav Mustafin <vmustafin@luxoft.com>2020-08-06 15:28:29 +0300
commit658390b6a6733cf9152aeda246055dc38084e215 (patch)
tree6b044735d0b631d886dd2e1fcd11706c951be9ae /base/src/main/java/com/smartdevicelink/proxy
parent3a782dadb3a8fc6d433b34996143dc501c06d771 (diff)
parent621dafbf92ae9dbcec8a82ea7820eecc662621d7 (diff)
downloadsdl_android-658390b6a6733cf9152aeda246055dc38084e215.tar.gz
Merge remote-tracking branch 'upstream/develop' into fork/0257_new_vehicle_data_hands_off_steering
Diffstat (limited to 'base/src/main/java/com/smartdevicelink/proxy')
-rw-r--r--base/src/main/java/com/smartdevicelink/proxy/RPCStruct.java5
-rw-r--r--base/src/main/java/com/smartdevicelink/proxy/SystemCapabilityManager.java661
-rw-r--r--base/src/main/java/com/smartdevicelink/proxy/interfaces/OnSystemCapabilityListener.java37
-rw-r--r--base/src/main/java/com/smartdevicelink/proxy/rpc/AddSubMenu.java39
-rw-r--r--base/src/main/java/com/smartdevicelink/proxy/rpc/DriverDistractionCapability.java122
-rw-r--r--base/src/main/java/com/smartdevicelink/proxy/rpc/HMICapabilities.java32
-rw-r--r--base/src/main/java/com/smartdevicelink/proxy/rpc/SystemCapability.java14
-rw-r--r--base/src/main/java/com/smartdevicelink/proxy/rpc/TextField.java76
-rw-r--r--base/src/main/java/com/smartdevicelink/proxy/rpc/enums/CharacterSet.java85
-rw-r--r--base/src/main/java/com/smartdevicelink/proxy/rpc/enums/SystemCapabilityType.java35
-rw-r--r--base/src/main/java/com/smartdevicelink/proxy/rpc/listeners/OnRPCResponseListener.java5
11 files changed, 336 insertions, 775 deletions
diff --git a/base/src/main/java/com/smartdevicelink/proxy/RPCStruct.java b/base/src/main/java/com/smartdevicelink/proxy/RPCStruct.java
index 69c3e2bc0..5eb293ba2 100644
--- a/base/src/main/java/com/smartdevicelink/proxy/RPCStruct.java
+++ b/base/src/main/java/com/smartdevicelink/proxy/RPCStruct.java
@@ -32,6 +32,7 @@
package com.smartdevicelink.proxy;
import com.smartdevicelink.marshal.JsonRPCMarshaller;
+import com.smartdevicelink.util.SdlDataTypeConverter;
import com.smartdevicelink.util.Version;
import org.json.JSONException;
@@ -345,11 +346,11 @@ public class RPCStruct {
}
public Double getDouble(String key) {
- return (Double) store.get(key);
+ return SdlDataTypeConverter.objectToDouble(store.get(key));
}
public Float getFloat(String key) {
- return (Float) store.get(key);
+ return SdlDataTypeConverter.objectToFloat(store.get(key));
}
public Boolean getBoolean(String key) { return (Boolean) store.get(key); }
diff --git a/base/src/main/java/com/smartdevicelink/proxy/SystemCapabilityManager.java b/base/src/main/java/com/smartdevicelink/proxy/SystemCapabilityManager.java
deleted file mode 100644
index 357d26799..000000000
--- a/base/src/main/java/com/smartdevicelink/proxy/SystemCapabilityManager.java
+++ /dev/null
@@ -1,661 +0,0 @@
-/*
- * Copyright (c) 2019, 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.
- */
-package com.smartdevicelink.proxy;
-
-import com.smartdevicelink.managers.ManagerUtility;
-import com.smartdevicelink.protocol.enums.FunctionID;
-import com.smartdevicelink.proxy.interfaces.ISdl;
-import com.smartdevicelink.proxy.interfaces.OnSystemCapabilityListener;
-import com.smartdevicelink.proxy.rpc.AppServiceCapability;
-import com.smartdevicelink.proxy.rpc.AppServicesCapabilities;
-import com.smartdevicelink.proxy.rpc.ButtonCapabilities;
-import com.smartdevicelink.proxy.rpc.DisplayCapabilities;
-import com.smartdevicelink.proxy.rpc.DisplayCapability;
-import com.smartdevicelink.proxy.rpc.GetSystemCapability;
-import com.smartdevicelink.proxy.rpc.GetSystemCapabilityResponse;
-import com.smartdevicelink.proxy.rpc.HMICapabilities;
-import com.smartdevicelink.proxy.rpc.OnHMIStatus;
-import com.smartdevicelink.proxy.rpc.OnSystemCapabilityUpdated;
-import com.smartdevicelink.proxy.rpc.RegisterAppInterfaceResponse;
-import com.smartdevicelink.proxy.rpc.SdlMsgVersion;
-import com.smartdevicelink.proxy.rpc.SetDisplayLayoutResponse;
-import com.smartdevicelink.proxy.rpc.SoftButtonCapabilities;
-import com.smartdevicelink.proxy.rpc.SystemCapability;
-import com.smartdevicelink.proxy.rpc.WindowCapability;
-import com.smartdevicelink.proxy.rpc.WindowTypeCapabilities;
-import com.smartdevicelink.proxy.rpc.enums.DisplayType;
-import com.smartdevicelink.proxy.rpc.enums.HMILevel;
-import com.smartdevicelink.proxy.rpc.enums.ImageType;
-import com.smartdevicelink.proxy.rpc.enums.MediaClockFormat;
-import com.smartdevicelink.proxy.rpc.enums.PredefinedWindows;
-import com.smartdevicelink.proxy.rpc.enums.Result;
-import com.smartdevicelink.proxy.rpc.enums.SystemCapabilityType;
-import com.smartdevicelink.proxy.rpc.enums.WindowType;
-import com.smartdevicelink.proxy.rpc.listeners.OnRPCListener;
-import com.smartdevicelink.proxy.rpc.listeners.OnRPCResponseListener;
-import com.smartdevicelink.util.CorrelationIdGenerator;
-import com.smartdevicelink.util.DebugTool;
-import com.smartdevicelink.util.Version;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-public class SystemCapabilityManager {
- private static final String TAG = "SystemCapabilityManager";
- private final HashMap<SystemCapabilityType, Object> cachedSystemCapabilities;
- private final HashMap<SystemCapabilityType, Boolean> systemCapabilitiesSubscriptionStatus;
- private final HashMap<SystemCapabilityType, CopyOnWriteArrayList<OnSystemCapabilityListener>> onSystemCapabilityListeners;
- private final Object LISTENER_LOCK;
- private final ISdl callback;
- private OnRPCListener rpcListener;
- private boolean shouldConvertDeprecatedDisplayCapabilities;
- private HMILevel currentHMILevel;
-
- public SystemCapabilityManager(ISdl callback) {
- this.callback = callback;
- this.LISTENER_LOCK = new Object();
- this.onSystemCapabilityListeners = new HashMap<>();
- this.cachedSystemCapabilities = new HashMap<>();
- this.systemCapabilitiesSubscriptionStatus = new HashMap<>();
- this.systemCapabilitiesSubscriptionStatus.put(SystemCapabilityType.DISPLAYS, true);
- this.shouldConvertDeprecatedDisplayCapabilities = true;
- this.currentHMILevel = HMILevel.HMI_NONE;
-
- setupRpcListeners();
- }
-
- private List<DisplayCapability> createDisplayCapabilityList(RegisterAppInterfaceResponse rpc) {
- return createDisplayCapabilityList(rpc.getDisplayCapabilities(), rpc.getButtonCapabilities(), rpc.getSoftButtonCapabilities());
- }
-
- private List<DisplayCapability> createDisplayCapabilityList(SetDisplayLayoutResponse rpc) {
- return createDisplayCapabilityList(rpc.getDisplayCapabilities(), rpc.getButtonCapabilities(), rpc.getSoftButtonCapabilities());
- }
-
- private List<DisplayCapability> createDisplayCapabilityList(DisplayCapabilities display, List<ButtonCapabilities> button, List<SoftButtonCapabilities> softButton) {
- // Based on deprecated Display capabilities we don't know if widgets are supported,
- // The Default MAIN window is the only window we know is supported
- WindowTypeCapabilities windowTypeCapabilities = new WindowTypeCapabilities(WindowType.MAIN, 1);
-
- DisplayCapability displayCapability = new DisplayCapability();
- if (display != null) {
- if (display.getDisplayName() != null) {
- displayCapability.setDisplayName(display.getDisplayName());
- } else if (display.getDisplayType() != null) {
- displayCapability.setDisplayName(display.getDisplayType().toString());
- }
- }
- displayCapability.setWindowTypeSupported(Collections.singletonList(windowTypeCapabilities));
-
- // Create a window capability object for the default MAIN window
- WindowCapability defaultWindowCapability = new WindowCapability();
- defaultWindowCapability.setWindowID(PredefinedWindows.DEFAULT_WINDOW.getValue());
- defaultWindowCapability.setButtonCapabilities(button);
- defaultWindowCapability.setSoftButtonCapabilities(softButton);
-
- // return if display capabilities don't exist.
- if (display == null) {
- defaultWindowCapability.setTextFields(ManagerUtility.WindowCapabilityUtility.getAllTextFields());
- defaultWindowCapability.setImageFields(ManagerUtility.WindowCapabilityUtility.getAllImageFields());
- displayCapability.setWindowCapabilities(Collections.singletonList(defaultWindowCapability));
- return Collections.singletonList(displayCapability);
- }
-
- // copy all available display capabilities
- defaultWindowCapability.setTemplatesAvailable(display.getTemplatesAvailable());
- defaultWindowCapability.setNumCustomPresetsAvailable(display.getNumCustomPresetsAvailable());
- defaultWindowCapability.setTextFields(display.getTextFields());
- defaultWindowCapability.setImageFields(display.getImageFields());
- ArrayList<ImageType> imageTypeSupported = new ArrayList<>();
- imageTypeSupported.add(ImageType.STATIC); // static images expected to always work on any head unit
- if (display.getGraphicSupported()) {
- imageTypeSupported.add(ImageType.DYNAMIC);
- }
- defaultWindowCapability.setImageTypeSupported(imageTypeSupported);
-
- displayCapability.setWindowCapabilities(Collections.singletonList(defaultWindowCapability));
- return Collections.singletonList(displayCapability);
- }
-
- private DisplayCapabilities createDeprecatedDisplayCapabilities(String displayName, WindowCapability defaultMainWindow) {
- DisplayCapabilities convertedCapabilities = new DisplayCapabilities();
- convertedCapabilities.setDisplayType(DisplayType.SDL_GENERIC); //deprecated but it is mandatory...
- convertedCapabilities.setDisplayName(displayName);
- convertedCapabilities.setTextFields(defaultMainWindow.getTextFields());
- convertedCapabilities.setImageFields(defaultMainWindow.getImageFields());
- convertedCapabilities.setTemplatesAvailable(defaultMainWindow.getTemplatesAvailable());
- convertedCapabilities.setNumCustomPresetsAvailable(defaultMainWindow.getNumCustomPresetsAvailable());
- convertedCapabilities.setMediaClockFormats(new ArrayList<MediaClockFormat>()); // mandatory field but allows empty array
- // if there are imageTypes in the response, we must assume graphics are supported
- convertedCapabilities.setGraphicSupported(defaultMainWindow.getImageTypeSupported() != null && defaultMainWindow.getImageTypeSupported().size() > 0);
-
- return convertedCapabilities;
- }
-
- private void updateDeprecatedDisplayCapabilities() {
- WindowCapability defaultMainWindowCapabilities = getDefaultMainWindowCapability();
- List<DisplayCapability> displayCapabilityList = convertToList(getCapability(SystemCapabilityType.DISPLAYS), DisplayCapability.class);
-
- if (defaultMainWindowCapabilities == null || displayCapabilityList == null || displayCapabilityList.size() == 0) {
- return;
- }
-
- // cover the deprecated capabilities for backward compatibility
- setCapability(SystemCapabilityType.DISPLAY, createDeprecatedDisplayCapabilities(displayCapabilityList.get(0).getDisplayName(), defaultMainWindowCapabilities));
- setCapability(SystemCapabilityType.BUTTON, defaultMainWindowCapabilities.getButtonCapabilities());
- setCapability(SystemCapabilityType.SOFTBUTTON, defaultMainWindowCapabilities.getSoftButtonCapabilities());
- }
-
- private void updateCachedDisplayCapabilityList(List<DisplayCapability> newCapabilities) {
- if (newCapabilities == null || newCapabilities.size() == 0) {
- DebugTool.logWarning(TAG, "Received invalid display capability list");
- return;
- }
-
- List<DisplayCapability> oldCapabilities = convertToList(getCapability(SystemCapabilityType.DISPLAYS), DisplayCapability.class);
-
- if (oldCapabilities == null || oldCapabilities.size() == 0) {
- setCapability(SystemCapabilityType.DISPLAYS, newCapabilities);
- updateDeprecatedDisplayCapabilities();
- return;
- }
-
- DisplayCapability oldDefaultDisplayCapabilities = oldCapabilities.get(0);
- ArrayList<WindowCapability> copyWindowCapabilities = new ArrayList<>(oldDefaultDisplayCapabilities.getWindowCapabilities());
-
- DisplayCapability newDefaultDisplayCapabilities = newCapabilities.get(0);
- List<WindowCapability> newWindowCapabilities = newDefaultDisplayCapabilities.getWindowCapabilities();
-
- if (newWindowCapabilities != null && !newWindowCapabilities.isEmpty()) {
- for (WindowCapability newWindow : newWindowCapabilities) {
- ListIterator<WindowCapability> iterator = copyWindowCapabilities.listIterator();
- boolean oldFound = false;
- while (iterator.hasNext()) {
- WindowCapability oldWindow = iterator.next();
- int newWindowID = newWindow.getWindowID() != null ? newWindow.getWindowID() : PredefinedWindows.DEFAULT_WINDOW.getValue();
- int oldWindowID = oldWindow.getWindowID() != null ? oldWindow.getWindowID() : PredefinedWindows.DEFAULT_WINDOW.getValue();
- if (newWindowID == oldWindowID) {
- iterator.set(newWindow); // replace the old window caps with new ones
- oldFound = true;
- break;
- }
- }
-
- if (!oldFound) {
- copyWindowCapabilities.add(newWindow); // this is a new unknown window
- }
- }
- }
-
- // replace the window capabilities array with the merged one.
- newDefaultDisplayCapabilities.setWindowCapabilities(copyWindowCapabilities);
- setCapability(SystemCapabilityType.DISPLAYS, Collections.singletonList(newDefaultDisplayCapabilities));
- updateDeprecatedDisplayCapabilities();
- }
-
-
- public WindowCapability getWindowCapability(int windowID) {
- List<DisplayCapability> capabilities = convertToList(getCapability(SystemCapabilityType.DISPLAYS), DisplayCapability.class);
- if (capabilities == null || capabilities.size() == 0) {
- return null;
- }
- DisplayCapability display = capabilities.get(0);
- for (WindowCapability windowCapability : display.getWindowCapabilities()) {
- int currentWindowID = windowCapability.getWindowID() != null ? windowCapability.getWindowID() : PredefinedWindows.DEFAULT_WINDOW.getValue();
- if (currentWindowID == windowID) {
- return windowCapability;
- }
- }
- return null;
- }
-
- public WindowCapability getDefaultMainWindowCapability() {
- return getWindowCapability(PredefinedWindows.DEFAULT_WINDOW.getValue());
- }
-
- public void parseRAIResponse(RegisterAppInterfaceResponse response) {
- if (response != null && response.getSuccess()) {
- this.shouldConvertDeprecatedDisplayCapabilities = true; // reset the flag
- setCapability(SystemCapabilityType.DISPLAYS, createDisplayCapabilityList(response));
- setCapability(SystemCapabilityType.HMI, response.getHmiCapabilities());
- setCapability(SystemCapabilityType.DISPLAY, response.getDisplayCapabilities());
- setCapability(SystemCapabilityType.AUDIO_PASSTHROUGH, response.getAudioPassThruCapabilities());
- setCapability(SystemCapabilityType.PCM_STREAMING, response.getPcmStreamingCapabilities());
- setCapability(SystemCapabilityType.BUTTON, response.getButtonCapabilities());
- setCapability(SystemCapabilityType.HMI_ZONE, response.getHmiZoneCapabilities());
- setCapability(SystemCapabilityType.PRESET_BANK, response.getPresetBankCapabilities());
- setCapability(SystemCapabilityType.SOFTBUTTON, response.getSoftButtonCapabilities());
- setCapability(SystemCapabilityType.SPEECH, response.getSpeechCapabilities());
- setCapability(SystemCapabilityType.VOICE_RECOGNITION, response.getVrCapabilities());
- setCapability(SystemCapabilityType.PRERECORDED_SPEECH, response.getPrerecordedSpeech());
- }
- }
-
- private void setupRpcListeners() {
- rpcListener = new OnRPCListener() {
- @Override
- public void onReceived(RPCMessage message) {
- if (message != null) {
- if (RPCMessage.KEY_RESPONSE.equals(message.getMessageType())) {
- switch (message.getFunctionID()) {
- case SET_DISPLAY_LAYOUT:
- SetDisplayLayoutResponse response = (SetDisplayLayoutResponse) message;
- setCapability(SystemCapabilityType.DISPLAY, response.getDisplayCapabilities());
- setCapability(SystemCapabilityType.BUTTON, response.getButtonCapabilities());
- setCapability(SystemCapabilityType.PRESET_BANK, response.getPresetBankCapabilities());
- setCapability(SystemCapabilityType.SOFTBUTTON, response.getSoftButtonCapabilities());
- if (shouldConvertDeprecatedDisplayCapabilities) {
- setCapability(SystemCapabilityType.DISPLAYS, createDisplayCapabilityList(response));
- }
- break;
- case GET_SYSTEM_CAPABILITY:
- GetSystemCapabilityResponse systemCapabilityResponse = (GetSystemCapabilityResponse) message;
- SystemCapability systemCapability = systemCapabilityResponse.getSystemCapability();
- if (systemCapabilityResponse.getSuccess() && SystemCapabilityType.DISPLAYS.equals(systemCapability.getSystemCapabilityType())) {
- shouldConvertDeprecatedDisplayCapabilities = false; // Successfully got DISPLAYS data. No conversion needed anymore
- List<DisplayCapability> newCapabilities = (List<DisplayCapability>) systemCapability.getCapabilityForType(SystemCapabilityType.DISPLAYS);
- updateCachedDisplayCapabilityList(newCapabilities);
- }
- break;
- }
- } else if (RPCMessage.KEY_NOTIFICATION.equals(message.getMessageType())) {
- switch (message.getFunctionID()) {
- case ON_HMI_STATUS:
- OnHMIStatus onHMIStatus = (OnHMIStatus) message;
- if (onHMIStatus.getWindowID() != null && onHMIStatus.getWindowID() != PredefinedWindows.DEFAULT_WINDOW.getValue()) {
- return;
- }
- currentHMILevel = onHMIStatus.getHmiLevel();
- break;
- case ON_SYSTEM_CAPABILITY_UPDATED:
- OnSystemCapabilityUpdated onSystemCapabilityUpdated = (OnSystemCapabilityUpdated) message;
- if (onSystemCapabilityUpdated.getSystemCapability() != null) {
- SystemCapability systemCapability = onSystemCapabilityUpdated.getSystemCapability();
- SystemCapabilityType systemCapabilityType = systemCapability.getSystemCapabilityType();
- Object capability = systemCapability.getCapabilityForType(systemCapabilityType);
- if (cachedSystemCapabilities.containsKey(systemCapabilityType)) { //The capability already exists
- switch (systemCapabilityType) {
- case APP_SERVICES:
- // App services only updates what was changed so we need
- // to update the capability rather than override it
- AppServicesCapabilities appServicesCapabilities = (AppServicesCapabilities) capability;
- if (capability != null) {
- List<AppServiceCapability> appServicesCapabilitiesList = appServicesCapabilities.getAppServices();
- AppServicesCapabilities cachedAppServicesCapabilities = (AppServicesCapabilities) cachedSystemCapabilities.get(systemCapabilityType);
- //Update the cached app services
- if (cachedAppServicesCapabilities != null) {
- cachedAppServicesCapabilities.updateAppServices(appServicesCapabilitiesList);
- }
- //Set the new capability object to the updated cached capabilities
- capability = cachedAppServicesCapabilities;
- }
- break;
- case DISPLAYS:
- shouldConvertDeprecatedDisplayCapabilities = false; // Successfully got DISPLAYS data. No conversion needed anymore
- // this notification can return only affected windows (hence not all windows)
- List<DisplayCapability> newCapabilities = (List<DisplayCapability>) capability;
- updateCachedDisplayCapabilityList(newCapabilities);
- }
- }
- if (capability != null) {
- setCapability(systemCapabilityType, capability);
- }
- }
- }
- }
- }
- }
- };
-
- if (callback != null) {
- callback.addOnRPCListener(FunctionID.GET_SYSTEM_CAPABILITY, rpcListener);
- callback.addOnRPCListener(FunctionID.SET_DISPLAY_LAYOUT, rpcListener);
- callback.addOnRPCListener(FunctionID.ON_SYSTEM_CAPABILITY_UPDATED, rpcListener);
- callback.addOnRPCListener(FunctionID.ON_HMI_STATUS, rpcListener);
- }
- }
-
- /**
- * Sets a capability in the cached map. This should only be done when an RPC is received and contains updates to the capability
- * that is being cached in the SystemCapabilityManager.
- * @param systemCapabilityType the system capability type that will be set
- * @param capability the value of the capability that will be set
- */
- public synchronized void setCapability(SystemCapabilityType systemCapabilityType, Object capability) {
- cachedSystemCapabilities.put(systemCapabilityType, capability);
- notifyListeners(systemCapabilityType, capability);
- }
-
- /**
- * Notifies listeners in the list about the new retrieved capability
- * @param systemCapabilityType the system capability type that was retrieved
- * @param capability the system capability value that was retrieved
- */
- private void notifyListeners(SystemCapabilityType systemCapabilityType, Object capability) {
- synchronized(LISTENER_LOCK) {
- CopyOnWriteArrayList<OnSystemCapabilityListener> listeners = onSystemCapabilityListeners.get(systemCapabilityType);
- if (listeners != null && listeners.size() > 0) {
- for (OnSystemCapabilityListener listener : listeners) {
- listener.onCapabilityRetrieved(capability);
- }
- }
- }
- }
-
- /**
- * Ability to see if the connected module supports the given capability. Useful to check before
- * attempting to query for capabilities that require asynchronous calls to initialize.
- * @param type the SystemCapabilityType that is to be checked
- * @return if that capability is supported with the current, connected module
- */
- public boolean isCapabilitySupported(SystemCapabilityType type) {
- if (cachedSystemCapabilities.get(type) != null) {
- //The capability exists in the map and is not null
- return true;
- } else if (cachedSystemCapabilities.containsKey(SystemCapabilityType.HMI)) {
- HMICapabilities hmiCapabilities = ((HMICapabilities) cachedSystemCapabilities.get(SystemCapabilityType.HMI));
- Version rpcVersion = null;
- if (callback != null) {
- SdlMsgVersion version = callback.getSdlMsgVersion();
- if (version != null) {
- rpcVersion = new Version(version.getMajorVersion(), version.getMinorVersion(), version.getPatchVersion());
- }
- }
- if (hmiCapabilities != null) {
- switch (type) {
- case NAVIGATION:
- return hmiCapabilities.isNavigationAvailable();
- case PHONE_CALL:
- return hmiCapabilities.isPhoneCallAvailable();
- case VIDEO_STREAMING:
- if (rpcVersion != null) {
- if (rpcVersion.isBetween(new Version(3, 0, 0), new Version(4, 4, 0)) >= 0) {
- //This was before the system capability feature was added so check if
- // graphics are supported instead
- DisplayCapabilities displayCapabilities = (DisplayCapabilities) getCapability(SystemCapabilityType.DISPLAY);
- if (displayCapabilities != null) {
- return displayCapabilities.getGraphicSupported() != null && displayCapabilities.getGraphicSupported();
- }
- }
- }
- return hmiCapabilities.isVideoStreamingAvailable();
- case REMOTE_CONTROL:
- return hmiCapabilities.isRemoteControlAvailable();
- case APP_SERVICES:
- if (rpcVersion != null) {
- if (rpcVersion.getMajor() == 5 && rpcVersion.getMinor() == 1) {
- //This is a corner case that the param was not available in 5.1.0, but
- //the app services feature was available.
- return true;
- }
- }
- return hmiCapabilities.isAppServicesAvailable();
- case DISPLAYS:
- return hmiCapabilities.isDisplaysCapabilityAvailable();
- case SEAT_LOCATION:
- return hmiCapabilities.isSeatLocationAvailable();
- default:
- return false;
- }
- }
- }
- return false;
- }
-
- /**
- * Checks is subscriptions are available on the connected head unit.
- * @return True if subscriptions are supported. False if not.
- */
- public boolean supportsSubscriptions() {
- if (callback != null && callback.getSdlMsgVersion() != null) {
- Version onSystemCapabilityNotificationRPCVersion = new Version(5, 1, 0);
- Version headUnitRPCVersion = new Version(callback.getSdlMsgVersion());
- return headUnitRPCVersion.isNewerThan(onSystemCapabilityNotificationRPCVersion) >= 0;
- }
- return false;
- }
-
- /**
- * Checks if the supplied capability type is currently subscribed for or not
- * @param systemCapabilityType type of capability desired
- * @return true if subscribed and false if not
- */
- private boolean isSubscribedToSystemCapability(SystemCapabilityType systemCapabilityType) {
- return Boolean.TRUE.equals(systemCapabilitiesSubscriptionStatus.get(systemCapabilityType));
- }
-
- /** Gets the capability object that corresponds to the supplied capability type by returning the currently cached value immediately (or null) as well as calling the listener immediately with the cached value, if available. If not available, the listener will retrieve a new value and return that when the head unit responds.
- * <strong>If capability is not cached, the method will return null and trigger the supplied listener when the capability becomes available</strong>
- * @param systemCapabilityType type of capability desired
- * @param scListener callback to execute upon retrieving capability
- * @param subscribe flag to subscribe to updates of the supplied capability type. True means subscribe; false means cancel subscription; null means don't change current subscription status.
- * @param forceUpdate flag to force getting a new fresh copy of the capability from the head unit even if it is cached
- * @return desired capability if it is cached in the manager, otherwise returns a null object and works in the background to retrieve the capability for the next call
- */
- private Object getCapabilityPrivate(final SystemCapabilityType systemCapabilityType, final OnSystemCapabilityListener scListener, final Boolean subscribe, final boolean forceUpdate) {
- Object cachedCapability = cachedSystemCapabilities.get(systemCapabilityType);
-
- // No need to force update if the app is subscribed to that type because updated values will be received via notifications anyway
- boolean shouldForceUpdate = forceUpdate && !isSubscribedToSystemCapability(systemCapabilityType);
- boolean shouldUpdateSystemCapabilitySubscription = (subscribe != null) && (subscribe != isSubscribedToSystemCapability(systemCapabilityType)) && supportsSubscriptions();
- boolean shouldSendGetCapabilityRequest = shouldForceUpdate || (cachedCapability == null) || shouldUpdateSystemCapabilitySubscription;
- boolean shouldCallListenerWithCachedValue = (cachedCapability != null) && (scListener != null) && !shouldSendGetCapabilityRequest;
-
- if (shouldCallListenerWithCachedValue) {
- scListener.onCapabilityRetrieved(cachedCapability);
- }
-
- if (shouldSendGetCapabilityRequest) {
- retrieveCapability(systemCapabilityType, scListener, subscribe);
- }
-
- return cachedCapability;
- }
-
- /** Gets the capability object that corresponds to the supplied capability type by returning the currently cached value immediately (or null) as well as calling the listener immediately with the cached value, if available. If not available, the listener will retrieve a new value and return that when the head unit responds.
- * <strong>If capability is not cached, the method will return null and trigger the supplied listener when the capability becomes available</strong>
- * @param systemCapabilityType type of capability desired
- * @param scListener callback to execute upon retrieving capability
- * @param forceUpdate flag to force getting a new fresh copy of the capability from the head unit even if it is cached
- * @return desired capability if it is cached in the manager, otherwise returns a null object
- */
- public Object getCapability(final SystemCapabilityType systemCapabilityType, final OnSystemCapabilityListener scListener, final boolean forceUpdate) {
- return getCapabilityPrivate(systemCapabilityType, scListener, null, forceUpdate);
- }
-
- /** Gets the capability object that corresponds to the supplied capability type by calling the listener immediately with the cached value, if available. If not available, the listener will retrieve a new value and return that when the head unit responds.
- * @param systemCapabilityType Type of capability desired
- * @param scListener callback to execute upon retrieving capability
- * @deprecated use {@link #getCapability(SystemCapabilityType, OnSystemCapabilityListener, boolean)} instead.
- */
- @Deprecated
- public void getCapability(final SystemCapabilityType systemCapabilityType, final OnSystemCapabilityListener scListener) {
- getCapabilityPrivate(systemCapabilityType, scListener, null, false);
- }
-
- /** Gets the capability object that corresponds to the supplied capability type by returning the currently cached value immediately if available. Otherwise returns a null object and works in the background to retrieve the capability for the next call
- * @param systemCapabilityType Type of capability desired
- * @return Desired capability if it is cached in the manager, otherwise returns null
- * @deprecated use {@link #getCapability(SystemCapabilityType, OnSystemCapabilityListener, boolean)} instead.
- */
- @Deprecated
- public Object getCapability(final SystemCapabilityType systemCapabilityType) {
- return getCapabilityPrivate(systemCapabilityType, null, null, false);
- }
-
- /**
- * Adds a listener to be called whenever a new capability is retrieved. This method automatically subscribes to the supplied capability type and may call the listener multiple times if there are future updates, unlike getCapability() methods, which only call the listener one time.
- * @param systemCapabilityType Type of capability desired
- * @param listener callback to execute upon retrieving capability
- */
- public void addOnSystemCapabilityListener(final SystemCapabilityType systemCapabilityType, final OnSystemCapabilityListener listener) {
- synchronized(LISTENER_LOCK) {
- if (systemCapabilityType != null && listener != null) {
- if (onSystemCapabilityListeners.get(systemCapabilityType) == null) {
- onSystemCapabilityListeners.put(systemCapabilityType, new CopyOnWriteArrayList<OnSystemCapabilityListener>());
- }
- onSystemCapabilityListeners.get(systemCapabilityType).add(listener);
- }
- }
- getCapabilityPrivate(systemCapabilityType, listener, true, false);
- }
-
- /**
- * Removes an OnSystemCapabilityListener that was previously added
- * @param systemCapabilityType Type of capability
- * @param listener the listener that should be removed
- * @return boolean that represents whether the removal was successful or not
- */
- public boolean removeOnSystemCapabilityListener(final SystemCapabilityType systemCapabilityType, final OnSystemCapabilityListener listener) {
- boolean success = false;
- synchronized(LISTENER_LOCK) {
- if (onSystemCapabilityListeners != null
- && systemCapabilityType != null
- && listener != null
- && onSystemCapabilityListeners.get(systemCapabilityType) != null) {
- success = onSystemCapabilityListeners.get(systemCapabilityType).remove(listener);
- // If the last listener for the supplied capability type is removed, unsubscribe from the capability type
- if (success && onSystemCapabilityListeners.get(systemCapabilityType).isEmpty() && isSubscribedToSystemCapability(systemCapabilityType) && systemCapabilityType != SystemCapabilityType.DISPLAYS) {
- retrieveCapability(systemCapabilityType, null, false);
- }
- }
- }
- return success;
- }
-
- /** Sends a GetSystemCapability request for the supplied SystemCapabilityType and call the listener's callback if the systemCapabilityType is queryable
- * @param systemCapabilityType Type of capability desired
- * @param subscribe flag to subscribe to updates of the supplied capability type. True means subscribe; false means cancel subscription; null means don't change current subscription status.
- */
- private void retrieveCapability(final SystemCapabilityType systemCapabilityType, final OnSystemCapabilityListener scListener, final Boolean subscribe) {
- if (currentHMILevel != null && currentHMILevel.equals(HMILevel.HMI_NONE)) {
- String message = String.format("Attempted to update type: %s in HMI level NONE, which is not allowed. " +
- "Please wait until you are in HMI BACKGROUND, LIMITED, or FULL before attempting to update any SystemCapabilityType", systemCapabilityType);
- DebugTool.logError(TAG, message);
- if (scListener != null) {
- scListener.onError(message);
- }
- return;
- }
- if (!systemCapabilityType.isQueryable() || systemCapabilityType == SystemCapabilityType.DISPLAYS) {
- String message = "This systemCapabilityType cannot be queried for";
- DebugTool.logError(TAG, message);
- if (scListener != null) {
- scListener.onError(message);
- }
- return;
- }
- final GetSystemCapability request = new GetSystemCapability();
- request.setSystemCapabilityType(systemCapabilityType);
-
- /*
- The subscription flag in the request should be set based on multiple variables:
- - if subscribe is null (no change), willSubscribe = current subscription status, or false if the HU does not support subscriptions
- - if subscribe is false, then willSubscribe = false
- - if subscribe is true and the HU supports subscriptions, then willSubscribe = true
- */
- boolean shouldSubscribe = (subscribe != null) ? subscribe : isSubscribedToSystemCapability(systemCapabilityType);
- final boolean willSubscribe = shouldSubscribe && supportsSubscriptions();
- request.setSubscribe(willSubscribe);
- request.setOnRPCResponseListener(new OnRPCResponseListener() {
- @Override
- public void onResponse(int correlationId, RPCResponse response) {
- if (response.getSuccess()) {
- Object retrievedCapability = ((GetSystemCapabilityResponse) response).getSystemCapability().getCapabilityForType(systemCapabilityType);
- setCapability(systemCapabilityType, retrievedCapability);
- // If the listener is not included in the onSystemCapabilityListeners map, then notify it
- // This will be triggered if we are just getting capability without adding a listener to the map
- if (scListener != null) {
- synchronized (LISTENER_LOCK) {
- CopyOnWriteArrayList<OnSystemCapabilityListener> notifiedListeners = onSystemCapabilityListeners.get(systemCapabilityType);
- boolean listenerAlreadyNotified = (notifiedListeners != null) && notifiedListeners.contains(scListener);
- if (!listenerAlreadyNotified) {
- scListener.onCapabilityRetrieved(retrievedCapability);
- }
- }
- }
- if (supportsSubscriptions()) {
- systemCapabilitiesSubscriptionStatus.put(systemCapabilityType, willSubscribe);
- }
- } else {
- if (scListener != null) {
- scListener.onError(response.getInfo());
- }
- }
- }
-
- @Override
- public void onError(int correlationId, Result resultCode, String info) {
- if (scListener != null) {
- scListener.onError(info);
- }
- }
- });
- request.setCorrelationID(CorrelationIdGenerator.generateId());
-
- if (callback != null) {
- callback.sendRPC(request);
- }
- }
-
- /**
- * Converts a capability object into a list.
- * @param object the capability that needs to be converted
- * @param classType The class type of that should be contained in the list
- * @return a List of capabilities if object is instance of List, otherwise it will return null.
- */
- @SuppressWarnings({"unchecked"})
- public static <T> List<T> convertToList(Object object, Class<T> classType) {
- if (classType != null && object != null && object instanceof List) {
- List list = (List) object;
- if (!list.isEmpty()) {
- if (classType.isInstance(list.get(0))) {
- return (List<T>) object;
- } else {
- //The list is not of the correct list type
- return null;
- }
- } else {
- //We return a new list of type T instead of null because while we don't know if
- //the original list was of type T we want to ensure that we don't throw a cast class exception
- //but still
- return new ArrayList<T>();
- }
- } else {
- return null;
- }
- }
-}
diff --git a/base/src/main/java/com/smartdevicelink/proxy/interfaces/OnSystemCapabilityListener.java b/base/src/main/java/com/smartdevicelink/proxy/interfaces/OnSystemCapabilityListener.java
deleted file mode 100644
index f1dd490a8..000000000
--- a/base/src/main/java/com/smartdevicelink/proxy/interfaces/OnSystemCapabilityListener.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2019, 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.
- */
-package com.smartdevicelink.proxy.interfaces;
-
-public interface OnSystemCapabilityListener {
- void onCapabilityRetrieved(Object capability);
- void onError(String info);
-}
diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/AddSubMenu.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/AddSubMenu.java
index e2bd7e675..7d54aebe2 100644
--- a/base/src/main/java/com/smartdevicelink/proxy/rpc/AddSubMenu.java
+++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/AddSubMenu.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc.
+ * Copyright (c) 2017 - 2020, SmartDeviceLink Consortium, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -13,9 +13,9 @@
* disclaimer in the documentation and/or other materials provided with the
* distribution.
*
- * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
+ * Neither the name of the SmartDeviceLink Consortium 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
@@ -98,6 +98,14 @@ import java.util.Hashtable;
* <td></td>
* <td>SmartDeviceLink 6.0</td>
* </tr>
+ * <tr>
+ * <td>parentID</td>
+ * <td>Integer</td>
+ * <td>unique ID of the sub menu, the command will be added to. If not provided or 0, it will be provided to the top level of the in application menu.</td>
+ * <td>N</td>
+ * <td>Min Value: 0 <p>Max Value: 2000000000</p> </td>
+ * <td>SmartDeviceLink 7.0.0</td>
+ * </tr>
* </table>
* <b>Response</b>
* <p>Indicates that the corresponding request either failed or succeeded. If the response returns with a SUCCESS result code, this means the SubMenu was added to the Command Menu successfully</p>
@@ -116,6 +124,7 @@ public class AddSubMenu extends RPCRequest {
public static final String KEY_MENU_ID = "menuID";
public static final String KEY_MENU_ICON = "menuIcon";
public static final String KEY_MENU_LAYOUT = "menuLayout";
+ public static final String KEY_PARENT_ID = "parentID";
/**
* Constructs a new AddSubMenu object
@@ -250,4 +259,26 @@ public class AddSubMenu extends RPCRequest {
public MenuLayout getMenuLayout() {
return (MenuLayout) getObject(MenuLayout.class, KEY_MENU_LAYOUT);
}
+
+ /**
+ * Sets the parentID.
+ *
+ * @param parentID unique ID of the sub menu, the command will be added to. If not provided or 0, it will be
+ * provided to the top level of the in application menu.
+ * @since SmartDeviceLink 7.0.0
+ */
+ public void setParentID(Integer parentID) {
+ setParameters(KEY_PARENT_ID, parentID);
+ }
+
+ /**
+ * Gets the parentID.
+ *
+ * @return Integer unique ID of the sub menu, the command will be added to. If not provided or 0, it will be
+ * provided to the top level of the in application menu.
+ * @since SmartDeviceLink 7.0.0
+ */
+ public Integer getParentID() {
+ return getInteger(KEY_PARENT_ID);
+ }
}
diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/DriverDistractionCapability.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/DriverDistractionCapability.java
new file mode 100644
index 000000000..c09a77f46
--- /dev/null
+++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/DriverDistractionCapability.java
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2017 - 2020, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium 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.
+ */
+package com.smartdevicelink.proxy.rpc;
+
+import com.smartdevicelink.proxy.RPCStruct;
+
+import java.util.Hashtable;
+
+/**
+ *
+ * <p><b>Parameter List</b></p>
+ *
+ * <table border="1" rules="all">
+ * <tr>
+ * <th>Param Name</th>
+ * <th>Type</th>
+ * <th>Description</th>
+ * <th>Required</th>
+ * <th>Version Available</th>
+ * </tr>
+ * <tr>
+ * <td>menuLength</td>
+ * <td>Integer</td>
+ * <td>The number of items allowed in a Choice Set or Command menu while the driver is distracted</td>
+ * <td>N</td>
+ * <td></td>
+ * </tr>
+ * <tr>
+ * <td>subMenuDepth</td>
+ * <td>Integer</td>
+ * <td>The depth of submenus allowed when the driver is distracted. e.g. 3 == top level menu ->submenu -> submenu; 1 == top level menu only</td>
+ * <td>N</td>
+ * <td></td>
+ * </tr>
+ * </table>
+ * @since SmartDeviceLink 7.0.0
+ */
+public class DriverDistractionCapability extends RPCStruct {
+ public static final String KEY_MENU_LENGTH = "menuLength";
+ public static final String KEY_SUB_MENU_DEPTH = "subMenuDepth";
+
+ /**
+ * Constructs a new DriverDistractionCapability object
+ */
+ public DriverDistractionCapability() { }
+
+ /**
+ * Constructs a new DriverDistractionCapability object indicated by the Hashtable parameter
+ *
+ * @param hash The Hashtable to use
+ */
+ public DriverDistractionCapability(Hashtable<String, Object> hash) {
+ super(hash);
+ }
+
+ /**
+ * Sets the menuLength.
+ *
+ * @param menuLength The number of items allowed in a Choice Set or Command menu while the driver is distracted
+ */
+ public void setMenuLength(Integer menuLength) {
+ setValue(KEY_MENU_LENGTH, menuLength);
+ }
+
+ /**
+ * Gets the menuLength.
+ *
+ * @return Integer The number of items allowed in a Choice Set or Command menu while the driver is distracted
+ */
+ public Integer getMenuLength() {
+ return getInteger(KEY_MENU_LENGTH);
+ }
+
+ /**
+ * Sets the subMenuDepth.
+ *
+ * @param subMenuDepth The depth of submenus allowed when the driver is distracted. e.g. 3 == top level menu ->
+ * submenu -> submenu; 1 == top level menu only
+ */
+ public void setSubMenuDepth(Integer subMenuDepth) {
+ setValue(KEY_SUB_MENU_DEPTH, subMenuDepth);
+ }
+
+ /**
+ * Gets the subMenuDepth.
+ *
+ * @return Integer The depth of submenus allowed when the driver is distracted. e.g. 3 == top level menu ->
+ * submenu -> submenu; 1 == top level menu only
+ */
+ public Integer getSubMenuDepth() {
+ return getInteger(KEY_SUB_MENU_DEPTH);
+ }
+}
diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/HMICapabilities.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/HMICapabilities.java
index d7a8c9001..f1b3c4821 100644
--- a/base/src/main/java/com/smartdevicelink/proxy/rpc/HMICapabilities.java
+++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/HMICapabilities.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc.
+ * Copyright (c) 2017 - 2020, SmartDeviceLink Consortium, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -13,9 +13,9 @@
* disclaimer in the documentation and/or other materials provided with the
* distribution.
*
- * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
+ * Neither the name of the SmartDeviceLink Consortium 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
@@ -43,6 +43,7 @@ public class HMICapabilities extends RPCStruct{
public static final String KEY_APP_SERVICES = "appServices";
public static final String KEY_DISPLAYS = "displays";
public static final String KEY_SEAT_LOCATION = "seatLocation";
+ public static final String KEY_DRIVER_DISTRACTION = "driverDistraction";
public HMICapabilities() { }
@@ -134,4 +135,27 @@ public class HMICapabilities extends RPCStruct{
setValue(KEY_SEAT_LOCATION, available);
}
+ /**
+ * Sets the driverDistraction.
+ *
+ * @param driverDistraction Availability of driver distraction capability. True: Available, False: Not Available
+ * @since SmartDeviceLink 7.0.0
+ */
+ public void setDriverDistraction(Boolean driverDistraction) {
+ setValue(KEY_DRIVER_DISTRACTION, driverDistraction);
+ }
+
+ /**
+ * Gets the driverDistraction.
+ *
+ * @return Boolean Availability of driver distraction capability. True: Available, False: Not Available
+ * @since SmartDeviceLink 7.0.0
+ */
+ public Boolean isDriverDistractionAvailable() {
+ Object available = getValue(KEY_DRIVER_DISTRACTION);
+ if (available == null) {
+ return false;
+ }
+ return (Boolean) available;
+ }
}
diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/SystemCapability.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/SystemCapability.java
index 73634c17b..314b6d0cc 100644
--- a/base/src/main/java/com/smartdevicelink/proxy/rpc/SystemCapability.java
+++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/SystemCapability.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc.
+ * Copyright (c) 2017 - 2020, SmartDeviceLink Consortium, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -13,9 +13,9 @@
* disclaimer in the documentation and/or other materials provided with the
* distribution.
*
- * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
+ * Neither the name of the SmartDeviceLink Consortium 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
@@ -51,6 +51,8 @@ public class SystemCapability extends RPCStruct {
public static final String KEY_APP_SERVICES_CAPABILITIES = "appServicesCapabilities";
public static final String KEY_SEAT_LOCATION_CAPABILITY = "seatLocationCapability";
public static final String KEY_DISPLAY_CAPABILITIES = "displayCapabilities";
+ public static final String KEY_DRIVER_DISTRACTION_CAPABILITY = "driverDistractionCapability";
+
public SystemCapability(){}
public SystemCapability(Hashtable<String, Object> hash) {
@@ -98,6 +100,8 @@ public class SystemCapability extends RPCStruct {
return getObject(SeatLocationCapability.class, KEY_SEAT_LOCATION_CAPABILITY);
} else if (type.equals(SystemCapabilityType.DISPLAYS)) {
return getObject(DisplayCapability.class, KEY_DISPLAY_CAPABILITIES);
+ } else if (type.equals(SystemCapabilityType.DRIVER_DISTRACTION)) {
+ return getObject(DriverDistractionCapability.class, KEY_DRIVER_DISTRACTION_CAPABILITY);
} else {
return null;
}
@@ -120,6 +124,8 @@ public class SystemCapability extends RPCStruct {
setValue(KEY_SEAT_LOCATION_CAPABILITY, capability);
} else if (type.equals(SystemCapabilityType.DISPLAYS)) {
setValue(KEY_DISPLAY_CAPABILITIES, capability);
+ } else if (type.equals(SystemCapabilityType.DRIVER_DISTRACTION)) {
+ setValue(KEY_DRIVER_DISTRACTION_CAPABILITY, capability);
} else {
return;
}
diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/TextField.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/TextField.java
index 514b5ba0f..497bd66ee 100644
--- a/base/src/main/java/com/smartdevicelink/proxy/rpc/TextField.java
+++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/TextField.java
@@ -1,34 +1,34 @@
-/*
- * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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.
- */
+/*
+ * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, 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 SmartDeviceLink Consortium, 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.
+ */
package com.smartdevicelink.proxy.rpc;
import android.support.annotation.NonNull;
@@ -58,7 +58,7 @@ import java.util.Hashtable;
* <tr>
* <td>characterSet</td>
* <td>CharacterSet</td>
- * <td>The character set that is supported in this field. </td>
+ * <td>The set of characters that are supported by this text field. All text is sent in UTF-8 format, but not all systems may support all of the characters expressed by UTF-8. All systems will support at least ASCII, but they may support more, either the LATIN-1 character set, or the full UTF-8 character set. </td>
* <td>SmartDeviceLink 1.0</td>
* </tr>
* <tr>
@@ -114,7 +114,9 @@ public class TextField extends RPCStruct {
/**
* Constructs a newly allocated TextField object
* @param name Enumeration identifying the field.
- * @param characterSet The character set that is supported in this field.
+ * @param characterSet The set of characters that are supported by this text field.
+ * All text is sent in UTF-8 format, but not all systems may support all of the characters expressed by UTF-8.
+ * All systems will support at least ASCII, but they may support more, either the LATIN-1 character set, or the full UTF-8 character set.
* @param width The number of characters in one row of this field.
* @param rows The number of rows for this text field.
*/
@@ -141,14 +143,18 @@ public class TextField extends RPCStruct {
}
/**
* Get the character set that is supported in this field.
- * @return the character set
+ * @return The set of characters that are supported by this text field.
+ * All text is sent in UTF-8 format, but not all systems may support all of the characters expressed by UTF-8.
+ * All systems will support at least ASCII, but they may support more, either the LATIN-1 character set, or the full UTF-8 character set.
*/
public CharacterSet getCharacterSet() {
return (CharacterSet) getObject(CharacterSet.class, KEY_CHARACTER_SET);
}
/**
* Set the character set that is supported in this field.
- * @param characterSet - the character set
+ * @param characterSet - The set of characters that are supported by this text field.
+ * All text is sent in UTF-8 format, but not all systems may support all of the characters expressed by UTF-8.
+ * All systems will support at least ASCII, but they may support more, either the LATIN-1 character set, or the full UTF-8 character set.
*/
public void setCharacterSet(@NonNull CharacterSet characterSet ) {
setValue(KEY_CHARACTER_SET, characterSet);
diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/enums/CharacterSet.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/enums/CharacterSet.java
index a1fb294e2..a2170c70a 100644
--- a/base/src/main/java/com/smartdevicelink/proxy/rpc/enums/CharacterSet.java
+++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/enums/CharacterSet.java
@@ -29,27 +29,64 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
-package com.smartdevicelink.proxy.rpc.enums;
-/**
- * Character sets supported by SDL.
- * @since SmartDeviceLink 1.0
- */
-public enum CharacterSet {
- TYPE2SET,
- TYPE5SET,
- CID1SET,
- CID2SET;
-
- /**
- * Convert String to CharacterSet
- * @param value String
- * @return CharacterSet
- */
- public static CharacterSet valueForString(String value) {
- try{
- return valueOf(value);
- }catch(Exception e){
- return null;
- }
- }
-}
+package com.smartdevicelink.proxy.rpc.enums;
+/**
+ * Character sets supported by SDL.
+ * @since SmartDeviceLink 1.0
+ */
+public enum CharacterSet {
+ /**
+ * @deprecated in SmartDeviceLink 7.0.0
+ */
+ @Deprecated
+ TYPE2SET,
+ /**
+ * @deprecated in SmartDeviceLink 7.0.0
+ */
+ @Deprecated
+ TYPE5SET,
+ /**
+ * @deprecated in SmartDeviceLink 7.0.0
+ */
+ @Deprecated
+ CID1SET,
+ /**
+ * @deprecated in SmartDeviceLink 7.0.0
+ */
+ @Deprecated
+ CID2SET,
+ /**
+ * ASCII as defined in https://en.wikipedia.org/wiki/ASCII as defined in codes 0-127.
+ * Non-printable characters such as tabs and back spaces are ignored.
+ *
+ * @since SmartDeviceLink 7.0.0
+ */
+ ASCII,
+ /**
+ * Latin-1, as defined in https://en.wikipedia.org/wiki/ISO/IEC_8859-1
+ *
+ * @since SmartDeviceLink 7.0.0
+ */
+ ISO_8859_1,
+ /**
+ * The UTF-8 character set that uses variable bytes per code point.
+ * See https://en.wikipedia.org/wiki/UTF-8 for more details.
+ * This is the preferred character set.
+ *
+ * @since SmartDeviceLink 7.0.0
+ */
+ UTF_8;
+
+ /**
+ * Convert String to CharacterSet
+ * @param value String
+ * @return CharacterSet
+ */
+ public static CharacterSet valueForString(String value) {
+ try{
+ return valueOf(value);
+ }catch(Exception e){
+ return null;
+ }
+ }
+}
diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/enums/SystemCapabilityType.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/enums/SystemCapabilityType.java
index 758a33905..775781000 100644
--- a/base/src/main/java/com/smartdevicelink/proxy/rpc/enums/SystemCapabilityType.java
+++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/enums/SystemCapabilityType.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc.
+ * Copyright (c) 2017 - 2020, SmartDeviceLink Consortium, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -13,9 +13,9 @@
* disclaimer in the documentation and/or other materials provided with the
* distribution.
*
- * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
+ * Neither the name of the SmartDeviceLink Consortium 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
@@ -155,6 +155,13 @@ package com.smartdevicelink.proxy.rpc.enums;
* <td align=center>N</td>
* <td>Available Asynchronously, Call is synchronous <strong>after</strong> initial call</strong></td>
* </tr>
+ * <tr>
+ * <td>DRIVER_DISTRACTION</td>
+ * <d>DriverDistractionCapability</td>
+ * <td>Returns DRIVER_DISTRACTION</td>
+ * <td align=center>N</td>
+ * <td><strong>Since 7.0</strong> Describes capabilities when the driver is distracted</td>
+ * </tr>
* </table>
*
*/
@@ -552,6 +559,26 @@ public enum SystemCapabilityType {
*/
SEAT_LOCATION (true),
+ /**
+ * <table border="1" rules="all">
+ * <tr>
+ * <th>Enum Name</th>
+ * <th>Return Type</th>
+ * <th>Description</th>
+ * <th>Requires Async?</th>
+ * <th>Notes</th>
+ * </tr>
+ * <tr>
+ * <td>DRIVER_DISTRACTION</td>
+ * <td>DriverDistractionCapability</td>
+ * <td>Returns DRIVER_DISTRACTION</td>
+ * <td align=center>N</td>
+ * <td><strong>Since 7.0</strong> Describes capabilities when the driver is distracted</td>
+ * </tr>
+ * </table>
+ */
+ DRIVER_DISTRACTION(true);
+
;
boolean IS_QUERYABLE;
diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/listeners/OnRPCResponseListener.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/listeners/OnRPCResponseListener.java
index 01980eb28..89b082326 100644
--- a/base/src/main/java/com/smartdevicelink/proxy/rpc/listeners/OnRPCResponseListener.java
+++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/listeners/OnRPCResponseListener.java
@@ -70,11 +70,16 @@ public abstract class OnRPCResponseListener extends OnRPCListener {
public abstract void onResponse(int correlationId, final RPCResponse response);
/**
+ * @deprecated This method has been deprecated in favor of just using the onResponse callback. In the next
+ * version this method will be removed and all responses successful or not will be returned
+ * through the onResponse method callback.
+ *
* Called when there was some sort of error during the original request.
* @param correlationId
* @param resultCode
* @param info
*/
+ @Deprecated
public void onError(int correlationId, Result resultCode, String info){
};